private MarketplaceWebServiceConfig CreateConfig(AmazonRegion region) { string rootUrl; switch (region) { case AmazonRegion.Australia: rootUrl = MwsEndpoint.Australia.RegionOrMarketPlaceEndpoint; break; case AmazonRegion.China: rootUrl = MwsEndpoint.China.RegionOrMarketPlaceEndpoint; break; case AmazonRegion.Europe: rootUrl = MwsEndpoint.Europe.RegionOrMarketPlaceEndpoint; break; case AmazonRegion.India: rootUrl = MwsEndpoint.India.RegionOrMarketPlaceEndpoint; break; case AmazonRegion.Japan: rootUrl = MwsEndpoint.Japan.RegionOrMarketPlaceEndpoint; break; case AmazonRegion.NorthAmerica: rootUrl = MwsEndpoint.NorthAmerica.RegionOrMarketPlaceEndpoint; break; case AmazonRegion.Brazil: rootUrl = MwsEndpoint.Brazil.RegionOrMarketPlaceEndpoint; break; default: throw new ArgumentException($"{region} is unknown - EasyMWS doesn't know the RootURL"); } var config = new MarketplaceWebServiceConfig { ServiceURL = rootUrl }; config = config.WithUserAgent("EasyMWS"); return(config); }
public string GetReport(string ReportId, string Path) { string amazonFileLocation = ""; GetReportRequest requestReport = new GetReportRequest(); #pragma warning disable CS0618 // Type or member is obsolete requestReport.Marketplace = api.MarketplaceId; #pragma warning restore CS0618 // Type or member is obsolete requestReport.Merchant = api.Merchant; requestReport.ReportId = ReportId; string Extension = string.Format("{1}{0}", ".txt", DateTime.Now.ToString("hh.mm.ss.ffffff")); string FullPath = Path + Extension; if (!File.Exists(FullPath)) { var stream = File.Create(FullPath); stream.Close(); } // string fileLocation = FileAmazon.createFile(reportId, "txt", ReportModule, ""); -> METHOD TO CREATE THE PATH if (FullPath != "") { var stream = File.Open(FullPath, FileMode.OpenOrCreate, FileAccess.ReadWrite); requestReport.Report = stream; MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig(); config.ServiceURL = webService.SERVICE_URL; config.WithUserAgent(webService.USER_AGENT); MarketplaceWebServiceClient client = new MarketplaceWebServiceClient(api.AccessKey, api.SecretKey, config); InvokeGetReport(client, requestReport); stream.Close(); amazonFileLocation = FullPath; } return(amazonFileLocation); }
public string RequestReport(string Type, DateTime From, DateTime To) { try { RequestReportRequest requestReport = new RequestReportRequest(); #pragma warning disable CS0618 // Type or member is obsolete requestReport.Marketplace = api.MarketplaceId; #pragma warning restore CS0618 // Type or member is obsolete requestReport.Merchant = api.Merchant; requestReport.StartDate = From; requestReport.EndDate = To; requestReport.ReportOptions = "true"; IdList idList = new IdList(); idList.Id = new List <string>() { api.MarketplaceId }; requestReport.MarketplaceIdList = idList; requestReport.ReportType = Type; MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig(); config.ServiceURL = webService.SERVICE_URL; config.WithUserAgent(webService.USER_AGENT); MarketplaceWebServiceClient client = new MarketplaceWebServiceClient(api.AccessKey, api.SecretKey, config); return(InvokeRequestReport(client, requestReport)); } catch (Exception ex) { return(ex.Message); } }
public string GetReportLatestReport(DateTime From, DateTime To, string ReportType) { List <string> ReportList = new List <string>(); GetReportListRequest requestReport = new GetReportListRequest(); requestReport.Acknowledged = false; requestReport.AvailableFromDate = From; requestReport.AvailableToDate = To; #pragma warning disable CS0618 // Type or member is obsolete requestReport.Marketplace = api.MarketplaceId; #pragma warning restore CS0618 // Type or member is obsolete requestReport.MaxCount = 99; requestReport.Merchant = api.Merchant; List <string> reportCode = new List <string>(); reportCode.Add(ReportType); TypeList typeList = new TypeList(); typeList.Type = reportCode; requestReport.ReportTypeList = typeList; MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig(); config.ServiceURL = webService.SERVICE_URL; config.WithUserAgent(webService.USER_AGENT); MarketplaceWebServiceClient client = new MarketplaceWebServiceClient(api.AccessKey, api.SecretKey, config); GetReportListResult getReportListResult = null; getReportListResult = InvokeGetReportList(client, requestReport); if (getReportListResult != null) { if (getReportListResult.HasNext) { while (getReportListResult.HasNext) { int i = 0; if (i % 2 == 0) { Thread.Sleep(2000); } GetReportListByNextTokenRequest getReportListByNextTokenRequest = new GetReportListByNextTokenRequest(); #pragma warning disable CS0618 // Type or member is obsolete getReportListByNextTokenRequest.Marketplace = api.MarketplaceId; #pragma warning restore CS0618 // Type or member is obsolete getReportListByNextTokenRequest.Merchant = api.Merchant; getReportListByNextTokenRequest.NextToken = getReportListResult.NextToken; string ReportId = InvokeGetReportListByNextToken(client, getReportListByNextTokenRequest); ReportList.Add(ReportId); i++; } } List <ReportInfo> reportInfoList = getReportListResult.ReportInfo; if (reportInfoList.Count > 0) { foreach (ReportInfo reportInfo in reportInfoList) { ReportList.Add(reportInfo.ReportId); } } else { Console.WriteLine("No reports returned from Amazon."); throw new Exception("No reports returned from Amazon."); } } return(ReportList[0]); }