· 7 years ago · Feb 19, 2018, 04:18 AM
1using MarketplaceWebService.Samples;
2using MWSFinancesService;
3using Newtonsoft.Json;
4
5namespace IgorsWebSellersToolbox.Controllers {
6
7 public class SalesController : Controller {
8
9 MWSFinancesServiceSample AmazonMWS_Finance_DLL = new MWSFinancesServiceSample(); //"MWSFinancesServiceSample()" is where the error is flaged
10
11 public ActionResult Profit() {
12 AmazonMWS_Finance_DLL.Global_accessKeyId = "Test Data";
13 AmazonMWS_Finance_DLL.Global_secretAccessKey = "Test Data";
14 AmazonMWS_Finance_DLL.Global_applicationName = "Test Data";
15 AmazonMWS_Finance_DLL.Global_applicationVersion = "Test Data";
16
17 return View();
18 }
19 }
20}
21
22using MWSFinancesService.Model;
23using System;
24using MWSFinancesService;
25using System.Collections.Generic;
26
27namespace MWSFinancesService {
28
29/// <summary>
30/// Runnable sample code to demonstrate usage of the C# client.
31///
32/// To use, import the client source as a console application,
33/// and mark this class as the startup object. Then, replace
34/// parameters below with sensible values and run.
35/// </summary>
36
37public class MWSFinancesServiceSample {
38
39
40 public string ActionToPerform;
41
42 public string Global_accessKeyId;
43 public string Global_secretAccessKey;
44 public string Global_applicationName;
45 public string Global_applicationVersion;
46
47 public string Main()
48 {
49 // TODO: Set the below configuration variables before attempting to run
50
51 // Developer AWS access key
52 string accessKey = Global_accessKeyId;
53
54 // Developer AWS secret key
55 string secretKey = Global_secretAccessKey;
56
57 // The client application name
58 string appName = Global_applicationName;
59
60 // The client application version
61 string appVersion = Global_applicationVersion;
62
63 // The endpoint for region service and version (see developer guide)
64 // ex: https://mws.amazonservices.com
65 string serviceURL = "https://mws.amazonservices.com";
66
67 // Create a configuration object
68 MWSFinancesServiceConfig config = new MWSFinancesServiceConfig();
69 config.ServiceURL = serviceURL;
70 // Set other client connection configurations here if needed
71 // Create the client itself
72 MWSFinancesService_interface client = new MWSFinancesServiceClient(accessKey, secretKey, appName, appVersion, config);
73
74 MWSFinancesServiceSample sample = new MWSFinancesServiceSample(client);
75
76 // Uncomment the operation you'd like to test here
77 // TODO: Modify the request created in the Invoke method to be valid
78
79 try
80 {
81 IMWSResponse response = null;
82 // response = sample.InvokeListFinancialEventGroups();
83 Console.WriteLine("Response:");
84 ResponseHeaderMetadata rhmd = response.ResponseHeaderMetadata;
85 // We recommend logging the request id and timestamp of every call.
86 Console.WriteLine("RequestId: " + rhmd.RequestId);
87 Console.WriteLine("Timestamp: " + rhmd.Timestamp);
88 string responseXml = response.ToXML();
89 Console.WriteLine(responseXml);
90 }
91 catch (MWSFinancesServiceException ex)
92 {
93 // Exception properties are important for diagnostics.
94 ResponseHeaderMetadata rhmd = ex.ResponseHeaderMetadata;
95 Console.WriteLine("Service Exception:");
96 if (rhmd != null)
97 {
98 Console.WriteLine("RequestId: " + rhmd.RequestId);
99 Console.WriteLine("Timestamp: " + rhmd.Timestamp);
100 }
101 Console.WriteLine("Message: " + ex.Message);
102 Console.WriteLine("StatusCode: " + ex.StatusCode);
103 Console.WriteLine("ErrorCode: " + ex.ErrorCode);
104 Console.WriteLine("ErrorType: " + ex.ErrorType);
105 throw ex;
106 }
107
108 return null;
109 }
110
111 public MWSFinancesService_interface client;
112
113 public MWSFinancesServiceSample(MWSFinancesService_interface Client)
114 {
115 this.client = Client;
116 }
117
118 public ListFinancialEventGroupsResponse InvokeListFinancialEventGroups()
119 {
120 // Create a request.
121 ListFinancialEventGroupsRequest request = new ListFinancialEventGroupsRequest();
122 string sellerId = "example";
123 request.SellerId = sellerId;
124 string mwsAuthToken = "example";
125 request.MWSAuthToken = mwsAuthToken;
126 decimal maxResultsPerPage = 1;
127 request.MaxResultsPerPage = maxResultsPerPage;
128 DateTime financialEventGroupStartedAfter = new DateTime();
129 request.FinancialEventGroupStartedAfter = financialEventGroupStartedAfter;
130 DateTime financialEventGroupStartedBefore = new DateTime();
131 request.FinancialEventGroupStartedBefore = financialEventGroupStartedBefore;
132 return this.client.ListFinancialEventGroups(request);
133 }
134 }
135}