From 672495402fdcbb35c7e57e5b321783fd2858af2e Mon Sep 17 00:00:00 2001 From: "john.birch-evans" Date: Thu, 23 Jan 2020 08:03:48 +0000 Subject: [PATCH 1/3] Add function to get the credits for an individual service --- src/Account/CreditClient.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Account/CreditClient.php b/src/Account/CreditClient.php index 24d18d5f..65b4c0fe 100644 --- a/src/Account/CreditClient.php +++ b/src/Account/CreditClient.php @@ -36,6 +36,20 @@ public function getAll() }, $body->data); } + /** + * Get credits for an individual service + * @param $service + * @return Credit + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function getByService($service) + { + $response = $this->request("GET", "v1/credits/" . $service); + $body = $this->decodeJson($response->getBody()->getContents()); + + return new Credit($body->data); + } + /** * Gets a paginated response of credits * From 89bffba6f0bf107650723ed47d12195f6ccc2ca8 Mon Sep 17 00:00:00 2001 From: "john.birch-evans" Date: Thu, 23 Jan 2020 08:24:49 +0000 Subject: [PATCH 2/3] Change service to reference to keep it in line with db naming --- src/Account/CreditClient.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Account/CreditClient.php b/src/Account/CreditClient.php index 65b4c0fe..211d17e3 100644 --- a/src/Account/CreditClient.php +++ b/src/Account/CreditClient.php @@ -38,13 +38,13 @@ public function getAll() /** * Get credits for an individual service - * @param $service + * @param $reference * @return Credit * @throws \GuzzleHttp\Exception\GuzzleException */ - public function getByService($service) + public function findByReference($reference) { - $response = $this->request("GET", "v1/credits/" . $service); + $response = $this->request("GET", "v1/credits/" . $reference); $body = $this->decodeJson($response->getBody()->getContents()); return new Credit($body->data); From ad89dbc482d9db4a9e2b310375a5982b335e73eb Mon Sep 17 00:00:00 2001 From: "john.birch-evans" Date: Fri, 24 Jan 2020 09:02:28 +0000 Subject: [PATCH 3/3] Change findByReference to getByReference to match naming conventions --- src/Account/CreditClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Account/CreditClient.php b/src/Account/CreditClient.php index 211d17e3..64105598 100644 --- a/src/Account/CreditClient.php +++ b/src/Account/CreditClient.php @@ -42,7 +42,7 @@ public function getAll() * @return Credit * @throws \GuzzleHttp\Exception\GuzzleException */ - public function findByReference($reference) + public function getByReference($reference) { $response = $this->request("GET", "v1/credits/" . $reference); $body = $this->decodeJson($response->getBody()->getContents());