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 Orders  Samples
-
 
30
 *
-
 
31
 *
-
 
32
 */
-
 
33
public class ListOrdersSample {
-
 
34
 
-
 
35
    /**
-
 
36
     * Just add few required parameters, and try the service
-
 
37
     * List Orders 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 Orders 
-
 
65
         ***********************************************************************/
-
 
66
         ListOrdersRequest request = new ListOrdersRequest();
-
 
67
         request.setSellerId(OrdersConfig.sellerId);
-
 
68
        
-
 
69
         // @TODO: set request parameters here
-
 
70
 
-
 
71
         invokeListOrders(service, request);
-
 
72
 
-
 
73
    }
-
 
74
 
-
 
75
 
-
 
76
                                        
-
 
77
    /**
-
 
78
     * List Orders  request sample
-
 
79
     * ListOrders can be used to find orders that meet the specified criteria.
-
 
80
     *   
-
 
81
     * @param service instance of MarketplaceWebServiceOrders service
-
 
82
     * @param request Action to invoke
-
 
83
     */
-
 
84
    public static void invokeListOrders(MarketplaceWebServiceOrders service, ListOrdersRequest request) {
-
 
85
        try {
-
 
86
            
-
 
87
            ListOrdersResponse response = service.listOrders(request);
-
 
88
 
-
 
89
            
-
 
90
            System.out.println ("ListOrders Action Response");
-
 
91
            System.out.println ("=============================================================================");
-
 
92
            System.out.println ();
-
 
93
 
-
 
94
            System.out.println("    ListOrdersResponse");
-
 
95
            System.out.println();
-
 
96
            if (response.isSetListOrdersResult()) {
-
 
97
                System.out.println("        ListOrdersResult");
-
 
98
                System.out.println();
-
 
99
                ListOrdersResult  listOrdersResult = response.getListOrdersResult();
-
 
100
                if (listOrdersResult.isSetNextToken()) {
-
 
101
                    System.out.println("            NextToken");
-
 
102
                    System.out.println();
-
 
103
                    System.out.println("                " + listOrdersResult.getNextToken());
-
 
104
                    System.out.println();
-
 
105
                }
-
 
106
                if (listOrdersResult.isSetCreatedBefore()) {
-
 
107
                    System.out.println("            CreatedBefore");
-
 
108
                    System.out.println();
-
 
109
                    System.out.println("                " + listOrdersResult.getCreatedBefore());
-
 
110
                    System.out.println();
-
 
111
                }
-
 
112
                if (listOrdersResult.isSetLastUpdatedBefore()) {
-
 
113
                    System.out.println("            LastUpdatedBefore");
-
 
114
                    System.out.println();
-
 
115
                    System.out.println("                " + listOrdersResult.getLastUpdatedBefore());
-
 
116
                    System.out.println();
-
 
117
                }
-
 
118
                if (listOrdersResult.isSetOrders()) {
-
 
119
                    System.out.println("            Orders");
-
 
120
                    System.out.println();
-
 
121
                    OrderList  orders = listOrdersResult.getOrders();
-
 
122
                    java.util.List<Order> orderList = orders.getOrder();
-
 
123
                    for (Order order : orderList) {
-
 
124
                        System.out.println("                Order");
-
 
125
                        System.out.println();
-
 
126
                        if (order.isSetAmazonOrderId()) {
-
 
127
                            System.out.println("                    AmazonOrderId");
-
 
128
                            System.out.println();
-
 
129
                            System.out.println("                        " + order.getAmazonOrderId());
-
 
130
                            System.out.println();
-
 
131
                        }
-
 
132
                        if (order.isSetSellerOrderId()) {
-
 
133
                            System.out.println("                    SellerOrderId");
-
 
134
                            System.out.println();
-
 
135
                            System.out.println("                        " + order.getSellerOrderId());
-
 
136
                            System.out.println();
-
 
137
                        }
-
 
138
                        if (order.isSetPurchaseDate()) {
-
 
139
                            System.out.println("                    PurchaseDate");
-
 
140
                            System.out.println();
-
 
141
                            System.out.println("                        " + order.getPurchaseDate());
-
 
142
                            System.out.println();
-
 
143
                        }
-
 
144
                        if (order.isSetLastUpdateDate()) {
-
 
145
                            System.out.println("                    LastUpdateDate");
-
 
146
                            System.out.println();
-
 
147
                            System.out.println("                        " + order.getLastUpdateDate());
-
 
148
                            System.out.println();
-
 
149
                        }
-
 
150
                        if (order.isSetOrderStatus()) {
-
 
151
                            System.out.println("                    OrderStatus");
-
 
152
                            System.out.println();
-
 
153
                            System.out.println("                        " + order.getOrderStatus().value());
-
 
154
                            System.out.println();
-
 
155
                        }
-
 
156
                        if (order.isSetFulfillmentChannel()) {
-
 
157
                            System.out.println("                    FulfillmentChannel");
-
 
158
                            System.out.println();
-
 
159
                            System.out.println("                        " + order.getFulfillmentChannel().value());
-
 
160
                            System.out.println();
-
 
161
                        }
-
 
162
                        if (order.isSetSalesChannel()) {
-
 
163
                            System.out.println("                    SalesChannel");
-
 
164
                            System.out.println();
-
 
165
                            System.out.println("                        " + order.getSalesChannel());
-
 
166
                            System.out.println();
-
 
167
                        }
-
 
168
                        if (order.isSetOrderChannel()) {
-
 
169
                            System.out.println("                    OrderChannel");
-
 
170
                            System.out.println();
-
 
171
                            System.out.println("                        " + order.getOrderChannel());
-
 
172
                            System.out.println();
-
 
173
                        }
-
 
174
                        if (order.isSetShipServiceLevel()) {
-
 
175
                            System.out.println("                    ShipServiceLevel");
-
 
176
                            System.out.println();
-
 
177
                            System.out.println("                        " + order.getShipServiceLevel());
-
 
178
                            System.out.println();
-
 
179
                        }
-
 
180
                        if (order.isSetShippingAddress()) {
-
 
181
                            System.out.println("                    ShippingAddress");
-
 
182
                            System.out.println();
-
 
183
                            Address  shippingAddress = order.getShippingAddress();
-
 
184
                            if (shippingAddress.isSetName()) {
-
 
185
                                System.out.println("                        Name");
-
 
186
                                System.out.println();
-
 
187
                                System.out.println("                            " + shippingAddress.getName());
-
 
188
                                System.out.println();
-
 
189
                            }
-
 
190
                            if (shippingAddress.isSetAddressLine1()) {
-
 
191
                                System.out.println("                        AddressLine1");
-
 
192
                                System.out.println();
-
 
193
                                System.out.println("                            " + shippingAddress.getAddressLine1());
-
 
194
                                System.out.println();
-
 
195
                            }
-
 
196
                            if (shippingAddress.isSetAddressLine2()) {
-
 
197
                                System.out.println("                        AddressLine2");
-
 
198
                                System.out.println();
-
 
199
                                System.out.println("                            " + shippingAddress.getAddressLine2());
-
 
200
                                System.out.println();
-
 
201
                            }
-
 
202
                            if (shippingAddress.isSetAddressLine3()) {
-
 
203
                                System.out.println("                        AddressLine3");
-
 
204
                                System.out.println();
-
 
205
                                System.out.println("                            " + shippingAddress.getAddressLine3());
-
 
206
                                System.out.println();
-
 
207
                            }
-
 
208
                            if (shippingAddress.isSetCity()) {
-
 
209
                                System.out.println("                        City");
-
 
210
                                System.out.println();
-
 
211
                                System.out.println("                            " + shippingAddress.getCity());
-
 
212
                                System.out.println();
-
 
213
                            }
-
 
214
                            if (shippingAddress.isSetCounty()) {
-
 
215
                                System.out.println("                        County");
-
 
216
                                System.out.println();
-
 
217
                                System.out.println("                            " + shippingAddress.getCounty());
-
 
218
                                System.out.println();
-
 
219
                            }
-
 
220
                            if (shippingAddress.isSetDistrict()) {
-
 
221
                                System.out.println("                        District");
-
 
222
                                System.out.println();
-
 
223
                                System.out.println("                            " + shippingAddress.getDistrict());
-
 
224
                                System.out.println();
-
 
225
                            }
-
 
226
                            if (shippingAddress.isSetStateOrRegion()) {
-
 
227
                                System.out.println("                        StateOrRegion");
-
 
228
                                System.out.println();
-
 
229
                                System.out.println("                            " + shippingAddress.getStateOrRegion());
-
 
230
                                System.out.println();
-
 
231
                            }
-
 
232
                            if (shippingAddress.isSetPostalCode()) {
-
 
233
                                System.out.println("                        PostalCode");
-
 
234
                                System.out.println();
-
 
235
                                System.out.println("                            " + shippingAddress.getPostalCode());
-
 
236
                                System.out.println();
-
 
237
                            }
-
 
238
                            if (shippingAddress.isSetCountryCode()) {
-
 
239
                                System.out.println("                        CountryCode");
-
 
240
                                System.out.println();
-
 
241
                                System.out.println("                            " + shippingAddress.getCountryCode());
-
 
242
                                System.out.println();
-
 
243
                            }
-
 
244
                            if (shippingAddress.isSetPhone()) {
-
 
245
                                System.out.println("                        Phone");
-
 
246
                                System.out.println();
-
 
247
                                System.out.println("                            " + shippingAddress.getPhone());
-
 
248
                                System.out.println();
-
 
249
                            }
-
 
250
                        } 
-
 
251
                        if (order.isSetOrderTotal()) {
-
 
252
                            System.out.println("                    OrderTotal");
-
 
253
                            System.out.println();
-
 
254
                            Money  orderTotal = order.getOrderTotal();
-
 
255
                            if (orderTotal.isSetCurrencyCode()) {
-
 
256
                                System.out.println("                        CurrencyCode");
-
 
257
                                System.out.println();
-
 
258
                                System.out.println("                            " + orderTotal.getCurrencyCode());
-
 
259
                                System.out.println();
-
 
260
                            }
-
 
261
                            if (orderTotal.isSetAmount()) {
-
 
262
                                System.out.println("                        Amount");
-
 
263
                                System.out.println();
-
 
264
                                System.out.println("                            " + orderTotal.getAmount());
-
 
265
                                System.out.println();
-
 
266
                            }
-
 
267
                        } 
-
 
268
                        if (order.isSetNumberOfItemsShipped()) {
-
 
269
                            System.out.println("                    NumberOfItemsShipped");
-
 
270
                            System.out.println();
-
 
271
                            System.out.println("                        " + order.getNumberOfItemsShipped());
-
 
272
                            System.out.println();
-
 
273
                        }
-
 
274
                        if (order.isSetNumberOfItemsUnshipped()) {
-
 
275
                            System.out.println("                    NumberOfItemsUnshipped");
-
 
276
                            System.out.println();
-
 
277
                            System.out.println("                        " + order.getNumberOfItemsUnshipped());
-
 
278
                            System.out.println();
-
 
279
                        }
-
 
280
                        if (order.isSetPaymentExecutionDetail()) {
-
 
281
                            System.out.println("                    PaymentExecutionDetail");
-
 
282
                            System.out.println();
-
 
283
                            PaymentExecutionDetailItemList  paymentExecutionDetail = order.getPaymentExecutionDetail();
-
 
284
                            java.util.List<PaymentExecutionDetailItem> paymentExecutionDetailItemList = paymentExecutionDetail.getPaymentExecutionDetailItem();
-
 
285
                            for (PaymentExecutionDetailItem paymentExecutionDetailItem : paymentExecutionDetailItemList) {
-
 
286
                                System.out.println("                        PaymentExecutionDetailItem");
-
 
287
                                System.out.println();
-
 
288
                                if (paymentExecutionDetailItem.isSetPayment()) {
-
 
289
                                    System.out.println("                            Payment");
-
 
290
                                    System.out.println();
-
 
291
                                    Money  payment = paymentExecutionDetailItem.getPayment();
-
 
292
                                    if (payment.isSetCurrencyCode()) {
-
 
293
                                        System.out.println("                                CurrencyCode");
-
 
294
                                        System.out.println();
-
 
295
                                        System.out.println("                                    " + payment.getCurrencyCode());
-
 
296
                                        System.out.println();
-
 
297
                                    }
-
 
298
                                    if (payment.isSetAmount()) {
-
 
299
                                        System.out.println("                                Amount");
-
 
300
                                        System.out.println();
-
 
301
                                        System.out.println("                                    " + payment.getAmount());
-
 
302
                                        System.out.println();
-
 
303
                                    }
-
 
304
                                } 
-
 
305
                                if (paymentExecutionDetailItem.isSetPaymentMethod()) {
-
 
306
                                    System.out.println("                            PaymentMethod");
-
 
307
                                    System.out.println();
-
 
308
                                    System.out.println("                                " + paymentExecutionDetailItem.getPaymentMethod());
-
 
309
                                    System.out.println();
-
 
310
                                }
-
 
311
                            }
-
 
312
                        } 
-
 
313
                        if (order.isSetPaymentMethod()) {
-
 
314
                            System.out.println("                    PaymentMethod");
-
 
315
                            System.out.println();
-
 
316
                            System.out.println("                        " + order.getPaymentMethod().value());
-
 
317
                            System.out.println();
-
 
318
                        }
-
 
319
                        if (order.isSetMarketplaceId()) {
-
 
320
                            System.out.println("                    MarketplaceId");
-
 
321
                            System.out.println();
-
 
322
                            System.out.println("                        " + order.getMarketplaceId());
-
 
323
                            System.out.println();
-
 
324
                        }
-
 
325
                        if (order.isSetBuyerEmail()) {
-
 
326
                            System.out.println("                    BuyerEmail");
-
 
327
                            System.out.println();
-
 
328
                            System.out.println("                        " + order.getBuyerEmail());
-
 
329
                            System.out.println();
-
 
330
                        }
-
 
331
                        if (order.isSetBuyerName()) {
-
 
332
                            System.out.println("                    BuyerName");
-
 
333
                            System.out.println();
-
 
334
                            System.out.println("                        " + order.getBuyerName());
-
 
335
                            System.out.println();
-
 
336
                        }
-
 
337
                        if (order.isSetShipmentServiceLevelCategory()) {
-
 
338
                            System.out.println("                    ShipmentServiceLevelCategory");
-
 
339
                            System.out.println();
-
 
340
                            System.out.println("                        " + order.getShipmentServiceLevelCategory());
-
 
341
                            System.out.println();
-
 
342
                        }
-
 
343
                        if (order.isSetShippedByAmazonTFM()) {
-
 
344
                            System.out.println("                    ShippedByAmazonTFM");
-
 
345
                            System.out.println();
-
 
346
                            System.out.println("                        " + order.isShippedByAmazonTFM());
-
 
347
                            System.out.println();
-
 
348
                        }
-
 
349
                        if (order.isSetTFMShipmentStatus()) {
-
 
350
                            System.out.println("                    TFMShipmentStatus");
-
 
351
                            System.out.println();
-
 
352
                            System.out.println("                        " + order.getTFMShipmentStatus());
-
 
353
                            System.out.println();
-
 
354
                        }
-
 
355
                    }
-
 
356
                } 
-
 
357
            } 
-
 
358
            if (response.isSetResponseMetadata()) {
-
 
359
                System.out.println("        ResponseMetadata");
-
 
360
                System.out.println();
-
 
361
                ResponseMetadata  responseMetadata = response.getResponseMetadata();
-
 
362
                if (responseMetadata.isSetRequestId()) {
-
 
363
                    System.out.println("            RequestId");
-
 
364
                    System.out.println();
-
 
365
                    System.out.println("                " + responseMetadata.getRequestId());
-
 
366
                    System.out.println();
-
 
367
                }
-
 
368
            } 
-
 
369
            System.out.println();
-
 
370
            System.out.println(response.getResponseHeaderMetadata());
-
 
371
            System.out.println();
-
 
372
 
-
 
373
           
-
 
374
        } catch (MarketplaceWebServiceOrdersException ex) {
-
 
375
            
-
 
376
            System.out.println("Caught Exception: " + ex.getMessage());
-
 
377
            System.out.println("Response Status Code: " + ex.getStatusCode());
-
 
378
            System.out.println("Error Code: " + ex.getErrorCode());
-
 
379
            System.out.println("Error Type: " + ex.getErrorType());
-
 
380
            System.out.println("Request ID: " + ex.getRequestId());
-
 
381
            System.out.println("XML: " + ex.getXML());
-
 
382
            System.out.print("ResponseHeaderMetadata: " + ex.getResponseHeaderMetadata());
-
 
383
        }
-
 
384
    }
-
 
385
        
-
 
386
}
-
 
387