public static string apiUrl = "https://api.zalando.com"; //this will be set when the app starts in the case we need to change country. public static async Task<string> callAsync(string api, Filter filter) { HttpClient client = new HttpClient(); Task<string> getStringTask = client.GetStringAsync(getApiUrl(api, filter)); string urlContents = await getStringTask; return urlContents; }
private async Task<List<Article>> getArticles(Filter filter) { Article article = new Article(); Task<List<Article>> task = article.readAPIAsync<Article>(filter); //"https://api.zalando.com/articles?brandFamily=nike&color=white&color=red&category=womens-shoes&page=1&pageSize=2"); List<Article> list = await task; return list; }
public async Task TestGetArticles() { Article article = new Article(); Filter filter = new Filter(); filter.setFilter("brandFamily=nike&color=white&color=red&category=womens-shoes&page=1&pageSize=2"); Task<List<Article>> task = article.readAPIAsync<Article>(filter); List<Article> list = await task; Assert.AreNotEqual(list.Count, 0); }
private async Task<List<Article>> getArticles(string fullText) { Filter filter = new Filter().addGender(gender).addFullText(fullText).addPaging(currentPage); Article article = new Article(); Task<List<Article>> task = article.readAPIAsync<Article>(filter); List<Article> list = await task; Articles = list; return list; }
private static Filter getFilter(string gender) { Filter filter = new Filter().addGender(gender); return filter; }
private static string getApiUrl(string api, Filter filter) { return apiUrl + api + filter.UrlFilter; }