Update readme file, Update composer.json file, Exception updates

Alle exceptions thrown in Response are now general AmazonError with json
return string for full compability
This commit is contained in:
2021-10-21 10:22:17 +09:00
parent 6f9bf781f2
commit 3b7f644ae9
6 changed files with 53 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
namespace gullevek\AmazonIncentives\Response;
use gullevek\AmazonIncentives\Exceptions\AmazonErrors;
use gullevek\AmazonIncentives\Debug\AmazonDebug;
class CancelResponse
@@ -93,7 +94,13 @@ class CancelResponse
public function parseJsonResponse(array $json_response): self
{
if (!is_array($json_response)) {
throw new \RuntimeException('Response must be a scalar value');
throw AmazonErrors::getError(
'FAILURE',
'E001',
'NonScalarValue',
'Response must be a scalar value',
0
);
}
if (array_key_exists('gcId', $json_response)) {
$this->id = $json_response['gcId'];

View File

@@ -2,6 +2,7 @@
namespace gullevek\AmazonIncentives\Response;
use gullevek\AmazonIncentives\Exceptions\AmazonErrors;
use gullevek\AmazonIncentives\Debug\AmazonDebug;
class CreateBalanceResponse
@@ -110,7 +111,13 @@ class CreateBalanceResponse
public function parseJsonResponse(array $json_response): self
{
if (!is_array($json_response)) {
throw new \RuntimeException('Response must be a scalar value');
throw AmazonErrors::getError(
'FAILURE',
'E001',
'NonScalarValue',
'Response must be a scalar value',
0
);
}
if (array_key_exists('amount', $json_response['availableFunds'])) {
$this->amount = $json_response['availableFunds']['amount'];

View File

@@ -2,6 +2,7 @@
namespace gullevek\AmazonIncentives\Response;
use gullevek\AmazonIncentives\Exceptions\AmazonErrors;
use gullevek\AmazonIncentives\Debug\AmazonDebug;
class CreateResponse
@@ -168,7 +169,13 @@ class CreateResponse
public function parseJsonResponse(array $json_response): self
{
if (!is_array($json_response)) {
throw new \RuntimeException('Response must be a scalar value');
throw AmazonErrors::getError(
'FAILURE',
'E001',
'NonScalarValue',
'Response must be a scalar value',
0
);
}
if (array_key_exists('gcId', $json_response)) {
$this->id = $json_response['gcId'];