public XmlFilter() { _rootOject = XmlProcessor.GetXmlRootObjectCommands(); _rootOjectResponse = XmlProcessor.GetXmlRootObjectResponse(); GetEOF(); }
//public List<SearchResult> Search(string country, // string language, // string SearchPlain, // string SearchCategory, // int SearchPage, // Boolean SearchWithStock, // // string[][] SearchParameter,//o to aray of arays, czy to to // string SearchOrder, // string SearchOrderType // ) //{ // var url = @"https://api.tme.eu/Products/Search.json"; // var prefixRequest = "POST" + "&" + WebUtility.UrlEncode(@url) + "&"; // var suffixRequest = ""; // var values = new List<KeyValuePair<string, string>>(); // values.Add(new KeyValuePair<string, string>("Country", country)); // values.Add(new KeyValuePair<string, string>("Language", language)); // values.Add(new KeyValuePair<string, string>("Token", _apiConfiguration.Token)); // values.Add(new KeyValuePair<string, string>("SearchPlain", SearchPlain)); // values.Add(new KeyValuePair<string, string>("SearchCategory", SearchCategory)); // values.Add(new KeyValuePair<string, string>("SearchPage", SearchPage.ToString())); // values.Add(new KeyValuePair<string, string>("SearchWithStock", SearchWithStock.ToString())); // // // values.Add(new KeyValuePair<string, string>("SearchParameter", SearchParameter.ToString()));// czy dziala // values.Add(new KeyValuePair<string, string>("SearchOrder", SearchOrder)); // values.Add(new KeyValuePair<string, string>("SearchOrderType", SearchOrderType)); // foreach (var el in values.OrderBy(x => x.Key)) // { // suffixRequest += suffixRequest.Length > 1 ? WebUtility.UrlEncode("&" + WebUtility.UrlEncode(el.Key) + "=" + WebUtility.UrlEncode(el.Value)) : WebUtility.UrlEncode(WebUtility.UrlEncode(el.Key) + "=" + WebUtility.UrlEncode(el.Value)); // } // string reply = this.SendPostRequest(url, values, UrlUtilities.CreateToken(prefixRequest + suffixRequest, _apiConfiguration.Secret)); // var root = JsonConvert.DeserializeObject<RootObjectResponse>(reply); // var data = JsonConvert.DeserializeObject<SearchList>(root.Data.ToString()); // return data.SearchListResult; //} public List <ApiProduct> GetProducts(List <string> SymbolList) { List <KeyValuePair <string, string> > values = CombineValues(SymbolList); string apiSignature = CreateApiSignature(Get_Products_Url, values); values.Add(new KeyValuePair <string, string>("ApiSignature", apiSignature)); RootObjectResponse root = _requestService.SendPostRequest(Get_Products_Url, values); return(((JObject)root.Data)["ProductList"].ToObject <List <ApiProduct> >()); }
public List <ApiStock> GetStocks(List <string> symbols) { List <KeyValuePair <string, string> > values = CombineValues(symbols); string apiSignature = CreateApiSignature(Get_Stocks_Url, values); values.Add(new KeyValuePair <string, string>("ApiSignature", apiSignature)); RootObjectResponse root = _requestService.SendPostRequest(Get_Stocks_Url, values); return(((JObject)root.Data).GetValue("ProductList").ToObject <List <ApiStock> >()); }
public ApiPriceResult <ApiProductPriceAndStock> GetPricesAndStocks(List <string> SymbolList) { List <KeyValuePair <string, string> > values = CombineValues(SymbolList); values.Add(new KeyValuePair <string, string>("Currency", _apiConfiguration.Currency)); string apiSignature = CreateApiSignature(Get_PricesAndStocks, values); values.Add(new KeyValuePair <string, string>("ApiSignature", apiSignature)); RootObjectResponse root = _requestService.SendPostRequest(Get_PricesAndStocks, values); return(((JObject)root.Data).ToObject <ApiPriceResult <ApiProductPriceAndStock> >());; }
public List <string> GetSymbols(string CategoryId) { List <KeyValuePair <string, string> > values = CombineValues(null); values.Add(new KeyValuePair <string, string>("CategoryId", CategoryId.ToString())); string apiSignature = CreateApiSignature(Get_Symbols_Url, values); values.Add(new KeyValuePair <string, string>("ApiSignature", apiSignature)); RootObjectResponse root = _requestService.SendPostRequest(Get_Symbols_Url, values); return((((JObject)root.Data)["SymbolList"]).ToObject <List <string> >()); }
public ApiCategory GetCategoriesTree(int CategoryId, Boolean Tree) { List <KeyValuePair <string, string> > values = CombineValues(null); if (CategoryId != -1) { values.Add(new KeyValuePair <string, string>("CategoryId", CategoryId.ToString())); } string apiSignature = CreateApiSignature(Get_Categories_Url, values); values.Add(new KeyValuePair <string, string>("ApiSignature", apiSignature)); RootObjectResponse root = _requestService.SendPostRequest(Get_Categories_Url, values); return(((JObject)root.Data).GetValue("CategoryTree").ToObject <ApiCategory>()); }
public static RootObjectResponse GetXmlRootObjectResponse() { XmlSerializer serializer = new XmlSerializer(typeof(RootObjectResponse)); Assembly assembly = Assembly.GetExecutingAssembly(); const string xmlRead = "IRCS_MS.Resource.responsesTable.xml"; using (Stream stream = assembly.GetManifestResourceStream(xmlRead)) { using (StreamReader reader = new StreamReader(stream)) { RootObjectResponse result = (RootObjectResponse)serializer.Deserialize(reader); return(result); } } }
public ApiSearchResult Search(string searchText, int searchPage) { List <KeyValuePair <string, string> > values = CombineValues(null); values.Add(new KeyValuePair <string, string>("SearchPlain", searchText)); values.Add(new KeyValuePair <string, string>("SearchPage", searchPage.ToString())); string apiSignature = CreateApiSignature(Get_SearchResult, values); values.Add(new KeyValuePair <string, string>("ApiSignature", apiSignature)); RootObjectResponse root = _requestService.SendPostRequest(Get_SearchResult, values); try { return(((JObject)root.Data).ToObject <ApiSearchResult>()); } catch (JsonSerializationException ex) { throw new ApplicationException("Podana fraza nie została znaleziona"); } }
static void Main(string[] args) { try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; var test = new tmeapiwrapper.ProductsWrapper("c2541a34499f09b3a322", "f1e6ec66ef75693b6bee3a33bf31e13d0cb9dcbeb5b57"); RootObjectResponse rootResponse = test.GetStocks("PL", "EN", new List <string>() { "1WAT-LED-LIGHT", "3CHAZ-LO", "2W08G-E4/51" }); var castTest = JsonConvert.DeserializeObject <ProductGetStocksResponseData>(rootResponse.Data.ToString()); foreach (var item in castTest.ProductList) { Console.WriteLine(item.Symbol + "amount: " + item.Amount); } } catch (Exception ex) { Console.WriteLine("There is an exception with service: " + ex.Message); } }