Пример #1
0
        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));
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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));
        }
Пример #5
0
        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));
        }
Пример #6
0
 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
 }
Пример #7
0
 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));
 }
Пример #8
0
 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);
 }