public function invoices($subscription_code) { try { $response = $this->config->client->get('subscriptions/' . $subscription_code . '/invoices'); return json_decode($response->getBody()->getContents()); } catch (ClientException $e) { $contents = json_decode($e->getResponse()->getBody()->getContents()); $exception = new RemoteException($e->getMessage()); $exception->setError(isset($contents->errors) ? $contents->errors[0] : ''); throw $exception; } }
public function handleException(Exception $e) { $exception = new RemoteException($e->getMessage()); $exception->setError('Ocorreu um erro desconhecido, por favor, tente novamente'); throw $exception; }