/** * Calls the authentication API * * @return AuthenticationTokenResponse * * @throws \SoapFault */ private function authenticate() { $try = 0; while (true) { $try++; try { $response = $this->soapClient->__soapCall('GetAuthenticationToken', array(array('authenticationRequest' => $this->authenticationRequest->toArray()))); return new AuthenticationTokenResponse(new \DateTime($response->GetAuthenticationTokenResult->DeprecatedDate), $response->GetAuthenticationTokenResult->Key); } catch (\SoapFault $e) { if (null !== $this->logger) { $this->logger->critical(sprintf('[%] %s', __CLASS__, $e->getMessage())); } if ($try >= $this->retries) { throw $e; } // waiting 500ms before next call usleep(500000); } } }
/** * Tests the toArray method */ public function testToArray() { $request = new AuthenticationRequest(1, 'fake_key'); $expected = array('AccountID' => 1, 'AuthenticationKey' => 'fake_key'); $this->assertEquals($expected, $request->toArray()); }