1
1
Async Amazon Incentives
2
2
=======================
3
3
4
+ This package provides an unofficial SDK for the [ Amazon Incentives API] ( https://developer.amazon.com/docs/incentives-api/digital-gift-cards.html ) .
5
+
4
6
## Installation
5
7
6
8
Use [ Composer] ( https://getcomposer.org ) to install the library:
@@ -11,6 +13,43 @@ $ composer require incenteev/async-amazon-incentives
11
13
12
14
## Usage
13
15
16
+ ``` php
17
+ use AsyncAws\Core\Configuration;
18
+ use Incenteev\AsyncAmazonIncentives\AmazonIncentivesClient;
19
+ use Incenteev\AsyncAmazonIncentives\Enum\CurrencyCode;
20
+ use Incenteev\AsyncAmazonIncentives\Exception\SystemTemporarilyUnavailableException;
21
+ use Incenteev\AsyncAmazonIncentives\Region;
22
+ use Incenteev\AsyncAmazonIncentives\ValueObject\MoneyAmount;
23
+
24
+ // Get your credentials in the Amazon Incentives portal
25
+ $accessKey = '';
26
+ $secretKey = '';
27
+ $partnerId = '';
28
+
29
+ // Choose the region corresponding to your partnership, with either the sandbox or production one.
30
+ $region = Region::EUROPE_AND_ASIA_SANDBOX;
31
+
32
+ $client = new AmazonIncentivesClient([
33
+ Configuration::OPTION_ACCESS_KEY_ID => $accessKey,
34
+ Configuration::OPTION_SECRET_ACCESS_KEY => $secretKey,
35
+ Configuration::OPTION_REGION => $region,
36
+ ]);
37
+
38
+ try {
39
+ $result = $client->createGiftCard([
40
+ 'partnerId' => $partnerId,
41
+ 'creationRequestId' => '', // Create the proper request id
42
+ 'value' => new MoneyAmount(['amount' => 10, 'currencyCode' => CurrencyCode::EUR]),
43
+ ]);
44
+
45
+ $code = $result->getGcClaimCode();
46
+ } catch (SystemTemporarilyUnavailableException $e) {
47
+ // TODO handle temporary failures according to the Amazon Incentives best practices
48
+ }
49
+ ```
50
+
51
+ > Note: due to the async nature of the project, the exception is not actually thrown by the call to ` createGiftCard `
52
+ > but when the Result object gets resolved.
14
53
15
54
## License
16
55
0 commit comments