internal async Task <RestResponse> SendJsonAsync(string method, string endpoint, object jsonObject, RequestOptions options) { options = options ?? RequestOptions.CreateFromDefaults(Config); string jsonString = JsonConvert.SerializeObject(jsonObject, Config.SerializerSettings); return(await SendInternalAsync(() => Config.RestClient.SendAsync(method, endpoint, jsonString, options.CancellationToken), options).ConfigureAwait(false)); }
internal async Task <HttpStatusCode> GetFollowingUserAsync(string userId, RequestOptions options) { options = options ?? RequestOptions.CreateFromDefaults(Config); options.IgnoreCodes = Utils.Ignore404; RestResponse response = await SendAsync("HEAD", $"me/follows/{userId}", options).ConfigureAwait(false); return(response.Status); }
internal async Task <HttpStatusCode> GetEmailVerificationStatusAsync(RequestOptions options) { options = options ?? RequestOptions.CreateFromDefaults(Config); options.IgnoreCodes = Utils.Ignore404; RestResponse response = await SendAsync("HEAD", $"me/email_verified", options).ConfigureAwait(false); return(response.Status); }
internal async Task <RestResponse> SendStreamAsync(string method, string endpoint, Stream stream, string fileName, RequestOptions options) { options = options ?? RequestOptions.CreateFromDefaults(Config); Dictionary <string, object> content = new Dictionary <string, object> { { "key", fileName }, { "file", stream } }; return(await SendInternalAsync(() => Config.RestClient.SendAsync(method, endpoint, content, options.CancellationToken), options).ConfigureAwait(false)); }
public async Task <FullGfyResponse> GetFullGfyAsync(string gfyId, RequestOptions options) { options = options ?? RequestOptions.CreateFromDefaults(Config); options.IgnoreCodes = Utils.Ignore404; RestResponse response = await SendAsync("GET", $"me/gfycats/{gfyId}/full", options).ConfigureAwait(false); if (response.Status == HttpStatusCode.NotFound) { return(null); } return(await response.ReadAsJsonAsync <FullGfyResponse>(Config).ConfigureAwait(false)); }
internal async Task PostGfyStreamAsync(UploadKey key, Stream stream, RequestOptions options) { options = options ?? RequestOptions.CreateFromDefaults(Config); options.UseAccessToken = false; RestResponse response = await SendStreamAsync("POST", "https://filedrop.gfycat.com/", stream, key.Gfycat, options).ConfigureAwait(false); // uploads as multipart }
private async Task <RestResponse> SendBinaryStreamAsync(string method, string endpoint, Stream stream, RequestOptions options) { options = options ?? RequestOptions.CreateFromDefaults(Config); return(await SendInternalAsync(() => Config.RestClient.SendAsync(method, endpoint, stream, options.CancellationToken), options).ConfigureAwait(false)); }
internal async Task UploadProfileImageAsync(string url, Stream picStream, RequestOptions options) { options = options ?? RequestOptions.CreateFromDefaults(Config); options.UseAccessToken = false; RestResponse response = await SendBinaryStreamAsync("PUT", url, picStream, options).ConfigureAwait(false); }