Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12459 kshitij.so 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 Feed Submissions  Samples
31
 *
32
 *
33
 */
34
public class CancelFeedSubmissionsSample {
35
 
36
    /**
37
     * Just add a few required parameters, and try the service
38
     * Cancel Feed Submissions 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
        MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();
54
 
55
        /************************************************************************
56
         * Uncomment to set the correct MWS endpoint.
57
         ************************************************************************/
58
        // US
59
        // config.setServiceURL("https://mws.amazonservices.com");
60
        // UK
61
        // config.setServiceURL("https://mws.amazonservices.co.uk");
62
        // Germany
63
        // config.setServiceURL("https://mws.amazonservices.de");
64
        // France
65
        // config.setServiceURL("https://mws.amazonservices.fr");
66
        // Italy
67
        // config.setServiceURL("https://mws.amazonservices.it");
68
        // Japan
69
        // config.setServiceURL("https://mws.amazonservices.jp");
70
        // China
71
        // config.setServiceURL("https://mws.amazonservices.com.cn");
72
        // Canada
73
        // config.setServiceURL("https://mws.amazonservices.ca");
74
        // India
75
        // config.setServiceURL("https://mws.amazonservices.in");
76
 
77
        /************************************************************************
78
         * You can also try advanced configuration options. Available options are:
79
         *
80
         *  - Signature Version
81
         *  - Proxy Host and Proxy Port
82
         *  - User Agent String to be sent to Marketplace Web Service
83
         *
84
         ***********************************************************************/
85
 
86
        /************************************************************************
87
         * Instantiate Http Client Implementation of Marketplace Web Service 
88
         ***********************************************************************/
89
 
90
        MarketplaceWebService service = new MarketplaceWebServiceClient(
91
                accessKeyId, secretAccessKey, appName, appVersion, config);
92
 
93
        /************************************************************************
94
         * Uncomment to try advanced configuration options. Available options are:
95
         *
96
         *  - Signature Version
97
         *  - Proxy Host and Proxy Port
98
         *  - Service URL
99
         *  - User Agent String to be sent to Marketplace Web Service   service
100
         *
101
         ***********************************************************************/
102
        // MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();
103
 
104
        // MarketplaceWebService service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKey, config);
105
 
106
        /************************************************************************
107
         * Uncomment to try out Mock Service that simulates Marketplace Web Service 
108
         * responses without calling Marketplace Web Service  service.
109
         *
110
         * Responses are loaded from local XML files. You can tweak XML files to
111
         * experiment with various outputs during development
112
         *
113
         * XML files available under com/amazonaws/mws/mock tree
114
         *
115
         ***********************************************************************/
116
        // MarketplaceWebService service = new MarketplaceWebServiceMock();
117
 
118
        /************************************************************************
119
         * Setup request parameters and uncomment invoke to try out 
120
         * sample for Cancel Feed Submissions 
121
         ***********************************************************************/
122
 
123
        /************************************************************************
124
         * Marketplace and Merchant IDs are required parameters for all 
125
         * Marketplace Web Service calls.
126
         ***********************************************************************/
127
        final String merchantId = "<Your Merchant ID>";
128
 
129
        CancelFeedSubmissionsRequest request = new CancelFeedSubmissionsRequest();
130
        request.setMerchant( merchantId );
131
 
132
        // @TODO: set request parameters here
133
 
134
        // invokeCancelFeedSubmissions(service, request);
135
 
136
    }
137
 
138
 
139
 
140
    /**
141
     * Cancel Feed Submissions  request sample
142
     * cancels feed submissions - by default all of the submissions of the
143
     * last 30 days that have not started processing
144
     *   
145
     * @param service instance of MarketplaceWebService service
146
     * @param request Action to invoke
147
     */
148
    public static void invokeCancelFeedSubmissions(MarketplaceWebService service, CancelFeedSubmissionsRequest request) {
149
        try {
150
 
151
            CancelFeedSubmissionsResponse response = service.cancelFeedSubmissions(request);
152
 
153
 
154
            System.out.println ("CancelFeedSubmissions Action Response");
155
            System.out.println ("=============================================================================");
156
            System.out.println ();
157
 
158
            System.out.print("    CancelFeedSubmissionsResponse");
159
            System.out.println();
160
            if (response.isSetCancelFeedSubmissionsResult()) {
161
                System.out.print("        CancelFeedSubmissionsResult");
162
                System.out.println();
163
                CancelFeedSubmissionsResult  cancelFeedSubmissionsResult = response.getCancelFeedSubmissionsResult();
164
                if (cancelFeedSubmissionsResult.isSetCount()) {
165
                    System.out.print("            Count");
166
                    System.out.println();
167
                    System.out.print("                " + cancelFeedSubmissionsResult.getCount());
168
                    System.out.println();
169
                }
170
                java.util.List<FeedSubmissionInfo> feedSubmissionInfoList = cancelFeedSubmissionsResult.getFeedSubmissionInfoList();
171
                for (FeedSubmissionInfo feedSubmissionInfo : feedSubmissionInfoList) {
172
                    System.out.print("            FeedSubmissionInfo");
173
                    System.out.println();
174
                    if (feedSubmissionInfo.isSetFeedSubmissionId()) {
175
                        System.out.print("                FeedSubmissionId");
176
                        System.out.println();
177
                        System.out.print("                    " + feedSubmissionInfo.getFeedSubmissionId());
178
                        System.out.println();
179
                    }
180
                    if (feedSubmissionInfo.isSetFeedType()) {
181
                        System.out.print("                FeedType");
182
                        System.out.println();
183
                        System.out.print("                    " + feedSubmissionInfo.getFeedType());
184
                        System.out.println();
185
                    }
186
                    if (feedSubmissionInfo.isSetSubmittedDate()) {
187
                        System.out.print("                SubmittedDate");
188
                        System.out.println();
189
                        System.out.print("                    " + feedSubmissionInfo.getSubmittedDate());
190
                        System.out.println();
191
                    }
192
                    if (feedSubmissionInfo.isSetFeedProcessingStatus()) {
193
                        System.out.print("                FeedProcessingStatus");
194
                        System.out.println();
195
                        System.out.print("                    " + feedSubmissionInfo.getFeedProcessingStatus());
196
                        System.out.println();
197
                    }
198
                    if (feedSubmissionInfo.isSetStartedProcessingDate()) {
199
                        System.out.print("                StartedProcessingDate");
200
                        System.out.println();
201
                        System.out.print("                    " + feedSubmissionInfo.getStartedProcessingDate());
202
                        System.out.println();
203
                    }
204
                    if (feedSubmissionInfo.isSetCompletedProcessingDate()) {
205
                        System.out.print("                CompletedProcessingDate");
206
                        System.out.println();
207
                        System.out.print("                    " + feedSubmissionInfo.getCompletedProcessingDate());
208
                        System.out.println();
209
                    }
210
                }
211
            } 
212
            if (response.isSetResponseMetadata()) {
213
                System.out.print("        ResponseMetadata");
214
                System.out.println();
215
                ResponseMetadata  responseMetadata = response.getResponseMetadata();
216
                if (responseMetadata.isSetRequestId()) {
217
                    System.out.print("            RequestId");
218
                    System.out.println();
219
                    System.out.print("                " + responseMetadata.getRequestId());
220
                    System.out.println();
221
                }
222
            } 
223
            System.out.println();
224
 
225
 
226
            System.out.println(response.getResponseHeaderMetadata());
227
            System.out.println();
228
 
229
        } catch (MarketplaceWebServiceException ex) {
230
 
231
            System.out.println("Caught Exception: " + ex.getMessage());
232
            System.out.println("Response Status Code: " + ex.getStatusCode());
233
            System.out.println("Error Code: " + ex.getErrorCode());
234
            System.out.println("Error Type: " + ex.getErrorType());
235
            System.out.println("Request ID: " + ex.getRequestId());
236
            System.out.print("XML: " + ex.getXML());
237
            System.out.println("ResponseHeaderMetadata: " + ex.getResponseHeaderMetadata());
238
        }
239
    }
240
 
241
}