From 6dd1995694568fe14612d10dead7b6343e5cfd9e Mon Sep 17 00:00:00 2001 From: Nick van de Groes Date: Fri, 13 Sep 2019 13:59:04 +0200 Subject: [PATCH 1/3] Added custom object deserializer for BunqMeTabResultInquiry --- BunqSdk/Json/BunqContractResolver.cs | 1 + .../Json/BunqMeTabResultInquiryConverter.cs | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 BunqSdk/Json/BunqMeTabResultInquiryConverter.cs diff --git a/BunqSdk/Json/BunqContractResolver.cs b/BunqSdk/Json/BunqContractResolver.cs index 5b2ca48..ecd8fbc 100644 --- a/BunqSdk/Json/BunqContractResolver.cs +++ b/BunqSdk/Json/BunqContractResolver.cs @@ -32,6 +32,7 @@ public BunqContractResolver(IReadOnlyCollection typesToExclude=null) RegisterConverter(typeof(float?), new NonIntegerNumberConverter()); RegisterConverter(typeof(Pagination), new PaginationConverter()); RegisterConverter(typeof(IAnchorObjectInterface), new AnchorObjectConverter()); + RegisterConverter(typeof(BunqMeTabResultInquiry), new BunqMeTabResultInquiryConverter()); if (typesToExclude == null) { diff --git a/BunqSdk/Json/BunqMeTabResultInquiryConverter.cs b/BunqSdk/Json/BunqMeTabResultInquiryConverter.cs new file mode 100644 index 0000000..8dae9ee --- /dev/null +++ b/BunqSdk/Json/BunqMeTabResultInquiryConverter.cs @@ -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 + { + /// + /// Field constants. + /// + protected const String FIELD_PAYMENT = "payment"; + + /// + /// Object type constants. + /// + 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( + 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() + }; + } + } +} From 13a0c293c6c9503d3368e752acc7f262ce7b7c1a Mon Sep 17 00:00:00 2001 From: Nick van de Groes Date: Mon, 16 Sep 2019 09:24:38 +0200 Subject: [PATCH 2/3] Regenerated changelog. --- CHANGELOG.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index faf3e67..ed24b90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,18 @@ ## [Unreleased](https://github.com/bunq/sdk_csharp/tree/HEAD) -[Full Changelog](https://github.com/bunq/sdk_csharp/compare/1.10.16...HEAD) +[Full Changelog](https://github.com/bunq/sdk_csharp/compare/1.12.0...HEAD) + +**Closed issues:** + +- BunqMeTab result\_inquiries empty [\#129](https://github.com/bunq/sdk_csharp/issues/129) + +**Merged pull requests:** + +- Added custom object deserializer for BunqMeTabResultInquiry [\#130](https://github.com/bunq/sdk_csharp/pull/130) ([NickvandeGroes](https://github.com/NickvandeGroes)) + +## [1.12.0](https://github.com/bunq/sdk_csharp/tree/1.12.0) (2019-09-10) +[Full Changelog](https://github.com/bunq/sdk_csharp/compare/1.10.16...1.12.0) **Closed issues:** @@ -89,7 +100,6 @@ **Merged pull requests:** - Added travis config. \(bunq/sdk\_csharp\#90\) [\#110](https://github.com/bunq/sdk_csharp/pull/110) ([OGKevin](https://github.com/OGKevin)) -- Change Java to Csharp in readme. \(bunq/sdk\_csharp\#97\) [\#98](https://github.com/bunq/sdk_csharp/pull/98) ([robinvanpoppel](https://github.com/robinvanpoppel)) - Oauth bunq/sdk\_csharp\#112 [\#113](https://github.com/bunq/sdk_csharp/pull/113) ([OGKevin](https://github.com/OGKevin)) - Auto reload context bunq/sdk\_csharp\#72 [\#111](https://github.com/bunq/sdk_csharp/pull/111) ([OGKevin](https://github.com/OGKevin)) - Updated the examples on readme. \(bunq/sdk\_csharp\#91\) [\#109](https://github.com/bunq/sdk_csharp/pull/109) ([OGKevin](https://github.com/OGKevin)) @@ -102,6 +112,10 @@ ## [0.13.1](https://github.com/bunq/sdk_csharp/tree/0.13.1) (2018-05-30) [Full Changelog](https://github.com/bunq/sdk_csharp/compare/0.13.0...0.13.1) +**Merged pull requests:** + +- Change Java to Csharp in readme. \(bunq/sdk\_csharp\#97\) [\#98](https://github.com/bunq/sdk_csharp/pull/98) ([robinvanpoppel](https://github.com/robinvanpoppel)) + ## [0.13.0](https://github.com/bunq/sdk_csharp/tree/0.13.0) (2018-03-20) [Full Changelog](https://github.com/bunq/sdk_csharp/compare/0.12.4...0.13.0) @@ -117,6 +131,7 @@ - Token request ideal is missing id attribute in response. [\#76](https://github.com/bunq/sdk_csharp/issues/76) - Field ID is missing from MasterCardAction [\#52](https://github.com/bunq/sdk_csharp/issues/52) - TokenQrRequestIdeal returns the wrong type [\#51](https://github.com/bunq/sdk_csharp/issues/51) +- Fix SessionServerConverter, bump up to 0.9.2.0-beta \[\#7\] [\#8](https://github.com/bunq/sdk_csharp/pull/8) ([dnl-blkv](https://github.com/dnl-blkv)) **Closed issues:** @@ -251,10 +266,6 @@ - \#5 Introduce BunqResponse [\#6](https://github.com/bunq/sdk_csharp/pull/6) ([dnl-blkv](https://github.com/dnl-blkv)) -**Fixed bugs:** - -- Fix SessionServerConverter, bump up to 0.9.2.0-beta \[\#7\] [\#8](https://github.com/bunq/sdk_csharp/pull/8) ([dnl-blkv](https://github.com/dnl-blkv)) - ## [0.9.1](https://github.com/bunq/sdk_csharp/tree/0.9.1) (2017-08-07) **Implemented enhancements:** From cac985ee12cd69e9de6fd483e58e5830168e9b77 Mon Sep 17 00:00:00 2001 From: Nick van de Groes Date: Mon, 16 Sep 2019 09:25:32 +0200 Subject: [PATCH 3/3] Version bump to 1.12.1. --- BunqSdk/BunqSdk.csproj | 2 +- BunqSdk/Http/ApiClient.cs | 2 +- README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BunqSdk/BunqSdk.csproj b/BunqSdk/BunqSdk.csproj index 0e2eefa..99db683 100644 --- a/BunqSdk/BunqSdk.csproj +++ b/BunqSdk/BunqSdk.csproj @@ -8,7 +8,7 @@ Bunq.Sdk - 1.12.0 + 1.12.1 Bunq.Sdk diff --git a/BunqSdk/Http/ApiClient.cs b/BunqSdk/Http/ApiClient.cs index 41399c3..57bbc1f 100644 --- a/BunqSdk/Http/ApiClient.cs +++ b/BunqSdk/Http/ApiClient.cs @@ -64,7 +64,7 @@ public class ApiClient /// Values for the default headers /// private const string CACHE_CONTROL_NONE = "no-cache"; - private const string USER_AGENT_BUNQ = "bunq-sdk-csharp/1.12.0"; + private const string USER_AGENT_BUNQ = "bunq-sdk-csharp/1.12.1"; private const string LANGUAGE_EN_US = "en_US"; private const string REGION_NL_NL = "nl_NL"; private const string GEOLOCATION_ZERO = "0 0 0 0 NL"; diff --git a/README.md b/README.md index 7694892..4e3658d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # bunq C# SDK -Version 1.12.0 +Version 1.12.1 ## Introduction Hi developers!