$headers * @return array */ public function get(string $url, OAuthToken $token, array $headers = []): array { $response = $this->httpClient->get($url, [ 'headers' => [ 'Authorization' => $token->getAuthorizationHeader(), ...$headers, ], ]); return json_decode($response->getBody(), true) ?? []; } /** * Make POST request to OAuth provider * * @param array $data * @param array $headers * @return array */ public function post(string $url, array $data = [], array $headers = []): array { $response = $this->httpClient->post($url, [ 'headers' => [ 'Content-Type' => 'application/x-www-form-urlencoded', ...$headers, ], 'body' => http_build_query($data), ]); return json_decode($response->getBody(), true) ?? []; } /** * Make authenticated POST request with OAuth token * * @param array $data * @param array $headers * @return array */ public function postAuthenticated( string $url, OAuthToken $token, array $data = [], array $headers = [] ): array { $response = $this->httpClient->post($url, [ 'headers' => [ 'Authorization' => $token->getAuthorizationHeader(), 'Content-Type' => 'application/json', ...$headers, ], 'body' => json_encode($data), ]); return json_decode($response->getBody(), true) ?? []; } /** * Make PUT request with OAuth token * * @param array $data * @param array $headers * @return array */ public function put( string $url, OAuthToken $token, array $data = [], array $headers = [] ): array { $response = $this->httpClient->put($url, [ 'headers' => [ 'Authorization' => $token->getAuthorizationHeader(), 'Content-Type' => 'application/json', ...$headers, ], 'body' => json_encode($data), ]); return json_decode($response->getBody(), true) ?? []; } /** * Make DELETE request with OAuth token * * @param array $headers * @return array */ public function delete(string $url, OAuthToken $token, array $headers = []): array { $response = $this->httpClient->delete($url, [ 'headers' => [ 'Authorization' => $token->getAuthorizationHeader(), ...$headers, ], ]); return json_decode($response->getBody(), true) ?? []; } }