Skip to content

Commit 0647b69

Browse files
authored
Merge pull request #4 from stof/docs
Add better documentation for the project
2 parents bc8fc57 + 07a2637 commit 0647b69

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Async Amazon Incentives
22
=======================
33

4+
This package provides an unofficial SDK for the [Amazon Incentives API](https://developer.amazon.com/docs/incentives-api/digital-gift-cards.html).
5+
46
## Installation
57

68
Use [Composer](https://getcomposer.org) to install the library:
@@ -11,6 +13,43 @@ $ composer require incenteev/async-amazon-incentives
1113

1214
## Usage
1315

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.
1453
1554
## License
1655

0 commit comments

Comments
 (0)