Example #1
0
 public TreeWrapper CancelFeedSubmissions(string[] feedIds=null, string[] feedTypes=null,
     string fromDate=null, string toDate=null)
 {
     var data = new Dictionary<string, string>() {
         {"Action", "CancelFeedSubmissions"},
         {"SubmittedFromDate", fromDate},
         {"SubmittedToDate", toDate}
     };
     data.Update(EnumerateParam("FeedSubmissionIdList.Id.", feedIds));
     data.Update(EnumerateParam("FeedTypeList.Type.", feedTypes));
     return MakeRequest(data);
 }
Example #2
0
 public TreeWrapper GetFeedSubmissionCount(string[] feedTypes=null, string[] processingStatuses=null,
     string fromDate=null, string toDate=null)
 {
     var data = new Dictionary<string, string>() {
         {"Action", "GetFeedSubmissionCount"},
         {"SubmittedFromDate", fromDate},
         {"SubmittedToDate", toDate}
     };
     data.Update(EnumerateParam("FeedTypeList.Type.", feedTypes));
     data.Update(EnumerateParam("FeedProcessingStatusList.Status.", processingStatuses));
     return MakeRequest(data);
 }
Example #3
0
 public TreeWrapper GetReportRequestList(string[] requestIds = null, string[] types = null,
     string[] processingStatuses = null, string maxCount = null,
     string fromDate = null, string toDate = null)
 {
     var data = new Dictionary<string, string>() {
         {"Action", "GetReportRequestList"},
         {"MaxCount", maxCount},
         {"RequestedFromDate", fromDate},
         {"RequestedToDate", toDate},
     };
     data.Update(EnumerateParam("ReportRequestIdList.Id.", requestIds));
     data.Update(EnumerateParam("ReportTypeList.Type.", types));
     data.Update(EnumerateParam("ReportProcessingStatusList.Status.", processingStatuses));
     return MakeRequest(data);
 }
Example #4
0
 public TreeWrapper GetOrder(string[] amazonOrderIds)
 {
     var data = new Dictionary<string, string>() {
         {"Action", "GetOrder"},
     };
     data.Update(EnumerateParam("AmazonOrderId.Id.", amazonOrderIds));
     return MakeRequest(data);
 }
Example #5
0
 /// <summary>
 /// Returns the current competitive pricing of a product,
 /// based on the SellerSKU and MarketplaceId that you specify.
 /// </summary>
 /// <param name="marketplaceId"></param>
 /// <param name="skus"></param>
 /// <returns></returns>
 public TreeWrapper GetCompetitivePricingForSku(string marketplaceId, string[] skus)
 {
     var data = new Dictionary<string, string>() {
         {"Action", "GetCompetitivePricingForSKU"},
         {"MarketplaceId", marketplaceId},
     };
     data.Update(EnumerateParam("SellerSKUList.SellerSKU.", skus));
     return MakeRequest(data);
 }
Example #6
0
 /// <summary>
 /// Returns the current competitive pricing of a product,
 /// based on the ASIN and MarketplaceId that you specify.
 /// </summary>
 /// <param name="?"></param>
 /// <param name="?"></param>
 /// <returns></returns>
 public TreeWrapper GetCompetitivePricingForAsin(string marketplaceId, string[] asins)
 {
     var data = new Dictionary<string, string>() {
         {"Action", "GetCompetitivePricingForASIN"},
         {"MarketplaceId", marketplaceId},
     };
     data.Update(EnumerateParam("ASINList.ASIN.", asins));
     return MakeRequest(data);
 }
Example #7
0
 public TreeWrapper GetLowestOfferListingsForAsin(string marketplaceId, string[] asins,
     string condition="All")
 {
     var data = new Dictionary<string, string>() {
         {"Action", "GetLowestOfferListingsForASIN"},
         {"MarketplaceId", marketplaceId},
         {"ItemCondition", condition},
     };
     data.Update(EnumerateParam("ASINList.ASIN.", asins));
     return MakeRequest(data);
 }
Example #8
0
 public TreeWrapper RequestReport(string reportType, string startDate = null, string endDate = null,
     string[] marketplaceIds = null)
 {
     var data = new Dictionary<string, string>() {
         {"Action", "RequestReport"},
         {"ReportType", reportType},
         {"StartDate", startDate},
         {"EndDate", endDate},
     };
     data.Update(EnumerateParam("MarketplaceIdList.Id.", marketplaceIds));
     return MakeRequest(data);
 }
Example #9
0
 public TreeWrapper GetReportCount(string[] reportTypes = null, string acknowledged = null,
     string fromDate = null, string toDate = null)
 {
     var data = new Dictionary<string, string>() {
         {"Action", "GetReportCount"},
         {"Acknowledged", acknowledged},
         {"AvailableFromDate", fromDate},
         {"AvailableToDate", toDate},
     };
     data.Update(EnumerateParam("ReportTypeList.Type.", reportTypes));
     return MakeRequest(data);
 }
Example #10
0
 public TreeWrapper ListOrders(string[] marketplaceIds, string createdAfter=null,
     string createdBefore=null, string lastUpdatedAfter=null,
     string lastUpdatedBefore=null, string[] orderStatus=null, string[] fulfillmentChannels=null,
     string[] paymentMethods = null, string buyerEmail = null, string sellerOrderid = null,
     int maxResults=100)
 {
     var data = new Dictionary<string, string>() {
         {"Action", "ListOrders"},
         {"CreatedAfter", createdAfter},
         {"CreatedBefore", createdBefore},
         {"LastUpdatedAfter", lastUpdatedAfter},
         {"LastUpdatedBefore", lastUpdatedBefore},
         {"BuyerEmail", buyerEmail},
         {"SellerOrderId", sellerOrderid},
         {"MaxResultsPerPage", maxResults.ToString()},
     };
     data.Update(EnumerateParam("OrderStatus.Status.", orderStatus));
     data.Update(EnumerateParam("MarketplaceId.Id.", marketplaceIds));
     data.Update(EnumerateParam("FulfillmentChannel.Channel.", fulfillmentChannels));
     data.Update(EnumerateParam("PaymentMethod.Method.", paymentMethods));
     return MakeRequest(data);
 }
 public void Update()
 {
     Dictionary<int, int> dict = new Dictionary<int, int>();
     dict.Add(1, 1);
     dict.Add(2, 2);
     dict.Add(3, 3);
     dict.Add(4, 2);
     Dictionary<int, int> dictCopy = new Dictionary<int, int>();
     dictCopy.Add(1, 3);
     dictCopy.Add(3, 9);
     dict.Update(dictCopy);
     Dictionary<int, int> dictOther = new Dictionary<int, int>();
     dictOther.Add(1, 3);
     dictOther.Add(2, 2);
     dictOther.Add(3, 9);
     dictOther.Add(4, 2);
     Assert.AreEqual(dictOther, dict);
 }
        /// <summary>
        /// Reads the KeyValuePairs from the given string and adds them to a dictionary
        /// </summary>
        /// <param name="dataString"></param>
        /// <returns></returns>
        public static Dictionary<string, string> Parse(string dataString)
        {
            var data = new Dictionary<string, string>();

            StringBuilder strBuild = new StringBuilder();
            bool isEscaped = false;
            bool terminated = true;
            bool isKey = true;

            string key = "";

            foreach (char c in dataString)
            {
                if (isEscaped)
                {
                    isEscaped = false;
                    strBuild.Append(c);
                    continue;
                }

                switch (c)
                {
                    case '"':
                        if (terminated)
                        {
                            //new key or value
                            terminated = false;
                        }
                        else
                        {
                            //end of key or value
                            terminated = true;

                            if (isKey)
                            {
                                key = strBuild.ToString();
                            }
                            else
                            {
                                data.Update(key, strBuild.ToString());
                            }

                            strBuild.Clear();
                        }
                        break;
                    case '\\':
                        if (!terminated)
                            isEscaped = true;
                        break;
                    case ':':
                        if (terminated)
                            isKey = false;
                        else
                            strBuild.Append(c);
                        break;
                    case ';':
                        if (terminated)
                            isKey = true;
                        else
                            strBuild.Append(c);
                        break;
                    default:
                        if (!terminated)
                            strBuild.Append(c);
                        break;
                }
            }
            return data;
        }
Example #13
0
 /// <summary>
 /// Uploads a feed ( xml or .tsv ) to the seller's inventory.
 /// Can be used for creating/updating products on amazon.
 /// </summary>
 /// <param name="feed"></param>
 /// <param name="feed_type"></param>
 /// <param name="marketplaceids"></param>
 /// <param name="content_type"></param>
 /// <param name="purge"></param>
 /// <returns></returns>
 public TreeWrapper SubmitFeed(string feed, string feedType, string[] marketplaceIds = null,
     string contentType = "text/xml", string purge = "false")
 {
     var data = new Dictionary<string, string>() {
         {"Action", "SubmitFeed"},
         {"FeedType", feedType},
         {"PurgeAndReplace", purge},
     };
     if (marketplaceIds != null)
         data.Update(EnumerateParam("MarketplaceIdList.Id.", marketplaceIds));
     var md = CalcMD5(feed);
     var headers = new Dictionary<HttpRequestHeader, string>(){
         {HttpRequestHeader.ContentMd5, md},
         {HttpRequestHeader.ContentType, contentType},
     };
     return MakeRequest(data, WebRequestMethods.Http.Post, headers, feed);
 }
Example #14
0
        /// <summary>
        /// Make request to Amazon MWS API with these parameters
        /// </summary>
        /// <param name="extraData"></param>
        /// <param name="method"></param>
        /// <param name="extraHeaders"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public TreeWrapper MakeRequest(IDictionary<string, string> extraData,
            string method = WebRequestMethods.Http.Get, IDictionary<HttpRequestHeader, string> extraHeaders = null,
            string body = null)
        {
            var qParams = new Dictionary<string, string>(){
                {"AWSAccessKeyId", this.accessKey},
                {ACCOUNT_TYPE, this.accountId},
                {"SignatureVersion", "2"},
                {"Timestamp", this.GetTimestamp()},
                {"Version", this.version},
                {"SignatureMethod", "HmacSHA256"},
            };
            qParams.Update(extraData.Where(i => !string.IsNullOrEmpty(i.Value)).ToDictionary(p => p.Key, p => p.Value));

            //TODO add encode('utf-8')
            var requestDescription = string.Join("&",
                from param in qParams
                select
                    string.Format("{0}={1}",
                        param.Key, Uri.EscapeDataString(param.Value)));
            var signature = this.CalcSignature(method, requestDescription);
            var url = string.Format("{0}{1}?{2}&Signature={3}",
                this.domain, this.uri, requestDescription, Uri.EscapeDataString(signature));
            var request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = method.ToString();
            request.UserAgent = "csharp-amazon-mws/0.0.1 (Language=CSharp)";
            if (extraHeaders != null)
                foreach (var x in extraHeaders)
                    request.Headers.Add(x.Key, x.Value);
            if (!string.IsNullOrEmpty(body))
            {
                var dataStream = request.GetRequestStream();
                var bytes = Encoding.UTF8.GetBytes(body);
                dataStream.Write(bytes, 0, body.Length);
                dataStream.Close();
            }
            var response = request.GetResponse();
            var parsedResponse = new TreeWrapper(response.GetResponseStream(), NS);
            response.Close();
            return parsedResponse;
        }
Example #15
0
 public TreeWrapper GetLowestOfferListingsForSku(string marketplaceId, string[] skus,
     string condition="Any")
 {
     var data = new Dictionary<string, string>() {
         {"Action", "GetLowestOfferListingsForSKU"},
         {"MarketplaceId", marketplaceId},
         {"ItemCondition", condition},
     };
     data.Update(EnumerateParam("SellerSKUList.SellerSKU.", skus));
     return MakeRequest(data);
 }
Example #16
0
 /// <summary>
 /// Returns a list of products and their attributes, based on a list of
 /// ASIN values that you specify.
 /// </summary>
 /// <param name="marketplaceId"></param>
 /// <param name="asins"></param>
 /// <returns></returns>
 public TreeWrapper GetMatchingProduct(string marketplaceId, string[] asins)
 {
     var data = new Dictionary<string, string>() {
         {"Action", "GetMatchingProduct"},
         {"MarketplaceId", marketplaceId},
     };
     data.Update(EnumerateParam("ASINList.ASIN.", asins));
     return MakeRequest(data);
 }