From 68c6f251b3a3439e48114a90bc9c6121935bcaf7 Mon Sep 17 00:00:00 2001 From: skaisser Date: Mon, 28 Mar 2016 14:49:58 -0300 Subject: [PATCH 1/3] Fix HandleError() error message --- src/Adapter/GuzzleHttpAdapter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Adapter/GuzzleHttpAdapter.php b/src/Adapter/GuzzleHttpAdapter.php index 3498a7f..8f76195 100644 --- a/src/Adapter/GuzzleHttpAdapter.php +++ b/src/Adapter/GuzzleHttpAdapter.php @@ -159,9 +159,9 @@ protected function handleError() { $body = (string) $this->response->getBody(); $code = (int) $this->response->getStatusCode(); - $content = json_decode($body); + $error = $content->errors[0]; - throw new HttpException(isset($content->message) ? $content->message : 'Request not processed.', $code); + throw new HttpException(isset($error) ? $error->description : 'Request not processed.', $code); } } \ No newline at end of file From fc2f3927835611d779f86c5c13a517328063c06a Mon Sep 17 00:00:00 2001 From: Shirleyson Kaisser Date: Fri, 22 Jul 2016 11:26:28 -0300 Subject: [PATCH 2/3] Added the Installment Atribute --- src/Entity/Payment.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Entity/Payment.php b/src/Entity/Payment.php index 72082c4..126335a 100644 --- a/src/Entity/Payment.php +++ b/src/Entity/Payment.php @@ -88,6 +88,10 @@ final class Payment extends \Softr\Asaas\Entity\AbstractEntity */ public $boletoUrl; + /** + * @var int + */ + public $installment; /** * @var int */ From f2000f791a765f0e9dccbc4eaf8af1ed57e6a2e1 Mon Sep 17 00:00:00 2001 From: Shirleyson Kaisser Date: Fri, 22 Jul 2016 11:38:24 -0300 Subject: [PATCH 3/3] add get payment by installment id --- src/Api/Payment.php | 16 ++++++++++++++++ src/Entity/Installment.php | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/Entity/Installment.php diff --git a/src/Api/Payment.php b/src/Api/Payment.php index f060751..ca53ef7 100644 --- a/src/Api/Payment.php +++ b/src/Api/Payment.php @@ -3,6 +3,7 @@ // Entities use Softr\Asaas\Entity\Payment as PaymentEntity; +use Softr\Asaas\Entity\Installment as InstallmentEntity; /** * Payment API Endpoint @@ -67,6 +68,21 @@ public function getByCustomer($customerId, array $filters = []) }, $payments->data); } + /** + * Get Payment By Installment Id + * + * @param int $installmentId Installment Id + * @return PaymentEntity + */ + public function getByInstallmentId($installmentId) + { + $installment = $this->adapter->get(sprintf('%s/payments?installment=%s', $this->endpoint, $installmentId)); + + $installment = json_decode($installment); + + return new InstallmentEntity($installment); + } + /** * Get Payments By Subscription Id * diff --git a/src/Entity/Installment.php b/src/Entity/Installment.php new file mode 100644 index 0000000..8dedb2e --- /dev/null +++ b/src/Entity/Installment.php @@ -0,0 +1,17 @@ + + */ +final class Installment extends \Softr\Asaas\Entity\AbstractEntity +{ + /** + * @var array + */ + public $data; + + +} \ No newline at end of file