Esempio n. 1
0
 /**
  * Perform a create session call to the AbiosGaming API.
  *
  * @access	private
  * @return	void
  */
 private function createSession()
 {
     $this->api->preferredFormat('object');
     $request = new Request($this->api, 'oauth/access_token');
     $request->addArgs(['grant_type' => 'client_credentials', 'client_id' => $this->api->getClientId(), 'client_secret' => $this->api->getClientSecret()]);
     $response = $request->send('POST');
     $this->sessionKey = $response->access_token;
     if (empty($this->sessionKey) || isset($response->error)) {
         throw new ApiException('Bad session returned from API: "' . $response->error_description);
     }
     $this->api->preferredFormat('array');
     $this->sessionTimestamp = time();
     $this->saveToCache();
 }
Esempio n. 2
0
 /**
  * @covers AbiosGaming\Request::mapArgs
  */
 public function testMappedParams()
 {
     // Get around stub out existence of session
     $stubApi = $this->getMockBuilder('AbiosGaming\\API')->setConstructorArgs([$this->clientId, $this->clientSecret])->setMethods(['getSession'])->getMock();
     $stubSession = $this->getMockBuilder('AbiosGaming\\Session')->disableOriginalConstructor()->getMock($stubApi);
     $stubApi->method('getSession')->willReturn($stubSession);
     $stubSession->method('getKey')->willReturn('FAKESESSION');
     $request = new Request($stubApi, 'getqueuestats');
     $request->addArgs(['ConquestChallenge', 'Gold1']);
     $this->assertStringEndsWith('/429/15', $request->getRequestedUrl());
 }