https://github.com/incenteev/async-amazon-incentives
SDK for the Amazon Incentives API based on the structure of the async-aws project
https://github.com/incenteev/async-amazon-incentives
hacktoberfest
Last synced: 12 months ago
JSON representation
SDK for the Amazon Incentives API based on the structure of the async-aws project
- Host: GitHub
- URL: https://github.com/incenteev/async-amazon-incentives
- Owner: Incenteev
- License: mit
- Created: 2023-07-05T09:16:38.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-14T07:27:27.000Z (over 1 year ago)
- Last Synced: 2025-05-29T10:14:53.407Z (about 1 year ago)
- Topics: hacktoberfest
- Language: PHP
- Homepage:
- Size: 47.9 KB
- Stars: 2
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Async Amazon Incentives
=======================
This package provides an unofficial SDK for the [Amazon Incentives API](https://developer.amazon.com/docs/incentives-api/digital-gift-cards.html).
## Installation
Use [Composer](https://getcomposer.org) to install the library:
```bash
$ composer require incenteev/async-amazon-incentives
```
## Usage
```php
use AsyncAws\Core\Configuration;
use Incenteev\AsyncAmazonIncentives\AmazonIncentivesClient;
use Incenteev\AsyncAmazonIncentives\Enum\CurrencyCode;
use Incenteev\AsyncAmazonIncentives\Exception\SystemTemporarilyUnavailableException;
use Incenteev\AsyncAmazonIncentives\Region;
use Incenteev\AsyncAmazonIncentives\ValueObject\MoneyAmount;
// Get your credentials in the Amazon Incentives portal
$accessKey = '';
$secretKey = '';
$partnerId = '';
// Choose the region corresponding to your partnership, with either the sandbox or production one.
$region = Region::EUROPE_AND_ASIA_SANDBOX;
$client = new AmazonIncentivesClient([
Configuration::OPTION_ACCESS_KEY_ID => $accessKey,
Configuration::OPTION_SECRET_ACCESS_KEY => $secretKey,
Configuration::OPTION_REGION => $region,
]);
try {
$result = $client->createGiftCard([
'partnerId' => $partnerId,
'creationRequestId' => '', // Create the proper request id
'value' => new MoneyAmount(['amount' => 10, 'currencyCode' => CurrencyCode::EUR]),
]);
$code = $result->getGcClaimCode();
} catch (SystemTemporarilyUnavailableException $e) {
// TODO handle temporary failures according to the Amazon Incentives best practices
}
```
> Note: due to the async nature of the project, the exception is not actually thrown by the call to `createGiftCard`
> but when the Result object gets resolved.
## License
This package is under the [MIT license](LICENSE).
## Reporting an issue or a feature request
Issues and feature requests are tracked in the [GitHub issue tracker](https://github.com/Incenteev/async-amazon-incentives/issues).