AGCOD Client SDK

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.

License

License

Categories

Categories

Java Languages CLI User Interface
GroupId

GroupId

com.github.mayflower
ArtifactId

ArtifactId

agcod-java-client
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

AGCOD Client SDK
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.
Project URL

Project URL

https://github.com/mayflower/agcod-java-client
Source Code Management

Source Code Management

https://github.com/mayflower/agcod-java-client.git

Download agcod-java-client

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.mayflower/agcod-java-client/ -->
<dependency>
    <groupId>com.github.mayflower</groupId>
    <artifactId>agcod-java-client</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.mayflower/agcod-java-client/
implementation 'com.github.mayflower:agcod-java-client:1.0'
// https://jarcasting.com/artifacts/com.github.mayflower/agcod-java-client/
implementation ("com.github.mayflower:agcod-java-client:1.0")
'com.github.mayflower:agcod-java-client:jar:1.0'
<dependency org="com.github.mayflower" name="agcod-java-client" rev="1.0">
  <artifact name="agcod-java-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.mayflower', module='agcod-java-client', version='1.0')
)
libraryDependencies += "com.github.mayflower" % "agcod-java-client" % "1.0"
[com.github.mayflower/agcod-java-client "1.0"]

Dependencies

compile (5)

Group / Artifact Type Version
software.amazon.awssdk : sdk-core jar 2.10.39
software.amazon.awssdk : aws-json-protocol jar 2.10.39
software.amazon.awssdk : protocol-core jar 2.10.39
software.amazon.awssdk : codegen-maven-plugin jar 2.10.39
com.fasterxml.jackson.core : jackson-annotations jar 2.9.0

test (4)

Group / Artifact Type Version
software.amazon.awssdk : sts jar 2.10.39
junit : junit jar 4.12
org.slf4j : slf4j-log4j12 jar 1.7.28
com.github.tomakehurst : wiremock jar 2.18.0

Project Modules

There are no modules declared in this project.

AGCOD Client for Java (based on AWS SDK 2.0)

Maven

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.

Getting Started

Docs

Before you begin, check the general documenation of the Amazon Incentives API.

Credentials for AGCOD

You need credentials for the AGCOD API. Amazon provides a scratchpad where you can test your credentials beforehand.

Minimum requirements

To run the SDK you will need Java 1.8+.

Using the Client

The recommended way to use the AGCOD Client for Java in your project is to consume it from Maven.

Importing the BOM

<dependency>
    <groupId>com.github.mayflower</groupId>
    <artifactId>agcod-java-client</artifactId>
    <version>1.0</version>
</dependency>

Initialize the Client

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();

Create Gift Card Request

CreateGiftCardResponse response = client.createGiftCard(CreateGiftCardRequest.builder()
        .creationRequestId("F0000")
        .partnerId("partnerId")
        .value(AgcodValue.builder()
                .amount(10F)
                .currencyCode(CurrencyCode.EUR)
                .build())
        .build());

Cancel Gift Card Request

CancelGiftCardResponse response = client.cancelGiftCard(CancelGiftCardRequest.builder()
        .creationRequestId("F0000")
        .partnerId("partnerId")
        .build());

Get Available Funds Request

GetAvailableFundsResponse response = client.getAvailableFunds(GetAvailableFundsRequest.builder()
        .partnerId("partnerId")
        .build());

Catching Errors

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

Note

Since Amazon Incentives "does not fall under Amazon Web Services (AWS)" an integration into the official AWS SDK is not desired.

To Do

com.github.mayflower

Mayflower GmbH

Versions

Version
1.0