public List <AnimeShortInfo> GetSearch(ShikiApi user = null) { var url = ShikiApiStatic.DomenApi + "animes?"; url += "order=" + Order + "&"; if (SearchText != "") { url += "search=" + SearchText + "&"; } if (Limit > 1) { url += "limit=" + Limit + "&"; } // тут всё верно. в запросе по умолчанию limit=1, я же хочу, чтобы (если не указано) выдавало страницу полностью (обычно до 50 строк) if (Censored) { url += "censored=" + "true" + "&"; } if (Page > 1) { url += "page=" + Page + "&"; } if (TitleScore > 0) { url += "score=" + TitleScore + "&"; } if (MyList.Count > 0) { url += "mylist=" + DictToStr(MyList) + "&"; } if (Kind.Count > 0) { url += "type=" + DictToStr(Kind) + "&"; } if (Duration.Count > 0) { url += "duration=" + DictToStr(Duration) + "&"; } if (Rating.Count > 0) { url += "rating=" + DictToStr(Rating) + "&"; } if (TitleStatus.Count > 0) { url += "status=" + DictToStr(TitleStatus) + "&"; } if (Season.Count > 0) { url += "season=" + DictToStr(Season) + "&"; } if (Genre.Count > 0) { url += "genre=" + DictToStr(Genre) + "&"; } if (Studio.Count > 0) { url += "studio=" + DictToStr(Studio) + "&"; } return(Query.GET <List <AnimeShortInfo> >(url, user)); }
internal static HttpStatusCode DELETE(string url, ShikiApi user = null) { using (var httpClient = new HttpClient()) { if (user != null) { httpClient.DefaultRequestHeaders.Add("X-User-Nickname", user.Nickname); httpClient.DefaultRequestHeaders.Add("X-User-Api-Access-Token", user.AccessToken); } httpClient.DefaultRequestHeaders.Add("User-Agent", ShikiApiStatic.ClientName); var response = httpClient.DeleteAsync(url); return(response.Result.StatusCode); } }
internal static T PUT <T>(string url, FormUrlEncodedContent args, ShikiApi user = null) { using (var httpClient = new HttpClient()) { if (user != null) { httpClient.DefaultRequestHeaders.Add("X-User-Nickname", user.Nickname); httpClient.DefaultRequestHeaders.Add("X-User-Api-Access-Token", user.AccessToken); } httpClient.DefaultRequestHeaders.Add("User-Agent", ShikiApiStatic.ClientName); var response = httpClient.PutAsync(url, args).Result.Content.ReadAsStringAsync().Result; var result = JsonConvert.DeserializeObject <T>(response); return(result); } }
internal static T GET <T>(string url, ShikiApi user = null) { using (var httpClient = new HttpClient()) { if (user != null) { httpClient.DefaultRequestHeaders.Add("X-User-Nickname", user.Nickname); httpClient.DefaultRequestHeaders.Add("X-User-Api-Access-Token", user.AccessToken); } httpClient.DefaultRequestHeaders.Add("User-Agent", ShikiApiStatic.ClientName); var response = httpClient.GetStringAsync(url).Result; //json_setting для работы сериализации IDictionary в полях rates_scores_stats и rates_statuses_stats в классах AnimeFullInfo и MangaFullInfo var json_setting = new JsonSerializerSettings { Converters = new JsonConverter[] { new JsonGenericDictionaryOrArrayConverterNameValueMod() } }; var result = JsonConvert.DeserializeObject <T>(response, json_setting); return(result); } }