不会的同窗请点击这里java
官方文档git
@Test
public void test01(){
//1.链接到spApi
//1.1配置本身的AWS凭证
AWSAuthenticationCredentials awsAuthenticationCredentials = AWSAuthenticationCredentials.builder()
.accessKeyId("you accessKeyId")
.secretKey("you secretKey")
.region("us-east-1")
.build();
//1.2配置您的AWS凭证提供商
AWSAuthenticationCredentialsProvider awsAuthenticationCredentialsProvider = AWSAuthenticationCredentialsProvider.builder()
.roleArn("you roleArn")//IAM角色
.roleSessionName("you roleSessionName")
.build();
//1.3配置LWA凭证
LWAAuthorizationCredentials lwaAuthorizationCredentials = LWAAuthorizationCredentials.builder()
.clientId("you clientId")
.clientSecret("you clientSecret")
.refreshToken("you refreshToken")
.endpoint("https://api.amazon.com/auth/o2/token")//LWA验证服务器URI
.build();
OrdersV0Api ordersV0Api = new OrdersV0Api.Builder().awsAuthenticationCredentials(awsAuthenticationCredentials)
.awsAuthenticationCredentialsProvider(awsAuthenticationCredentialsProvider)
.lwaAuthorizationCredentials(lwaAuthorizationCredentials)
//本次试验为测试环境
.endpoint("https://sandbox.sellingpartnerapi-na.amazon.com")
.build();
复制代码
OrdersV0.jsongithub
请选中带有x-amazon-spds-sandbox-behaviors的内容为测试请求要求。json
请求要求:api
请求代码:服务器
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());
复制代码
请求结果:微信
请求要求:markdown
请求代码:ide
GetOrderResponse order = null;
try {
order = ordersV0Api.getOrder("TEST_CASE_200");
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println("order.getPayload() = " + order.getPayload());
复制代码
请求结果:oop
请求要求:
请求代码:
GetOrderBuyerInfoResponse order = null;
try {
order = ordersV0Api.getOrderBuyerInfo("TEST_CASE_200");
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println("order.getPayload() = " + order.getPayload());
复制代码
请求结果:
请求要求:
请求代码:
GetOrderAddressResponse order = null;
try {
order = ordersV0Api.getOrderAddress("TEST_CASE_200");
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println("order.getPayload() = " + order.getPayload());
复制代码
请求结果:
请求要求:
请求代码:
GetOrderItemsResponse order = null;
try {
order = ordersV0Api.getOrderItems("TEST_CASE_200",null);
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println("order.getPayload() = " + order.getPayload());
复制代码
请求结果:
请求要求:
请求代码:
GetOrderItemsBuyerInfoResponse order = null;
try {
order = ordersV0Api.getOrderItemsBuyerInfo("TEST_CASE_200",null);
} catch (ApiException e) {
e.printStackTrace();
}
System.out.println("order.getPayload() = " + order.getPayload());
复制代码
请求结果:
到此官方文档的六个接口都以测试完毕!
PS:你们看了后以为对本身有帮助能够三连留言,欢迎提出宝贵意见,如想进行技术交流欢迎加入Amazon各种API开发交流群!请添加技术人员微信:x118422邀请进群~