public function it_do_sport_api_ng_request_with_authenticated_credentials(CredentialInterface $credential, BetfairGuzzleClient $betfairHttpClient, Param $param, Response $response) { $operationName = 'listApiThing'; $credential->isAuthenticated()->willReturn(true); $credential->getApplicationKey()->willReturn('app-key'); $credential->getSessionToken()->willReturn('session-token'); $expectedGuzzleParameters = array("X-Application" => 'app-key', "X-Authentication" => 'session-token', 'method' => "SportsAPING/v1.0/" . $operationName, 'type' => 'betting', 'params' => $param); $betfairHttpClient->apiNgRequest($expectedGuzzleParameters)->shouldBeCalled()->willReturn($response); $response->getBody()->shouldBeCalled()->willReturn('body response'); $this->apiNgRequest($operationName, $param, "betting")->shouldReturn("body response"); }
/** * @param string $operationName operation name * @param ParamInterface $param Param to be serialized in the request * @param string $type * @return string $bodyString */ public function apiNgRequest($operationName, ParamInterface $param, $type = "betting") { $requestParameters = array_merge($this->getDefaultAuthHeaderArray(), $this->builtJsonRpcArrayParameters($operationName, $param, $type), array("type" => $type)); $response = $this->betfairGuzzleClient->apiNgRequest($requestParameters); return $response->getBody(); }