From b4602c36b870185c86163978589e2a8f5955031b Mon Sep 17 00:00:00 2001 From: Rudenko Oleksandr Date: Wed, 9 Nov 2022 00:56:26 +0200 Subject: [PATCH 1/4] Fix handling 403 Forbidden Pipedrive's response --- src/Http/Request.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Http/Request.php b/src/Http/Request.php index e18a8af..502d5b4 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -89,16 +89,24 @@ protected function handleResponse(Response $response) throw new ItemNotFoundException(isset($content->error) ? $content->error : "Error unknown."); } + if ($response->getStatusCode() == 403) { + throw new PipedriveException( + isset($content->error) ? $content->error : 'Forbidden', + $response->getStatusCode() + ); + } + $this->throwPipedriveException($content); } return $response; } - + /** * Throws PipedriveException with message depending on content. * * @param string $content + * @throws \Devio\Pipedrive\Exceptions\PipedriveException */ protected function throwPipedriveException($content) { From e14eabf60d1606d84ad9d86b52ca091e125939a3 Mon Sep 17 00:00:00 2001 From: Oleksandr Rudenko <81565672+ORudenkoAS@users.noreply.github.com> Date: Fri, 11 Nov 2022 20:36:03 +0200 Subject: [PATCH 2/4] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2af668c..ea6b616 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "devio/pipedrive", + "name": "orudenkoas/pipedrive", "description": "Complete Pipedrive API client for PHP and/or Laravel", "keywords": ["pipedrive", "api", "client", "laravel"], "license": "MIT", From 1796c47eb3439038088a88d9452ef3175c87b6b8 Mon Sep 17 00:00:00 2001 From: Rudenko Oleksandr Date: Fri, 11 Nov 2022 20:49:52 +0200 Subject: [PATCH 3/4] Add handling 401 Unauthorized response --- src/Http/Request.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Http/Request.php b/src/Http/Request.php index 502d5b4..c868f3c 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -89,6 +89,13 @@ protected function handleResponse(Response $response) throw new ItemNotFoundException(isset($content->error) ? $content->error : "Error unknown."); } + if ($response->getStatusCode() == 401) { + throw new PipedriveException( + isset($content->error) ? $content->error : 'Unauthorized', + $response->getStatusCode() + ); + } + if ($response->getStatusCode() == 403) { throw new PipedriveException( isset($content->error) ? $content->error : 'Forbidden', From 4b079f04415f58bf9e29c402622e96fb61c12b5f Mon Sep 17 00:00:00 2001 From: Rudenko Oleksandr Date: Fri, 11 Nov 2022 21:11:40 +0200 Subject: [PATCH 4/4] rollback original repo name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ea6b616..2af668c 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "orudenkoas/pipedrive", + "name": "devio/pipedrive", "description": "Complete Pipedrive API client for PHP and/or Laravel", "keywords": ["pipedrive", "api", "client", "laravel"], "license": "MIT",