Ejemplo n.º 1
0
        protected virtual async Task <WebCallResult <T> > SendRequestAsync <T>(
            RestApiClient apiClient,
            Uri uri,
            HttpMethod method,
            CancellationToken cancellationToken,
            Dictionary <string, object>?parameters = null,
            bool signed = false,
            HttpMethodParameterPosition?parameterPosition   = null,
            ArrayParametersSerialization?arraySerialization = null,
            int requestWeight           = 1,
            JsonSerializer?deserializer = null,
            Dictionary <string, string>?additionalHeaders = null,
            bool ignoreRatelimit = false
            ) where T : class
        {
            var requestId = NextId();

            if (signed)
            {
                var syncTimeResult = await apiClient.SyncTimeAsync().ConfigureAwait(false);

                if (!syncTimeResult)
                {
                    log.Write(LogLevel.Debug, $"[{requestId}] Failed to sync time, aborting request: " + syncTimeResult.Error);
                    return(syncTimeResult.As <T>(default));
Ejemplo n.º 2
0
        protected virtual async Task <WebCallResult> SendRequestAsync(RestApiClient apiClient,
                                                                      Uri uri,
                                                                      HttpMethod method,
                                                                      CancellationToken cancellationToken,
                                                                      Dictionary <string, object>?parameters = null,
                                                                      bool signed = false,
                                                                      HttpMethodParameterPosition?parameterPosition   = null,
                                                                      ArrayParametersSerialization?arraySerialization = null,
                                                                      int requestWeight           = 1,
                                                                      JsonSerializer?deserializer = null,
                                                                      Dictionary <string, string>?additionalHeaders = null,
                                                                      bool ignoreRatelimit = false)
        {
            var request = await PrepareRequestAsync(apiClient, uri, method, cancellationToken, parameters, signed, parameterPosition, arraySerialization, requestWeight, deserializer, additionalHeaders, ignoreRatelimit).ConfigureAwait(false);

            if (!request)
            {
                return(new WebCallResult(request.Error !));
            }

            var result = await GetResponseAsync <object>(apiClient, request.Data, deserializer, cancellationToken, true).ConfigureAwait(false);

            return(result.AsDataless());
        }