Subversion Repositories SmartDukaan

Rev

Rev 12573 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12573 Rev 12575
Line 1... Line -...
1
Unexpected error.  File contents could not be restored from local history during undo/redo.
-
 
2
1
/******************************************************************************* 
-
 
2
 *  Copyright 2008-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
-
 
3
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
-
 
4
 *  
-
 
5
 *  You may not use this file except in compliance with the License. 
-
 
6
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
-
 
7
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
-
 
8
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
-
 
9
 *  specific language governing permissions and limitations under the License.
-
 
10
 * ***************************************************************************** 
-
 
11
 * 
-
 
12
 *  Marketplace Web Service Orders Java Library
-
 
13
 *  API Version: 2011-01-01
-
 
14
 * 
-
 
15
 */
-
 
16
 
-
 
17
 
-
 
18
 
-
 
19
package com.amazonservices.mws.orders.samples;
-
 
20
 
-
 
21
import java.util.List;
-
 
22
import java.util.ArrayList;
-
 
23
import com.amazonservices.mws.orders.*;
-
 
24
import com.amazonservices.mws.orders.model.*;
-
 
25
import com.amazonservices.mws.orders.mock.MarketplaceWebServiceOrdersMock;
-
 
26
 
-
 
27
/**
-
 
28
 *
-
 
29
 * List Order Items  Samples
-
 
30
 *
-
 
31
 *
-
 
32
 */
-
 
33
public class ListOrderItemsSample {
-
 
34
 
-
 
35
    /**
-
 
36
     * Just add few required parameters, and try the service
-
 
37
     * List Order Items functionality
-
 
38
     *
-
 
39
     * @param args unused
-
 
40
     */
-
 
41
    public static void main(String... args) {
-
 
42
        
-
 
43
        MarketplaceWebServiceOrders service = new MarketplaceWebServiceOrdersClient(
-
 
44
					OrdersConfig.accessKeyId, 
-
 
45
					OrdersConfig.secretAccessKey, 
-
 
46
					OrdersConfig.applicationName, 
-
 
47
					OrdersConfig.applicationVersion, 
-
 
48
					OrdersConfig.config);
-
 
49
 
-
 
50
        /************************************************************************
-
 
51
         * Uncomment to try out Mock Service that simulates Marketplace Web Service Orders 
-
 
52
         * responses without calling Marketplace Web Service Orders  service.
-
 
53
         *
-
 
54
         * Responses are loaded from local XML files. You can tweak XML files to
-
 
55
         * experiment with various outputs during development
-
 
56
         *
-
 
57
         * XML files available under com/amazonservices/mws/orders/mock tree
-
 
58
         *
-
 
59
         ***********************************************************************/
-
 
60
        // MarketplaceWebServiceOrders service = new MarketplaceWebServiceOrdersMock();
-
 
61
 
-
 
62
        /************************************************************************
-
 
63
         * Setup request parameters and uncomment invoke to try out 
-
 
64
         * sample for List Order Items 
-
 
65
         ***********************************************************************/
-
 
66
         ListOrderItemsRequest request = new ListOrderItemsRequest();
-
 
67
         request.setSellerId(OrdersConfig.sellerId);
-
 
68
        
-
 
69
         // @TODO: set request parameters here
-
 
70
 
-
 
71
         invokeListOrderItems(service, request);
-
 
72
 
-
 
73
    }
-
 
74
 
-
 
75
 
-
 
76
                                    
-
 
77
    /**
-
 
78
     * List Order Items  request sample
-
 
79
     * This operation can be used to list the items of the order indicated by the
-
 
80
     * given order id (only a single Amazon order id is allowed).
-
 
81
     *   
-
 
82
     * @param service instance of MarketplaceWebServiceOrders service
-
 
83
     * @param request Action to invoke
-
 
84
     */
-
 
85
    public static void invokeListOrderItems(MarketplaceWebServiceOrders service, ListOrderItemsRequest request) {
-
 
86
        try {
-
 
87
            
-
 
88
            ListOrderItemsResponse response = service.listOrderItems(request);
-
 
89
 
-
 
90
            
-
 
91
            System.out.println ("ListOrderItems Action Response");
-
 
92
            System.out.println ("=============================================================================");
-
 
93
            System.out.println ();
-
 
94
 
-
 
95
            System.out.println("    ListOrderItemsResponse");
-
 
96
            System.out.println();
-
 
97
            if (response.isSetListOrderItemsResult()) {
-
 
98
                System.out.println("        ListOrderItemsResult");
-
 
99
                System.out.println();
-
 
100
                ListOrderItemsResult  listOrderItemsResult = response.getListOrderItemsResult();
-
 
101
                if (listOrderItemsResult.isSetNextToken()) {
-
 
102
                    System.out.println("            NextToken");
-
 
103
                    System.out.println();
-
 
104
                    System.out.println("                " + listOrderItemsResult.getNextToken());
-
 
105
                    System.out.println();
-
 
106
                }
-
 
107
                if (listOrderItemsResult.isSetAmazonOrderId()) {
-
 
108
                    System.out.println("            AmazonOrderId");
-
 
109
                    System.out.println();
-
 
110
                    System.out.println("                " + listOrderItemsResult.getAmazonOrderId());
-
 
111
                    System.out.println();
-
 
112
                }
-
 
113
                if (listOrderItemsResult.isSetOrderItems()) {
-
 
114
                    System.out.println("            OrderItems");
-
 
115
                    System.out.println();
-
 
116
                    OrderItemList  orderItems = listOrderItemsResult.getOrderItems();
-
 
117
                    java.util.List<OrderItem> orderItemList = orderItems.getOrderItem();
-
 
118
                    for (OrderItem orderItem : orderItemList) {
-
 
119
                        System.out.println("                OrderItem");
-
 
120
                        System.out.println();
-
 
121
                        if (orderItem.isSetASIN()) {
-
 
122
                            System.out.println("                    ASIN");
-
 
123
                            System.out.println();
-
 
124
                            System.out.println("                        " + orderItem.getASIN());
-
 
125
                            System.out.println();
-
 
126
                        }
-
 
127
                        if (orderItem.isSetSellerSKU()) {
-
 
128
                            System.out.println("                    SellerSKU");
-
 
129
                            System.out.println();
-
 
130
                            System.out.println("                        " + orderItem.getSellerSKU());
-
 
131
                            System.out.println();
-
 
132
                        }
-
 
133
                        if (orderItem.isSetOrderItemId()) {
-
 
134
                            System.out.println("                    OrderItemId");
-
 
135
                            System.out.println();
-
 
136
                            System.out.println("                        " + orderItem.getOrderItemId());
-
 
137
                            System.out.println();
-
 
138
                        }
-
 
139
                        if (orderItem.isSetTitle()) {
-
 
140
                            System.out.println("                    Title");
-
 
141
                            System.out.println();
-
 
142
                            System.out.println("                        " + orderItem.getTitle());
-
 
143
                            System.out.println();
-
 
144
                        }
-
 
145
                        if (orderItem.isSetQuantityOrdered()) {
-
 
146
                            System.out.println("                    QuantityOrdered");
-
 
147
                            System.out.println();
-
 
148
                            System.out.println("                        " + orderItem.getQuantityOrdered());
-
 
149
                            System.out.println();
-
 
150
                        }
-
 
151
                        if (orderItem.isSetQuantityShipped()) {
-
 
152
                            System.out.println("                    QuantityShipped");
-
 
153
                            System.out.println();
-
 
154
                            System.out.println("                        " + orderItem.getQuantityShipped());
-
 
155
                            System.out.println();
-
 
156
                        }
-
 
157
                        if (orderItem.isSetItemPrice()) {
-
 
158
                            System.out.println("                    ItemPrice");
-
 
159
                            System.out.println();
-
 
160
                            Money  itemPrice = orderItem.getItemPrice();
-
 
161
                            if (itemPrice.isSetCurrencyCode()) {
-
 
162
                                System.out.println("                        CurrencyCode");
-
 
163
                                System.out.println();
-
 
164
                                System.out.println("                            " + itemPrice.getCurrencyCode());
-
 
165
                                System.out.println();
-
 
166
                            }
-
 
167
                            if (itemPrice.isSetAmount()) {
-
 
168
                                System.out.println("                        Amount");
-
 
169
                                System.out.println();
-
 
170
                                System.out.println("                            " + itemPrice.getAmount());
-
 
171
                                System.out.println();
-
 
172
                            }
-
 
173
                        } 
-
 
174
                        if (orderItem.isSetShippingPrice()) {
-
 
175
                            System.out.println("                    ShippingPrice");
-
 
176
                            System.out.println();
-
 
177
                            Money  shippingPrice = orderItem.getShippingPrice();
-
 
178
                            if (shippingPrice.isSetCurrencyCode()) {
-
 
179
                                System.out.println("                        CurrencyCode");
-
 
180
                                System.out.println();
-
 
181
                                System.out.println("                            " + shippingPrice.getCurrencyCode());
-
 
182
                                System.out.println();
-
 
183
                            }
-
 
184
                            if (shippingPrice.isSetAmount()) {
-
 
185
                                System.out.println("                        Amount");
-
 
186
                                System.out.println();
-
 
187
                                System.out.println("                            " + shippingPrice.getAmount());
-
 
188
                                System.out.println();
-
 
189
                            }
-
 
190
                        } 
-
 
191
                        if (orderItem.isSetGiftWrapPrice()) {
-
 
192
                            System.out.println("                    GiftWrapPrice");
-
 
193
                            System.out.println();
-
 
194
                            Money  giftWrapPrice = orderItem.getGiftWrapPrice();
-
 
195
                            if (giftWrapPrice.isSetCurrencyCode()) {
-
 
196
                                System.out.println("                        CurrencyCode");
-
 
197
                                System.out.println();
-
 
198
                                System.out.println("                            " + giftWrapPrice.getCurrencyCode());
-
 
199
                                System.out.println();
-
 
200
                            }
-
 
201
                            if (giftWrapPrice.isSetAmount()) {
-
 
202
                                System.out.println("                        Amount");
-
 
203
                                System.out.println();
-
 
204
                                System.out.println("                            " + giftWrapPrice.getAmount());
-
 
205
                                System.out.println();
-
 
206
                            }
-
 
207
                        } 
-
 
208
                        if (orderItem.isSetItemTax()) {
-
 
209
                            System.out.println("                    ItemTax");
-
 
210
                            System.out.println();
-
 
211
                            Money  itemTax = orderItem.getItemTax();
-
 
212
                            if (itemTax.isSetCurrencyCode()) {
-
 
213
                                System.out.println("                        CurrencyCode");
-
 
214
                                System.out.println();
-
 
215
                                System.out.println("                            " + itemTax.getCurrencyCode());
-
 
216
                                System.out.println();
-
 
217
                            }
-
 
218
                            if (itemTax.isSetAmount()) {
-
 
219
                                System.out.println("                        Amount");
-
 
220
                                System.out.println();
-
 
221
                                System.out.println("                            " + itemTax.getAmount());
-
 
222
                                System.out.println();
-
 
223
                            }
-
 
224
                        } 
-
 
225
                        if (orderItem.isSetShippingTax()) {
-
 
226
                            System.out.println("                    ShippingTax");
-
 
227
                            System.out.println();
-
 
228
                            Money  shippingTax = orderItem.getShippingTax();
-
 
229
                            if (shippingTax.isSetCurrencyCode()) {
-
 
230
                                System.out.println("                        CurrencyCode");
-
 
231
                                System.out.println();
-
 
232
                                System.out.println("                            " + shippingTax.getCurrencyCode());
-
 
233
                                System.out.println();
-
 
234
                            }
-
 
235
                            if (shippingTax.isSetAmount()) {
-
 
236
                                System.out.println("                        Amount");
-
 
237
                                System.out.println();
-
 
238
                                System.out.println("                            " + shippingTax.getAmount());
-
 
239
                                System.out.println();
-
 
240
                            }
-
 
241
                        } 
-
 
242
                        if (orderItem.isSetGiftWrapTax()) {
-
 
243
                            System.out.println("                    GiftWrapTax");
-
 
244
                            System.out.println();
-
 
245
                            Money  giftWrapTax = orderItem.getGiftWrapTax();
-
 
246
                            if (giftWrapTax.isSetCurrencyCode()) {
-
 
247
                                System.out.println("                        CurrencyCode");
-
 
248
                                System.out.println();
-
 
249
                                System.out.println("                            " + giftWrapTax.getCurrencyCode());
-
 
250
                                System.out.println();
-
 
251
                            }
-
 
252
                            if (giftWrapTax.isSetAmount()) {
-
 
253
                                System.out.println("                        Amount");
-
 
254
                                System.out.println();
-
 
255
                                System.out.println("                            " + giftWrapTax.getAmount());
-
 
256
                                System.out.println();
-
 
257
                            }
-
 
258
                        } 
-
 
259
                        if (orderItem.isSetShippingDiscount()) {
-
 
260
                            System.out.println("                    ShippingDiscount");
-
 
261
                            System.out.println();
-
 
262
                            Money  shippingDiscount = orderItem.getShippingDiscount();
-
 
263
                            if (shippingDiscount.isSetCurrencyCode()) {
-
 
264
                                System.out.println("                        CurrencyCode");
-
 
265
                                System.out.println();
-
 
266
                                System.out.println("                            " + shippingDiscount.getCurrencyCode());
-
 
267
                                System.out.println();
-
 
268
                            }
-
 
269
                            if (shippingDiscount.isSetAmount()) {
-
 
270
                                System.out.println("                        Amount");
-
 
271
                                System.out.println();
-
 
272
                                System.out.println("                            " + shippingDiscount.getAmount());
-
 
273
                                System.out.println();
-
 
274
                            }
-
 
275
                        } 
-
 
276
                        if (orderItem.isSetPromotionDiscount()) {
-
 
277
                            System.out.println("                    PromotionDiscount");
-
 
278
                            System.out.println();
-
 
279
                            Money  promotionDiscount = orderItem.getPromotionDiscount();
-
 
280
                            if (promotionDiscount.isSetCurrencyCode()) {
-
 
281
                                System.out.println("                        CurrencyCode");
-
 
282
                                System.out.println();
-
 
283
                                System.out.println("                            " + promotionDiscount.getCurrencyCode());
-
 
284
                                System.out.println();
-
 
285
                            }
-
 
286
                            if (promotionDiscount.isSetAmount()) {
-
 
287
                                System.out.println("                        Amount");
-
 
288
                                System.out.println();
-
 
289
                                System.out.println("                            " + promotionDiscount.getAmount());
-
 
290
                                System.out.println();
-
 
291
                            }
-
 
292
                        } 
-
 
293
                        if (orderItem.isSetPromotionIds()) {
-
 
294
                            System.out.println("                    PromotionIds");
-
 
295
                            System.out.println();
-
 
296
                            PromotionIdList  promotionIds = orderItem.getPromotionIds();
-
 
297
                            java.util.List<String> promotionIdList  =  promotionIds.getPromotionId();
-
 
298
                            for (String promotionId : promotionIdList) { 
-
 
299
                                System.out.println("                        PromotionId");
-
 
300
                                    System.out.println();
-
 
301
                                System.out.println("                            " + promotionId);
-
 
302
                            }	
-
 
303
                        } 
-
 
304
                        if (orderItem.isSetCODFee()) {
-
 
305
                            System.out.println("                    CODFee");
-
 
306
                            System.out.println();
-
 
307
                            Money  CODFee = orderItem.getCODFee();
-
 
308
                            if (CODFee.isSetCurrencyCode()) {
-
 
309
                                System.out.println("                        CurrencyCode");
-
 
310
                                System.out.println();
-
 
311
                                System.out.println("                            " + CODFee.getCurrencyCode());
-
 
312
                                System.out.println();
-
 
313
                            }
-
 
314
                            if (CODFee.isSetAmount()) {
-
 
315
                                System.out.println("                        Amount");
-
 
316
                                System.out.println();
-
 
317
                                System.out.println("                            " + CODFee.getAmount());
-
 
318
                                System.out.println();
-
 
319
                            }
-
 
320
                        } 
-
 
321
                        if (orderItem.isSetCODFeeDiscount()) {
-
 
322
                            System.out.println("                    CODFeeDiscount");
-
 
323
                            System.out.println();
-
 
324
                            Money  CODFeeDiscount = orderItem.getCODFeeDiscount();
-
 
325
                            if (CODFeeDiscount.isSetCurrencyCode()) {
-
 
326
                                System.out.println("                        CurrencyCode");
-
 
327
                                System.out.println();
-
 
328
                                System.out.println("                            " + CODFeeDiscount.getCurrencyCode());
-
 
329
                                System.out.println();
-
 
330
                            }
-
 
331
                            if (CODFeeDiscount.isSetAmount()) {
-
 
332
                                System.out.println("                        Amount");
-
 
333
                                System.out.println();
-
 
334
                                System.out.println("                            " + CODFeeDiscount.getAmount());
-
 
335
                                System.out.println();
-
 
336
                            }
-
 
337
                        } 
-
 
338
                        if (orderItem.isSetGiftMessageText()) {
-
 
339
                            System.out.println("                    GiftMessageText");
-
 
340
                            System.out.println();
-
 
341
                            System.out.println("                        " + orderItem.getGiftMessageText());
-
 
342
                            System.out.println();
-
 
343
                        }
-
 
344
                        if (orderItem.isSetGiftWrapLevel()) {
-
 
345
                            System.out.println("                    GiftWrapLevel");
-
 
346
                            System.out.println();
-
 
347
                            System.out.println("                        " + orderItem.getGiftWrapLevel());
-
 
348
                            System.out.println();
-
 
349
                        }
-
 
350
                        if (orderItem.isSetInvoiceData()) {
-
 
351
                            System.out.println("                    InvoiceData");
-
 
352
                            System.out.println();
-
 
353
                            InvoiceData  invoiceData = orderItem.getInvoiceData();
-
 
354
                            if (invoiceData.isSetInvoiceRequirement()) {
-
 
355
                                System.out.println("                        InvoiceRequirement");
-
 
356
                                System.out.println();
-
 
357
                                System.out.println("                            " + invoiceData.getInvoiceRequirement());
-
 
358
                                System.out.println();
-
 
359
                            }
-
 
360
                            if (invoiceData.isSetBuyerSelectedInvoiceCategory()) {
-
 
361
                                System.out.println("                        BuyerSelectedInvoiceCategory");
-
 
362
                                System.out.println();
-
 
363
                                System.out.println("                            " + invoiceData.getBuyerSelectedInvoiceCategory());
-
 
364
                                System.out.println();
-
 
365
                            }
-
 
366
                            if (invoiceData.isSetInvoiceTitle()) {
-
 
367
                                System.out.println("                        InvoiceTitle");
-
 
368
                                System.out.println();
-
 
369
                                System.out.println("                            " + invoiceData.getInvoiceTitle());
-
 
370
                                System.out.println();
-
 
371
                            }
-
 
372
                            if (invoiceData.isSetInvoiceInformation()) {
-
 
373
                                System.out.println("                        InvoiceInformation");
-
 
374
                                System.out.println();
-
 
375
                                System.out.println("                            " + invoiceData.getInvoiceInformation());
-
 
376
                                System.out.println();
-
 
377
                            }
-
 
378
                        } 
-
 
379
                    }
-
 
380
                } 
-
 
381
            } 
-
 
382
            if (response.isSetResponseMetadata()) {
-
 
383
                System.out.println("        ResponseMetadata");
-
 
384
                System.out.println();
-
 
385
                ResponseMetadata  responseMetadata = response.getResponseMetadata();
-
 
386
                if (responseMetadata.isSetRequestId()) {
-
 
387
                    System.out.println("            RequestId");
-
 
388
                    System.out.println();
-
 
389
                    System.out.println("                " + responseMetadata.getRequestId());
-
 
390
                    System.out.println();
-
 
391
                }
-
 
392
            } 
-
 
393
            System.out.println();
-
 
394
            System.out.println(response.getResponseHeaderMetadata());
-
 
395
            System.out.println();
-
 
396
 
-
 
397
           
-
 
398
        } catch (MarketplaceWebServiceOrdersException ex) {
-
 
399
            
-
 
400
            System.out.println("Caught Exception: " + ex.getMessage());
-
 
401
            System.out.println("Response Status Code: " + ex.getStatusCode());
-
 
402
            System.out.println("Error Code: " + ex.getErrorCode());
-
 
403
            System.out.println("Error Type: " + ex.getErrorType());
-
 
404
            System.out.println("Request ID: " + ex.getRequestId());
-
 
405
            System.out.println("XML: " + ex.getXML());
-
 
406
            System.out.print("ResponseHeaderMetadata: " + ex.getResponseHeaderMetadata());
-
 
407
        }
-
 
408
    }
-
 
409
            
-
 
410
}
-
 
411