不會的同窗請點擊這裏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邀請進羣~