diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..9f6afc9
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+BunqSdk/Model/Generated linguist-generated=true
diff --git a/BunqSdk.Samples/PaymentListSample.cs b/BunqSdk.Samples/PaymentListSample.cs
index e395d47..1be874d 100644
--- a/BunqSdk.Samples/PaymentListSample.cs
+++ b/BunqSdk.Samples/PaymentListSample.cs
@@ -1,5 +1,7 @@
using System;
+using System.Collections.Generic;
using Bunq.Sdk.Context;
+using Bunq.Sdk.Http;
using Bunq.Sdk.Model.Generated;
using Bunq.Sdk.Samples.Utils;
@@ -7,15 +9,53 @@ namespace Bunq.Sdk.Samples
{
public class PaymentListSample : ISample
{
+ ///
+ /// Message constants.
+ ///
+ private const string MESSAGE_LATEST_PAGE_IDS = "Latest page IDs: ";
+ private const string MESSAGE_SECOND_LATEST_PAGE_IDS = "Second latest page IDs: ";
+ private const string MESSAGE_NO_PRIOR_PAYMENTS_FOUND = "No prior payments found!";
+
+ ///
+ /// Size of each page of payment listing.
+ ///
+ private const int PAGE_SIZE = 3;
+
+ ///
+ /// Constants to be changed to run the example.
+ ///
private const int USER_ITEM_ID = 0; // Put your user ID here
private const int MONETARY_ACCOUNT_ITEM_ID = 0; // Put your monetary account ID here
public void Run()
{
var apiContext = ApiContext.Restore();
- var paymentList = Payment.List(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID).Value;
+ var paginationCountOnly = new Pagination
+ {
+ Count = PAGE_SIZE,
+ };
+ Console.WriteLine(MESSAGE_LATEST_PAGE_IDS);
+ var paymentResponse = Payment.List(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID,
+ paginationCountOnly.UrlParamsCountOnly);
+ PrintPayments(paymentResponse.Value);
+ var pagination = paymentResponse.Pagination;
+
+ if (pagination.HasPreviousPage())
+ {
+ Console.WriteLine(MESSAGE_SECOND_LATEST_PAGE_IDS);
+ var previousPaymentResponse = Payment.List(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID,
+ pagination.UrlParamsPreviousPage);
+ PrintPayments(previousPaymentResponse.Value);
+ }
+ else
+ {
+ Console.WriteLine(MESSAGE_NO_PRIOR_PAYMENTS_FOUND);
+ }
+ }
- foreach (var payment in paymentList)
+ private static void PrintPayments(IEnumerable payments)
+ {
+ foreach (var payment in payments)
{
Console.WriteLine(payment.Id);
}
diff --git a/BunqSdk.Tests/BunqSdkTestBase.cs b/BunqSdk.Tests/BunqSdkTestBase.cs
index d1e125c..e3200b0 100644
--- a/BunqSdk.Tests/BunqSdkTestBase.cs
+++ b/BunqSdk.Tests/BunqSdkTestBase.cs
@@ -24,7 +24,7 @@ public class BunqSdkTestBase
/// Configuration items.
///
private static readonly string API_KEY = Config.GetApiKey();
- private static readonly string FIELD_PERMITTED_IP = Config.GetPermittedIp();
+ private static readonly string[] FIELD_PERMITTED_IPS = Config.GetPermittedIps();
///
/// Gets an Api Context, re-creates if needed and returns it.
@@ -54,9 +54,8 @@ protected static ApiContext GetApiContext()
private static ApiContext CreateApiContext()
{
- var permittedIps = new List {FIELD_PERMITTED_IP};
-
- return ApiContext.Create(ApiEnvironmentType.SANDBOX, API_KEY, DEVICE_DESCRIPTION_TEST, permittedIps);
+ return ApiContext.Create(ApiEnvironmentType.SANDBOX, API_KEY, DEVICE_DESCRIPTION_TEST,
+ new List(FIELD_PERMITTED_IPS));
}
}
}
diff --git a/BunqSdk.Tests/Config.cs b/BunqSdk.Tests/Config.cs
index 33b66d5..a2077a9 100644
--- a/BunqSdk.Tests/Config.cs
+++ b/BunqSdk.Tests/Config.cs
@@ -1,4 +1,5 @@
-using System.IO;
+using System.Collections.Immutable;
+using System.IO;
using Bunq.Sdk.Model.Generated.Object;
using Newtonsoft.Json.Linq;
@@ -6,10 +7,23 @@ namespace Bunq.Sdk.Tests
{
public class Config
{
+ ///
+ /// Delimiter between the IP addresses in the PERMITTED_IPS field.
+ ///
+ private const char DELIMITER_IPS = ',';
+
+ ///
+ /// Length of an empty array.
+ ///
+ private const int LENGTH_NONE = 0;
+
+ ///
+ /// Field constants.
+ ///
private const string FIELD_CONFIG_FILE_PATH = "../../../Resources/config.json";
private const string FIELD_USER_ID = "USER_ID";
private const string FIELD_API_KEY = "API_KEY";
- private const string FIELD_PERMITTED_IP = "ipAddress";
+ private const string FIELD_PERMITTED_IPS = "PERMITTED_IPS";
private const string FIELD_ATTACHMENT_PUBLIC_TEST = "AttachmentPublicTest";
private const string FIELD_ATTACHMENT_PATH_IN = "PATH_IN";
private const string FIELD_ATTACHMENT_DESCRIPTION = "DESCRIPTION";
@@ -28,7 +42,7 @@ public static int GetCashRegisterId()
return GetConfig()[FIELD_TAB_USAGE_SINGLE][FIELD_CASH_REGISTER_ID].ToObject();
}
- public static Pointer GetCounterAliasOther()
+ public static Pointer GetCounterPartyAliasOther()
{
var alias = GetConfig()[FIELD_COUNTER_PARTY_OTHER][FIELD_COUNTER_ALIAS].ToString();
var type = GetConfig()[FIELD_COUNTER_PARTY_OTHER][FIELD_COUNTER_TYPE].ToString();
@@ -36,7 +50,7 @@ public static Pointer GetCounterAliasOther()
return new Pointer(type, alias);
}
- public static Pointer GetCounterAliasSelf()
+ public static Pointer GetCounterPartyAliasSelf()
{
var alias = GetConfig()[FIELD_COUNTER_PARTY_SELF][FIELD_COUNTER_ALIAS].ToString();
var type = GetConfig()[FIELD_COUNTER_PARTY_SELF][FIELD_COUNTER_TYPE].ToString();
@@ -69,9 +83,13 @@ public static string GetAttachmentContentType()
return GetConfig()[FIELD_ATTACHMENT_PUBLIC_TEST][FIELD_ATTACHMENT_CONTENT_TYPE].ToString();
}
- public static string GetPermittedIp()
+ public static string[] GetPermittedIps()
{
- return GetConfig()[FIELD_PERMITTED_IP].ToString();
+ var permittedIpsString = GetConfig()[FIELD_PERMITTED_IPS].ToString();
+
+ return permittedIpsString.Length == LENGTH_NONE ?
+ new string[LENGTH_NONE] :
+ permittedIpsString.Split(DELIMITER_IPS);
}
public static string GetApiKey()
diff --git a/BunqSdk.Tests/Http/PaginationScenarioTest.cs b/BunqSdk.Tests/Http/PaginationScenarioTest.cs
new file mode 100644
index 0000000..ea69a90
--- /dev/null
+++ b/BunqSdk.Tests/Http/PaginationScenarioTest.cs
@@ -0,0 +1,108 @@
+using System.Collections.Generic;
+using Bunq.Sdk.Context;
+using Bunq.Sdk.Http;
+using Bunq.Sdk.Json;
+using Bunq.Sdk.Model.Generated;
+using Bunq.Sdk.Model.Generated.Object;
+using Xunit;
+
+namespace Bunq.Sdk.Tests.Http
+{
+ ///
+ /// Tests:
+ /// Pagination
+ ///
+ public class PaginationScenarioTest : BunqSdkTestBase
+ {
+ ///
+ /// Config values.
+ ///
+ private static readonly int USER_ID = Config.GetUserId();
+ private static readonly int MONETARY_ACCOUNT_ID = Config.GetMonetarytAccountId();
+ private static readonly Pointer COUNTER_PARTY_OTHER = Config.GetCounterPartyAliasOther();
+
+ ///
+ /// Constants for scenario testing.
+ ///
+ private const int PAYMENT_LISTING_PAGE_SIZE = 2;
+ private const int PAYMENT_REQUIRED_COUNT_MINIMUM = PAYMENT_LISTING_PAGE_SIZE * 2;
+ private const int NUMBER_ZERO = 0;
+
+ ///
+ /// Constants for payment creation.
+ ///
+ private const string PAYMENT_AMOUNT_EUR = "0.01";
+ private const string PAYMENT_CURRENCY = "EUR";
+ private const string PAYMENT_DESCRIPTION = "C# test Payment";
+
+ ///
+ /// API context to use for the test API calls.
+ ///
+ private static readonly ApiContext API_CONTEXT = GetApiContext();
+
+ [Fact]
+ public void TestApiScenarioPaymentListingWithPagination()
+ {
+ EnsureEnoughPayments();
+ var paymentsExpected = new List(GetPaymentsRequired());
+ var paginationCountOnly = new Pagination
+ {
+ Count = PAYMENT_LISTING_PAGE_SIZE
+ };
+
+ var responseLatest = ListPayments(paginationCountOnly.UrlParamsCountOnly);
+ var paginationLatest = responseLatest.Pagination;
+ var responsePrevious = ListPayments(paginationLatest.UrlParamsPreviousPage);
+ var paginationPrevious = responsePrevious.Pagination;
+ var responsePreviousNext = ListPayments(paginationPrevious.UrlParamsNextPage);
+
+ var paymentsActual = new List();
+ paymentsActual.AddRange(responsePreviousNext.Value);
+ paymentsActual.AddRange(responsePrevious.Value);
+ var paymentsExpectedSerialized = BunqJsonConvert.SerializeObject(paymentsExpected);
+ var paymentsActualSerialized = BunqJsonConvert.SerializeObject(paymentsActual);
+
+ Assert.Equal(paymentsExpectedSerialized, paymentsActualSerialized);
+ }
+
+ private static void EnsureEnoughPayments()
+ {
+ for (var i = NUMBER_ZERO; i < GetPaymentsMissingCount(); ++i)
+ {
+ CreatePayment();
+ }
+ }
+
+ private static int GetPaymentsMissingCount()
+ {
+ return PAYMENT_REQUIRED_COUNT_MINIMUM - GetPaymentsRequired().Count;
+ }
+
+ private static IList GetPaymentsRequired()
+ {
+ var pagination = new Pagination
+ {
+ Count = PAYMENT_REQUIRED_COUNT_MINIMUM
+ };
+
+ return ListPayments(pagination.UrlParamsCountOnly).Value;
+ }
+
+ private static BunqResponse> ListPayments(IDictionary urlParams)
+ {
+ return Payment.List(API_CONTEXT, USER_ID, MONETARY_ACCOUNT_ID, urlParams);
+ }
+
+ private static void CreatePayment()
+ {
+ var requestMap = new Dictionary
+ {
+ {Payment.FIELD_AMOUNT, new Amount(PAYMENT_AMOUNT_EUR, PAYMENT_CURRENCY)},
+ {Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION},
+ {Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_OTHER}
+ };
+
+ Payment.Create(API_CONTEXT, requestMap, USER_ID, MONETARY_ACCOUNT_ID);
+ }
+ }
+}
diff --git a/BunqSdk.Tests/Http/PaginationTest.cs b/BunqSdk.Tests/Http/PaginationTest.cs
new file mode 100644
index 0000000..e59a137
--- /dev/null
+++ b/BunqSdk.Tests/Http/PaginationTest.cs
@@ -0,0 +1,151 @@
+using System.Collections.Generic;
+using Bunq.Sdk.Exception;
+using Bunq.Sdk.Http;
+using Xunit;
+
+namespace Bunq.Sdk.Tests.Http
+{
+ ///
+ /// Tests:
+ /// Pagination
+ ///
+ public class PaginationTest
+ {
+ ///
+ /// Values of pagination properties for testing.
+ ///
+ private const int PAGINATION_OLDER_ID_CUSTOM = 1;
+ private const int PAGINATION_NEWER_ID_CUSTOM = 2;
+ private const int PAGINATION_FUTURE_ID_CUSTOM = 3;
+ private const int PAGINATION_COUNT_CUSTOM = 5;
+
+ [Fact]
+ public void TestGetUrlParamsCountOnly()
+ {
+ var pagination = CreatePaginationWithAllPropertiesSet();
+ var urlParamsCountOnlyExpected = new Dictionary
+ {
+ {Pagination.PARAM_COUNT, PAGINATION_COUNT_CUSTOM.ToString()}
+ };
+
+ Assert.Equal(urlParamsCountOnlyExpected, pagination.UrlParamsCountOnly);
+ }
+
+ private static Pagination CreatePaginationWithAllPropertiesSet()
+ {
+ return new Pagination
+ {
+ OlderId = PAGINATION_OLDER_ID_CUSTOM,
+ NewerId = PAGINATION_NEWER_ID_CUSTOM,
+ FutureId = PAGINATION_FUTURE_ID_CUSTOM,
+ Count = PAGINATION_COUNT_CUSTOM
+ };
+ }
+
+ [Fact]
+ public void TestGetUrlParamsPreviousPage()
+ {
+ var pagination = CreatePaginationWithAllPropertiesSet();
+ var urlParamsPreviousPageExpected = new Dictionary
+ {
+ {Pagination.PARAM_COUNT, PAGINATION_COUNT_CUSTOM.ToString()},
+ {Pagination.PARAM_OLDER_ID, PAGINATION_OLDER_ID_CUSTOM.ToString()}
+ };
+
+ Assert.True(pagination.HasPreviousPage());
+ Assert.Equal(urlParamsPreviousPageExpected, pagination.UrlParamsPreviousPage);
+ }
+
+ [Fact]
+ public void TestGetUrlParamsPreviousPageNoCount()
+ {
+ var pagination = CreatePaginationWithAllPropertiesSet();
+ pagination.Count = null;
+ var urlParamsPreviousPageExpected = new Dictionary
+ {
+ {Pagination.PARAM_OLDER_ID, PAGINATION_OLDER_ID_CUSTOM.ToString()}
+ };
+
+ Assert.True(pagination.HasPreviousPage());
+ Assert.Equal(urlParamsPreviousPageExpected, pagination.UrlParamsPreviousPage);
+ }
+
+ [Fact]
+ public void TestGetUrlParamsNextPageNewer()
+ {
+ var pagination = CreatePaginationWithAllPropertiesSet();
+ var urlParamsNextPageExpected = new Dictionary
+ {
+ {Pagination.PARAM_COUNT, PAGINATION_COUNT_CUSTOM.ToString()},
+ {Pagination.PARAM_NEWER_ID, PAGINATION_NEWER_ID_CUSTOM.ToString()}
+ };
+
+ Assert.True(pagination.HasNextPageAssured());
+ Assert.Equal(urlParamsNextPageExpected, pagination.UrlParamsNextPage);
+ }
+
+ [Fact]
+ public void TestGetUrlParamsNextPageNewerNoCount()
+ {
+ var pagination = CreatePaginationWithAllPropertiesSet();
+ pagination.Count = null;
+ var urlParamsNextPageExpected = new Dictionary
+ {
+ {Pagination.PARAM_NEWER_ID, PAGINATION_NEWER_ID_CUSTOM.ToString()}
+ };
+
+ Assert.True(pagination.HasNextPageAssured());
+ Assert.Equal(urlParamsNextPageExpected, pagination.UrlParamsNextPage);
+ }
+
+ [Fact]
+ public void TestGetUrlParamsNextPageFuture()
+ {
+ var pagination = CreatePaginationWithAllPropertiesSet();
+ pagination.NewerId = null;
+ var urlParamsNextPageExpected = new Dictionary
+ {
+ {Pagination.PARAM_COUNT, PAGINATION_COUNT_CUSTOM.ToString()},
+ {Pagination.PARAM_NEWER_ID, PAGINATION_FUTURE_ID_CUSTOM.ToString()}
+ };
+
+ Assert.False(pagination.HasNextPageAssured());
+ Assert.Equal(urlParamsNextPageExpected, pagination.UrlParamsNextPage);
+ }
+
+ [Fact]
+ public void TestGetUrlParamsNextPageFutureNoCount()
+ {
+ var pagination = CreatePaginationWithAllPropertiesSet();
+ pagination.NewerId = null;
+ var urlParamsNextPageExpected = new Dictionary
+ {
+ {Pagination.PARAM_COUNT, PAGINATION_COUNT_CUSTOM.ToString()},
+ {Pagination.PARAM_NEWER_ID, PAGINATION_FUTURE_ID_CUSTOM.ToString()}
+ };
+
+ Assert.False(pagination.HasNextPageAssured());
+ Assert.Equal(urlParamsNextPageExpected, pagination.UrlParamsNextPage);
+ }
+
+ [Fact]
+ public void TestGetUrlParamsPreviousPageFromPaginationWithNoPreviousPage()
+ {
+ var pagination = CreatePaginationWithAllPropertiesSet();
+ pagination.OlderId = null;
+
+ Assert.False(pagination.HasPreviousPage());
+ Assert.Throws(() => pagination.UrlParamsPreviousPage);
+ }
+
+ [Fact]
+ public void TestGetUrlParamsNextPageFromPaginationWithNoNextPage()
+ {
+ var pagination = CreatePaginationWithAllPropertiesSet();
+ pagination.NewerId = null;
+ pagination.FutureId = null;
+
+ Assert.Throws(() => pagination.UrlParamsNextPage);
+ }
+ }
+}
diff --git a/BunqSdk.Tests/Model/Generated/PaymentChatTest.cs b/BunqSdk.Tests/Model/Generated/PaymentChatTest.cs
index e01bfdf..add8425 100644
--- a/BunqSdk.Tests/Model/Generated/PaymentChatTest.cs
+++ b/BunqSdk.Tests/Model/Generated/PaymentChatTest.cs
@@ -17,14 +17,14 @@ public class PaymentChatTest : BunqSdkTestBase
///
/// Config values.
///
- private const string AMOUNT_IN_EUR = "0.01";
+ private const string AMOUNT_EUR = "0.01";
private const string CURRENCY = "EUR";
private const string PAYMENT_DESCRIPTION = "Payment From C# Test";
private const string MESSAGE_TEXT = "test msg send from C# test";
private static readonly int USER_ID = Config.GetUserId();
private static readonly int MONETARTY_ACCOUNT_ID = Config.GetMonetarytAccountId();
- private static readonly Pointer COUNTER_PARTY_ALIAS = Config.GetCounterAliasSelf();
+ private static readonly Pointer COUNTER_PARTY_ALIAS = Config.GetCounterPartyAliasSelf();
///
/// API context used for the test API calls.
@@ -52,7 +52,7 @@ private static int CreatePaymentAndGetId()
{
var requestMap = new Dictionary
{
- {Payment.FIELD_AMOUNT, new Amount(AMOUNT_IN_EUR, CURRENCY)},
+ {Payment.FIELD_AMOUNT, new Amount(AMOUNT_EUR, CURRENCY)},
{Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_ALIAS},
{Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION},
};
diff --git a/BunqSdk.Tests/Model/Generated/PaymentTest.cs b/BunqSdk.Tests/Model/Generated/PaymentTest.cs
index bd7eb7a..b01be02 100644
--- a/BunqSdk.Tests/Model/Generated/PaymentTest.cs
+++ b/BunqSdk.Tests/Model/Generated/PaymentTest.cs
@@ -15,14 +15,14 @@ public class PaymentTest : BunqSdkTestBase
///
/// Config values.
///
- private const string AMOUNT_IN_EUR = "0.01";
- private const string FIELD_CURRENCY = "EUR";
- private const string FIELD_PAYMENT_DESCRIPTION = "C# test Payment";
+ private const string PAYMENT_AMOUNT_EUR = "0.01";
+ private const string PAYMENT_CURRENCY = "EUR";
+ private const string PAYMENT_DESCRIPTION = "C# test Payment";
private static readonly int USER_ID = Config.GetUserId();
private static readonly int MONETARY_ACCOUNT_ID = Config.GetMonetarytAccountId();
- private static readonly Pointer COUNTER_PARTY_SELF = Config.GetCounterAliasSelf();
- private static readonly Pointer COUNTER_PARTY_OTHER = Config.GetCounterAliasOther();
+ private static readonly Pointer COUNTER_PARTY_SELF = Config.GetCounterPartyAliasSelf();
+ private static readonly Pointer COUNTER_PARTY_OTHER = Config.GetCounterPartyAliasOther();
///
/// API context to use for the test API calls.
@@ -39,8 +39,8 @@ public void TestMakePaymentToOtherUser()
{
var requestMap = new Dictionary
{
- {Payment.FIELD_AMOUNT, new Amount(AMOUNT_IN_EUR, FIELD_CURRENCY)},
- {Payment.FIELD_DESCRIPTION, FIELD_PAYMENT_DESCRIPTION},
+ {Payment.FIELD_AMOUNT, new Amount(PAYMENT_AMOUNT_EUR, PAYMENT_CURRENCY)},
+ {Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION},
{Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_OTHER}
};
@@ -57,8 +57,8 @@ public void TestMakePaymentToOtherAccount()
{
var requestMap = new Dictionary
{
- {Payment.FIELD_AMOUNT, new Amount(AMOUNT_IN_EUR, FIELD_CURRENCY)},
- {Payment.FIELD_DESCRIPTION, FIELD_PAYMENT_DESCRIPTION},
+ {Payment.FIELD_AMOUNT, new Amount(PAYMENT_AMOUNT_EUR, PAYMENT_CURRENCY)},
+ {Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION},
{Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_SELF}
};
diff --git a/BunqSdk.Tests/Model/Generated/RequestInquiryTest.cs b/BunqSdk.Tests/Model/Generated/RequestInquiryTest.cs
index 7b7ebdb..2daca50 100644
--- a/BunqSdk.Tests/Model/Generated/RequestInquiryTest.cs
+++ b/BunqSdk.Tests/Model/Generated/RequestInquiryTest.cs
@@ -16,7 +16,7 @@ public class RequestInquiryTest : BunqSdkTestBase
///
/// Config values.
///
- private const string AMOUNT_IN_EUR = "0.01";
+ private const string AMOUNT_EUR = "0.01";
private const string FIELD_CURRENCY = "EUR";
private const string FIELD_PAYMENT_DESCRIPTION = "C# test Payment";
private const string FIELD_STATUS = "ACCEPTED";
@@ -25,7 +25,7 @@ public class RequestInquiryTest : BunqSdkTestBase
private static readonly int USER_ID = Config.GetUserId();
private static readonly int MONETARY_ACCOUNT_ID = Config.GetMonetarytAccountId();
private static readonly int SECOND_MONETARY_ACCOUNT_ID = Config.GetSecondMonetaryAccountId();
- private static readonly Pointer COUNTER_PARTY_SELF = Config.GetCounterAliasSelf();
+ private static readonly Pointer COUNTER_PARTY_SELF = Config.GetCounterPartyAliasSelf();
///
/// API context to use for the test API calls.
@@ -40,7 +40,7 @@ public void TestRequestInquiry()
{
var requestMap = new Dictionary
{
- {RequestInquiry.FIELD_AMOUNT_INQUIRED, new Amount(AMOUNT_IN_EUR, FIELD_CURRENCY)},
+ {RequestInquiry.FIELD_AMOUNT_INQUIRED, new Amount(AMOUNT_EUR, FIELD_CURRENCY)},
{RequestInquiry.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_SELF},
{RequestInquiry.FIELD_DESCRIPTION, FIELD_PAYMENT_DESCRIPTION},
{RequestInquiry.FIELD_ALLOW_BUNQME, false}
diff --git a/BunqSdk.Tests/Model/Generated/TabUsageSingleTest.cs b/BunqSdk.Tests/Model/Generated/TabUsageSingleTest.cs
index 922d758..7fdd921 100644
--- a/BunqSdk.Tests/Model/Generated/TabUsageSingleTest.cs
+++ b/BunqSdk.Tests/Model/Generated/TabUsageSingleTest.cs
@@ -18,7 +18,7 @@ public class TabUsageSingleTest : BunqSdkTestBase
///
private const string TAB_FIELD_DESCRIPTION = "Pay the tab for Java test please.";
private const string FIELD_STATUS_OPEN = "OPEN";
- private const string AMOUNT_IN_EUR = "10.00";
+ private const string AMOUNT_EUR = "10.00";
private const string FIELD_CURRENCY = "EUR";
private const string TAB_ITEM_FIELD_DESCRIPTION = "Super expensive java tea";
private const string FIELD_STATUS_WAITING = "WAITING_FOR_PAYMENT";
@@ -64,7 +64,7 @@ private static string CreateTabAndGetUuid()
{
{TabUsageSingle.FIELD_DESCRIPTION, TAB_FIELD_DESCRIPTION},
{TabUsageSingle.FIELD_STATUS, FIELD_STATUS_OPEN},
- {TabUsageSingle.FIELD_AMOUNT_TOTAL, new Amount(AMOUNT_IN_EUR, FIELD_CURRENCY)}
+ {TabUsageSingle.FIELD_AMOUNT_TOTAL, new Amount(AMOUNT_EUR, FIELD_CURRENCY)}
};
return TabUsageSingle.Create(API_CONTEXT, createTabMap, USER_ID, MONETARY_ACCOUNT_ID,
@@ -75,7 +75,7 @@ private static void AddTabItem(string tabUuid)
{
var tabItemMap = new Dictionary
{
- {TabItemShop.FIELD_AMOUNT, new Amount(AMOUNT_IN_EUR, FIELD_CURRENCY)},
+ {TabItemShop.FIELD_AMOUNT, new Amount(AMOUNT_EUR, FIELD_CURRENCY)},
{TabItemShop.FIELD_DESCRIPTION, TAB_ITEM_FIELD_DESCRIPTION}
};
TabItemShop.Create(API_CONTEXT, tabItemMap, USER_ID, MONETARY_ACCOUNT_ID, CASH_REGISTER_ID, tabUuid);
diff --git a/BunqSdk.Tests/Resources/config.example.json b/BunqSdk.Tests/Resources/config.example.json
index 8cc4bd0..f549508 100644
--- a/BunqSdk.Tests/Resources/config.example.json
+++ b/BunqSdk.Tests/Resources/config.example.json
@@ -3,7 +3,7 @@
"USER_ID": "XXXX",
"MONETARY_ACCOUNT_ID": "XXXX",
"MONETARY_ACCOUNT_ID2": "XXXX",
- "ipAddress": "",
+ "PERMITTED_IPS": ",",
"AttachmentPublicTest": {
"CONTENT_TYPE": "image/png",
"DESCRIPTION": "TEST PNG PHP",
diff --git a/BunqSdk/BunqSdk.csproj b/BunqSdk/BunqSdk.csproj
index 0a24c7b..430fd6e 100755
--- a/BunqSdk/BunqSdk.csproj
+++ b/BunqSdk/BunqSdk.csproj
@@ -10,7 +10,7 @@
Bunq.Sdk
- 0.10.0.0
+ 0.11.0.0
beta
diff --git a/BunqSdk/Context/ApiContext.cs b/BunqSdk/Context/ApiContext.cs
index 33959f7..670be34 100644
--- a/BunqSdk/Context/ApiContext.cs
+++ b/BunqSdk/Context/ApiContext.cs
@@ -75,7 +75,7 @@ private ApiContext()
/// Create and initialize an API Context with current IP as permitted.
///
public static ApiContext Create(ApiEnvironmentType environmentType, string apiKey, string deviceDescription,
- string proxy=null)
+ string proxy = null)
{
return Create(environmentType, apiKey, deviceDescription, new List(), proxy);
}
@@ -84,7 +84,7 @@ public static ApiContext Create(ApiEnvironmentType environmentType, string apiKe
/// Create and initialize an API Context.
///
public static ApiContext Create(ApiEnvironmentType environmentType, string apiKey, string deviceDescription,
- IList permittedIps, string proxy=null)
+ IList permittedIps, string proxy = null)
{
var apiContext = new ApiContext
{
diff --git a/BunqSdk/Http/ApiClient.cs b/BunqSdk/Http/ApiClient.cs
index 3ea0201..fcd185a 100644
--- a/BunqSdk/Http/ApiClient.cs
+++ b/BunqSdk/Http/ApiClient.cs
@@ -4,6 +4,7 @@
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
+using System.Text;
using Bunq.Sdk.Context;
using Bunq.Sdk.Exception;
using Bunq.Sdk.Json;
@@ -39,7 +40,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/0.10.0.0-beta";
+ private const string USER_AGENT_BUNQ = "bunq-sdk-csharp/0.11.0.0-beta";
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";
@@ -49,6 +50,21 @@ public class ApiClient
///
private const string DELIMITER_HEADER_VALUE = ",";
+ ///
+ /// Delimiter between path and params in URI.
+ ///
+ public const char DELIMITER_URI_QUERY = '?';
+
+ ///
+ /// Delimiter between key and value of a URI param.
+ ///
+ public const char DELIMITER_URI_PARAM_KEY_VALUE = '=';
+
+ ///
+ /// Delimiter between URI params.
+ ///
+ public const char DELIMITER_URI_PARAMS = '&';
+
private readonly HttpClient client;
private readonly ApiContext apiContext;
@@ -84,28 +100,28 @@ private HttpClientHandler CreateHttpClientHandler()
return handler;
}
-
///
/// Executes a POST request and returns the resulting HTTP response message.
///
public BunqResponseRaw Post(string uriRelative, byte[] requestBytes,
IDictionary customHeaders)
{
- return SendRequest(HttpMethod.Post, uriRelative, requestBytes, customHeaders);
+ return SendRequest(HttpMethod.Post, uriRelative, requestBytes, new Dictionary(),
+ customHeaders);
}
private BunqResponseRaw SendRequest(HttpMethod method, string uriRelative, byte[] requestBodyBytes,
- IDictionary customHeaders)
+ IDictionary uriParams, IDictionary customHeaders)
{
- var requestMessage = CreateHttpRequestMessage(method, uriRelative, requestBodyBytes);
+ var requestMessage = CreateHttpRequestMessage(method, uriRelative, uriParams, requestBodyBytes);
return SendRequest(requestMessage, customHeaders);
}
private BunqResponseRaw SendRequest(HttpMethod method, string uriRelative,
- IDictionary customHeaders)
+ IDictionary uriParams, IDictionary customHeaders)
{
- var requestMessage = CreateHttpRequestMessage(method, uriRelative);
+ var requestMessage = CreateHttpRequestMessage(method, uriRelative, uriParams);
return SendRequest(requestMessage, customHeaders);
}
@@ -150,17 +166,38 @@ private void ValidateResponse(HttpResponseMessage responseMessage)
}
private static HttpRequestMessage CreateHttpRequestMessage(HttpMethod method, string uriRelative,
- byte[] requestBodyBytes)
+ IDictionary uriParams, byte[] requestBodyBytes)
{
- var requestMessage = CreateHttpRequestMessage(method, uriRelative);
+ var requestMessage = CreateHttpRequestMessage(method, uriRelative, uriParams);
requestMessage.Content = new ByteArrayContent(requestBodyBytes);
return requestMessage;
}
- private static HttpRequestMessage CreateHttpRequestMessage(HttpMethod method, string uriRelative)
+ private static HttpRequestMessage CreateHttpRequestMessage(HttpMethod method, string uriRelative,
+ IDictionary uriParams)
{
- return new HttpRequestMessage(method, uriRelative);
+ var uriWithParams = GetUriWithParams(uriRelative, uriParams);
+
+ return new HttpRequestMessage(method, uriWithParams);
+ }
+
+ private static string GetUriWithParams(string uri, IDictionary uriParams)
+ {
+ if (uriParams.Count <= 0) return uri;
+
+ var uriWithParamsBuilder = new StringBuilder(uri);
+ uriWithParamsBuilder.Append(DELIMITER_URI_QUERY);
+ uriWithParamsBuilder.Append(GenerateUriParamsString(uriParams));
+
+ return uriWithParamsBuilder.ToString();
+ }
+
+ private static string GenerateUriParamsString(IDictionary uriParams)
+ {
+ return uriParams
+ .Select(entry => entry.Key + DELIMITER_URI_PARAM_KEY_VALUE + entry.Value)
+ .Aggregate((current, next) => current + DELIMITER_URI_PARAMS + next);
}
private static void SetDefaultHeaders(HttpRequestMessage requestMessage)
@@ -266,15 +303,17 @@ private static IList FetchErrorDescriptions(JObject responseBodyObject)
public BunqResponseRaw Put(string uriRelative, byte[] requestBytes,
IDictionary customHeaders)
{
- return SendRequest(HttpMethod.Put, uriRelative, requestBytes, customHeaders);
+ return SendRequest(HttpMethod.Put, uriRelative, requestBytes, new Dictionary(),
+ customHeaders);
}
///
/// Executes a GET request and returns the resulting HTTP response message.
///
- public BunqResponseRaw Get(string uriRelative, IDictionary customHeaders)
+ public BunqResponseRaw Get(string uriRelative, IDictionary uriParams,
+ IDictionary customHeaders)
{
- return SendRequest(HttpMethod.Get, uriRelative, customHeaders);
+ return SendRequest(HttpMethod.Get, uriRelative, uriParams, customHeaders);
}
///
@@ -282,7 +321,7 @@ public BunqResponseRaw Get(string uriRelative, IDictionary custo
///
public BunqResponseRaw Delete(string uriRelative, IDictionary customHeaders)
{
- return SendRequest(HttpMethod.Delete, uriRelative, customHeaders);
+ return SendRequest(HttpMethod.Delete, uriRelative, new Dictionary(), customHeaders);
}
}
}
diff --git a/BunqSdk/Http/BunqResponse.cs b/BunqSdk/Http/BunqResponse.cs
index 6f4b121..2707695 100644
--- a/BunqSdk/Http/BunqResponse.cs
+++ b/BunqSdk/Http/BunqResponse.cs
@@ -6,11 +6,13 @@ public class BunqResponse
{
public T Value { get; private set; }
public IDictionary Headers { get; private set; }
+ public Pagination Pagination { get; private set; }
- public BunqResponse(T value, IDictionary headers)
+ public BunqResponse(T value, IDictionary headers, Pagination pagination = null)
{
Value = value;
Headers = headers;
+ Pagination = pagination;
}
}
}
diff --git a/BunqSdk/Http/Pagination.cs b/BunqSdk/Http/Pagination.cs
new file mode 100644
index 0000000..0361f23
--- /dev/null
+++ b/BunqSdk/Http/Pagination.cs
@@ -0,0 +1,115 @@
+using System.Collections.Generic;
+using Bunq.Sdk.Exception;
+
+namespace Bunq.Sdk.Http
+{
+ public class Pagination
+ {
+ ///
+ /// Error constants.
+ ///
+ private const string ERROR_NO_PREVIOUS_PAGE =
+ "Could not generate previous page URL params: previous page not found.";
+ private const string ERROR_NO_NEXT_PAGE = "Could not generate next page URL params: next page not found.";
+
+ ///
+ /// URL param constants.
+ ///
+ public const string PARAM_OLDER_ID = "older_id";
+ public const string PARAM_NEWER_ID = "newer_id";
+ public const string PARAM_FUTURE_ID = "future_id";
+ public const string PARAM_COUNT = "count";
+
+ public int? OlderId { get; set; }
+ public int? NewerId { get; set; }
+ public int? FutureId { get; set; }
+ public int? Count { get; set; }
+
+ ///
+ /// Get the URL params required to request the next page of the listing.
+ ///
+ public IDictionary UrlParamsNextPage
+ {
+ get
+ {
+ AssertHasNextPage();
+
+ var urlParams = new Dictionary();
+ urlParams[PARAM_NEWER_ID] = NextId.ToString();
+ AddCountToParamsIfNeeded(urlParams);
+
+ return urlParams;
+ }
+ }
+
+ private void AssertHasNextPage()
+ {
+ if (NextId == null)
+ {
+ throw new BunqException(ERROR_NO_NEXT_PAGE);
+ }
+ }
+
+ private void AddCountToParamsIfNeeded(IDictionary urlParams)
+ {
+ if (Count != null)
+ {
+ urlParams[PARAM_COUNT] = Count.ToString();
+ }
+ }
+
+ private int? NextId
+ {
+ get { return HasNextPageAssured() ? NewerId : FutureId; }
+ }
+
+ public bool HasNextPageAssured()
+ {
+ return NewerId != null;
+ }
+
+ ///
+ /// Get the URL params required to request the latest page with count of this pagination.
+ ///
+ public IDictionary UrlParamsCountOnly
+ {
+ get
+ {
+ var urlParams = new Dictionary();
+ AddCountToParamsIfNeeded(urlParams);
+
+ return urlParams;
+ }
+ }
+
+ ///
+ /// Get the URL params required to request the previous page of the listing.
+ ///
+ public IDictionary UrlParamsPreviousPage
+ {
+ get
+ {
+ AssertHasPreviousPage();
+
+ var urlParams = new Dictionary();
+ urlParams[PARAM_OLDER_ID] = OlderId.ToString();
+ AddCountToParamsIfNeeded(urlParams);
+
+ return urlParams;
+ }
+ }
+
+ private void AssertHasPreviousPage()
+ {
+ if (!HasPreviousPage())
+ {
+ throw new BunqException(ERROR_NO_PREVIOUS_PAGE);
+ }
+ }
+
+ public bool HasPreviousPage()
+ {
+ return OlderId != null;
+ }
+ }
+}
diff --git a/BunqSdk/Json/BunqContractResolver.cs b/BunqSdk/Json/BunqContractResolver.cs
index 6b37db5..9ded7c9 100644
--- a/BunqSdk/Json/BunqContractResolver.cs
+++ b/BunqSdk/Json/BunqContractResolver.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Bunq.Sdk.Context;
+using Bunq.Sdk.Http;
using Bunq.Sdk.Model;
using Bunq.Sdk.Model.Generated.Object;
using Newtonsoft.Json;
@@ -26,6 +27,7 @@ public BunqContractResolver()
RegisterConverter(typeof(decimal?), new NonIntegerNumberConverter());
RegisterConverter(typeof(double?), new NonIntegerNumberConverter());
RegisterConverter(typeof(float?), new NonIntegerNumberConverter());
+ RegisterConverter(typeof(Pagination), new PaginationConverter());
}
private void RegisterConverter(Type objectType, JsonConverter converter)
diff --git a/BunqSdk/Json/PaginationConverter.cs b/BunqSdk/Json/PaginationConverter.cs
new file mode 100644
index 0000000..2231d87
--- /dev/null
+++ b/BunqSdk/Json/PaginationConverter.cs
@@ -0,0 +1,129 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Bunq.Sdk.Http;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+namespace Bunq.Sdk.Json
+{
+ ///
+ /// Custom (de)serialization of SessionServer required due to the unconventional structure of the
+ /// SessionServer POST response.
+ ///
+ public class PaginationConverter : JsonConverter
+ {
+ ///
+ /// Field constants.
+ ///
+ private const string FIELD_OLDER_URL = "older_url";
+ private const string FIELD_NEWER_URL = "newer_url";
+ private const string FIELD_FUTURE_URL = "future_url";
+
+ ///
+ /// Indices of param key and value after parsing.
+ ///
+ private const int INDEX_PARAM_KEY = 0;
+ private const int INDEX_PARAM_VALUE = 1;
+
+ ///
+ /// Base dummy URL to hack through the incomplete relative URI functionality of dotnetcore.
+ ///
+ private const string URI_BASE_DUMMY = "https://example.com";
+
+ public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
+ JsonSerializer serializer)
+ {
+ var responseJson = JObject.Load(reader);
+ var paginationBody = ParsePaginationBody(responseJson);
+
+ return new Pagination
+ {
+ OlderId = GetValueOrNull(paginationBody, Pagination.PARAM_OLDER_ID),
+ NewerId = GetValueOrNull(paginationBody, Pagination.PARAM_NEWER_ID),
+ FutureId = GetValueOrNull(paginationBody, Pagination.PARAM_FUTURE_ID),
+ Count = GetValueOrNull(paginationBody, Pagination.PARAM_COUNT),
+ };
+ }
+
+ private static T GetValueOrNull(IDictionary dictionary, string key)
+ {
+ return dictionary.ContainsKey(key) ? dictionary[key] : default(T);
+ }
+
+ private static IDictionary ParsePaginationBody(JObject responseJson)
+ {
+ var paginationBody = new Dictionary();
+ UpdatePaginationBodyFromResponseField(
+ paginationBody,
+ Pagination.PARAM_OLDER_ID,
+ responseJson,
+ FIELD_OLDER_URL,
+ Pagination.PARAM_OLDER_ID
+ );
+ UpdatePaginationBodyFromResponseField(
+ paginationBody,
+ Pagination.PARAM_NEWER_ID,
+ responseJson,
+ FIELD_NEWER_URL,
+ Pagination.PARAM_NEWER_ID
+ );
+ UpdatePaginationBodyFromResponseField(
+ paginationBody,
+ Pagination.PARAM_FUTURE_ID,
+ responseJson,
+ FIELD_FUTURE_URL,
+ Pagination.PARAM_NEWER_ID
+ );
+
+ return paginationBody;
+ }
+
+ private static void UpdatePaginationBodyFromResponseField(IDictionary paginationBody,
+ string idField, JObject responseJson, string responseField, string responseParam)
+ {
+ var responseToken = responseJson[responseField];
+
+ if (responseToken == null || responseToken.Value() == null) return;
+
+ foreach (var param in ParseUriParams(responseToken))
+ {
+ if (responseParam.Equals(param.Key))
+ {
+ paginationBody[idField] = int.Parse(param.Value);
+ }
+ else if (Pagination.PARAM_COUNT.Equals(param.Key) &&
+ !paginationBody.ContainsKey(Pagination.PARAM_COUNT))
+ {
+ paginationBody[Pagination.PARAM_COUNT] = int.Parse(param.Value);
+ }
+ }
+ }
+
+ private static IDictionary ParseUriParams(JToken uriToken)
+ {
+ if (uriToken == null) return new Dictionary();
+
+ return new Uri(URI_BASE_DUMMY + uriToken).Query
+ .TrimStart(ApiClient.DELIMITER_URI_QUERY)
+ .Split(ApiClient.DELIMITER_URI_PARAMS)
+ .Select(param => param.Split(ApiClient.DELIMITER_URI_PARAM_KEY_VALUE))
+ .ToDictionary(pair => pair[INDEX_PARAM_KEY], pair => pair[INDEX_PARAM_VALUE]);
+ }
+
+ public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override bool CanWrite
+ {
+ get { return false; }
+ }
+
+ public override bool CanConvert(Type objectType)
+ {
+ return objectType == typeof(Pagination);
+ }
+ }
+}
diff --git a/BunqSdk/Model/BunqModel.cs b/BunqSdk/Model/BunqModel.cs
index a116066..20e7aeb 100644
--- a/BunqSdk/Model/BunqModel.cs
+++ b/BunqSdk/Model/BunqModel.cs
@@ -15,6 +15,7 @@ public abstract class BunqModel
private const string FIELD_RESPONSE = "Response";
private const string FIELD_ID = "Id";
private const string FIELD_UUID = "Uuid";
+ private const string FIELD_PAGINATION = "Pagination";
///
/// Index of the very first item in an array.
@@ -39,14 +40,14 @@ protected static BunqResponse FromJsonArrayNested(BunqResponseRaw response
///
protected static BunqResponse ProcessForId(BunqResponseRaw responseRaw)
{
- var responseContent = GetResponseContent(responseRaw);
- var jsonObjectString = GetWrappedContentString(responseContent, FIELD_ID);
- var responseValue = BunqJsonConvert.DeserializeObject(jsonObjectString).IdInt;
+ var responseItemObject = GetResponseItemObject(responseRaw);
+ var unwrappedItemJsonString = GetUnwrappedItemJsonString(responseItemObject, FIELD_ID);
+ var responseValue = BunqJsonConvert.DeserializeObject(unwrappedItemJsonString).IdInt;
return new BunqResponse(responseValue, responseRaw.Headers);
}
- private static JObject GetResponseContent(BunqResponseRaw responseRaw)
+ private static JObject GetResponseItemObject(BunqResponseRaw responseRaw)
{
var json = Encoding.UTF8.GetString(responseRaw.BodyBytes);
var responseWithWrapper = BunqJsonConvert.DeserializeObject(json);
@@ -54,7 +55,7 @@ private static JObject GetResponseContent(BunqResponseRaw responseRaw)
return responseWithWrapper.GetValue(FIELD_RESPONSE).ToObject().Value(INDEX_FIRST);
}
- private static string GetWrappedContentString(JObject json, string wrapper)
+ private static string GetUnwrappedItemJsonString(JObject json, string wrapper)
{
return json.GetValue(wrapper).ToString();
}
@@ -64,9 +65,9 @@ private static string GetWrappedContentString(JObject json, string wrapper)
///
protected static BunqResponse ProcessForUuid(BunqResponseRaw responseRaw)
{
- var responseContent = GetResponseContent(responseRaw);
- var jsonObjectString = GetWrappedContentString(responseContent, FIELD_UUID);
- var responseValue = BunqJsonConvert.DeserializeObject(jsonObjectString).UuidString;
+ var responseItemObject = GetResponseItemObject(responseRaw);
+ var unwrappedItemJsonString = GetUnwrappedItemJsonString(responseItemObject, FIELD_UUID);
+ var responseValue = BunqJsonConvert.DeserializeObject(unwrappedItemJsonString).UuidString;
return new BunqResponse(responseValue, responseRaw.Headers);
}
@@ -76,17 +77,17 @@ protected static BunqResponse ProcessForUuid(BunqResponseRaw responseRaw
///
protected static BunqResponse FromJson(BunqResponseRaw responseRaw, string wrapper)
{
- var responseContent = GetResponseContent(responseRaw);
- var objectContentString = GetWrappedContentString(responseContent, wrapper);
- var responseValue = BunqJsonConvert.DeserializeObject(objectContentString);
+ var responseItemObject = GetResponseItemObject(responseRaw);
+ var unwrappedItemJsonString = GetUnwrappedItemJsonString(responseItemObject, wrapper);
+ var responseValue = BunqJsonConvert.DeserializeObject(unwrappedItemJsonString);
return new BunqResponse(responseValue, responseRaw.Headers);
}
protected static BunqResponse FromJson(BunqResponseRaw responseRaw)
{
- var responseContent = GetResponseContent(responseRaw);
- var responseValue = BunqJsonConvert.DeserializeObject(responseContent.ToString());
+ var responseItemObject = GetResponseItemObject(responseRaw);
+ var responseValue = BunqJsonConvert.DeserializeObject(responseItemObject.ToString());
return new BunqResponse(responseValue, responseRaw.Headers);
}
@@ -96,31 +97,42 @@ protected static BunqResponse FromJson(BunqResponseRaw responseRaw)
///
protected static BunqResponse> FromJsonList(BunqResponseRaw responseRaw, string wrapper)
{
- var responseObjectsArray = GetResponseContentArray(responseRaw);
- var responseValue = responseObjectsArray
- .Select(objectContentWithWrapper =>
- GetWrappedContentString(objectContentWithWrapper.ToObject(), wrapper))
- .Select(BunqJsonConvert.DeserializeObject).ToList();
+ var responseObject = DeserializeResponseObject(responseRaw);
+ var responseValue = responseObject
+ .GetValue(FIELD_RESPONSE).ToObject()
+ .Select(unwrappedItemObject =>
+ GetUnwrappedItemJsonString(unwrappedItemObject.ToObject(), wrapper))
+ .Select(BunqJsonConvert.DeserializeObject)
+ .ToList();
+ var pagination = DeserializePagination(responseObject);
- return new BunqResponse>(responseValue, responseRaw.Headers);
+ return new BunqResponse>(responseValue, responseRaw.Headers, pagination);
}
protected static BunqResponse> FromJsonList(BunqResponseRaw responseRaw)
{
- var responseObjectsArray = GetResponseContentArray(responseRaw);
- var responseValue = responseObjectsArray
- .Select(objectContent => BunqJsonConvert.DeserializeObject(objectContent.ToString()))
+ var responseObject = DeserializeResponseObject(responseRaw);
+ var responseValue = responseObject
+ .GetValue(FIELD_RESPONSE).ToObject()
+ .Select(itemObject => BunqJsonConvert.DeserializeObject(itemObject.ToString()))
.ToList();
+ var pagination = DeserializePagination(responseObject);
+
+ return new BunqResponse>(responseValue, responseRaw.Headers, pagination);
+ }
- return new BunqResponse>(responseValue, responseRaw.Headers);
+ private static Pagination DeserializePagination(JObject responseObject)
+ {
+ var paginationBody = responseObject.GetValue(FIELD_PAGINATION).ToString();
+
+ return BunqJsonConvert.DeserializeObject(paginationBody);
}
- private static JArray GetResponseContentArray(BunqResponseRaw responseRaw)
+ private static JObject DeserializeResponseObject(BunqResponseRaw responseRaw)
{
var json = Encoding.UTF8.GetString(responseRaw.BodyBytes);
- var responseWithWrapper = BunqJsonConvert.DeserializeObject(json);
- return responseWithWrapper.GetValue(FIELD_RESPONSE).ToObject();
+ return BunqJsonConvert.DeserializeObject(json);
}
public override string ToString()
diff --git a/BunqSdk/Model/Generated/AttachmentConversationContent.cs b/BunqSdk/Model/Generated/AttachmentConversationContent.cs
index 3545e6d..f2a81b0 100644
--- a/BunqSdk/Model/Generated/AttachmentConversationContent.cs
+++ b/BunqSdk/Model/Generated/AttachmentConversationContent.cs
@@ -20,22 +20,18 @@ public class AttachmentConversationContent : BunqModel
///
private const string OBJECT_TYPE = "AttachmentConversationContent";
- public static BunqResponse List(ApiContext apiContext, int userId, int chatConversationId,
- int attachmentId)
- {
- return List(apiContext, userId, chatConversationId, attachmentId, new Dictionary());
- }
-
///
/// Get the raw content of a specific attachment.
///
public static BunqResponse List(ApiContext apiContext, int userId, int chatConversationId,
- int attachmentId, IDictionary customHeaders)
+ int attachmentId, IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
var responseRaw =
apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, chatConversationId, attachmentId),
- customHeaders);
+ new Dictionary(), customHeaders);
return new BunqResponse(responseRaw.BodyBytes, responseRaw.Headers);
}
diff --git a/BunqSdk/Model/Generated/AttachmentMonetaryAccount.cs b/BunqSdk/Model/Generated/AttachmentMonetaryAccount.cs
index fdfe13c..bc21c68 100644
--- a/BunqSdk/Model/Generated/AttachmentMonetaryAccount.cs
+++ b/BunqSdk/Model/Generated/AttachmentMonetaryAccount.cs
@@ -34,12 +34,6 @@ public class AttachmentMonetaryAccount : BunqModel
[JsonProperty(PropertyName = "id")]
public int? Id { get; private set; }
- public static BunqResponse Create(ApiContext apiContext, byte[] requestBytes, int userId,
- int monetaryAccountId)
- {
- return Create(apiContext, requestBytes, userId, monetaryAccountId, new Dictionary());
- }
-
///
/// Create a new monetary account attachment. Create a POST request with a payload that contains the binary
/// representation of the file, without any JSON wrapping. Make sure you define the MIME type (i.e. image/jpeg)
@@ -47,8 +41,10 @@ public static BunqResponse Create(ApiContext apiContext, byte[] requestByte
/// X-Bunq-Attachment-Description header.
///
public static BunqResponse Create(ApiContext apiContext, byte[] requestBytes, int userId,
- int monetaryAccountId, IDictionary customHeaders)
+ int monetaryAccountId, IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
var responseRaw = apiClient.Post(string.Format(ENDPOINT_URL_CREATE, userId, monetaryAccountId),
requestBytes, customHeaders);
diff --git a/BunqSdk/Model/Generated/AttachmentPublic.cs b/BunqSdk/Model/Generated/AttachmentPublic.cs
index 25c83b5..792bac1 100644
--- a/BunqSdk/Model/Generated/AttachmentPublic.cs
+++ b/BunqSdk/Model/Generated/AttachmentPublic.cs
@@ -47,11 +47,6 @@ public class AttachmentPublic : BunqModel
[JsonProperty(PropertyName = "attachment")]
public Attachment Attachment { get; private set; }
- public static BunqResponse Create(ApiContext apiContext, byte[] requestBytes)
- {
- return Create(apiContext, requestBytes, new Dictionary());
- }
-
///
/// Create a new public attachment. Create a POST request with a payload that contains a binary representation
/// of the file, without any JSON wrapping. Make sure you define the MIME type (i.e. image/jpeg, or image/png)
@@ -59,28 +54,28 @@ public static BunqResponse Create(ApiContext apiContext, byte[] requestB
/// X-Bunq-Attachment-Description header.
///
public static BunqResponse Create(ApiContext apiContext, byte[] requestBytes,
- IDictionary customHeaders)
+ IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
var responseRaw = apiClient.Post(ENDPOINT_URL_CREATE, requestBytes, customHeaders);
return ProcessForUuid(responseRaw);
}
- public static BunqResponse Get(ApiContext apiContext, string attachmentPublicUuid)
- {
- return Get(apiContext, attachmentPublicUuid, new Dictionary());
- }
-
///
/// Get a specific attachment's metadata through its UUID. The Content-Type header of the response will describe
/// the MIME type of the attachment file.
///
public static BunqResponse Get(ApiContext apiContext, string attachmentPublicUuid,
- IDictionary customHeaders)
+ IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
- var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, attachmentPublicUuid), customHeaders);
+ var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, attachmentPublicUuid),
+ new Dictionary(), customHeaders);
return FromJson(responseRaw, OBJECT_TYPE);
}
diff --git a/BunqSdk/Model/Generated/AttachmentPublicContent.cs b/BunqSdk/Model/Generated/AttachmentPublicContent.cs
index 20ad778..14391c4 100644
--- a/BunqSdk/Model/Generated/AttachmentPublicContent.cs
+++ b/BunqSdk/Model/Generated/AttachmentPublicContent.cs
@@ -20,19 +20,17 @@ public class AttachmentPublicContent : BunqModel
///
private const string OBJECT_TYPE = "AttachmentPublicContent";
- public static BunqResponse List(ApiContext apiContext, string attachmentPublicUuid)
- {
- return List(apiContext, attachmentPublicUuid, new Dictionary());
- }
-
///
/// Get the raw content of a specific attachment.
///
public static BunqResponse List(ApiContext apiContext, string attachmentPublicUuid,
- IDictionary customHeaders)
+ IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
- var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, attachmentPublicUuid), customHeaders);
+ var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, attachmentPublicUuid),
+ new Dictionary(), customHeaders);
return new BunqResponse(responseRaw.BodyBytes, responseRaw.Headers);
}
diff --git a/BunqSdk/Model/Generated/AttachmentTab.cs b/BunqSdk/Model/Generated/AttachmentTab.cs
index 3212fe6..47eaed6 100644
--- a/BunqSdk/Model/Generated/AttachmentTab.cs
+++ b/BunqSdk/Model/Generated/AttachmentTab.cs
@@ -47,12 +47,6 @@ public class AttachmentTab : BunqModel
[JsonProperty(PropertyName = "attachment")]
public Attachment Attachment { get; private set; }
- public static BunqResponse Create(ApiContext apiContext, byte[] requestBytes, int userId,
- int monetaryAccountId)
- {
- return Create(apiContext, requestBytes, userId, monetaryAccountId, new Dictionary());
- }
-
///
/// Upload a new attachment to use with a tab, and to read its metadata. Create a POST request with a payload
/// that contains the binary representation of the file, without any JSON wrapping. Make sure you define the
@@ -60,8 +54,10 @@ public static BunqResponse Create(ApiContext apiContext, byte[] requestByte
/// attachment using the X-Bunq-Attachment-Description header.
///
public static BunqResponse Create(ApiContext apiContext, byte[] requestBytes, int userId,
- int monetaryAccountId, IDictionary customHeaders)
+ int monetaryAccountId, IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
var responseRaw = apiClient.Post(string.Format(ENDPOINT_URL_CREATE, userId, monetaryAccountId),
requestBytes, customHeaders);
@@ -69,22 +65,18 @@ public static BunqResponse Create(ApiContext apiContext, byte[] requestByte
return ProcessForId(responseRaw);
}
- public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId,
- int attachmentTabId)
- {
- return Get(apiContext, userId, monetaryAccountId, attachmentTabId, new Dictionary());
- }
-
///
/// Get a specific attachment. The header of the response contains the content-type of the attachment.
///
public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId,
- int attachmentTabId, IDictionary customHeaders)
+ int attachmentTabId, IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
var responseRaw =
apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, monetaryAccountId, attachmentTabId),
- customHeaders);
+ new Dictionary(), customHeaders);
return FromJson(responseRaw, OBJECT_TYPE);
}
diff --git a/BunqSdk/Model/Generated/AttachmentTabContent.cs b/BunqSdk/Model/Generated/AttachmentTabContent.cs
index d637923..41536b5 100644
--- a/BunqSdk/Model/Generated/AttachmentTabContent.cs
+++ b/BunqSdk/Model/Generated/AttachmentTabContent.cs
@@ -20,22 +20,18 @@ public class AttachmentTabContent : BunqModel
///
private const string OBJECT_TYPE = "AttachmentTabContent";
- public static BunqResponse List(ApiContext apiContext, int userId, int monetaryAccountId,
- int attachmentTabId)
- {
- return List(apiContext, userId, monetaryAccountId, attachmentTabId, new Dictionary());
- }
-
///
/// Get the raw content of a specific attachment.
///
public static BunqResponse List(ApiContext apiContext, int userId, int monetaryAccountId,
- int attachmentTabId, IDictionary customHeaders)
+ int attachmentTabId, IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
var responseRaw =
apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId, attachmentTabId),
- customHeaders);
+ new Dictionary(), customHeaders);
return new BunqResponse(responseRaw.BodyBytes, responseRaw.Headers);
}
diff --git a/BunqSdk/Model/Generated/Avatar.cs b/BunqSdk/Model/Generated/Avatar.cs
index 54b446d..256cf1e 100644
--- a/BunqSdk/Model/Generated/Avatar.cs
+++ b/BunqSdk/Model/Generated/Avatar.cs
@@ -44,16 +44,13 @@ public class Avatar : BunqModel
[JsonProperty(PropertyName = "image")]
public List Image { get; private set; }
- public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap)
- {
- return Create(apiContext, requestMap, new Dictionary());
- }
-
///
///
public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap,
- IDictionary customHeaders)
+ IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap));
var responseRaw = apiClient.Post(ENDPOINT_URL_CREATE, requestBytes, customHeaders);
@@ -61,18 +58,16 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Get(ApiContext apiContext, string avatarUuid)
- {
- return Get(apiContext, avatarUuid, new Dictionary());
- }
-
///
///
public static BunqResponse Get(ApiContext apiContext, string avatarUuid,
- IDictionary customHeaders)
+ IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
- var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, avatarUuid), customHeaders);
+ var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, avatarUuid),
+ new Dictionary(), customHeaders);
return FromJson(responseRaw, OBJECT_TYPE);
}
diff --git a/BunqSdk/Model/Generated/BillingContractSubscription.cs b/BunqSdk/Model/Generated/BillingContractSubscription.cs
new file mode 100644
index 0000000..d4580a8
--- /dev/null
+++ b/BunqSdk/Model/Generated/BillingContractSubscription.cs
@@ -0,0 +1,103 @@
+using System.Collections.Generic;
+using System.Text;
+using Bunq.Sdk.Context;
+using Bunq.Sdk.Http;
+using Bunq.Sdk.Json;
+using Newtonsoft.Json;
+
+namespace Bunq.Sdk.Model.Generated
+{
+ ///
+ /// Show the subscription billing contract for the authenticated user.
+ ///
+ public class BillingContractSubscription : BunqModel
+ {
+ ///
+ /// Field constants.
+ ///
+ public const string FIELD_SUBSCRIPTION_TYPE = "subscription_type";
+
+ ///
+ /// Endpoint constants.
+ ///
+ private const string ENDPOINT_URL_CREATE = "user/{0}/billing-contract-subscription";
+ private const string ENDPOINT_URL_LISTING = "user/{0}/billing-contract-subscription";
+
+ ///
+ /// Object type.
+ ///
+ private const string OBJECT_TYPE = "BillingContractSubscription";
+
+ ///
+ /// The id of the billing contract.
+ ///
+ [JsonProperty(PropertyName = "id")]
+ public int? Id { get; private set; }
+
+ ///
+ /// The timestamp when the billing contract was made.
+ ///
+ [JsonProperty(PropertyName = "created")]
+ public string Created { get; private set; }
+
+ ///
+ /// The timestamp when the billing contract was last updated.
+ ///
+ [JsonProperty(PropertyName = "updated")]
+ public string Updated { get; private set; }
+
+ ///
+ /// The date from when the billing contract is valid.
+ ///
+ [JsonProperty(PropertyName = "contract_date_start")]
+ public string ContractDateStart { get; private set; }
+
+ ///
+ /// The date until when the billing contract is valid.
+ ///
+ [JsonProperty(PropertyName = "contract_date_end")]
+ public string ContractDateEnd { get; private set; }
+
+ ///
+ /// The version of the billing contract.
+ ///
+ [JsonProperty(PropertyName = "contract_version")]
+ public int? ContractVersion { get; private set; }
+
+ ///
+ /// The subscription type of the user. Can be one of PERSON_SUPER_LIGHT_V1, PERSON_LIGHT_V1, PERSON_MORE_V1,
+ /// PERSON_FREE_V1, PERSON_PREMIUM_V1, COMPANY_V1, or COMPANY_V2.
+ ///
+ [JsonProperty(PropertyName = "subscription_type")]
+ public string SubscriptionType { get; private set; }
+
+ ///
+ ///
+ public static BunqResponse Create(ApiContext apiContext,
+ IDictionary requestMap, int userId, IDictionary customHeaders = null)
+ {
+ if (customHeaders == null) customHeaders = new Dictionary();
+
+ var apiClient = new ApiClient(apiContext);
+ var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap));
+ var responseRaw = apiClient.Post(string.Format(ENDPOINT_URL_CREATE, userId), requestBytes, customHeaders);
+
+ return FromJson(responseRaw, OBJECT_TYPE);
+ }
+
+ ///
+ /// Get all subscription billing contract for the authenticated user.
+ ///
+ public static BunqResponse> List(ApiContext apiContext, int userId,
+ IDictionary urlParams = null, IDictionary customHeaders = null)
+ {
+ if (urlParams == null) urlParams = new Dictionary();
+ if (customHeaders == null) customHeaders = new Dictionary();
+
+ var apiClient = new ApiClient(apiContext);
+ var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId), urlParams, customHeaders);
+
+ return FromJsonList(responseRaw, OBJECT_TYPE);
+ }
+ }
+}
diff --git a/BunqSdk/Model/Generated/Card.cs b/BunqSdk/Model/Generated/Card.cs
index 6ef4474..f108372 100644
--- a/BunqSdk/Model/Generated/Card.cs
+++ b/BunqSdk/Model/Generated/Card.cs
@@ -76,6 +76,12 @@ public class Card : BunqModel
[JsonProperty(PropertyName = "status")]
public string Status { get; private set; }
+ ///
+ /// The sub-status of the card. Can be NONE or REPLACED.
+ ///
+ [JsonProperty(PropertyName = "sub_status")]
+ public string SubStatus { get; private set; }
+
///
/// The order status of the card. Can be CARD_UPDATE_REQUESTED, CARD_UPDATE_SENT, CARD_UPDATE_ACCEPTED,
/// ACCEPTED_FOR_PRODUCTION or DELIVERED_TO_CUSTOMER.
@@ -138,11 +144,12 @@ public class Card : BunqModel
[JsonProperty(PropertyName = "pin_code_assignment")]
public List PinCodeAssignment { get; private set; }
- public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap,
- int userId, int cardId)
- {
- return Update(apiContext, requestMap, userId, cardId, new Dictionary());
- }
+ ///
+ /// ID of the MA to be used as fallback for this card if insufficient balance. Fallback account is removed if
+ /// not supplied.
+ ///
+ [JsonProperty(PropertyName = "monetary_account_id_fallback")]
+ public int? MonetaryAccountIdFallback { get; private set; }
///
/// Update the card details. Allow to change pin code, status, limits, country permissions and the monetary
@@ -150,8 +157,10 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary
public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap,
- int userId, int cardId, IDictionary customHeaders)
+ int userId, int cardId, IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap));
requestBytes = SecurityUtils.Encrypt(apiContext, requestBytes, customHeaders);
@@ -161,36 +170,32 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary(responseRaw, OBJECT_TYPE);
}
- public static BunqResponse Get(ApiContext apiContext, int userId, int cardId)
- {
- return Get(apiContext, userId, cardId, new Dictionary());
- }
-
///
/// Return the details of a specific card.
///
public static BunqResponse Get(ApiContext apiContext, int userId, int cardId,
- IDictionary customHeaders)
+ IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
- var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, cardId), customHeaders);
+ var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, cardId),
+ new Dictionary(), customHeaders);
return FromJson(responseRaw, OBJECT_TYPE);
}
- public static BunqResponse> List(ApiContext apiContext, int userId)
- {
- return List(apiContext, userId, new Dictionary());
- }
-
///
/// Return all the cards available to the user.
///
public static BunqResponse> List(ApiContext apiContext, int userId,
- IDictionary customHeaders)
+ IDictionary urlParams = null, IDictionary customHeaders = null)
{
+ if (urlParams == null) urlParams = new Dictionary();
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
- var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId), customHeaders);
+ var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId), urlParams, customHeaders);
return FromJsonList(responseRaw, OBJECT_TYPE);
}
diff --git a/BunqSdk/Model/Generated/CardDebit.cs b/BunqSdk/Model/Generated/CardDebit.cs
index a0d85fa..2b3da4f 100644
--- a/BunqSdk/Model/Generated/CardDebit.cs
+++ b/BunqSdk/Model/Generated/CardDebit.cs
@@ -23,6 +23,8 @@ public class CardDebit : BunqModel
public const string FIELD_PIN_CODE = "pin_code";
public const string FIELD_ALIAS = "alias";
public const string FIELD_TYPE = "type";
+ public const string FIELD_PIN_CODE_ASSIGNMENT = "pin_code_assignment";
+ public const string FIELD_MONETARY_ACCOUNT_ID_FALLBACK = "monetary_account_id_fallback";
///
/// Endpoint constants.
@@ -52,6 +54,12 @@ public class CardDebit : BunqModel
[JsonProperty(PropertyName = "updated")]
public string Updated { get; private set; }
+ ///
+ /// The public UUID of the card.
+ ///
+ [JsonProperty(PropertyName = "public_uuid")]
+ public string PublicUuid { get; private set; }
+
///
/// The second line of text on the card
///
@@ -64,6 +72,12 @@ public class CardDebit : BunqModel
[JsonProperty(PropertyName = "name_on_card")]
public string NameOnCard { get; private set; }
+ ///
+ /// The last 4 digits of the PAN of the card.
+ ///
+ [JsonProperty(PropertyName = "primary_account_number_four_digit")]
+ public string PrimaryAccountNumberFourDigit { get; private set; }
+
///
/// The status to set for the card. After ordering the card it will be DEACTIVATED.
///
@@ -94,24 +108,45 @@ public class CardDebit : BunqModel
[JsonProperty(PropertyName = "country_permission")]
public List CountryPermission { get; private set; }
+ ///
+ /// The monetary account this card was ordered on and the label user that owns the card.
+ ///
+ [JsonProperty(PropertyName = "label_monetary_account_ordered")]
+ public MonetaryAccountReference LabelMonetaryAccountOrdered { get; private set; }
+
+ ///
+ /// The monetary account that this card is currently linked to and the label user viewing it.
+ ///
+ [JsonProperty(PropertyName = "label_monetary_account_current")]
+ public MonetaryAccountReference LabelMonetaryAccountCurrent { get; private set; }
+
///
/// The label for the user who requested the card.
///
[JsonProperty(PropertyName = "alias")]
public LabelUser Alias { get; private set; }
- public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap,
- int userId)
- {
- return Create(apiContext, requestMap, userId, new Dictionary());
- }
+ ///
+ /// Array of Types, PINs, account IDs assigned to the card.
+ ///
+ [JsonProperty(PropertyName = "pin_code_assignment")]
+ public List PinCodeAssignment { get; private set; }
+
+ ///
+ /// ID of the MA to be used as fallback for this card if insufficient balance. Fallback account is removed if
+ /// not supplied.
+ ///
+ [JsonProperty(PropertyName = "monetary_account_id_fallback")]
+ public int? MonetaryAccountIdFallback { get; private set; }
///
/// Create a new debit card request.
///
public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap,
- int userId, IDictionary customHeaders)
+ int userId, IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap));
requestBytes = SecurityUtils.Encrypt(apiContext, requestBytes, customHeaders);
diff --git a/BunqSdk/Model/Generated/CardName.cs b/BunqSdk/Model/Generated/CardName.cs
index cd1f4d7..fa8e1ed 100644
--- a/BunqSdk/Model/Generated/CardName.cs
+++ b/BunqSdk/Model/Generated/CardName.cs
@@ -28,19 +28,17 @@ public class CardName : BunqModel
[JsonProperty(PropertyName = "possible_card_name_array")]
public List PossibleCardNameArray { get; private set; }
- public static BunqResponse> List(ApiContext apiContext, int userId)
- {
- return List(apiContext, userId, new Dictionary());
- }
-
///
/// Return all the accepted card names for a specific user.
///
public static BunqResponse> List(ApiContext apiContext, int userId,
- IDictionary customHeaders)
+ IDictionary urlParams = null, IDictionary customHeaders = null)
{
+ if (urlParams == null) urlParams = new Dictionary();
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
- var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId), customHeaders);
+ var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId), urlParams, customHeaders);
return FromJsonList(responseRaw, OBJECT_TYPE);
}
diff --git a/BunqSdk/Model/Generated/CashRegister.cs b/BunqSdk/Model/Generated/CashRegister.cs
index 2004e69..09db40f 100644
--- a/BunqSdk/Model/Generated/CashRegister.cs
+++ b/BunqSdk/Model/Generated/CashRegister.cs
@@ -91,20 +91,16 @@ public class CashRegister : BunqModel
[JsonProperty(PropertyName = "tab_text_waiting_screen")]
public List TabTextWaitingScreen { get; private set; }
- public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap,
- int userId, int monetaryAccountId)
- {
- return Create(apiContext, requestMap, userId, monetaryAccountId, new Dictionary());
- }
-
///
/// Create a new CashRegister. Only an UserCompany can create a CashRegisters. They need to be created with
/// status PENDING_APPROVAL, an bunq admin has to approve your CashRegister before you can use it. In the
/// sandbox testing environment an CashRegister will be automatically approved immediately after creation.
///
public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap,
- int userId, int monetaryAccountId, IDictionary customHeaders)
+ int userId, int monetaryAccountId, IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap));
var responseRaw = apiClient.Post(string.Format(ENDPOINT_URL_CREATE, userId, monetaryAccountId),
@@ -113,39 +109,30 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Get(ApiContext apiContext, int userId, int monetaryAccountId,
- int cashRegisterId)
- {
- return Get(apiContext, userId, monetaryAccountId, cashRegisterId, new Dictionary());
- }
-
///
/// Get a specific CashRegister.
///
public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId,
- int cashRegisterId, IDictionary customHeaders)
+ int cashRegisterId, IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, monetaryAccountId, cashRegisterId),
- customHeaders);
+ new Dictionary(), customHeaders);
return FromJson(responseRaw, OBJECT_TYPE);
}
- public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap,
- int userId, int monetaryAccountId, int cashRegisterId)
- {
- return Update(apiContext, requestMap, userId, monetaryAccountId, cashRegisterId,
- new Dictionary());
- }
-
///
/// Modify or close an existing CashRegister. You must set the status back to PENDING_APPROVAL if you modify the
/// name, avatar or location of a CashRegister. To close a cash register put its status to CLOSED.
///
public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap,
- int userId, int monetaryAccountId, int cashRegisterId, IDictionary customHeaders)
+ int userId, int monetaryAccountId, int cashRegisterId, IDictionary customHeaders = null)
{
+ if (customHeaders == null) customHeaders = new Dictionary();
+
var apiClient = new ApiClient(apiContext);
var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap));
var responseRaw =
@@ -155,19 +142,17 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary> List(ApiContext apiContext, int userId, int monetaryAccountId)
- {
- return List(apiContext, userId, monetaryAccountId, new Dictionary());
- }
-
///