Merge branch 'development' Wrapper method additions

This commit is contained in:
2022-06-10 14:51:22 +09:00
3 changed files with 26 additions and 5 deletions

View File

@@ -129,6 +129,16 @@ class AWS
return new CreateBalanceResponse($result);
}
/**
* return a new curl connection client class
*
* @return Client Curl connection Client
*/
public function newClient(): Client
{
return new Client();
}
/**
* General request method for all actions
* Calls the Client class that actually runs the json request
@@ -190,7 +200,7 @@ class AWS
$date_time_string,
$service_target
);
return (new Client())->request($url, $headers, $payload);
return ($this->newClient())->request($url, $headers, $payload);
}
/**

View File

@@ -67,7 +67,7 @@ final class AmazonIncentives
*/
public function buyGiftCard(float $value, string $creation_request_id = null): Response\CreateResponse
{
return (new AWS($this->config))->getCode($value, $creation_request_id);
return ($this->newAWS())->getCode($value, $creation_request_id);
}
@@ -82,7 +82,7 @@ final class AmazonIncentives
*/
public function cancelGiftCard(string $creation_request_id, string $gift_card_id): Response\CancelResponse
{
return (new AWS($this->config))->cancelCode($creation_request_id, $gift_card_id);
return ($this->newAWS())->cancelCode($creation_request_id, $gift_card_id);
}
/**
@@ -94,7 +94,7 @@ final class AmazonIncentives
*/
public function getAvailableFunds(): Response\CreateBalanceResponse
{
return (new AWS($this->config))->getBalance();
return ($this->newAWS())->getBalance();
}
/**
@@ -119,6 +119,17 @@ final class AmazonIncentives
return new static($key, $secret, $partner, $endpoint, $currency, $debug);
}
/**
* wrapper to create new AWS class.
* used in all buy/cancel/get calss
*
* @return AWS Main AWS worker class
*/
public function newAWS(): AWS
{
return new AWS($this->config);
}
/**
* Decodes the Exception message body
* Returns an array with code (Amazon error codes), type (Amazon error info)

View File

@@ -88,7 +88,7 @@ $run_fund_test = true;
// run the normal get/cancel gift card tests
$run_gift_tests = true;
// run mock error check tests
$run_mocks = false;
$run_mocks = true;
// should we print debug info
$debug_print = false;