Skip to content

Commit

Permalink
Merge pull request #8 from goaround/goaround-patch-3
Browse files Browse the repository at this point in the history
Provide a valid default endpoint
  • Loading branch information
kamerk22 authored Oct 3, 2021
2 parents 575508a + 9ee6fab commit 521a0f5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"homepage": "https://github.com/kamerk22/amazongiftcode",
"keywords": ["Laravel", "AmazonGiftCode", "Amazon", "GiftCard", "AGCOD", "Incentives API", "Amazon Incentives API"],
"require": {
"illuminate/support": "~5|^6.0|^7.0"
"illuminate/support": "~5|^6.0|^7.0|^8.0"
},
"require-dev": {
"phpunit/phpunit": "~7.0|~8.0",
Expand Down
4 changes: 2 additions & 2 deletions config/amazongiftcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
|
*/

'endpoint' => env('GIFT_CARD_ENDPOINT', 'agcod-v2-gamma.amazon.com'),
'endpoint' => env('GIFT_CARD_ENDPOINT', 'https://agcod-v2-gamma.amazon.com'),


/*
Expand Down Expand Up @@ -57,4 +57,4 @@

'debug' => env('GIFT_CARD_DEBUG', false)

];
];
10 changes: 5 additions & 5 deletions src/AWS/AWS.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ public function __construct(Config $config)

/**
* @param $amount
* @param $creationId
* @return CreateResponse
*
* @throws AmazonErrors
*/
public function getCode($amount): CreateResponse
public function getCode($amount, $creationId = null): CreateResponse
{
$serviceOperation = self::CREATE_GIFT_CARD_SERVICE;
$payload = $this->getGiftCardPayload($amount);
$payload = $this->getGiftCardPayload($amount, $creationId);
$canonicalRequest = $this->getCanonicalRequest($serviceOperation, $payload);
$dateTimeString = $this->getTimestamp();
$result = json_decode($this->makeRequest($payload, $canonicalRequest, $serviceOperation, $dateTimeString), true);
Expand Down Expand Up @@ -231,8 +232,6 @@ public function buildDerivedKey($rawOutput = true): string
*/
public function getRegion(): string
{


$endpoint = $this->_config->getEndpoint();
$regionName = 'us-east-1';

Expand All @@ -247,13 +246,14 @@ public function getRegion(): string

/**
* @param $amount
* @param $creationId
* @return string
*/
public function getGiftCardPayload($amount, $creationId = null): string
{
$amount = trim($amount);
$payload = [
"creationRequestId" => $this->_config->getPartner() . "_" . time(),
'creationRequestId' => $creationId ?: uniqid($this->_config->getPartner().'_'),
'partnerId' => $this->_config->getPartner(),
'value' =>
[
Expand Down
7 changes: 4 additions & 3 deletions src/AmazonGiftCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ public function __construct($key = null, $secret = null, $partner = null, $endpo

/**
* @param Float $value
* @param string $creationRequestId
* @return Response\CreateResponse
*
* @throws AmazonErrors
*/
public function buyGiftCard(Float $value): Response\CreateResponse
public function buyGiftCard(Float $value, string $creationRequestId = null): Response\CreateResponse
{
return (new AWS($this->_config))->getCode($value);
return (new AWS($this->_config))->getCode($value, $creationRequestId);
}


Expand Down Expand Up @@ -72,4 +73,4 @@ public static function make($key = null, $secret = null, $partner = null, $endpo
return new static($key, $secret, $partner, $endpoint, $currency);
}

}
}

0 comments on commit 521a0f5

Please sign in to comment.