Exemplo n.º 1
0
        public async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken ct = default)
        {
            await Credentials.ApplyAsync(request);

            var response = await Http.SendAsync(request, ct);

            if (!response.IsSuccessStatusCode)
            {
                JetfireApiError error = null;
                try
                {
                    var body = await response.Content.ReadAsStringAsync();

                    error = JsonSerializer.Deserialize <JetfireApiError>(body, JsonConfig.SerializerOptions);
                }
                catch (Exception) { }

                throw new JetfireApiException(
                          response.StatusCode,
                          request.Method,
                          request.RequestUri,
                          error
                          );
            }

            return(response);
        }