/// <summary>
        /// Sends the upload request asynchronously.
        /// </summary>
        /// <typeparam name="TRequest">The type of the request.</typeparam>
        /// <typeparam name="TResponse">The type of the response.</typeparam>
        /// <typeparam name="TError">The type of the error.</typeparam>
        /// <param name="request">The request.</param>
        /// <param name="host">The server host to send the request to.</param>
        /// <param name="route">The route name.</param>
        /// <param name="requestEncoder">The request encoder.</param>
        /// <param name="resposneDecoder">The response decoder.</param>
        /// <param name="errorDecoder">The error decoder.</param>
        /// <returns>An asynchronous task for the response.</returns>
        /// <exception cref="ApiException{TError}">
        /// This exception is thrown when there is an error reported by the server.
        /// </exception>
        async Task <TResponse> ITransport.SendRpcRequestAsync <TRequest, TResponse, TError>(
            TRequest request,
            string host,
            string route,
            IEncoder <TRequest> requestEncoder,
            IDecoder <TResponse> resposneDecoder,
            IDecoder <TError> errorDecoder)
        {
            var serializedArg = JsonWriter.Write(request, requestEncoder);
            var res           = await this.RequestJsonStringWithRetry(host, route, RouteStyle.Rpc, serializedArg)
                                .ConfigureAwait(false);

            if (res.IsError)
            {
                throw StructuredException <TError> .Decode <ApiException <TError> >(res.ObjectResult, errorDecoder);
            }

            return(JsonReader.Read(res.ObjectResult, resposneDecoder));
        }
Beispiel #2
0
        /// <summary>
        /// Sends the download request asynchronously.
        /// </summary>
        /// <typeparam name="TRequest">The type of the request.</typeparam>
        /// <typeparam name="TResponse">The type of the response.</typeparam>
        /// <typeparam name="TError">The type of the error.</typeparam>
        /// <param name="request">The request.</param>
        /// <param name="host">The server host to send the request to.</param>
        /// <param name="route">The route name.</param>
        /// <param name="requestEncoder">The request encoder.</param>
        /// <param name="resposneDecoder">The response decoder.</param>
        /// <param name="errorDecoder">The error decoder.</param>
        /// <returns>An asynchronous task for the response.</returns>
        /// <exception cref="ApiException{TError}">
        /// This exception is thrown when there is an error reported by the server.
        /// </exception>
        async Task <IDownloadResponse <TResponse> > ITransport.SendDownloadRequestAsync <TRequest, TResponse, TError>(
            TRequest request,
            string host,
            string route,
            IEncoder <TRequest> requestEncoder,
            IDecoder <TResponse> resposneDecoder,
            IDecoder <TError> errorDecoder)
        {
            var serializedArg = JsonWriter.Write(request, requestEncoder, true);
            var res           = await this.RequestJsonStringWithRetry(host, route, RouteStyle.Download, serializedArg)
                                .ConfigureAwait(false);

            if (res.IsError)
            {
                throw StructuredException <TError> .Decode <ApiException <TError> >(
                          res.ObjectResult, errorDecoder, () => new ApiException <TError>(res.RequestId));
            }

            var response = JsonReader.Read(res.ObjectResult, resposneDecoder);

            return(new DownloadResponse <TResponse>(response, res.HttpResponse));
        }
 /// <summary>
 /// <para>Decode from given json.</para>
 /// </summary>
 internal static PathRootException Decode(string json, sys.Func <PathRootException> exceptionFunc)
 {
     return(StructuredException <PathRootError> .Decode <PathRootException>(json, PathRootError.Decoder, exceptionFunc));
 }
 /// <summary>
 /// <para>Decode from given json.</para>
 /// </summary>
 internal static AuthException Decode(string json)
 {
     return(StructuredException <AuthError> .Decode <AuthException>(json, AuthError.Decoder));
 }
Beispiel #5
0
 /// <summary>
 /// <para>Decode from given json.</para>
 /// </summary>
 internal static AuthException Decode(string json, sys.Func <AuthException> exceptionFunc)
 {
     return(StructuredException <AuthError> .Decode <AuthException>(json, AuthError.Decoder, exceptionFunc));
 }
 /// <summary>
 /// <para>Decode from given json.</para>
 /// </summary>
 internal static RateLimitException Decode(string json, sys.Func <RateLimitException> exceptionFunc)
 {
     return(StructuredException <RateLimitError> .Decode <RateLimitException>(json, RateLimitError.Decoder, exceptionFunc));
 }