Skip to content

Commit

Permalink
Update WholesaleClient.cs (#1593)
Browse files Browse the repository at this point in the history
  • Loading branch information
johevemi authored Mar 30, 2023
1 parent 9334efc commit 32bb190
Showing 1 changed file with 5 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -520,39 +520,8 @@ public string BaseUrl
PrepareRequest(client_, request_, url_);

var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
var disposeResponse_ = true;
try
{
var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}

ProcessResponse(client_, response_);

var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<Stream>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
return objectResponse_.Object;
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
finally
{
if (disposeResponse_)
response_.Dispose();
}
var stream = await response_.Content.ReadAsStreamAsync().ConfigureAwait(false);
return stream;
}
}
finally
Expand Down Expand Up @@ -634,7 +603,7 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu
var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name);
if (field != null)
{
var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute))
var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute))
as System.Runtime.Serialization.EnumMemberAttribute;
if (attribute != null)
{
Expand All @@ -646,7 +615,7 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu
return converted == null ? string.Empty : converted;
}
}
else if (value is bool)
else if (value is bool)
{
return System.Convert.ToString((bool)value, cultureInfo).ToLowerInvariant();
}
Expand Down Expand Up @@ -895,4 +864,4 @@ public ApiException(string message, int statusCode, string response, System.Coll
#pragma warning restore 114
#pragma warning restore 108
#pragma warning restore 3016
#pragma warning restore 8603
#pragma warning restore 8603

0 comments on commit 32bb190

Please sign in to comment.