예제 #1
0
        public async Task <TResponse> SendRequestAsync <TResponse>(ICommonRequest request, string endpoint) where TResponse : ICommonResponse
        {
            request.SetEndpoint(endpoint);
            request.SetAuthorization(_sdkCommonOptions.SecretId, _sdkCommonOptions.SecretKey);

            using (var response = await HttpClient.SendAsync(request.HttpRequestMessage))
            {
                var result = await response.Content.ReadAsStringAsync();

                return(JObject.Parse(result).SelectToken("$.Response").ToObject <TResponse>());
            }
        }
        public virtual async Task <TResponse> SendRequestAsync <TResponse>(ICommonRequest request, string endpoint,
                                                                           AbpTencentCloudCommonOptions options) where TResponse : ICommonResponse
        {
            request.SetEndpoint(endpoint);
            request.SetAuthorization(options.SecretId, options.SecretKey);

            using var response = await HttpClient.SendAsync(request.HttpRequestMessage);

            var result = await response.Content.ReadAsStringAsync();

            return(request.ResultRoot.IsNullOrEmpty()
                ? JObject.Parse(result).ToObject <TResponse>()
                : JObject.Parse(result).SelectToken($"$.{request.ResultRoot}").ToObject <TResponse>());
        }