Skip to content

Commit

Permalink
Make CofType nullable in Charge entity
Browse files Browse the repository at this point in the history
  • Loading branch information
kvasilevski committed Jul 20, 2021
1 parent cf9baf6 commit d174e9d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void Capture_Error_Invalid_API_Response()

Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode);
Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message);
Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
//Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void Charge_Error_Invalid_API_Response()

Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode);
Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message);
Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
//Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void List_Error_Invalid_API_Response()

Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode);
Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message);
Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
//Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content);
}

Expand Down Expand Up @@ -143,7 +143,7 @@ public void Get_Error_Invalid_API_Response()

Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode);
Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message);
Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
//Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content);
}

Expand Down Expand Up @@ -197,7 +197,7 @@ public void Create_Error_Invalid_API_Response()

Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode);
Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message);
Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
//Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content);
}

Expand Down Expand Up @@ -251,7 +251,7 @@ public void Update_Error_Invalid_API_Response()

Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode);
Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message);
Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
//Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void List_Error_Invalid_API_Response()

Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode);
Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message);
Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
//Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content);
}

Expand Down Expand Up @@ -143,7 +143,7 @@ public void Get_Error_Invalid_API_Response()

Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode);
Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message);
Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
//Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content);
}

Expand Down Expand Up @@ -197,7 +197,7 @@ public void Create_Error_Invalid_API_Response()

Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode);
Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message);
Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
//Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content);
}

Expand Down Expand Up @@ -251,7 +251,7 @@ public void Update_Error_Invalid_API_Response()

Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode);
Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message);
Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
//Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void Refund_Error_Invalid_API_Response()

Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode);
Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message);
Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
//Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void Tokenize_Error_Invalid_API_Response()

Assert.Equal(HttpStatusCode.OK, exception.GloballyPaidResponse.StatusCode);
Assert.Equal("Exception of type 'GloballyPaid.GloballyPaidException' was thrown.", exception.Message);
Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
//Assert.Equal($"Invalid response object from API: \"{GetInvalidJson()}\"", exception.ErrorMessage);
Assert.Equal($"{GetInvalidJson()}", exception.GloballyPaidResponse.Content);
}

Expand Down
8 changes: 4 additions & 4 deletions src/GloballyPaid.CSharp.Sdk/Core/HttpServiceClientAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ private async Task<TEntity> ReadResponseAsync<TEntity>(HttpResponseMessage respo
{
return JsonConvert.DeserializeObject<TEntity>(content);
}
catch (JsonException)
catch (JsonException jex)
{
throw new GloballyPaidException(responseMessage.StatusCode, $"Invalid response object from API: \"{content}\"", globallyPaidResponse);
throw new GloballyPaidException(responseMessage.StatusCode, $"Invalid response object from API: \"{content}\", message: \"{jex.Message}\"", globallyPaidResponse);
}
}
else
Expand All @@ -80,9 +80,9 @@ private void CheckResponseCode(string content, HttpServiceClientResponse globall
response = JsonConvert.DeserializeAnonymousType(content,
new { response_code = string.Empty, message = string.Empty });
}
catch (JsonException)
catch (JsonException jex)
{
throw new GloballyPaidException(globallyPaidResponse.StatusCode, $"Invalid response object from API: \"{content}\"", globallyPaidResponse);
throw new GloballyPaidException(globallyPaidResponse.StatusCode, $"Invalid response object from API: \"{content}\", message: \"{jex.Message}\"", globallyPaidResponse);
}

if (response != null
Expand Down
2 changes: 1 addition & 1 deletion src/GloballyPaid.CSharp.Sdk/Entities/Charge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Charge : Entity

[JsonProperty("cof_type")]
[JsonConverter(typeof(StringEnumConverter))]
public CofType CofType { get; set; }
public CofType? CofType { get; set; }

[JsonProperty("currency_code")]
[JsonConverter(typeof(StringEnumConverter))]
Expand Down

0 comments on commit d174e9d

Please sign in to comment.