public async Task <JSON_List> ListFiles() { using (HttpClient localHttpClient = new HttpClient(new HCHandler())) { var RequestUri = new pUri("file/listing", new AuthDictionary() { { "folder_id", "_root" } }); using (HttpResponseMessage response = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); if (result.CheckStatus()) { return(result.Jobj().SelectToken("data").ToString() == "[]" ? new JSON_List() { FilesList = new Dictionary <string, JSON_FileMetadata>() } : JsonConvert.DeserializeObject <JSON_List>(result, JSONhandler)); } else { throw ShowError(result); } } } }
public async Task <JSON_ListPushes> ListContinue(string Cursor, int Limit) { var parameters = new Dictionary <string, string>() { { "active", "true" }, { "limit", Limit.ToString() }, { "cursor", Cursor } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri("pushes", parameters); using (HttpResponseMessage resPonse = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false)) { string result = await resPonse.Content.ReadAsStringAsync(); if (resPonse.StatusCode == HttpStatusCode.OK) { var FinRes = JsonConvert.DeserializeObject <JSON_ListPushes>(result, JSONhandler); // FinRes.ApiLimits = GetApiLimits(resPonse) return(FinRes); } else { ShowError(result); } return(null); } } }
public async Task <bool> Remove(string VideoID) { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri(string.Format("/me/history/{0}", VideoID)); HttpResponseMessage ResPonse = await localHttpClient.DeleteAsync(RequestUri).ConfigureAwait(false); return(ResPonse.StatusCode == System.Net.HttpStatusCode.OK ? true : throw ShowError(await ResPonse.Content.ReadAsStringAsync())); } }
public async Task <bool> Delete() { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri($"/playlist/{PlaylistID}"); HttpResponseMessage ResPonse = await localHttpClient.DeleteAsync(RequestUri).ConfigureAwait(false); return(ResPonse.StatusCode == System.Net.HttpStatusCode.OK ? true : throw ShowError(await ResPonse.Content.ReadAsStringAsync())); } }
public async Task <bool> Exists(string VideoID) { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri($"/user/me/likes/{VideoID}"); HttpResponseMessage ResPonse = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JObject.Parse(result).SelectToken("list").ToList().Count > 0 : throw ShowError(result)); } }
public async Task <bool> Exists(string VideoID) { var parameters = new Dictionary <string, string>(); // parameters.Add("fields", String.Join(",", utilitiez.GetStringsFromClassConstants(GetType(FieldsVideo)))) using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri(string.Format("/user/me/favorites/{0}", VideoID), parameters); HttpResponseMessage ResPonse = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JObject.Parse(result).SelectToken("list").ToList().Count > 0 : throw ShowError(result)); } }
public async Task <JSON_PlayListMetadata> Metadata() { var parameters = new Dictionary <string, string> { { "fields", string.Join(",", GetStringsFromClassConstants(typeof(FieldsPlaylist))) } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri($"/playlist/{PlaylistID}", parameters); HttpResponseMessage ResPonse = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_PlayListMetadata>(result, JSONhandler) : throw ShowError(result)); } }
public async Task <JSON_ListVideos> ListFavorites(VideoSortEnum Sort = VideoSortEnum.recent, int Limit = 10, int OffSet = 1) { var parameters = new Dictionary <string, string> { { "fields", string.Join(",", GetStringsFromClassConstants(typeof(FieldsVideo))) }, { "limit", Limit.ToString() }, { "page", OffSet.ToString() }, { "sort", Sort.ToString() } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri(string.Format("/user/me/favorites"), parameters); HttpResponseMessage ResPonse = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_ListVideos>(result, JSONhandler) : throw ShowError(result)); } }
public async Task <bool> Delete(string IDen) { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri($"devices/{IDen}"); HttpResponseMessage ResPonse = await localHttpClient.DeleteAsync(RequestUri).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); if (ResPonse.StatusCode == HttpStatusCode.OK) { return(true); } else { ShowError(result); return(false); } } }
public async Task <JSON_ListDevices> List() { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri("devices"); using (HttpResponseMessage resPonse = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false)) { string result = await resPonse.Content.ReadAsStringAsync(); if (resPonse.StatusCode == HttpStatusCode.OK) { return(JsonConvert.DeserializeObject <JSON_ListDevices>(result, JSONhandler)); } else { ShowError(result); return(null); } } } }
public async Task <JSON_UserInfo> UserInfo() { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri("users/me"); using (System.Net.Http.HttpResponseMessage resPonse = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false)) { string result = await resPonse.Content.ReadAsStringAsync(); if (resPonse.StatusCode == HttpStatusCode.OK) { var FinRes = JsonConvert.DeserializeObject <JSON_UserInfo>(result, JSONhandler); // FinRes.ApiLimits = GetApiLimits(resPonse) return(FinRes); } else { ShowError(result); return(null); } } } }