Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
8224 manish.sha 1
/******************************************************************************* 
2
 *  Copyright 2009 Amazon Services.
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 Java Library
13
 *  API Version: 2009-01-01
14
 *  Generated: Wed Feb 18 13:28:48 PST 2009 
15
 * 
16
 */
17
 
18
 
19
 
20
package com.amazonaws.mws.samples;
21
 
22
import java.util.HashMap;
23
import java.util.List;
24
import java.util.ArrayList;
25
import java.util.Map;
26
 
27
import com.amazonaws.mws.*;
28
import com.amazonaws.mws.model.*;
29
import com.amazonaws.mws.mock.MarketplaceWebServiceMock;
30
 
31
/**
32
 *
33
 * Get Report List  Samples
34
 *
35
 *
36
 */
37
public class GetReportListSample {
38
 
39
    /**
40
     * Just add a few required parameters, and try the service
41
     * Get Report List functionality
42
     *
43
     * @param args unused
44
     */
45
    public static void main(String... args) {
46
 
47
        /************************************************************************
48
         * Access Key ID and Secret Access Key ID, obtained from:
49
         * http://aws.amazon.com
50
         ***********************************************************************/
51
    	final String accessKeyId = "AKIAII3SGRXBJDPCHSGQ";
52
		final String secretAccessKey = "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";
53
 
54
		final String appName = "Test";
55
		final String appVersion = "1.0";
56
		final String merchantId = "AF6E3O0VE0X4D";
57
 
58
        MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();
59
 
60
        /************************************************************************
61
         * Uncomment to set the appropriate MWS endpoint.
62
         ************************************************************************/
63
        // US
64
        // config.setServiceURL("https://mws.amazonservices.com");
65
        // UK
66
        // config.setServiceURL("https://mws.amazonservices.co.uk");
67
        // Germany
68
        // config.setServiceURL("https://mws.amazonservices.de");
69
        // France
70
        // config.setServiceURL("https://mws.amazonservices.fr");
71
        // Italy
72
        // config.setServiceURL("https://mws.amazonservices.it");
73
        // Japan
74
        // config.setServiceURL("https://mws.amazonservices.jp");
75
        // China
76
        // config.setServiceURL("https://mws.amazonservices.com.cn");
77
        // Canada
78
        // config.setServiceURL("https://mws.amazonservices.ca");
79
        // India
80
           config.setServiceURL("https://mws.amazonservices.in");
81
 
82
        /************************************************************************
83
         * You can also try advanced configuration options. Available options are:
84
         *
85
         *  - Signature Version
86
         *  - Proxy Host and Proxy Port
87
         *  - User Agent String to be sent to Marketplace Web Service
88
         *
89
         ***********************************************************************/
90
 
91
        /************************************************************************
92
         * Instantiate Http Client Implementation of Marketplace Web Service        
93
         ***********************************************************************/
94
 
95
        MarketplaceWebService service = new MarketplaceWebServiceClient(
96
                accessKeyId, secretAccessKey, appName, appVersion, config);
97
 
98
        /************************************************************************
99
         * Uncomment to try out Mock Service that simulates Marketplace Web Service 
100
         * responses without calling Marketplace Web Service  service.
101
         *
102
         * Responses are loaded from local XML files. You can tweak XML files to
103
         * experiment with various outputs during development
104
         *
105
         * XML files available under com/amazonaws/mws/mock tree
106
         *
107
         ***********************************************************************/
108
        // MarketplaceWebService service = new MarketplaceWebServiceMock();
109
 
110
        /************************************************************************
111
         * Setup request parameters and uncomment invoke to try out 
112
         * sample for Get Report List 
113
         ***********************************************************************/
114
 
115
        /************************************************************************
116
         * Marketplace and Merchant IDs are required parameters for all 
117
         * Marketplace Web Service calls.
118
         ***********************************************************************/
119
        GetReportListRequest request = new GetReportListRequest();
120
        request.setMerchant( merchantId );
121
 
122
        // @TODO: set request parameters here
123
 
124
         invokeGetReportList(service, request);
125
 
126
    }
127
 
128
 
129
 
130
    /**
131
     * Get Report List  request sample
132
     * returns a list of reports; by default the most recent ten reports,
133
     * regardless of their acknowledgement status
134
     *   
135
     * @param service instance of MarketplaceWebService service
136
     * @param request Action to invoke
137
     */
138
    public static Map<String,String> invokeGetReportList(MarketplaceWebService service, GetReportListRequest request) {
139
    	Map<String,String> reportIdrequestIdmap = new HashMap<String,String>();
140
        try {
141
 
142
            GetReportListResponse response = service.getReportList(request);
143
 
144
            System.out.println ("GetReportList Action Response");
145
            System.out.println ("=============================================================================");
146
            System.out.println ();
147
 
148
            System.out.print("    GetReportListResponse");
149
            System.out.println();
150
            if (response.isSetGetReportListResult()) {
151
                System.out.print("        GetReportListResult");
152
                System.out.println();
153
                GetReportListResult  getReportListResult = response.getGetReportListResult();
154
                if (getReportListResult.isSetNextToken()) {
155
                    System.out.print("            NextToken");
156
                    System.out.println();
157
                    System.out.print("                " + getReportListResult.getNextToken());
158
                    System.out.println();
159
                }
160
                if (getReportListResult.isSetHasNext()) {
161
                    System.out.print("            HasNext");
162
                    System.out.println();
163
                    System.out.print("                " + getReportListResult.isHasNext());
164
                    System.out.println();
165
                }
166
                java.util.List<ReportInfo> reportInfoListList = getReportListResult.getReportInfoList();
167
                for (ReportInfo reportInfoList : reportInfoListList) {
168
                    System.out.print("            ReportInfoList");
169
                    System.out.println();
170
                    if (reportInfoList.isSetReportId()) {
171
                        System.out.print("                ReportId");
172
                        System.out.println();
173
                        System.out.print("                    " + reportInfoList.getReportId());
174
                        System.out.println();
175
                    }
176
                    if (reportInfoList.isSetReportType()) {
177
                        System.out.print("                ReportType");
178
                        System.out.println();
179
                        System.out.print("                    " + reportInfoList.getReportType());
180
                        System.out.println();
181
                    }
182
                    if (reportInfoList.isSetReportRequestId()) {
183
                        System.out.print("                ReportRequestId");
184
                        System.out.println();
185
                        System.out.print("                    " + reportInfoList.getReportRequestId());
186
                        System.out.println();
187
                        //if (reportInfoList.isSetAcknowledged())
188
                        reportIdrequestIdmap.put(reportInfoList.getReportRequestId(),reportInfoList.getReportId());
189
                    }
190
                    if (reportInfoList.isSetAvailableDate()) {
191
                        System.out.print("                AvailableDate");
192
                        System.out.println();
193
                        System.out.print("                    " + reportInfoList.getAvailableDate());
194
                        System.out.println();
195
                    }
196
                    if (reportInfoList.isSetAcknowledged()) {
197
                        System.out.print("                Acknowledged");
198
                        System.out.println();
199
                        System.out.print("                    " + reportInfoList.isAcknowledged());
200
                        System.out.println();
201
                    }
202
                    if (reportInfoList.isSetAcknowledgedDate()) {
203
                        System.out.print("                AcknowledgedDate");
204
                        System.out.println();
205
                        System.out.print("                    " + reportInfoList.getAcknowledgedDate());
206
                        System.out.println();
207
                    }
208
                }
209
            } 
210
            if (response.isSetResponseMetadata()) {
211
                System.out.print("        ResponseMetadata");
212
                System.out.println();
213
                ResponseMetadata  responseMetadata = response.getResponseMetadata();
214
                if (responseMetadata.isSetRequestId()) {
215
                    System.out.print("            RequestId");
216
                    System.out.println();
217
                    System.out.print("                " + responseMetadata.getRequestId());
218
                    System.out.println();
219
                }
220
            } 
221
            System.out.println();
222
            System.out.println(response.getResponseHeaderMetadata());
223
            System.out.println();
224
 
225
 
226
        } catch (MarketplaceWebServiceException ex) {
227
 
228
            System.out.println("Caught Exception: " + ex.getMessage());
229
            System.out.println("Response Status Code: " + ex.getStatusCode());
230
            System.out.println("Error Code: " + ex.getErrorCode());
231
            System.out.println("Error Type: " + ex.getErrorType());
232
            System.out.println("Request ID: " + ex.getRequestId());
233
            System.out.print("XML: " + ex.getXML());
234
            System.out.println("ResponseHeaderMetadata: " + ex.getResponseHeaderMetadata());
235
        }
236
        return reportIdrequestIdmap;
237
    }
238
 
239
}