1. Obtain the official SDK of Amazon
For those of you who don’t, please click here
The official documentation
2. The results are as follows
@Test
public void test01(a){
1. Connect to spApi
1.1 Configure your own AWS credentials
AWSAuthenticationCredentials awsAuthenticationCredentials = AWSAuthenticationCredentials.builder()
.accessKeyId("you accessKeyId")
.secretKey("you secretKey")
.region("us-east-1")
.build();
//1.2 Configure your AWS credential provider
AWSAuthenticationCredentialsProvider awsAuthenticationCredentialsProvider = AWSAuthenticationCredentialsProvider.builder()
.roleArn("you roleArn")/ / IAM role
.roleSessionName("you roleSessionName")
.build();
1.3 Configuring LWA Credentials
LWAAuthorizationCredentials lwaAuthorizationCredentials = LWAAuthorizationCredentials.builder()
.clientId("you clientId")
.clientSecret("you clientSecret")
.refreshToken("you refreshToken")
.endpoint("https://api.amazon.com/auth/o2/token")//LWA validates the server URI
.build();
OrdersV0Api ordersV0Api = new OrdersV0Api.Builder().awsAuthenticationCredentials(awsAuthenticationCredentials)
.awsAuthenticationCredentialsProvider(awsAuthenticationCredentialsProvider)
.lwaAuthorizationCredentials(lwaAuthorizationCredentials)
// This experiment is a test environment
.endpoint("https://sandbox.sellingpartnerapi-na.amazon.com")
.build();
Copy the code
3. Refer to the orderSv0.json file to send the test request
OrdersV0.json
Select the content with X-Amazon-SPDS-Sandbox-behaviors as test requirements.
4. In field
4.1 getOrders
Request request:
Request code:
List<String> marketplaceIds = Arrays.asList("ATVPDKIKX0DER");
GetOrdersResponse orders = null;
try {
orders = ordersV0Api.getOrders(marketplaceIds, "TEST_CASE_200".null.null.null.null.null.null.null.null.null.null.null.null);
} catch (ApiException e) {
e.printStackTrace();
System.out.println("orders.getErrors().toString() = " + orders.getErrors().toString());
}
System.out.println("orders.getPayload().getOrders() = " + orders.getPayload().getOrders());
Copy the code
Request result:
4.2 getOrder
Request request:
Request code:
GetOrderResponse order = null;
try {
order = ordersV0Api.getOrder("TEST_CASE_200");
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println("order.getPayload() = " + order.getPayload());
Copy the code
Request result:
4.3 getOrderBuyerInfo
Request request:
Request code:
GetOrderBuyerInfoResponse order = null;
try {
order = ordersV0Api.getOrderBuyerInfo("TEST_CASE_200");
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println("order.getPayload() = " + order.getPayload());
Copy the code
Request result:
4.4 getOrderAddress
Request request:
Request code:
GetOrderAddressResponse order = null;
try {
order = ordersV0Api.getOrderAddress("TEST_CASE_200");
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println("order.getPayload() = " + order.getPayload());
Copy the code
Request result:
4.5 getOrderItems
Request request:
Request code:
GetOrderItemsResponse order = null;
try {
order = ordersV0Api.getOrderItems("TEST_CASE_200".null);
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println("order.getPayload() = " + order.getPayload());
Copy the code
Request result:
4.6 getOrderItemsBuyerInfo
Request request:
Request code:
GetOrderItemsBuyerInfoResponse order = null;
try {
order = ordersV0Api.getOrderItemsBuyerInfo("TEST_CASE_200".null);
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println("order.getPayload() = " + order.getPayload());
Copy the code
Request result:
All six interfaces to this official document have been tested!
PS: If you think it is helpful to you, you can leave a message in three consecutive times. Welcome to put forward your valuable opinions. If you want to have technical exchanges, you are welcome to join the Amazon API development Communication Group! Please add technical personnel on wechat:x118422Invite into the group