/** * @return string $sessionToken * @throws \Betfair\Exception\BetfairLoginException */ private function login() { /** @var Response $result */ $result = $this->betfairGuzzleClient->betfairLogin($this->builtLoginArrayParameters()); if ($result && $result->getStatusCode() == 200) { return $this->extractSessionTokenFromResponseBody($result->getBody()); } throw new BetfairLoginException(sprintf("Error during credentials verification.")); }
public function it_raise_betfar_login_exception_when_response_not_have_a_200_status_code(CredentialInterface $credential, BetfairGuzzleClient $betfairHttpClient, Response $response) { $credential->getUsername()->shouldBeCalled()->willReturn('usr1'); $credential->getPassword()->shouldBeCalled()->willReturn('pwd1'); $credential->getApplicationKey()->shouldBeCalled()->willReturn('appkey'); $expectedLoginGuzzleParameters = array('username' => 'usr1', 'password' => 'pwd1', 'X-Application' => 'appkey'); $betfairHttpClient->betfairLogin($expectedLoginGuzzleParameters)->shouldBeCalled()->willReturn($response); $response->getStatusCode()->shouldBeCalled()->willReturn(401); $response->getBody()->shouldNotBeCalled(); $this->shouldThrow('Betfair\\Exception\\BetfairLoginException')->duringAuthenticateCredential(); }