/** * Get account information for the logged-in user. * * @param bool $reset * * @return array */ public function getAccountInfo($reset = false) { if (!isset($this->accountInfo) || $reset) { $client = $this->connector->getClient(); $url = $this->accountsEndpoint . 'me'; try { $this->accountInfo = (array) $client->get($url)->json(); } catch (BadResponseException $e) { throw ApiResponseException::create($e->getRequest(), $e->getResponse(), $e->getPrevious()); } } return $this->accountInfo; }
/** * Send a Guzzle request. * * Using this method allows exceptions to be standardized. * * @param RequestInterface $request * @param ClientInterface $client * * @return array */ public static function send(RequestInterface $request, ClientInterface $client) { $response = null; try { $response = $client->send($request); $data = $response->json(); return (array) $data; } catch (BadResponseException $e) { throw ApiResponseException::create($e->getRequest(), $e->getResponse()); } catch (ParseException $e) { throw ApiResponseException::create($request, $response); } }