incenteev / async-amazon-incentives
基于async-aws项目结构的Amazon Incentives API的SDK
v1.1.0
2024-05-03 12:29 UTC
Requires
- php: ^8.1
- ext-dom: *
- ext-simplexml: *
- async-aws/core: ^1.9
Requires (Dev)
- async-aws/code-generator: dev-master
- friendsofphp/php-cs-fixer: ^3.18
- phpstan/phpstan: ^1.10
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^10.2
README
此包为Amazon Incentives API提供了一个非官方的SDK。
安装
使用Composer安装库
$ composer require incenteev/async-amazon-incentives
使用方法
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 }
注意:由于项目异步特性,异常并非在调用
createGiftCard
时抛出,而是在Result对象解析时抛出。
许可证
本包采用MIT许可证。
报告问题或功能请求
问题和功能请求在GitHub问题跟踪器中跟踪。