/** * @dataProvider jsonProvider */ public function testDecode($input, $asArray, $expected) { $this->assertEquals($expected, JsonDecoder::decode($input, $asArray)); }
/** * @param string $method * @param string $host * @param string $path * @param array $parameters * @param array $headers * @return Response * @throws BadRequest * @throws Forbidden * @throws NotAuthorized * @throws NotFound * @throws RateLimit * @throws ServerError * @throws ServiceUnavailable */ private function http($method, $host, $path, array $parameters, $headers = []) { $this->method = $method; $this->resource = $path; $this->resetLastResponse(); if (strpos($path, TONUpload::DEFAULT_DOMAIN) === 0) { $url = $path; } else { if ($host == self::UPLOAD_HOST) { $url = sprintf('%s/%s/%s', $host, self::API_REST_VERSION, $path); } else { $url = sprintf('%s/%s/%s', $host, self::API_VERSION, $path); } } $this->response->setApiPath($path); $result = $this->oAuthRequest($url, $method, $parameters, $headers); $response = JsonDecoder::decode($result, $this->decodeJsonAsArray); $this->response->setBody($response); if ($this->getLastHttpCode() > 399) { $this->manageErrors($response); } return $this->response; }