The AGCOD (Amazon Gift Cards On Demand) SDK for Java is a client based on the official AWS SDK Java v2 for the Amazon Incentives API.
Before you begin, check the general documenation of the Amazon Incentives API.
You need credentials for the AGCOD API. Amazon provides a scratchpad where you can test your credentials beforehand.
To run the SDK you will need Java 1.8+.
The recommended way to use the AGCOD Client for Java in your project is to consume it from Maven.
<dependency>
<groupId>com.github.mayflower</groupId>
<artifactId>agcod-java-client</artifactId>
<version>1.0</version>
</dependency>
AgcodClient client = AgcodClient.builder()
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("accessKey", "secretKey")))
.region(Region.US_EAST_1)
.endpointOverride(AgcodHost.SANDBOX_NORTH_AMERICA.getUri())
.overrideConfiguration(o -> o
.addExecutionInterceptor(new AcceptJsonInterceptor()))
.build();
CreateGiftCardResponse response = client.createGiftCard(CreateGiftCardRequest.builder()
.creationRequestId("F0000")
.partnerId("partnerId")
.value(AgcodValue.builder()
.amount(10F)
.currencyCode(CurrencyCode.EUR)
.build())
.build());
CancelGiftCardResponse response = client.cancelGiftCard(CancelGiftCardRequest.builder()
.creationRequestId("F0000")
.partnerId("partnerId")
.build());
GetAvailableFundsResponse response = client.getAvailableFunds(GetAvailableFundsRequest.builder()
.partnerId("partnerId")
.build());
The client will throw the following exceptions according to the documentation:
Amazon Error Code | Java Exception | Comment |
---|---|---|
F100 | SystemErrorException | System Errors |
F2xx | PartnerInputErrorException | Partner Input Errors |
F3xx | PartnerAccessErrorException | Partner Account/Access/Onboarding Errors |
F400 | ResendErrorException | System Temporarily Unavailable: The library will attempt automatic retries on this error up to 8 times with an exponential backoff strategy |
F500 | UnknownErrorException | Unknown Error |
Since Amazon Incentives "does not fall under Amazon Web Services (AWS)" an integration into the official AWS SDK is not desired.
- Create Gift Card
- Cancel Gift Card
- Get Available Funds
- Parse dates in response as
Date
- not asString
- Support for physical gift cards