protected override void RegisterServices(IKernel kernel) { kernel.Bind <MarketplaceWebServiceOrders.MarketplaceWebServiceOrders>().ToMethod(context => { var amazonAppSettings = context.Kernel.Get <AmazonAppSettings>(); var config = new MarketplaceWebServiceOrdersConfig { ServiceURL = amazonAppSettings.OrdersApiEndpoint }; return(new MarketplaceWebServiceOrdersClient ("MrCMS", MrCMSApplication.AssemblyVersion, amazonAppSettings.AWSAccessKeyId, amazonAppSettings.SecretKey, config)); }).InRequestScope(); kernel.Bind <MarketplaceWebServiceProducts.MarketplaceWebServiceProducts>().ToMethod(context => { var amazonAppSettings = context.Kernel.Get <AmazonAppSettings>(); var config = new MarketplaceWebServiceProductsConfig { ServiceURL = amazonAppSettings.ProductsApiEndpoint }; return(new MarketplaceWebServiceProductsClient ("MrCMS", MrCMSApplication.AssemblyVersion, amazonAppSettings.AWSAccessKeyId, amazonAppSettings.SecretKey, config)); }).InRequestScope(); kernel.Bind <MarketplaceWebService.MarketplaceWebService>().ToMethod(context => { var amazonAppSettings = context.Kernel.Get <AmazonAppSettings>(); var config = new MarketplaceWebServiceConfig { ServiceURL = amazonAppSettings.ProductsApiEndpoint }; return(new MarketplaceWebServiceClient(amazonAppSettings.AWSAccessKeyId, amazonAppSettings.SecretKey, "MrCMS", MrCMSApplication.AssemblyVersion, config)); }).InRequestScope(); }
private IMarketplaceWebServiceProducts CreateService() { /************************************************************************ * Access Key ID and Secret Access Key ID ***********************************************************************/ string accessKeyId = base.AccessInfo.KeyId; string secretAccessKey = base.AccessInfo.SecretKeyId; /************************************************************************ * The application name and version are included in each MWS call's * HTTP User-Agent field. These are required fields. ***********************************************************************/ string applicationName = base.ApplicationInfo.Name; string applicationVersion = base.ApplicationInfo.Version; /************************************************************************ * Uncomment to try advanced configuration options. Available options are: * * - Proxy Host and Proxy Port * - MWS Service endpoint URL * - User Agent String to be sent to FBA Inventory Service MWS service * ***********************************************************************/ var config = new MarketplaceWebServiceProductsConfig { ServiceURL = base.ServiceUrl.Value }; /************************************************************************ * Instantiate Implementation of Marketplace Web Service Orders ***********************************************************************/ return(new MarketplaceWebServiceProductsClient(applicationName, applicationVersion, accessKeyId, secretAccessKey, config)); }
public AmazonMwsDataAccessor() { var config = new MarketplaceWebServiceProductsConfig(); config.ServiceURL = SERVICEURL; config.SignatureMethod = "HmacSHA256"; _productClient = new MarketplaceWebServiceProductsClient("AmazonJavascriptScratchpad", "1.0", ACCESSKEY, SECRETKEY, config); }
public MarketplaceWebServiceProducts(string appName, string appVersion, string accessKey, string secretKey, string serviceURL, string sellerId, string mwsAuthToken, string marketplaceId) { //Create a configuration object MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig(); config.ServiceURL = serviceURL; // Create the client itself productClient = new MarketplaceWebServiceProductsClient(appName, appVersion, accessKey, secretKey, config); }
public MarketplaceWebServiceProductsClient GetProductsApiService() { var config = new MarketplaceWebServiceProductsConfig() { ServiceURL = _amazonAppSettings.ProductsApiEndpoint }; return(new MarketplaceWebServiceProductsClient("MrCMS", MrCMSApplication.AssemblyVersion, MrCMSApplication.Get <AmazonAppSettings>().AWSAccessKeyId, MrCMSApplication.Get <AmazonAppSettings>().SecretKey, config)); }
public HomeController() { sellerId = ConfigurationManager.AppSettings["SellerId"]; marketplaceID = ConfigurationManager.AppSettings["MarketplaceID"]; accessKeyID = ConfigurationManager.AppSettings["AccessKeyID"]; secretKey = ConfigurationManager.AppSettings["SecretKey"]; serviceURL = ConfigurationManager.AppSettings["ServiceURL"]; _productConfig = new MarketplaceWebServiceProductsConfig { ServiceURL = serviceURL }; _productClient = new MarketplaceWebServiceProductsClient("MWS", "1.0", accessKeyID, secretKey, _productConfig); }
public MarketplaceWebServiceProductsClient GetMWSProductsClient() { MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig(); config.ServiceURL = "https://mws.amazonservices.com/Products/2011-10-01"; MarketplaceWebServiceProductsClient service = new MarketplaceWebServiceProductsClient( "berkeley", "1.0", this.AccessKeyId, this.SecretAccessKey, config); return(service); }
public MwsProductsApi(string sellerId, string marketPlaceId, string accessKeyId, string secretAccessKeyId, string serviceUrl) { m_sellerId = sellerId; m_marketPlaceId = marketPlaceId; MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig { ServiceURL = serviceUrl }; m_productClient = new MarketplaceWebServiceProductsClient(string.Empty, string.Empty, accessKeyId, secretAccessKeyId, config); MarketplaceWebServiceConfig configService = new MarketplaceWebServiceConfig() .WithServiceURL("https://mws.amazonservices.com"); configService.SetUserAgentHeader(string.Empty, string.Empty, "C#"); m_service = new MarketplaceWebServiceClient(accessKeyId, secretAccessKeyId, configService); }
static void Main(string[] args) { /* Config */ var sellerId = "<seller id>"; var accessKey = "<access key"; var marketPlaceId = "<marketplace id>"; var secretKey = "<secret key>"; var appName = "<application name>"; var appVersion = "<application version>"; /* Example Products API Client */ var config = new MarketplaceWebServiceProductsConfig { ServiceURL = "https://mws.amazonservices.com" }; var client = new MarketplaceWebServiceProductsClient(appName, appVersion, accessKey, secretKey, config); var request = new GetMatchingProductForIdRequest(); request.IdList = new IdListType(); request.IdType = "<id type>"; // UPC, ISBN, EAN, ASIN request.IdList.Id.Add("<id>"); request.MarketplaceId = marketPlaceId; try { // try to get the response from the server var response = client.GetMatchingProductForId(request); } catch (MarketplaceWebServiceProductsException ex) { // something went wrong // check the value of ErrorCode } }
private List <AsinProductData> GetDataFromMws(List <string> requestedAsins) { List <AsinProductData> asinData = new List <AsinProductData>(); 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"]; MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig(); config.ServiceURL = "https://mws.amazonservices.com "; config.SetUserAgentHeader("CMA", "1.0", "C#", new string[] { }); MarketplaceWebServiceProductsClient client = new MarketplaceWebServiceProductsClient(accessKey, secretKey, config); MarketplaceWebServiceProducts.Model.GetCompetitivePricingForASINRequest request = new MarketplaceWebServiceProducts.Model.GetCompetitivePricingForASINRequest(); request.ASINList = new MarketplaceWebServiceProducts.Model.ASINListType(); request.ASINList.ASIN = requestedAsins; request.SellerId = System.Configuration.ConfigurationManager.AppSettings["MwsSeller"]; request.MarketplaceId = System.Configuration.ConfigurationManager.AppSettings["MwsMktpl"]; MarketplaceWebServiceProducts.Model.GetCompetitivePricingForASINResponse response = new MarketplaceWebServiceProducts.Model.GetCompetitivePricingForASINResponse(); try { response = client.GetCompetitivePricingForASIN(request); } catch {} 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.GetCompetitivePricingForASIN(request); } catch {} } foreach (var result in response.GetCompetitivePricingForASINResult) { AsinProductData asinDataItem = new AsinProductData(); asinDataItem.Asin = result.ASIN; if (result.IsSetProduct()) { if (result.Product.IsSetSalesRankings()) { foreach (var salesRank in result.Product.SalesRankings.SalesRank) { if (salesRank.ProductCategoryId.Contains("display")) { asinDataItem.SalesRankTopLevel = (int)salesRank.Rank; asinDataItem.SalesRankTopLevelCategory = salesRank.ProductCategoryId; } else if (!asinDataItem.SalesRankSecondary.ContainsKey(salesRank.ProductCategoryId)) { asinDataItem.SalesRankSecondary.Add(salesRank.ProductCategoryId, (int)salesRank.Rank); } } } if (result.Product.IsSetCompetitivePricing()) { foreach (var price in result.Product.CompetitivePricing.CompetitivePrices.CompetitivePrice) { if (price.CompetitivePriceId.Equals("1")) { asinDataItem.CurrentlyOwnBuyBox = price.belongsToRequester; if (price.IsSetPrice() && price.Price.IsSetLandedPrice()) { asinDataItem.BuyBoxTotalPrice = price.Price.LandedPrice.Amount; } } } } } asinData.Add(asinDataItem); } return(asinData); }
public List <AmazonCategoryList> GetProductCategories(List <string> requestedAsins) { List <AmazonCategoryList> asinData = new List <AmazonCategoryList>(); 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"]; MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig(); config.ServiceURL = "https://mws.amazonservices.com "; config.SetUserAgentHeader("CMA", "1.0", "C#", new string[] { }); MarketplaceWebServiceProductsClient client = new MarketplaceWebServiceProductsClient(accessKey, secretKey, config); requestedAsins = requestedAsins.Distinct().ToList(); StringBuilder csv = new StringBuilder(); csv.Append(string.Format("{0},{1},{2}{3}", "ASIN", "CatID", "CatName", Environment.NewLine)); for (int i = 0; i < requestedAsins.Count; i++) { string asin = requestedAsins[i]; Console.WriteLine("{0}/{1} ({2:0.00}%)", i, requestedAsins.Count, i * 100.0 / requestedAsins.Count); MarketplaceWebServiceProducts.Model.GetProductCategoriesForASINRequest request = new MarketplaceWebServiceProducts.Model.GetProductCategoriesForASINRequest(); request.ASIN = asin; request.SellerId = System.Configuration.ConfigurationManager.AppSettings["MwsSeller"]; request.MarketplaceId = System.Configuration.ConfigurationManager.AppSettings["MwsMktpl"]; MarketplaceWebServiceProducts.Model.GetProductCategoriesForASINResponse response = new MarketplaceWebServiceProducts.Model.GetProductCategoriesForASINResponse(); try { response = client.GetProductCategoriesForASIN(request); } catch { } while (response.ResponseHeaderMetadata == null || response.ResponseHeaderMetadata.QuotaRemaining < 10) { if (response.ResponseHeaderMetadata == null) { Console.WriteLine(string.Format("No response given to MWS Request")); break; } else { Console.WriteLine(string.Format("API Quota reached. Remaining: {0} of {1}, Resets: {2},", response.ResponseHeaderMetadata.QuotaRemaining, response.ResponseHeaderMetadata.QuotaMax, response.ResponseHeaderMetadata.QuotaResetsAt.Value.ToShortTimeString())); } Thread.Sleep(30000); try { response = client.GetProductCategoriesForASIN(request); } catch { } } if (response != null && response.IsSetGetProductCategoriesForASINResult()) { if (response.GetProductCategoriesForASINResult.IsSetSelf()) { AmazonCategoryList asinDeets = new AmazonCategoryList(); asinDeets.Asin = asin; foreach (var cat in response.GetProductCategoriesForASINResult.Self) { var newLine = string.Format("{0},{1},{2}{3}", asin, cat.ProductCategoryId, cat.ProductCategoryName, Environment.NewLine); csv.Append(newLine); } } } Thread.Sleep(5000); } try { File.WriteAllText("AmazonCategories.csv", csv.ToString()); } catch (Exception e) { } Console.WriteLine("CHECK THE NEXT PART IF IT FAILED."); return(asinData); }
public void RunTest() { // TODO: Set the below configuration variables before attempting to run // Developer AWS access key string accessKey = "AKIAJZY7ZVPLTWQYHWYA"; // Developer AWS secret key string secretKey = "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"; // The client application name string appName = "CSharpSampleCode"; // The client application version string appVersion = "1.0"; // The endpoint for region service and version (see developer guide) // ex: https://mws.amazonservices.com string serviceURL = "https://mws.amazonservices.com"; // Create a configuration object MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig(); config.ServiceURL = serviceURL; // Set other client connection configurations here if needed // Create the client itself MarketplaceWebServiceProductsClient client = new MarketplaceWebServiceProductsClient(appName, appVersion, accessKey, secretKey, config); this.client = client; // Uncomment the operation you'd like to test here // TODO: Modify the request created in the Invoke method to be valid try { IMWSResponse response = null; // response = sample.InvokeGetCompetitivePricingForASIN(); // response = sample.InvokeGetCompetitivePricingForSKU(); // response = sample.InvokeGetLowestOfferListingsForASIN(); // response = sample.InvokeGetLowestOfferListingsForSKU(); // response = sample.InvokeGetLowestPricedOffersForASIN(); // response = sample.InvokeGetLowestPricedOffersForSKU(); // response = sample.InvokeGetMatchingProduct(); // response = sample.InvokeGetMatchingProductForId(); // response = sample.InvokeGetMyFeesEstimate(); response = InvokeGetMyPriceForASIN(); // response = sample.InvokeGetMyPriceForSKU(); // response = sample.InvokeGetProductCategoriesForASIN(); // response = sample.InvokeGetProductCategoriesForSKU(); // response = sample.InvokeGetServiceStatus(); // response = sample.InvokeListMatchingProducts(); Console.WriteLine("Response:"); ResponseHeaderMetadata rhmd = response.ResponseHeaderMetadata; // We recommend logging the request id and timestamp of every call. Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); string responseXml = response.ToXML(); Console.WriteLine(responseXml); } catch (MarketplaceWebServiceProductsException ex) { // Exception properties are important for diagnostics. ResponseHeaderMetadata rhmd = ex.ResponseHeaderMetadata; Console.WriteLine("Service Exception:"); if (rhmd != null) { Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); } Console.WriteLine("Message: " + ex.Message); Console.WriteLine("StatusCode: " + ex.StatusCode); Console.WriteLine("ErrorCode: " + ex.ErrorCode); Console.WriteLine("ErrorType: " + ex.ErrorType); throw ex; } }
/** * Samples for Marketplace Web Service Products functionality */ public static void Main(string [] args) { Console.WriteLine("==========================================="); Console.WriteLine("Welcome to Marketplace Web Service Products Samples!"); Console.WriteLine("==========================================="); Console.WriteLine("To get started:"); Console.WriteLine("==========================================="); Console.WriteLine(" - Fill in your MWS credentials"); Console.WriteLine(" - Uncomment sample you're interested in trying"); Console.WriteLine(" - Set request with desired parameters"); Console.WriteLine(" - Hit F5 to run!"); Console.WriteLine(); Console.WriteLine("==========================================="); Console.WriteLine("Samples Output"); Console.WriteLine("==========================================="); Console.WriteLine(); /************************************************************************ * Access Key ID and Secret Access Key ID ***********************************************************************/ String accessKeyId = "<Your Access Key Id>"; String secretAccessKey = "<Your Secret Access Key>"; String merchantId = "<Your Merchant Id>"; String marketplaceId = "<Your Marketplace Id>"; /************************************************************************ * The application name and version are included in each MWS call's * HTTP User-Agent field. ***********************************************************************/ const string applicationName = "<Your Application Name>"; const string applicationVersion = "<Your Application Version>"; /************************************************************************ * Uncomment to try advanced configuration options. Available options are: * * - Signature Version * - Proxy Host and Proxy Port * - Service URL * - User Agent String to be sent to Marketplace Web Service Products service * ***********************************************************************/ MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig(); // // IMPORTANT: Uncomment out the appropriate line for the country you wish // to sell in: // // United States: // config.ServiceURL = "https://mws.amazonservices.com/Products/2011-10-01"; // // Canada: // config.ServiceURL = "https://mws.amazonservices.ca/Products/2011-10-01"; // // Europe: // config.ServiceURL = "https://mws-eu.amazonservices.com/Products/2011-10-01"; // // Japan: // config.ServiceURL = "https://mws.amazonservices.jp/Products/2011-10-01"; // // China: // config.ServiceURL = "https://mws.amazonservices.com.cn/Products/2011-10-01"; // /************************************************************************ * Instantiate Implementation of Marketplace Web Service Products ***********************************************************************/ MarketplaceWebServiceProductsClient service = new MarketplaceWebServiceProductsClient( applicationName, applicationVersion, accessKeyId, secretAccessKey, config); /************************************************************************ * Uncomment to try out Mock Service that simulates Marketplace Web Service Products * responses without calling Marketplace Web Service Products service. * * Responses are loaded from local XML files. You can tweak XML files to * experiment with various outputs during development * * XML files available under MarketplaceWebServiceProducts\Mock tree * ***********************************************************************/ // MarketplaceWebServiceProducts service = new MarketplaceWebServiceProductsMock(); /************************************************************************ * Uncomment to invoke Get Matching Product Action ***********************************************************************/ // GetMatchingProductRequest request = new GetMatchingProductRequest(); // @TODO: set request parameters here // request.SellerId = merchantId; // GetMatchingProductSample.InvokeGetMatchingProduct(service, request); /************************************************************************ * Uncomment to invoke Get Lowest Offer Listings For ASIN Action ***********************************************************************/ // GetLowestOfferListingsForASINRequest request = new GetLowestOfferListingsForASINRequest(); // @TODO: set request parameters here // request.SellerId = merchantId; // GetLowestOfferListingsForASINSample.InvokeGetLowestOfferListingsForASIN(service, request); /************************************************************************ * Uncomment to invoke Get Service Status Action ***********************************************************************/ // GetServiceStatusRequest request = new GetServiceStatusRequest(); // @TODO: set request parameters here // request.SellerId = merchantId; // GetServiceStatusSample.InvokeGetServiceStatus(service, request); /************************************************************************ * Uncomment to invoke Get Matching Product For Id Action ***********************************************************************/ // GetMatchingProductForIdRequest request = new GetMatchingProductForIdRequest(); // @TODO: set request parameters here // request.SellerId = merchantId; // GetMatchingProductForIdSample.InvokeGetMatchingProductForId(service, request); /************************************************************************ * Uncomment to invoke Get My Price For SKU Action ***********************************************************************/ // GetMyPriceForSKURequest request = new GetMyPriceForSKURequest(); // @TODO: set request parameters here // request.SellerId = merchantId; // GetMyPriceForSKUSample.InvokeGetMyPriceForSKU(service, request); /************************************************************************ * Uncomment to invoke List Matching Products Action ***********************************************************************/ // ListMatchingProductsRequest request = new ListMatchingProductsRequest(); // @TODO: set request parameters here // request.SellerId = merchantId; // ListMatchingProductsSample.InvokeListMatchingProducts(service, request); /************************************************************************ * Uncomment to invoke Get Competitive Pricing For SKU Action ***********************************************************************/ // GetCompetitivePricingForSKURequest request = new GetCompetitivePricingForSKURequest(); // @TODO: set request parameters here // request.SellerId = merchantId; // GetCompetitivePricingForSKUSample.InvokeGetCompetitivePricingForSKU(service, request); /************************************************************************ * Uncomment to invoke Get Competitive Pricing For ASIN Action ***********************************************************************/ // GetCompetitivePricingForASINRequest request = new GetCompetitivePricingForASINRequest(); // @TODO: set request parameters here // request.SellerId = merchantId; // GetCompetitivePricingForASINSample.InvokeGetCompetitivePricingForASIN(service, request); /************************************************************************ * Uncomment to invoke Get Product Categories For SKU Action ***********************************************************************/ // GetProductCategoriesForSKURequest request = new GetProductCategoriesForSKURequest(); // @TODO: set request parameters here // request.SellerId = merchantId; // GetProductCategoriesForSKUSample.InvokeGetProductCategoriesForSKU(service, request); /************************************************************************ * Uncomment to invoke Get My Price For ASIN Action ***********************************************************************/ // GetMyPriceForASINRequest request = new GetMyPriceForASINRequest(); // @TODO: set request parameters here // request.SellerId = merchantId; // GetMyPriceForASINSample.InvokeGetMyPriceForASIN(service, request); /************************************************************************ * Uncomment to invoke Get Lowest Offer Listings For SKU Action ***********************************************************************/ // GetLowestOfferListingsForSKURequest request = new GetLowestOfferListingsForSKURequest(); // @TODO: set request parameters here // request.SellerId = merchantId; // GetLowestOfferListingsForSKUSample.InvokeGetLowestOfferListingsForSKU(service, request); /************************************************************************ * Uncomment to invoke Get Product Categories For ASIN Action ***********************************************************************/ // GetProductCategoriesForASINRequest request = new GetProductCategoriesForASINRequest(); // @TODO: set request parameters here // request.SellerId = merchantId; // GetProductCategoriesForASINSample.InvokeGetProductCategoriesForASIN(service, request); Console.WriteLine(); Console.WriteLine("==========================================="); Console.WriteLine("End of output. You can close this window"); Console.WriteLine("==========================================="); System.Threading.Thread.Sleep(50000); }