Skip to content

Commit

Permalink
Fix #8
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysnhall committed Sep 16, 2021
1 parent a038c12 commit 3919926
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# Changelog

## v0.3.1

### Fixed issues
* Add check and exception when a null or empty client ID is passed to the Oauth/Client class. [Issue #8](https://github.com/rhysnhall/etsy-php-sdk/issues/8)
* Updated handleAcessTokenError() method to check for the existence of 'error_description' in the response body. [Issue #8](https://github.com/rhysnhall/etsy-php-sdk/issues/8)

## v0.3.0

### New
* Added `config` property to the Client class. This currently only support the value '404_error' which when set to true will throw an error when a resource returns 404 instead of returning a null value. This value is unset/false by default.
* Added `config` property to the Client class. This currently only supports the value '404_error' which when set to true will throw an error when a resource returns 404 instead of returning a null value. This value is unset/false by default.

### Fixed issues
* Fixed breaking issue with class names in the resource updateRequest method. This issue only relates to Linux environments. [#6] (https://github.com/rhysnhall/etsy-php-sdk/issues/6)
* Fixed breaking issue with class names in the resource updateRequest method. This issue only relates to Linux environments. [#6](https://github.com/rhysnhall/etsy-php-sdk/issues/6)

### Minor notes
* Fixed some typos in Client error messages.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rhysnhall/etsy-php-sdk",
"version": "0.3.0",
"version": "0.3.1",
"description": "PHP SDK for Etsy API v3.",
"type": "library",
"keywords": [
Expand Down
12 changes: 10 additions & 2 deletions src/OAuth/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ class Client {
/**
* Create a new instance of Client.
*
* @param string $client_id
* @return void
*/
public function __construct(
$client_id
string $client_id
) {
if(is_null($client_id) || !trim($client_id)) {
throw new OAuthException("No client ID found. A valid client ID is required.");
}
$this->client_id = $client_id;
}

Expand Down Expand Up @@ -264,8 +268,12 @@ private function handleAcessTokenError(\Exception $e) {
$response = $e->getResponse();
$body = json_decode($response->getBody(), false);
$status_code = $response->getStatusCode();
$error_msg = "with error \"{$body->error}\"";
if($body->error_description ?? false) {
$error_msg .= "and message \"{$body->error_description}\"";
}
throw new OAuthException(
"Received HTTP status code [$status_code] with error \"{$body->error}\" and message \"{$body->error_description}\" when requesting access token."
"Received HTTP status code [$status_code] {$error_msg} when requesting access token."
);
}

Expand Down

0 comments on commit 3919926

Please sign in to comment.