/// <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); }
/// <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; }