-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using Bunq.Sdk.Model.Core; | ||
using Bunq.Sdk.Model.Generated.Endpoint; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using Newtonsoft.Json.Serialization; | ||
|
||
namespace Bunq.Sdk.Json | ||
{ | ||
public class BunqMeTabResultInquiryConverter: JsonConverter | ||
{ | ||
/// <summary> | ||
/// Field constants. | ||
/// </summary> | ||
protected const String FIELD_PAYMENT = "payment"; | ||
|
||
/// <summary> | ||
/// Object type constants. | ||
/// </summary> | ||
protected const String OBJECT_TYPE_PAYMENT = "Payment"; | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
new JsonSerializer().Serialize(writer, value); | ||
} | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
JObject jsonObject = JObject.Load(reader); | ||
|
||
BunqMeTabResultInquiry tabResultInquiry = JsonConvert.DeserializeObject<BunqMeTabResultInquiry>( | ||
jsonObject.ToString(), | ||
GetSerializerSettingsWithoutTabResultInquiryResolver() | ||
); | ||
|
||
JObject paymentJsonObjectWrapped = (JObject) jsonObject.GetValue(FIELD_PAYMENT); | ||
JObject paymentJsonObject = (JObject) paymentJsonObjectWrapped.GetValue(OBJECT_TYPE_PAYMENT); | ||
|
||
Payment paymentObject = Payment.CreateFromJsonString(paymentJsonObject.ToString()); | ||
tabResultInquiry.Payment = paymentObject; | ||
|
||
return tabResultInquiry; | ||
} | ||
|
||
public override bool CanConvert(Type objectType) | ||
{ | ||
return typeof(IAnchorObjectInterface).GetTypeInfo().IsAssignableFrom(objectType); | ||
} | ||
|
||
private JsonSerializerSettings GetSerializerSettingsWithoutTabResultInquiryResolver() | ||
{ | ||
return new JsonSerializerSettings() | ||
{ | ||
ContractResolver = new DefaultContractResolver() | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# bunq C# SDK | ||
Version 1.12.0 | ||
Version 1.12.1 | ||
|
||
## Introduction | ||
Hi developers! | ||
|