Esempio n. 1
0
        public async Task <TResponse> PutAsync <TRequest, TResponse>(string requestUri, TRequest model, CancellationToken cancellationToken = default)
        {
            var httpMessage = await _httpClient.PutAsync(requestUri, JsonRequest.For(model), cancellationToken);

            var content = await httpMessage.Content.ReadAsStringAsync();

            JsonResponse <TResponse> response;

            if (httpMessage.IsSuccessStatusCode)
            {
                response = new JsonResponse <TResponse>(content);
            }
            else
            {
                response = new JsonResponse <TResponse>(content, httpMessage.StatusCode, httpMessage.ReasonPhrase);
                httpMessage.HandleHttpError(response);
            }
            return(response.Data);
        }