private List <AsinPrepData> GetDataFromMws(List <string> requestedAsins) { List <AsinPrepData> asinData = new List <AsinPrepData>(); string accessKey = System.Configuration.ConfigurationManager.AppSettings["MwsAccK"]; string secretKey = System.Configuration.ConfigurationManager.AppSettings["MwsSecK"]; string sellerId = System.Configuration.ConfigurationManager.AppSettings["MwsSeller"]; string marketplaceId = System.Configuration.ConfigurationManager.AppSettings["MwsMktpl"]; FBAInboundServiceMWSConfig config = new FBAInboundServiceMWSConfig(); config.ServiceURL = "https://mws.amazonservices.com "; config.SetUserAgentHeader("CMA", "1.0", "C#", new string[] { }); FBAInboundServiceMWSClient client = new FBAInboundServiceMWSClient(accessKey, secretKey, config); FBAInboundServiceMWS.Model.GetPrepInstructionsForASINRequest request = new FBAInboundServiceMWS.Model.GetPrepInstructionsForASINRequest(); request.AsinList = new FBAInboundServiceMWS.Model.AsinList(); request.AsinList.Id = requestedAsins; request.SellerId = System.Configuration.ConfigurationManager.AppSettings["MwsSeller"]; request.ShipToCountryCode = "US"; FBAInboundServiceMWS.Model.GetPrepInstructionsForASINResponse response = new FBAInboundServiceMWS.Model.GetPrepInstructionsForASINResponse(); try { response = client.GetPrepInstructionsForASIN(request); } catch (Exception e) {} while (response.ResponseHeaderMetadata == null || response.ResponseHeaderMetadata.QuotaRemaining < 1000) { if (response.ResponseHeaderMetadata == null) { this.StatusDescription = string.Format("No response given to MWS Request"); } else { this.StatusDescription = string.Format("API Quota reached. Remaining: {0} of {1}, Resets: {2},", response.ResponseHeaderMetadata.QuotaRemaining, response.ResponseHeaderMetadata.QuotaMax, response.ResponseHeaderMetadata.QuotaResetsAt.Value.ToShortTimeString()); } Thread.Sleep(20000); try { response = client.GetPrepInstructionsForASIN(request); } catch (Exception e) { } } foreach (var result in response.GetPrepInstructionsForASINResult.ASINPrepInstructionsList.ASINPrepInstructions) { if (result.IsSetASIN()) { AsinPrepData asinPrep = new AsinPrepData(); asinPrep.Asin = result.ASIN; if (result.IsSetBarcodeInstruction()) { if (result.BarcodeInstruction.Equals("RequiresFNSKULabel")) { asinPrep.Labelling = "Required"; } else if (result.BarcodeInstruction.Equals("MustProvideSellerSKU")) { asinPrep.Labelling = "Undetermined"; } } if (result.IsSetPrepGuidance()) { if (result.PrepGuidance.Equals("SeePrepInstructionsList")) { // prep exists if (result.IsSetPrepInstructionList()) { foreach (var prep in result.PrepInstructionList.PrepInstruction) { asinPrep.Prep += prep; } } } else if (result.PrepGuidance.Equals("NoAdditionalPrepRequired")) { asinPrep.Prep = "None"; } else if (result.PrepGuidance.Equals("ConsultHelpDocuments")) { asinPrep.Prep = "Undetermined"; } } asinData.Add(asinPrep); } } return(asinData); }
private List<AsinPrepData> GetDataFromMws(List<string> requestedAsins) { List<AsinPrepData> asinData = new List<AsinPrepData>(); string accessKey = System.Configuration.ConfigurationManager.AppSettings["MwsAccK"]; string secretKey = System.Configuration.ConfigurationManager.AppSettings["MwsSecK"]; string sellerId = System.Configuration.ConfigurationManager.AppSettings["MwsSeller"]; string marketplaceId = System.Configuration.ConfigurationManager.AppSettings["MwsMktpl"]; FBAInboundServiceMWSConfig config = new FBAInboundServiceMWSConfig(); config.ServiceURL = "https://mws.amazonservices.com "; config.SetUserAgentHeader("CMA", "1.0", "C#", new string[] { }); FBAInboundServiceMWSClient client = new FBAInboundServiceMWSClient(accessKey, secretKey, config); FBAInboundServiceMWS.Model.GetPrepInstructionsForASINRequest request = new FBAInboundServiceMWS.Model.GetPrepInstructionsForASINRequest(); request.AsinList = new FBAInboundServiceMWS.Model.AsinList(); request.AsinList.Id = requestedAsins; request.SellerId = System.Configuration.ConfigurationManager.AppSettings["MwsSeller"]; request.ShipToCountryCode = "US"; FBAInboundServiceMWS.Model.GetPrepInstructionsForASINResponse response = new FBAInboundServiceMWS.Model.GetPrepInstructionsForASINResponse(); try { response = client.GetPrepInstructionsForASIN(request); } catch (Exception e) {} while (response.ResponseHeaderMetadata == null || response.ResponseHeaderMetadata.QuotaRemaining < 1000) { if (response.ResponseHeaderMetadata == null) { this.StatusDescription = string.Format("No response given to MWS Request"); } else this.StatusDescription = string.Format("API Quota reached. Remaining: {0} of {1}, Resets: {2},", response.ResponseHeaderMetadata.QuotaRemaining, response.ResponseHeaderMetadata.QuotaMax, response.ResponseHeaderMetadata.QuotaResetsAt.Value.ToShortTimeString()); Thread.Sleep(20000); try { response = client.GetPrepInstructionsForASIN(request); } catch (Exception e) { } } foreach (var result in response.GetPrepInstructionsForASINResult.ASINPrepInstructionsList.ASINPrepInstructions) { if (result.IsSetASIN()) { AsinPrepData asinPrep = new AsinPrepData(); asinPrep.Asin = result.ASIN; if (result.IsSetBarcodeInstruction()) { if (result.BarcodeInstruction.Equals("RequiresFNSKULabel")) asinPrep.Labelling = "Required"; else if (result.BarcodeInstruction.Equals("MustProvideSellerSKU")) asinPrep.Labelling = "Undetermined"; } if (result.IsSetPrepGuidance()) { if (result.PrepGuidance.Equals("SeePrepInstructionsList")) { // prep exists if (result.IsSetPrepInstructionList()) { foreach (var prep in result.PrepInstructionList.PrepInstruction) { asinPrep.Prep += prep; } } } else if (result.PrepGuidance.Equals("NoAdditionalPrepRequired")) { asinPrep.Prep = "None"; } else if (result.PrepGuidance.Equals("ConsultHelpDocuments")) { asinPrep.Prep = "Undetermined"; } } asinData.Add(asinPrep); } } return asinData; }