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.List;
23
import java.util.ArrayList;
24
import com.amazonaws.mws.*;
25
import com.amazonaws.mws.model.*;
26
import com.amazonaws.mws.mock.MarketplaceWebServiceMock;
27
 
28
/**
29
 *
30
 * Cancel Report Requests  Samples
31
 *
32
 *
33
 */
34
public class CancelReportRequestsSample {
35
 
36
    /**
37
     * Just add a few required parameters, and try the service
38
     * Cancel Report Requests functionality
39
     *
40
     * @param args unused
41
     */
42
    public static void main(String... args) {
43
 
44
        /************************************************************************
45
         * Access Key ID and Secret Access Key ID, obtained from:
46
         * http://aws.amazon.com
47
         ***********************************************************************/
48
        final String accessKeyId = "<Your Access Key ID>";
49
        final String secretAccessKey = "<Your Secret Access Key>";
50
 
51
        final String appName = "<Your Application or Company Name>";
52
        final String appVersion = "<Your Application Version or Build Number or Release Date>";
53
 
54
        MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();
55
 
56
        /************************************************************************
57
         * Uncomment to set the correct MWS endpoint.
58
         ************************************************************************/
59
        // US
60
        // config.setServiceURL("https://mws.amazonservices.com");
61
        // UK
62
        // config.setServiceURL("https://mws.amazonservices.co.uk");
63
        // Germany
64
        // config.setServiceURL("https://mws.amazonservices.de");
65
        // France
66
        // config.setServiceURL("https://mws.amazonservices.fr");
67
        // Italy
68
        // config.setServiceURL("https://mws.amazonservices.it");
69
        // Japan
70
        // config.setServiceURL("https://mws.amazonservices.jp");
71
        // China
72
        // config.setServiceURL("https://mws.amazonservices.com.cn");
73
        // Canada
74
        // config.setServiceURL("https://mws.amazonservices.ca");
75
        // India
76
        // config.setServiceURL("https://mws.amazonservices.in");
77
 
78
        /************************************************************************
79
         * You can also try advanced configuration options. Available options are:
80
         *
81
         *  - Signature Version
82
         *  - Proxy Host and Proxy Port
83
         *  - User Agent String to be sent to Marketplace Web Service
84
         *
85
         ***********************************************************************/
86
 
87
        /************************************************************************
88
         * Instantiate Http Client Implementation of Marketplace Web Service        
89
         ***********************************************************************/
90
 
91
        MarketplaceWebService service = new MarketplaceWebServiceClient(
92
                accessKeyId, secretAccessKey, appName, appVersion, config);
93
 
94
 
95
        /************************************************************************
96
         * Uncomment to try out Mock Service that simulates Marketplace Web Service 
97
         * responses without calling Marketplace Web Service  service.
98
         *
99
         * Responses are loaded from local XML files. You can tweak XML files to
100
         * experiment with various outputs during development
101
         *
102
         * XML files available under com/amazonaws/mws/mock tree
103
         *
104
         ***********************************************************************/
105
        // MarketplaceWebService service = new MarketplaceWebServiceMock();
106
 
107
        /************************************************************************
108
         * Setup request parameters and uncomment invoke to try out 
109
         * sample for Cancel Report Requests 
110
         ***********************************************************************/
111
 
112
        /************************************************************************
113
         * Marketplace and Merchant IDs are required parameters for all 
114
         * Marketplace Web Service calls.
115
         ***********************************************************************/
116
        final String merchantId = "<Your Merchant ID>";
117
 
118
        CancelReportRequestsRequest request = new CancelReportRequestsRequest();
119
        request.setMerchant( merchantId );
120
 
121
        // @TODO: set request parameters here
122
 
123
        // invokeCancelReportRequests(service, request);
124
 
125
    }
126
 
127
 
128
 
129
    /**
130
     * Cancel Report Requests  request sample
131
     * cancels report requests that have not yet started processing,
132
     * by default all those within the last 90 days
133
     *   
134
     * @param service instance of MarketplaceWebService service
135
     * @param request Action to invoke
136
     */
137
    public static void invokeCancelReportRequests(MarketplaceWebService service, CancelReportRequestsRequest request) {
138
        try {
139
 
140
            CancelReportRequestsResponse response = service.cancelReportRequests(request);
141
 
142
 
143
            System.out.println ("CancelReportRequests Action Response");
144
            System.out.println ("=============================================================================");
145
            System.out.println ();
146
 
147
            System.out.print("    CancelReportRequestsResponse");
148
            System.out.println();
149
            if (response.isSetCancelReportRequestsResult()) {
150
                System.out.print("        CancelReportRequestsResult");
151
                System.out.println();
152
                CancelReportRequestsResult  cancelReportRequestsResult = response.getCancelReportRequestsResult();
153
                if (cancelReportRequestsResult.isSetCount()) {
154
                    System.out.print("            Count");
155
                    System.out.println();
156
                    System.out.print("                " + cancelReportRequestsResult.getCount());
157
                    System.out.println();
158
                }
159
                java.util.List<ReportRequestInfo> reportRequestInfoList = cancelReportRequestsResult.getReportRequestInfoList();
160
                for (ReportRequestInfo reportRequestInfo : reportRequestInfoList) {
161
                    System.out.print("            ReportRequestInfo");
162
                    System.out.println();
163
                    if (reportRequestInfo.isSetReportRequestId()) {
164
                        System.out.print("                ReportRequestId");
165
                        System.out.println();
166
                        System.out.print("                    " + reportRequestInfo.getReportRequestId());
167
                        System.out.println();
168
                    }
169
                    if (reportRequestInfo.isSetReportType()) {
170
                        System.out.print("                ReportType");
171
                        System.out.println();
172
                        System.out.print("                    " + reportRequestInfo.getReportType());
173
                        System.out.println();
174
                    }
175
                    if (reportRequestInfo.isSetStartDate()) {
176
                        System.out.print("                StartDate");
177
                        System.out.println();
178
                        System.out.print("                    " + reportRequestInfo.getStartDate());
179
                        System.out.println();
180
                    }
181
                    if (reportRequestInfo.isSetEndDate()) {
182
                        System.out.print("                EndDate");
183
                        System.out.println();
184
                        System.out.print("                    " + reportRequestInfo.getEndDate());
185
                        System.out.println();
186
                    }
187
                    if (reportRequestInfo.isSetSubmittedDate()) {
188
                        System.out.print("                SubmittedDate");
189
                        System.out.println();
190
                        System.out.print("                    " + reportRequestInfo.getSubmittedDate());
191
                        System.out.println();
192
                    }
193
                    if (reportRequestInfo.isSetReportProcessingStatus()) {
194
                        System.out.print("                ReportProcessingStatus");
195
                        System.out.println();
196
                        System.out.print("                    " + reportRequestInfo.getReportProcessingStatus());
197
                        System.out.println();
198
                    }
199
                }
200
            } 
201
            if (response.isSetResponseMetadata()) {
202
                System.out.print("        ResponseMetadata");
203
                System.out.println();
204
                ResponseMetadata  responseMetadata = response.getResponseMetadata();
205
                if (responseMetadata.isSetRequestId()) {
206
                    System.out.print("            RequestId");
207
                    System.out.println();
208
                    System.out.print("                " + responseMetadata.getRequestId());
209
                    System.out.println();
210
                }
211
            } 
212
            System.out.println();
213
            System.out.println(response.getResponseHeaderMetadata());
214
            System.out.println();
215
 
216
 
217
        } catch (MarketplaceWebServiceException ex) {
218
 
219
            System.out.println("Caught Exception: " + ex.getMessage());
220
            System.out.println("Response Status Code: " + ex.getStatusCode());
221
            System.out.println("Error Code: " + ex.getErrorCode());
222
            System.out.println("Error Type: " + ex.getErrorType());
223
            System.out.println("Request ID: " + ex.getRequestId());
224
            System.out.print("XML: " + ex.getXML());
225
            System.out.println("ResponseHeaderMetadata: " + ex.getResponseHeaderMetadata());
226
        }
227
    }
228
 
229
}