From b35caf57fcd8b026349bb61c87ee7622573313ff Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Sun, 3 Sep 2017 18:04:55 +0200 Subject: [PATCH 01/19] Add pagination [#17] --- BunqSdk.Samples/PaymentListSample.cs | 44 ++++- BunqSdk/Context/ApiContext.cs | 4 +- BunqSdk/Http/ApiClient.cs | 67 ++++++-- BunqSdk/Http/BunqResponse.cs | 4 +- BunqSdk/Http/Pagination.cs | 106 +++++++++++++ BunqSdk/Json/BunqContractResolver.cs | 2 + BunqSdk/Json/PaginationConverter.cs | 129 +++++++++++++++ BunqSdk/Model/BunqModel.cs | 64 +++++--- .../AttachmentConversationContent.cs | 12 +- .../Generated/AttachmentMonetaryAccount.cs | 10 +- BunqSdk/Model/Generated/AttachmentPublic.cs | 21 +-- .../Generated/AttachmentPublicContent.cs | 12 +- BunqSdk/Model/Generated/AttachmentTab.cs | 22 +-- .../Model/Generated/AttachmentTabContent.cs | 12 +- BunqSdk/Model/Generated/Avatar.cs | 21 +-- .../Generated/BillingContractSubscription.cs | 103 ++++++++++++ BunqSdk/Model/Generated/Card.cs | 39 +++-- BunqSdk/Model/Generated/CardDebit.cs | 47 +++++- BunqSdk/Model/Generated/CardName.cs | 12 +- BunqSdk/Model/Generated/CashRegister.cs | 45 ++---- BunqSdk/Model/Generated/CashRegisterQrCode.cs | 49 ++---- .../Generated/CashRegisterQrCodeContent.cs | 13 +- BunqSdk/Model/Generated/CertificatePinned.cs | 47 ++---- BunqSdk/Model/Generated/ChatConversation.cs | 25 ++- BunqSdk/Model/Generated/ChatMessage.cs | 12 +- .../Model/Generated/ChatMessageAttachment.cs | 10 +- BunqSdk/Model/Generated/ChatMessageText.cs | 10 +- BunqSdk/Model/Generated/Customer.cs | 99 ++++++++++++ BunqSdk/Model/Generated/CustomerLimit.cs | 56 +++++++ .../Generated/CustomerStatementExport.cs | 48 ++---- .../CustomerStatementExportContent.cs | 12 +- BunqSdk/Model/Generated/Device.cs | 25 ++- BunqSdk/Model/Generated/DeviceServer.cs | 33 ++-- BunqSdk/Model/Generated/DraftPayment.cs | 150 ++++++++++++++++++ .../Model/Generated/DraftShareInviteBank.cs | 44 ++--- .../DraftShareInviteBankQrCodeContent.cs | 11 +- .../Model/Generated/ExportAnnualOverview.cs | 34 ++-- .../Generated/ExportAnnualOverviewContent.cs | 11 +- .../Generated/InstallationServerPublicKey.cs | 13 +- BunqSdk/Model/Generated/Invoice.cs | 23 ++- BunqSdk/Model/Generated/InvoiceByUser.cs | 24 ++- BunqSdk/Model/Generated/MonetaryAccount.cs | 24 ++- .../Model/Generated/MonetaryAccountBank.cs | 44 ++--- BunqSdk/Model/Generated/Object/Address.cs | 6 + .../Generated/Object/CardCountryPermission.cs | 6 + BunqSdk/Model/Generated/Object/CardLimit.cs | 6 + .../Generated/Object/DraftPaymentEntry.cs | 73 +++++++++ .../Generated/Object/DraftPaymentResponse.cs | 21 +++ .../Generated/Object/LabelMonetaryAccount.cs | 6 + BunqSdk/Model/Generated/Payment.cs | 33 ++-- BunqSdk/Model/Generated/PaymentBatch.cs | 45 ++---- BunqSdk/Model/Generated/PaymentChat.cs | 36 ++--- BunqSdk/Model/Generated/PermittedIp.cs | 47 ++---- BunqSdk/Model/Generated/RequestInquiry.cs | 45 ++---- .../Model/Generated/RequestInquiryBatch.cs | 48 ++---- BunqSdk/Model/Generated/RequestInquiryChat.cs | 37 ++--- BunqSdk/Model/Generated/RequestResponse.cs | 49 +++--- .../Model/Generated/RequestResponseChat.cs | 37 ++--- BunqSdk/Model/Generated/Schedule.cs | 24 ++- BunqSdk/Model/Generated/ScheduleInstance.cs | 38 ++--- BunqSdk/Model/Generated/SchedulePayment.cs | 55 +++---- .../Model/Generated/SchedulePaymentBatch.cs | 33 ++-- BunqSdk/Model/Generated/ScheduleUser.cs | 12 +- BunqSdk/Model/Generated/Session.cs | 9 +- .../Generated/ShareInviteBankAmountUsed.cs | 12 +- .../Model/Generated/ShareInviteBankInquiry.cs | 48 ++---- .../Generated/ShareInviteBankResponse.cs | 34 ++-- BunqSdk/Model/Generated/Tab.cs | 27 ++-- BunqSdk/Model/Generated/TabAttachmentTab.cs | 11 +- .../Generated/TabAttachmentTabContent.cs | 12 +- BunqSdk/Model/Generated/TabItemShop.cs | 61 +++---- BunqSdk/Model/Generated/TabItemShopBatch.cs | 11 +- BunqSdk/Model/Generated/TabQrCodeContent.cs | 13 +- BunqSdk/Model/Generated/TabResultInquiry.cs | 29 ++-- BunqSdk/Model/Generated/TabResultResponse.cs | 26 ++- BunqSdk/Model/Generated/TabUsageMultiple.cs | 60 +++---- BunqSdk/Model/Generated/TabUsageSingle.cs | 60 +++---- .../Model/Generated/TokenQrRequestIdeal.cs | 10 +- BunqSdk/Model/Generated/User.cs | 25 ++- BunqSdk/Model/Generated/UserCompany.cs | 45 ++++-- .../Generated/UserCredentialPasswordIp.cs | 24 ++- BunqSdk/Model/Generated/UserLight.cs | 13 +- BunqSdk/Model/Generated/UserPerson.cs | 23 +-- 83 files changed, 1604 insertions(+), 1199 deletions(-) create mode 100644 BunqSdk/Http/Pagination.cs create mode 100644 BunqSdk/Json/PaginationConverter.cs create mode 100644 BunqSdk/Model/Generated/BillingContractSubscription.cs create mode 100644 BunqSdk/Model/Generated/Customer.cs create mode 100644 BunqSdk/Model/Generated/CustomerLimit.cs create mode 100644 BunqSdk/Model/Generated/DraftPayment.cs create mode 100644 BunqSdk/Model/Generated/Object/DraftPaymentEntry.cs create mode 100644 BunqSdk/Model/Generated/Object/DraftPaymentResponse.cs diff --git a/BunqSdk.Samples/PaymentListSample.cs b/BunqSdk.Samples/PaymentListSample.cs index e395d47..3f864fc 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.HasPreviousItem()) + { + 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/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..58ab0eb 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; @@ -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..512f389 --- /dev/null +++ b/BunqSdk/Http/Pagination.cs @@ -0,0 +1,106 @@ +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: there is no previous page."; + + /// + /// 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"; + + /// + /// 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"; + + 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 + { + var urlParams = new Dictionary(); + urlParams[PARAM_NEWER_ID] = NextId.ToString(); + AddCountToParamsIfNeeded(urlParams); + + return urlParams; + } + } + + private void AddCountToParamsIfNeeded(IDictionary urlParams) + { + if (Count != null) + { + urlParams[PARAM_COUNT] = Count.ToString(); + } + } + + private int? NextId + { + get { return HasNextItemAssured() ? NewerId : FutureId; } + } + + public bool HasNextItemAssured() + { + 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 + { + if (!HasPreviousItem()) + { + throw new BunqException(ERROR_NO_PREVIOUS_PAGE); + } + + var urlParams = new Dictionary(); + urlParams[PARAM_OLDER_ID] = OlderId.ToString(); + AddCountToParamsIfNeeded(urlParams); + + return urlParams; + } + } + + public bool HasPreviousItem() + { + 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..cafb6b2 --- /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 though 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..983704a 100644 --- a/BunqSdk/Model/Generated/Card.cs +++ b/BunqSdk/Model/Generated/Card.cs @@ -138,11 +138,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 +151,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 +164,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()); - } - /// /// Get a collection of CashRegister for a given user and monetary account. /// public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - 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, monetaryAccountId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); diff --git a/BunqSdk/Model/Generated/CashRegisterQrCode.cs b/BunqSdk/Model/Generated/CashRegisterQrCode.cs index d9c313e..07300af 100644 --- a/BunqSdk/Model/Generated/CashRegisterQrCode.cs +++ b/BunqSdk/Model/Generated/CashRegisterQrCode.cs @@ -70,19 +70,14 @@ public class CashRegisterQrCode : BunqModel [JsonProperty(PropertyName = "tab_object")] public Tab TabObject { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int cashRegisterId) - { - return Create(apiContext, requestMap, userId, monetaryAccountId, cashRegisterId, - new Dictionary()); - } - /// /// Create a new QR code for this CashRegister. You can only have one ACTIVE CashRegister QR code at the time. /// public static BunqResponse Create(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 = @@ -92,20 +87,15 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int cashRegisterId, int cashRegisterQrCodeId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, cashRegisterId, cashRegisterQrCodeId, - new Dictionary()); - } - /// /// Modify a QR code in a given CashRegister. You can only have one ACTIVE CashRegister QR code at the time. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, int userId, int monetaryAccountId, int cashRegisterId, int cashRegisterQrCodeId, - 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 = @@ -116,43 +106,36 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary Get(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, int cashRegisterQrCodeId) - { - return Get(apiContext, userId, monetaryAccountId, cashRegisterId, cashRegisterQrCodeId, - new Dictionary()); - } - /// /// Get the information of a specific QR code. To get the RAW content of the QR code use ../qr-code/{id}/content /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, int cashRegisterQrCodeId, IDictionary customHeaders) + int cashRegisterId, int cashRegisterQrCodeId, 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, cashRegisterQrCodeId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, int cashRegisterId) - { - return List(apiContext, userId, monetaryAccountId, cashRegisterId, new Dictionary()); - } - /// /// Get a collection of QR code information from a given CashRegister /// public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, int cashRegisterId, IDictionary customHeaders) + int monetaryAccountId, int cashRegisterId, 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, monetaryAccountId, cashRegisterId), + apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId, cashRegisterId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); diff --git a/BunqSdk/Model/Generated/CashRegisterQrCodeContent.cs b/BunqSdk/Model/Generated/CashRegisterQrCodeContent.cs index eff39a1..14fe355 100644 --- a/BunqSdk/Model/Generated/CashRegisterQrCodeContent.cs +++ b/BunqSdk/Model/Generated/CashRegisterQrCodeContent.cs @@ -20,23 +20,18 @@ public class CashRegisterQrCodeContent : BunqModel /// private const string OBJECT_TYPE = "CashRegisterQrCodeContent"; - public static BunqResponse List(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, int qrCodeId) - { - return List(apiContext, userId, monetaryAccountId, cashRegisterId, qrCodeId, - new Dictionary()); - } - /// /// Show the raw contents of a QR code /// public static BunqResponse List(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, int qrCodeId, IDictionary customHeaders) + int cashRegisterId, int qrCodeId, 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, cashRegisterId, qrCodeId), - customHeaders); + new Dictionary(), customHeaders); return new BunqResponse(responseRaw.BodyBytes, responseRaw.Headers); } diff --git a/BunqSdk/Model/Generated/CertificatePinned.cs b/BunqSdk/Model/Generated/CertificatePinned.cs index b79e859..012aca7 100644 --- a/BunqSdk/Model/Generated/CertificatePinned.cs +++ b/BunqSdk/Model/Generated/CertificatePinned.cs @@ -3,7 +3,6 @@ using Bunq.Sdk.Context; using Bunq.Sdk.Http; using Bunq.Sdk.Json; -using Bunq.Sdk.Model.Generated.Object; using Newtonsoft.Json; namespace Bunq.Sdk.Model.Generated @@ -33,10 +32,10 @@ public class CertificatePinned : BunqModel private const string OBJECT_TYPE = "CertificatePinned"; /// - /// The certificate chain in .PEM format. + /// The certificate chain in .PEM format. Certificates are glued with newline characters. /// [JsonProperty(PropertyName = "certificate_chain")] - public List CertificateChain { get; private set; } + public string CertificateChain { get; private set; } /// /// The id generated for the pinned certificate chain. @@ -44,18 +43,14 @@ public class CertificatePinned : BunqModel [JsonProperty(PropertyName = "id")] public int? Id { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId) - { - return Create(apiContext, requestMap, userId, new Dictionary()); - } - /// /// Pin the certificate chain. /// 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)); var responseRaw = apiClient.Post(string.Format(ENDPOINT_URL_CREATE, userId), requestBytes, customHeaders); @@ -63,17 +58,14 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Delete(ApiContext apiContext, int userId, int certificatePinnedId) - { - return Delete(apiContext, userId, certificatePinnedId, new Dictionary()); - } - /// /// Remove the pinned certificate chain with the specific ID. /// public static BunqResponse Delete(ApiContext apiContext, int userId, int certificatePinnedId, - IDictionary customHeaders) + IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Delete(string.Format(ENDPOINT_URL_DELETE, userId, certificatePinnedId), customHeaders); @@ -81,37 +73,32 @@ public static BunqResponse Delete(ApiContext apiContext, int userId, int return new BunqResponse(null, responseRaw.Headers); } - public static BunqResponse> List(ApiContext apiContext, int userId) - { - return List(apiContext, userId, new Dictionary()); - } - /// /// List all the pinned certificate chain for the given 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); } - public static BunqResponse Get(ApiContext apiContext, int userId, int certificatePinnedId) - { - return Get(apiContext, userId, certificatePinnedId, new Dictionary()); - } - /// /// Get the pinned certificate chain with the specified ID. /// public static BunqResponse Get(ApiContext apiContext, int userId, int certificatePinnedId, - 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, certificatePinnedId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/ChatConversation.cs b/BunqSdk/Model/Generated/ChatConversation.cs index 17817b0..62608fb 100644 --- a/BunqSdk/Model/Generated/ChatConversation.cs +++ b/BunqSdk/Model/Generated/ChatConversation.cs @@ -20,35 +20,30 @@ public class ChatConversation : BunqModel /// private const string OBJECT_TYPE = "ChatConversation"; - public static BunqResponse> List(ApiContext apiContext, int userId) - { - return List(apiContext, userId, new Dictionary()); - } - /// /// 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); } - public static BunqResponse Get(ApiContext apiContext, int userId, int chatConversationId) - { - return Get(apiContext, userId, chatConversationId, new Dictionary()); - } - /// /// public static BunqResponse Get(ApiContext apiContext, int userId, int chatConversationId, - 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, chatConversationId), customHeaders); + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, chatConversationId), + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/ChatMessage.cs b/BunqSdk/Model/Generated/ChatMessage.cs index 8c592e6..17f467a 100644 --- a/BunqSdk/Model/Generated/ChatMessage.cs +++ b/BunqSdk/Model/Generated/ChatMessage.cs @@ -69,19 +69,17 @@ public class ChatMessage : BunqModel [JsonProperty(PropertyName = "content")] public BunqModel Content { get; private set; } - public static BunqResponse> List(ApiContext apiContext, int userId, int chatConversationId) - { - return List(apiContext, userId, chatConversationId, new Dictionary()); - } - /// /// Get all the messages that are part of a specific conversation. /// public static BunqResponse> List(ApiContext apiContext, int userId, int chatConversationId, - 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, chatConversationId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, chatConversationId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); diff --git a/BunqSdk/Model/Generated/ChatMessageAttachment.cs b/BunqSdk/Model/Generated/ChatMessageAttachment.cs index 23777cd..b4e02ae 100644 --- a/BunqSdk/Model/Generated/ChatMessageAttachment.cs +++ b/BunqSdk/Model/Generated/ChatMessageAttachment.cs @@ -34,18 +34,14 @@ public class ChatMessageAttachment : BunqModel [JsonProperty(PropertyName = "id")] public int? Id { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int chatConversationId) - { - return Create(apiContext, requestMap, userId, chatConversationId, new Dictionary()); - } - /// /// Create a new message holding a file attachment to a specific conversation. /// public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int chatConversationId, IDictionary customHeaders) + int userId, int chatConversationId, 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, chatConversationId), diff --git a/BunqSdk/Model/Generated/ChatMessageText.cs b/BunqSdk/Model/Generated/ChatMessageText.cs index 66629f4..0c1f515 100644 --- a/BunqSdk/Model/Generated/ChatMessageText.cs +++ b/BunqSdk/Model/Generated/ChatMessageText.cs @@ -34,18 +34,14 @@ public class ChatMessageText : BunqModel [JsonProperty(PropertyName = "id")] public int? Id { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int chatConversationId) - { - return Create(apiContext, requestMap, userId, chatConversationId, new Dictionary()); - } - /// /// Add a new text message to a specific conversation. /// public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int chatConversationId, IDictionary customHeaders) + int userId, int chatConversationId, 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, chatConversationId), diff --git a/BunqSdk/Model/Generated/Customer.cs b/BunqSdk/Model/Generated/Customer.cs new file mode 100644 index 0000000..9f349fc --- /dev/null +++ b/BunqSdk/Model/Generated/Customer.cs @@ -0,0 +1,99 @@ +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 +{ + /// + /// Used to view a customer. + /// + public class Customer : BunqModel + { + /// + /// Field constants. + /// + public const string FIELD_BILLING_ACCOUNT_ID = "billing_account_id"; + + /// + /// Endpoint constants. + /// + private const string ENDPOINT_URL_LISTING = "user/{0}/customer"; + private const string ENDPOINT_URL_READ = "user/{0}/customer/{1}"; + private const string ENDPOINT_URL_UPDATE = "user/{0}/customer/{1}"; + + /// + /// Object type. + /// + private const string OBJECT_TYPE = "Customer"; + + /// + /// The id of the customer. + /// + [JsonProperty(PropertyName = "id")] + public int? Id { get; private set; } + + /// + /// The timestamp of the customer object's creation. + /// + [JsonProperty(PropertyName = "created")] + public string Created { get; private set; } + + /// + /// The timestamp of the customer object's last update. + /// + [JsonProperty(PropertyName = "updated")] + public string Updated { get; private set; } + + /// + /// The primary billing account account's id. + /// + [JsonProperty(PropertyName = "billing_account_id")] + public string BillingAccountId { get; private set; } + + /// + /// + 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); + } + + /// + /// + public static BunqResponse Get(ApiContext apiContext, int userId, int customerId, + IDictionary customHeaders = null) + { + if (customHeaders == null) customHeaders = new Dictionary(); + + var apiClient = new ApiClient(apiContext); + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, customerId), + new Dictionary(), customHeaders); + + return FromJson(responseRaw, OBJECT_TYPE); + } + + /// + /// + public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, + int userId, int customerId, 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.Put(string.Format(ENDPOINT_URL_UPDATE, userId, customerId), requestBytes, + customHeaders); + + return ProcessForId(responseRaw); + } + } +} diff --git a/BunqSdk/Model/Generated/CustomerLimit.cs b/BunqSdk/Model/Generated/CustomerLimit.cs new file mode 100644 index 0000000..37ba240 --- /dev/null +++ b/BunqSdk/Model/Generated/CustomerLimit.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using Bunq.Sdk.Context; +using Bunq.Sdk.Http; +using Newtonsoft.Json; + +namespace Bunq.Sdk.Model.Generated +{ + /// + /// Show the limits for the authenticated user. + /// + public class CustomerLimit : BunqModel + { + /// + /// Endpoint constants. + /// + private const string ENDPOINT_URL_LISTING = "user/{0}/limit"; + + /// + /// Object type. + /// + private const string OBJECT_TYPE = "CustomerLimit"; + + /// + /// The limit of monetary accounts. + /// + [JsonProperty(PropertyName = "limit_monetary_account")] + public int? LimitMonetaryAccount { get; private set; } + + /// + /// The limit of Maestro cards. + /// + [JsonProperty(PropertyName = "limit_card_debit_maestro")] + public int? LimitCardDebitMaestro { get; private set; } + + /// + /// The limit of MasterCard cards. + /// + [JsonProperty(PropertyName = "limit_card_debit_mastercard")] + public int? LimitCardDebitMastercard { get; private set; } + + /// + /// Get all limits 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/CustomerStatementExport.cs b/BunqSdk/Model/Generated/CustomerStatementExport.cs index 27aee4a..eff1708 100644 --- a/BunqSdk/Model/Generated/CustomerStatementExport.cs +++ b/BunqSdk/Model/Generated/CustomerStatementExport.cs @@ -94,17 +94,13 @@ public class CustomerStatementExport : BunqModel [JsonProperty(PropertyName = "alias_monetary_account")] public MonetaryAccountReference AliasMonetaryAccount { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId) - { - return Create(apiContext, requestMap, userId, monetaryAccountId, new Dictionary()); - } - /// /// 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,56 +109,44 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Get(ApiContext apiContext, int userId, - int monetaryAccountId, int customerStatementExportId) - { - return Get(apiContext, userId, monetaryAccountId, customerStatementExportId, - new Dictionary()); - } - /// /// public static BunqResponse Get(ApiContext apiContext, int userId, - int monetaryAccountId, int customerStatementExportId, IDictionary customHeaders) + int monetaryAccountId, int customerStatementExportId, 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, customerStatementExportId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId) - { - return List(apiContext, userId, monetaryAccountId, new Dictionary()); - } - /// /// public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, IDictionary customHeaders) + int monetaryAccountId, 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, monetaryAccountId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } - public static BunqResponse Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int customerStatementExportId) - { - return Delete(apiContext, userId, monetaryAccountId, customerStatementExportId, - new Dictionary()); - } - /// /// public static BunqResponse Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int customerStatementExportId, IDictionary customHeaders) + int customerStatementExportId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Delete( diff --git a/BunqSdk/Model/Generated/CustomerStatementExportContent.cs b/BunqSdk/Model/Generated/CustomerStatementExportContent.cs index c8d0fa0..70913c0 100644 --- a/BunqSdk/Model/Generated/CustomerStatementExportContent.cs +++ b/BunqSdk/Model/Generated/CustomerStatementExportContent.cs @@ -21,21 +21,17 @@ public class CustomerStatementExportContent : BunqModel /// private const string OBJECT_TYPE = "CustomerStatementExportContent"; - public static BunqResponse List(ApiContext apiContext, int userId, int monetaryAccountId, - int customerStatementId) - { - return List(apiContext, userId, monetaryAccountId, customerStatementId, new Dictionary()); - } - /// /// public static BunqResponse List(ApiContext apiContext, int userId, int monetaryAccountId, - int customerStatementId, IDictionary customHeaders) + int customerStatementId, 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, customerStatementId), - customHeaders); + new Dictionary(), customHeaders); return new BunqResponse(responseRaw.BodyBytes, responseRaw.Headers); } diff --git a/BunqSdk/Model/Generated/Device.cs b/BunqSdk/Model/Generated/Device.cs index b796c54..9aadf41 100644 --- a/BunqSdk/Model/Generated/Device.cs +++ b/BunqSdk/Model/Generated/Device.cs @@ -31,35 +31,32 @@ public class Device : BunqModel [JsonProperty(PropertyName = "DeviceServer")] public DeviceServer DeviceServer { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int deviceId) - { - return Get(apiContext, deviceId, new Dictionary()); - } - /// /// Get a single Device. A Device is either a DevicePhone or a DeviceServer. /// public static BunqResponse Get(ApiContext apiContext, int deviceId, - 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, deviceId), customHeaders); + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, deviceId), + new Dictionary(), customHeaders); return FromJson(responseRaw); } - public static BunqResponse> List(ApiContext apiContext) - { - return List(apiContext, new Dictionary()); - } - /// /// Get a collection of Devices. A Device is either a DevicePhone or a DeviceServer. /// - public static BunqResponse> List(ApiContext apiContext, IDictionary customHeaders) + public static BunqResponse> List(ApiContext apiContext, + 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(ENDPOINT_URL_LISTING, customHeaders); + var responseRaw = apiClient.Get(ENDPOINT_URL_LISTING, urlParams, customHeaders); return FromJsonList(responseRaw); } diff --git a/BunqSdk/Model/Generated/DeviceServer.cs b/BunqSdk/Model/Generated/DeviceServer.cs index 4f46ed6..8894405 100644 --- a/BunqSdk/Model/Generated/DeviceServer.cs +++ b/BunqSdk/Model/Generated/DeviceServer.cs @@ -68,19 +68,16 @@ public class DeviceServer : BunqModel [JsonProperty(PropertyName = "status")] public string Status { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap) - { - return Create(apiContext, requestMap, new Dictionary()); - } - /// /// Create a new DeviceServer. Provide the Installation token in the "X-Bunq-Client-Authentication" header. And /// sign this request with the key of which you used the public part to create the Installation. Your API key /// will be bound to the ip address of this DeviceServer. /// 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); @@ -88,36 +85,32 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Get(ApiContext apiContext, int deviceServerId) - { - return Get(apiContext, deviceServerId, new Dictionary()); - } - /// /// Get one of your DeviceServers. /// public static BunqResponse Get(ApiContext apiContext, int deviceServerId, - 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, deviceServerId), customHeaders); + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, deviceServerId), + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext) - { - return List(apiContext, new Dictionary()); - } - /// /// Get a collection of all the DeviceServers you have created. /// public static BunqResponse> List(ApiContext apiContext, - 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(ENDPOINT_URL_LISTING, customHeaders); + var responseRaw = apiClient.Get(ENDPOINT_URL_LISTING, urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/DraftPayment.cs b/BunqSdk/Model/Generated/DraftPayment.cs new file mode 100644 index 0000000..af7c91f --- /dev/null +++ b/BunqSdk/Model/Generated/DraftPayment.cs @@ -0,0 +1,150 @@ +using System.Collections.Generic; +using System.Text; +using Bunq.Sdk.Context; +using Bunq.Sdk.Http; +using Bunq.Sdk.Json; +using Bunq.Sdk.Model.Generated.Object; +using Newtonsoft.Json; + +namespace Bunq.Sdk.Model.Generated +{ + /// + /// A DraftPayment is like a regular Payment, but it needs to be accepted by the sending party before the actual + /// Payment is done. + /// + public class DraftPayment : BunqModel + { + /// + /// Field constants. + /// + public const string FIELD_STATUS = "status"; + public const string FIELD_ENTRIES = "entries"; + public const string FIELD_PREVIOUS_UPDATED_TIMESTAMP = "previous_updated_timestamp"; + public const string FIELD_NUMBER_OF_REQUIRED_ACCEPTS = "number_of_required_accepts"; + + /// + /// Endpoint constants. + /// + private const string ENDPOINT_URL_CREATE = "user/{0}/monetary-account/{1}/draft-payment"; + private const string ENDPOINT_URL_UPDATE = "user/{0}/monetary-account/{1}/draft-payment/{2}"; + private const string ENDPOINT_URL_LISTING = "user/{0}/monetary-account/{1}/draft-payment"; + private const string ENDPOINT_URL_READ = "user/{0}/monetary-account/{1}/draft-payment/{2}"; + + /// + /// Object type. + /// + private const string OBJECT_TYPE = "DraftPayment"; + + /// + /// The id of the DraftPayment. + /// + [JsonProperty(PropertyName = "id")] + public int? Id { get; private set; } + + /// + /// The id of the MonetaryAccount the DraftPayment applies to. + /// + [JsonProperty(PropertyName = "monetary_account_id")] + public int? MonetaryAccountId { get; private set; } + + /// + /// The label of the User who created the DraftPayment. + /// + [JsonProperty(PropertyName = "user_alias_created")] + public LabelUser UserAliasCreated { get; private set; } + + /// + /// All responses to this draft payment. + /// + [JsonProperty(PropertyName = "responses")] + public List Responses { get; private set; } + + /// + /// The status of the DraftPayment. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; private set; } + + /// + /// The type of the DraftPayment. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// The entries in the DraftPayment. + /// + [JsonProperty(PropertyName = "entries")] + public List Entries { get; private set; } + + /// + /// The Payment or PaymentBatch. This will only be present after the DraftPayment has been accepted. + /// + [JsonProperty(PropertyName = "object")] + public BunqModel Object { get; private set; } + + /// + /// Create a new DraftPayment. + /// + public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, + 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), + requestBytes, customHeaders); + + return ProcessForId(responseRaw); + } + + /// + /// Update a DraftPayment. + /// + public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, + int userId, int monetaryAccountId, int draftPaymentId, 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.Put(string.Format(ENDPOINT_URL_UPDATE, userId, monetaryAccountId, draftPaymentId), + requestBytes, customHeaders); + + return ProcessForId(responseRaw); + } + + /// + /// Get a listing of all DraftPayments from a given MonetaryAccount. + /// + public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, + 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, monetaryAccountId), urlParams, + customHeaders); + + return FromJsonList(responseRaw, OBJECT_TYPE); + } + + /// + /// Get a specific DraftPayment. + /// + public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, + int draftPaymentId, 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, draftPaymentId), + new Dictionary(), customHeaders); + + return FromJson(responseRaw, OBJECT_TYPE); + } + } +} diff --git a/BunqSdk/Model/Generated/DraftShareInviteBank.cs b/BunqSdk/Model/Generated/DraftShareInviteBank.cs index d00ee84..3197bc7 100644 --- a/BunqSdk/Model/Generated/DraftShareInviteBank.cs +++ b/BunqSdk/Model/Generated/DraftShareInviteBank.cs @@ -77,17 +77,13 @@ public class DraftShareInviteBank : BunqModel [JsonProperty(PropertyName = "id")] public int? Id { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId) - { - return Create(apiContext, requestMap, userId, new Dictionary()); - } - /// /// 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)); var responseRaw = apiClient.Post(string.Format(ENDPOINT_URL_CREATE, userId), requestBytes, customHeaders); @@ -95,38 +91,30 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Get(ApiContext apiContext, int userId, - int draftShareInviteBankId) - { - return Get(apiContext, userId, draftShareInviteBankId, new Dictionary()); - } - /// /// Get the details of a specific draft of a share invite. /// public static BunqResponse Get(ApiContext apiContext, int userId, - int draftShareInviteBankId, IDictionary customHeaders) + int draftShareInviteBankId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, draftShareInviteBankId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse Update(ApiContext apiContext, - IDictionary requestMap, int userId, int draftShareInviteBankId) - { - return Update(apiContext, requestMap, userId, draftShareInviteBankId, new Dictionary()); - } - /// /// Update a draft share invite. When sending status CANCELLED it is possible to cancel the draft share invite. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, int userId, int draftShareInviteBankId, - 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.Put(string.Format(ENDPOINT_URL_UPDATE, userId, draftShareInviteBankId), @@ -135,18 +123,16 @@ public static BunqResponse Update(ApiContext apiContext, return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId) - { - return List(apiContext, userId, new Dictionary()); - } - /// /// 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/DraftShareInviteBankQrCodeContent.cs b/BunqSdk/Model/Generated/DraftShareInviteBankQrCodeContent.cs index 1e0a42b..6915732 100644 --- a/BunqSdk/Model/Generated/DraftShareInviteBankQrCodeContent.cs +++ b/BunqSdk/Model/Generated/DraftShareInviteBankQrCodeContent.cs @@ -20,21 +20,18 @@ public class DraftShareInviteBankQrCodeContent : BunqModel /// private const string OBJECT_TYPE = "DraftShareInviteBankQrCodeContent"; - public static BunqResponse List(ApiContext apiContext, int userId, int draftShareInviteBankId) - { - return List(apiContext, userId, draftShareInviteBankId, new Dictionary()); - } - /// /// Returns the raw content of the QR code that links to this draft share invite. The raw content is the binary /// representation of a file, without any JSON wrapping. /// public static BunqResponse List(ApiContext apiContext, int userId, int draftShareInviteBankId, - 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, userId, draftShareInviteBankId), - customHeaders); + new Dictionary(), customHeaders); return new BunqResponse(responseRaw.BodyBytes, responseRaw.Headers); } diff --git a/BunqSdk/Model/Generated/ExportAnnualOverview.cs b/BunqSdk/Model/Generated/ExportAnnualOverview.cs index 44880bb..48fdff3 100644 --- a/BunqSdk/Model/Generated/ExportAnnualOverview.cs +++ b/BunqSdk/Model/Generated/ExportAnnualOverview.cs @@ -61,18 +61,14 @@ public class ExportAnnualOverview : BunqModel [JsonProperty(PropertyName = "alias_user")] public LabelUser AliasUser { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId) - { - return Create(apiContext, requestMap, userId, new Dictionary()); - } - /// /// Create a new annual overview for a specific year. An overview can be generated only for a past year. /// 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)); var responseRaw = apiClient.Post(string.Format(ENDPOINT_URL_CREATE, userId), requestBytes, customHeaders); @@ -80,38 +76,32 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Get(ApiContext apiContext, int userId, - int exportAnnualOverviewId) - { - return Get(apiContext, userId, exportAnnualOverviewId, new Dictionary()); - } - /// /// Get an annual overview for a user by its id. /// public static BunqResponse Get(ApiContext apiContext, int userId, - int exportAnnualOverviewId, IDictionary customHeaders) + int exportAnnualOverviewId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, exportAnnualOverviewId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId) - { - return List(apiContext, userId, new Dictionary()); - } - /// /// List all the annual overviews for a 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/ExportAnnualOverviewContent.cs b/BunqSdk/Model/Generated/ExportAnnualOverviewContent.cs index d201666..593488f 100644 --- a/BunqSdk/Model/Generated/ExportAnnualOverviewContent.cs +++ b/BunqSdk/Model/Generated/ExportAnnualOverviewContent.cs @@ -20,20 +20,17 @@ public class ExportAnnualOverviewContent : BunqModel /// private const string OBJECT_TYPE = "ExportAnnualOverviewContent"; - public static BunqResponse List(ApiContext apiContext, int userId, int exportAnnualOverviewId) - { - return List(apiContext, userId, exportAnnualOverviewId, new Dictionary()); - } - /// /// Used to retrieve the raw content of an annual overview. /// public static BunqResponse List(ApiContext apiContext, int userId, int exportAnnualOverviewId, - 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, userId, exportAnnualOverviewId), - customHeaders); + new Dictionary(), customHeaders); return new BunqResponse(responseRaw.BodyBytes, responseRaw.Headers); } diff --git a/BunqSdk/Model/Generated/InstallationServerPublicKey.cs b/BunqSdk/Model/Generated/InstallationServerPublicKey.cs index 5a519b8..1c88f64 100644 --- a/BunqSdk/Model/Generated/InstallationServerPublicKey.cs +++ b/BunqSdk/Model/Generated/InstallationServerPublicKey.cs @@ -27,19 +27,18 @@ public class InstallationServerPublicKey : BunqModel [JsonProperty(PropertyName = "server_public_key")] public string ServerPublicKey { get; private set; } - public static BunqResponse> List(ApiContext apiContext, int installationId) - { - return List(apiContext, installationId, new Dictionary()); - } - /// /// Show the ServerPublicKey for this Installation. /// public static BunqResponse> List(ApiContext apiContext, int installationId, - 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, installationId), customHeaders); + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, installationId), urlParams, + customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/Invoice.cs b/BunqSdk/Model/Generated/Invoice.cs index 76c6fcc..ed1d218 100644 --- a/BunqSdk/Model/Generated/Invoice.cs +++ b/BunqSdk/Model/Generated/Invoice.cs @@ -125,36 +125,31 @@ public class Invoice : BunqModel [JsonProperty(PropertyName = "vat_number")] public string VatNumber { get; private set; } - public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId) - { - return List(apiContext, userId, monetaryAccountId, new Dictionary()); - } - /// /// public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - 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, monetaryAccountId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, int invoiceId) - { - return Get(apiContext, userId, monetaryAccountId, invoiceId, new Dictionary()); - } - /// /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, int invoiceId, - 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, monetaryAccountId, invoiceId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/InvoiceByUser.cs b/BunqSdk/Model/Generated/InvoiceByUser.cs index c7e011b..6af6784 100644 --- a/BunqSdk/Model/Generated/InvoiceByUser.cs +++ b/BunqSdk/Model/Generated/InvoiceByUser.cs @@ -118,34 +118,30 @@ public class InvoiceByUser : BunqModel [JsonProperty(PropertyName = "vat_number")] public string VatNumber { get; private set; } - public static BunqResponse> List(ApiContext apiContext, int userId) - { - return List(apiContext, userId, new Dictionary()); - } - /// /// 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); } - public static BunqResponse Get(ApiContext apiContext, int userId, int invoiceByUserId) - { - return Get(apiContext, userId, invoiceByUserId, new Dictionary()); - } - /// /// public static BunqResponse Get(ApiContext apiContext, int userId, int invoiceByUserId, - 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, invoiceByUserId), customHeaders); + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, invoiceByUserId), + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/MonetaryAccount.cs b/BunqSdk/Model/Generated/MonetaryAccount.cs index 5aa9380..02ecb96 100644 --- a/BunqSdk/Model/Generated/MonetaryAccount.cs +++ b/BunqSdk/Model/Generated/MonetaryAccount.cs @@ -29,36 +29,32 @@ public class MonetaryAccount : BunqModel [JsonProperty(PropertyName = "MonetaryAccountBank")] public MonetaryAccountBank MonetaryAccountBank { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId) - { - return Get(apiContext, userId, monetaryAccountId, new Dictionary()); - } - /// /// Get a specific MonetaryAccount. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - 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, monetaryAccountId), customHeaders); + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, monetaryAccountId), + new Dictionary(), customHeaders); return FromJson(responseRaw); } - public static BunqResponse> List(ApiContext apiContext, int userId) - { - return List(apiContext, userId, new Dictionary()); - } - /// /// Get a collection of all your MonetaryAccounts. /// 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); } diff --git a/BunqSdk/Model/Generated/MonetaryAccountBank.cs b/BunqSdk/Model/Generated/MonetaryAccountBank.cs index d6f75ea..1c9327e 100644 --- a/BunqSdk/Model/Generated/MonetaryAccountBank.cs +++ b/BunqSdk/Model/Generated/MonetaryAccountBank.cs @@ -172,18 +172,14 @@ public class MonetaryAccountBank : BunqModel [JsonProperty(PropertyName = "setting")] public MonetaryAccountSetting Setting { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId) - { - return Create(apiContext, requestMap, userId, new Dictionary()); - } - /// /// Create new MonetaryAccountBank. /// 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)); var responseRaw = apiClient.Post(string.Format(ENDPOINT_URL_CREATE, userId), requestBytes, customHeaders); @@ -191,37 +187,29 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Get(ApiContext apiContext, int userId, - int monetaryAccountBankId) - { - return Get(apiContext, userId, monetaryAccountBankId, new Dictionary()); - } - /// /// Get a specific MonetaryAccountBank. /// public static BunqResponse Get(ApiContext apiContext, int userId, - int monetaryAccountBankId, IDictionary customHeaders) + int monetaryAccountBankId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, monetaryAccountBankId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountBankId) - { - return Update(apiContext, requestMap, userId, monetaryAccountBankId, new Dictionary()); - } - /// /// Update a specific existing MonetaryAccountBank. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountBankId, IDictionary customHeaders) + int userId, int monetaryAccountBankId, 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.Put(string.Format(ENDPOINT_URL_UPDATE, userId, monetaryAccountBankId), @@ -230,19 +218,17 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary> List(ApiContext apiContext, int userId) - { - return List(apiContext, userId, new Dictionary()); - } - /// /// Gets a listing of all MonetaryAccountBanks of a given 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/Object/Address.cs b/BunqSdk/Model/Generated/Object/Address.cs index 7e38889..4adbcb0 100644 --- a/BunqSdk/Model/Generated/Object/Address.cs +++ b/BunqSdk/Model/Generated/Object/Address.cs @@ -42,6 +42,12 @@ public class Address : BunqModel [JsonProperty(PropertyName = "country")] public string Country { get; set; } + /// + /// The province according to local standard. + /// + [JsonProperty(PropertyName = "province")] + public string Province { get; set; } + public Address(string street, string houseNumber, string postalCode, string city, string country) { Street = street; diff --git a/BunqSdk/Model/Generated/Object/CardCountryPermission.cs b/BunqSdk/Model/Generated/Object/CardCountryPermission.cs index 301529d..c8d3e8f 100644 --- a/BunqSdk/Model/Generated/Object/CardCountryPermission.cs +++ b/BunqSdk/Model/Generated/Object/CardCountryPermission.cs @@ -18,6 +18,12 @@ public class CardCountryPermission : BunqModel [JsonProperty(PropertyName = "expiry_time")] public string ExpiryTime { get; set; } + /// + /// The id of the card country permission entry. + /// + [JsonProperty(PropertyName = "id")] + public int? Id { get; set; } + public CardCountryPermission(string country) { Country = country; diff --git a/BunqSdk/Model/Generated/Object/CardLimit.cs b/BunqSdk/Model/Generated/Object/CardLimit.cs index c831091..762744b 100644 --- a/BunqSdk/Model/Generated/Object/CardLimit.cs +++ b/BunqSdk/Model/Generated/Object/CardLimit.cs @@ -25,6 +25,12 @@ public class CardLimit : BunqModel [JsonProperty(PropertyName = "type")] public string Type { get; set; } + /// + /// The id of the card limit entry. + /// + [JsonProperty(PropertyName = "id")] + public int? Id { get; set; } + public CardLimit(string dailyLimit, string currency, string type) { DailyLimit = dailyLimit; diff --git a/BunqSdk/Model/Generated/Object/DraftPaymentEntry.cs b/BunqSdk/Model/Generated/Object/DraftPaymentEntry.cs new file mode 100644 index 0000000..7d3ac30 --- /dev/null +++ b/BunqSdk/Model/Generated/Object/DraftPaymentEntry.cs @@ -0,0 +1,73 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Bunq.Sdk.Model.Generated.Object +{ + /// + /// + public class DraftPaymentEntry : BunqModel + { + /// + /// The amount of the payment. + /// + [JsonProperty(PropertyName = "amount")] + public Amount Amount { get; set; } + + /// + /// The LabelMonetaryAccount containing the public information of the other (counterparty) side of the + /// DraftPayment. + /// + [JsonProperty(PropertyName = "counterparty_alias")] + public MonetaryAccountReference CounterpartyAlias { get; set; } + + /// + /// The description for the DraftPayment. Maximum 140 characters for DraftPayments to external IBANs, 9000 + /// characters for DraftPayments to only other bunq MonetaryAccounts. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Optional data to be included with the Payment specific to the merchant. + /// + [JsonProperty(PropertyName = "merchant_reference")] + public string MerchantReference { get; set; } + + /// + /// The Attachments attached to the DraftPayment. + /// + [JsonProperty(PropertyName = "attachment")] + public List Attachment { get; set; } + + /// + /// Whether or not sending a bunq.to payment is allowed. + /// + [JsonProperty(PropertyName = "allow_bunqto")] + public bool? AllowBunqto { get; set; } + + /// + /// The id of the draft payment entry. + /// + [JsonProperty(PropertyName = "id")] + public int? Id { get; set; } + + /// + /// The LabelMonetaryAccount containing the public information of 'this' (party) side of the DraftPayment. + /// + [JsonProperty(PropertyName = "alias")] + public MonetaryAccountReference Alias { get; set; } + + /// + /// The type of the draft payment entry. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + public DraftPaymentEntry(Amount amount, MonetaryAccountReference counterpartyAlias, string description) + { + Amount = amount; + CounterpartyAlias = counterpartyAlias; + Description = description; + } + } +} diff --git a/BunqSdk/Model/Generated/Object/DraftPaymentResponse.cs b/BunqSdk/Model/Generated/Object/DraftPaymentResponse.cs new file mode 100644 index 0000000..c554244 --- /dev/null +++ b/BunqSdk/Model/Generated/Object/DraftPaymentResponse.cs @@ -0,0 +1,21 @@ +using Newtonsoft.Json; + +namespace Bunq.Sdk.Model.Generated.Object +{ + /// + /// + public class DraftPaymentResponse : BunqModel + { + /// + /// The status with which was responded. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// The user that responded to the DraftPayment. + /// + [JsonProperty(PropertyName = "user_alias_created")] + public LabelUser UserAliasCreated { get; set; } + } +} diff --git a/BunqSdk/Model/Generated/Object/LabelMonetaryAccount.cs b/BunqSdk/Model/Generated/Object/LabelMonetaryAccount.cs index b829d62..0e60388 100644 --- a/BunqSdk/Model/Generated/Object/LabelMonetaryAccount.cs +++ b/BunqSdk/Model/Generated/Object/LabelMonetaryAccount.cs @@ -41,5 +41,11 @@ public class LabelMonetaryAccount : BunqModel /// [JsonProperty(PropertyName = "bunq_me")] public MonetaryAccountReference BunqMe { get; set; } + + /// + /// Whether or not the monetary account is light. + /// + [JsonProperty(PropertyName = "is_light")] + public bool? IsLight { get; set; } } } diff --git a/BunqSdk/Model/Generated/Payment.cs b/BunqSdk/Model/Generated/Payment.cs index d224f7f..6c8cea1 100644 --- a/BunqSdk/Model/Generated/Payment.cs +++ b/BunqSdk/Model/Generated/Payment.cs @@ -180,18 +180,14 @@ public class Payment : BunqModel [JsonProperty(PropertyName = "allow_chat")] public bool? AllowChat { 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 Payment. /// 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), @@ -200,37 +196,32 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Get(ApiContext apiContext, int userId, int monetaryAccountId, int paymentId) - { - return Get(apiContext, userId, monetaryAccountId, paymentId, new Dictionary()); - } - /// /// Get a specific previous Payment. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, int paymentId, - 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, monetaryAccountId, paymentId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId) - { - return List(apiContext, userId, monetaryAccountId, new Dictionary()); - } - /// /// Get a listing of all Payments performed on a given MonetaryAccount (incoming and outgoing). /// public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - 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, monetaryAccountId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); diff --git a/BunqSdk/Model/Generated/PaymentBatch.cs b/BunqSdk/Model/Generated/PaymentBatch.cs index 8f7f53d..a955f0a 100644 --- a/BunqSdk/Model/Generated/PaymentBatch.cs +++ b/BunqSdk/Model/Generated/PaymentBatch.cs @@ -37,18 +37,14 @@ public class PaymentBatch : BunqModel [JsonProperty(PropertyName = "payments")] public List Payments { 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 payment batch by sending an array of single payment objects, that will become part of the batch. /// 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), @@ -57,19 +53,14 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int paymentBatchId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, paymentBatchId, - new Dictionary()); - } - /// /// Revoke a bunq.to payment batch. The status of all the payments will be set to REVOKED. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int paymentBatchId, IDictionary customHeaders) + int userId, int monetaryAccountId, int paymentBatchId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap)); var responseRaw = @@ -79,38 +70,32 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary Get(ApiContext apiContext, int userId, int monetaryAccountId, - int paymentBatchId) - { - return Get(apiContext, userId, monetaryAccountId, paymentBatchId, new Dictionary()); - } - /// /// Return the details of a specific payment batch. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int paymentBatchId, IDictionary customHeaders) + int paymentBatchId, 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, paymentBatchId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId) - { - return List(apiContext, userId, monetaryAccountId, new Dictionary()); - } - /// /// Return all the payment batches for a monetary account. /// public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - 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, monetaryAccountId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); diff --git a/BunqSdk/Model/Generated/PaymentChat.cs b/BunqSdk/Model/Generated/PaymentChat.cs index 6c8eb5d..a938f76 100644 --- a/BunqSdk/Model/Generated/PaymentChat.cs +++ b/BunqSdk/Model/Generated/PaymentChat.cs @@ -53,19 +53,14 @@ public class PaymentChat : BunqModel [JsonProperty(PropertyName = "unread_message_count")] public int? UnreadMessageCount { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int paymentId) - { - return Create(apiContext, requestMap, userId, monetaryAccountId, paymentId, - new Dictionary()); - } - /// /// Create a chat for a specific payment. /// public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int paymentId, IDictionary customHeaders) + int userId, int monetaryAccountId, int paymentId, 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, paymentId), @@ -74,20 +69,15 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int paymentId, int paymentChatId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, paymentId, paymentChatId, - new Dictionary()); - } - /// /// Update the last read message in the chat of a specific payment. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, int userId, int monetaryAccountId, int paymentId, int paymentChatId, - 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 = @@ -97,21 +87,19 @@ public static BunqResponse Update(ApiContext apiContext, IDictionar return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - int paymentId) - { - return List(apiContext, userId, monetaryAccountId, paymentId, new Dictionary()); - } - /// /// Get the chat for a specific payment. /// public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - int paymentId, IDictionary customHeaders) + int paymentId, 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, monetaryAccountId, paymentId), - customHeaders); + urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/PermittedIp.cs b/BunqSdk/Model/Generated/PermittedIp.cs index 10a1f4c..1f6fc96 100644 --- a/BunqSdk/Model/Generated/PermittedIp.cs +++ b/BunqSdk/Model/Generated/PermittedIp.cs @@ -44,36 +44,28 @@ public class PermittedIp : BunqModel [JsonProperty(PropertyName = "status")] public string Status { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int userId, int credentialPasswordIpId, - int permittedIpId) - { - return Get(apiContext, userId, credentialPasswordIpId, permittedIpId, new Dictionary()); - } - /// /// public static BunqResponse Get(ApiContext apiContext, int userId, int credentialPasswordIpId, - int permittedIpId, IDictionary customHeaders) + int permittedIpId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, credentialPasswordIpId, permittedIpId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int credentialPasswordIpId) - { - return Create(apiContext, requestMap, userId, credentialPasswordIpId, new Dictionary()); - } - /// /// public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int credentialPasswordIpId, IDictionary customHeaders) + int userId, int credentialPasswordIpId, 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, credentialPasswordIpId), @@ -82,36 +74,29 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary> List(ApiContext apiContext, int userId, - int credentialPasswordIpId) - { - return List(apiContext, userId, credentialPasswordIpId, new Dictionary()); - } - /// /// public static BunqResponse> List(ApiContext apiContext, int userId, - int credentialPasswordIpId, IDictionary customHeaders) + int credentialPasswordIpId, 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, credentialPasswordIpId), - customHeaders); + urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } - public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userId, int credentialPasswordIpId, int permittedIpId) - { - return Update(apiContext, requestMap, userId, credentialPasswordIpId, permittedIpId, - new Dictionary()); - } - /// /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userId, int credentialPasswordIpId, int permittedIpId, IDictionary customHeaders) + int userId, int credentialPasswordIpId, int permittedIpId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap)); var responseRaw = diff --git a/BunqSdk/Model/Generated/RequestInquiry.cs b/BunqSdk/Model/Generated/RequestInquiry.cs index 1fb0e60..68dfe6a 100644 --- a/BunqSdk/Model/Generated/RequestInquiry.cs +++ b/BunqSdk/Model/Generated/RequestInquiry.cs @@ -196,18 +196,14 @@ public class RequestInquiry : BunqModel [JsonProperty(PropertyName = "allow_chat")] public bool? AllowChat { 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 payment request. /// 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), @@ -216,19 +212,14 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int requestInquiryId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, requestInquiryId, - new Dictionary()); - } - /// /// Revoke a request for payment, by updating the status to REVOKED. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int requestInquiryId, IDictionary customHeaders) + int userId, int monetaryAccountId, int requestInquiryId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap)); var responseRaw = @@ -238,40 +229,34 @@ public static BunqResponse Update(ApiContext apiContext, IDictio return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId) - { - return List(apiContext, userId, monetaryAccountId, new Dictionary()); - } - /// /// Get all payment requests for a user's monetary account. /// public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - 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, monetaryAccountId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int requestInquiryId) - { - return Get(apiContext, userId, monetaryAccountId, requestInquiryId, new Dictionary()); - } - /// /// Get the details of a specific payment request, including its status. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int requestInquiryId, IDictionary customHeaders) + int requestInquiryId, 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, requestInquiryId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/RequestInquiryBatch.cs b/BunqSdk/Model/Generated/RequestInquiryBatch.cs index 8a62471..63b6fd7 100644 --- a/BunqSdk/Model/Generated/RequestInquiryBatch.cs +++ b/BunqSdk/Model/Generated/RequestInquiryBatch.cs @@ -45,18 +45,14 @@ public class RequestInquiryBatch : BunqModel [JsonProperty(PropertyName = "total_amount_inquired")] public Amount TotalAmountInquired { 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 request batch by sending an array of single request objects, that will become part of the batch. /// 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), @@ -65,19 +61,15 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int requestInquiryBatchId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, requestInquiryBatchId, - new Dictionary()); - } - /// /// Revoke a request batch. The status of all the requests will be set to REVOKED. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int requestInquiryBatchId, IDictionary customHeaders) + int userId, int monetaryAccountId, int requestInquiryBatchId, + IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap)); var responseRaw = @@ -87,40 +79,34 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary Get(ApiContext apiContext, int userId, int monetaryAccountId, - int requestInquiryBatchId) - { - return Get(apiContext, userId, monetaryAccountId, requestInquiryBatchId, new Dictionary()); - } - /// /// Return the details of a specific request batch. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int requestInquiryBatchId, IDictionary customHeaders) + int requestInquiryBatchId, 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, requestInquiryBatchId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId) - { - return List(apiContext, userId, monetaryAccountId, new Dictionary()); - } - /// /// Return all the request batches for a monetary account. /// public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, IDictionary customHeaders) + int monetaryAccountId, 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, monetaryAccountId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); diff --git a/BunqSdk/Model/Generated/RequestInquiryChat.cs b/BunqSdk/Model/Generated/RequestInquiryChat.cs index 2bc84be..f288594 100644 --- a/BunqSdk/Model/Generated/RequestInquiryChat.cs +++ b/BunqSdk/Model/Generated/RequestInquiryChat.cs @@ -56,19 +56,14 @@ public class RequestInquiryChat : BunqModel [JsonProperty(PropertyName = "unread_message_count")] public int? UnreadMessageCount { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int requestInquiryId) - { - return Create(apiContext, requestMap, userId, monetaryAccountId, requestInquiryId, - new Dictionary()); - } - /// /// Create a chat for a specific request inquiry. /// public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int requestInquiryId, IDictionary customHeaders) + int userId, int monetaryAccountId, int requestInquiryId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap)); var responseRaw = @@ -78,21 +73,15 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Update(ApiContext apiContext, - IDictionary requestMap, int userId, int monetaryAccountId, int requestInquiryId, - int requestInquiryChatId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, requestInquiryId, requestInquiryChatId, - new Dictionary()); - } - /// /// Update the last read message in the chat of a specific request inquiry. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, int userId, int monetaryAccountId, int requestInquiryId, - int requestInquiryChatId, IDictionary customHeaders) + int requestInquiryChatId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap)); var responseRaw = @@ -103,22 +92,20 @@ public static BunqResponse Update(ApiContext apiContext, return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, int requestInquiryId) - { - return List(apiContext, userId, monetaryAccountId, requestInquiryId, new Dictionary()); - } - /// /// Get the chat for a specific request inquiry. /// public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, int requestInquiryId, IDictionary customHeaders) + int monetaryAccountId, int requestInquiryId, 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, monetaryAccountId, requestInquiryId), - customHeaders); + urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/RequestResponse.cs b/BunqSdk/Model/Generated/RequestResponse.cs index 19ac913..0a8a1d6 100644 --- a/BunqSdk/Model/Generated/RequestResponse.cs +++ b/BunqSdk/Model/Generated/RequestResponse.cs @@ -135,7 +135,7 @@ public class RequestResponse : BunqModel public Geolocation Geolocation { get; private set; } /// - /// The type of the RequestInquiry. Can be DIRECT_DEBIT, IDEAL or INTERNAL. + /// The type of the RequestInquiry. Can be DIRECT_DEBIT, DIRECT_DEBIT_B2B, IDEAL or INTERNAL. /// [JsonProperty(PropertyName = "type")] public string Type { get; private set; } @@ -171,26 +171,33 @@ public class RequestResponse : BunqModel [JsonProperty(PropertyName = "allow_chat")] public bool? AllowChat { get; private set; } + /// + /// The credit scheme id provided by the counterparty for DIRECT_DEBIT inquiries. + /// + [JsonProperty(PropertyName = "credit_scheme_identifier")] + public string CreditSchemeIdentifier { get; private set; } + + /// + /// The mandate id provided by the counterparty for DIRECT_DEBIT inquiries. + /// + [JsonProperty(PropertyName = "mandate_identifier")] + public string MandateIdentifier { get; private set; } + /// /// The whitelist id for this action or null. /// [JsonProperty(PropertyName = "eligible_whitelist_id")] public int? EligibleWhitelistId { get; private set; } - public static BunqResponse Update(ApiContext apiContext, - IDictionary requestMap, int userId, int monetaryAccountId, int requestResponseId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, requestResponseId, - new Dictionary()); - } - /// /// Update the status to accept or reject the RequestResponse. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, int userId, int monetaryAccountId, int requestResponseId, - 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 = @@ -200,40 +207,34 @@ public static BunqResponse Update(ApiContext apiContext, return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId) - { - return List(apiContext, userId, monetaryAccountId, new Dictionary()); - } - /// /// Get all RequestResponses for a MonetaryAccount. /// public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - 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, monetaryAccountId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int requestResponseId) - { - return Get(apiContext, userId, monetaryAccountId, requestResponseId, new Dictionary()); - } - /// /// Get the details for a specific existing RequestResponse. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int requestResponseId, IDictionary customHeaders) + int requestResponseId, 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, requestResponseId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/RequestResponseChat.cs b/BunqSdk/Model/Generated/RequestResponseChat.cs index 1f5f4e2..7500f64 100644 --- a/BunqSdk/Model/Generated/RequestResponseChat.cs +++ b/BunqSdk/Model/Generated/RequestResponseChat.cs @@ -56,19 +56,14 @@ public class RequestResponseChat : BunqModel [JsonProperty(PropertyName = "unread_message_count")] public int? UnreadMessageCount { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int requestResponseId) - { - return Create(apiContext, requestMap, userId, monetaryAccountId, requestResponseId, - new Dictionary()); - } - /// /// Create a chat for a specific request response. /// public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int requestResponseId, IDictionary customHeaders) + int userId, int monetaryAccountId, int requestResponseId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap)); var responseRaw = @@ -78,21 +73,15 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Update(ApiContext apiContext, - IDictionary requestMap, int userId, int monetaryAccountId, int requestResponseId, - int requestResponseChatId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, requestResponseId, requestResponseChatId, - new Dictionary()); - } - /// /// Update the last read message in the chat of a specific request response. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, int userId, int monetaryAccountId, int requestResponseId, - int requestResponseChatId, IDictionary customHeaders) + int requestResponseChatId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap)); var responseRaw = @@ -103,22 +92,20 @@ public static BunqResponse Update(ApiContext apiContext, return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, int requestResponseId) - { - return List(apiContext, userId, monetaryAccountId, requestResponseId, new Dictionary()); - } - /// /// Get the chat for a specific request response. /// public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, int requestResponseId, IDictionary customHeaders) + int monetaryAccountId, int requestResponseId, 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, monetaryAccountId, requestResponseId), - customHeaders); + urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/Schedule.cs b/BunqSdk/Model/Generated/Schedule.cs index 7dcd984..3f5eb0a 100644 --- a/BunqSdk/Model/Generated/Schedule.cs +++ b/BunqSdk/Model/Generated/Schedule.cs @@ -20,40 +20,34 @@ public class Schedule : BunqModel /// private const string OBJECT_TYPE = "Schedule"; - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int scheduleId) - { - return Get(apiContext, userId, monetaryAccountId, scheduleId, new Dictionary()); - } - /// /// Get a specific schedule definition for a given monetary account. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int scheduleId, IDictionary customHeaders) + int scheduleId, 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, scheduleId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId) - { - return List(apiContext, userId, monetaryAccountId, new Dictionary()); - } - /// /// Get a collection of scheduled definition for a given monetary account. You can add the parameter type to /// filter the response. When type={SCHEDULE_DEFINITION_PAYMENT,SCHEDULE_DEFINITION_PAYMENT_BATCH} is provided /// only schedule definition object that relate to these definitions are returned. /// public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - 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, monetaryAccountId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); diff --git a/BunqSdk/Model/Generated/ScheduleInstance.cs b/BunqSdk/Model/Generated/ScheduleInstance.cs index 8296c08..ddfe2db 100644 --- a/BunqSdk/Model/Generated/ScheduleInstance.cs +++ b/BunqSdk/Model/Generated/ScheduleInstance.cs @@ -66,40 +66,30 @@ public class ScheduleInstance : BunqModel [JsonProperty(PropertyName = "result_object")] public BunqModel ResultObject { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int scheduleId, int scheduleInstanceId) - { - return Get(apiContext, userId, monetaryAccountId, scheduleId, scheduleInstanceId, - new Dictionary()); - } - /// /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int scheduleId, int scheduleInstanceId, IDictionary customHeaders) + int scheduleId, int scheduleInstanceId, 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, scheduleId, scheduleInstanceId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int scheduleId, int scheduleInstanceId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, scheduleId, scheduleInstanceId, - new Dictionary()); - } - /// /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, int userId, int monetaryAccountId, int scheduleId, int scheduleInstanceId, - 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 = @@ -110,20 +100,18 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary> List(ApiContext apiContext, int userId, - int monetaryAccountId, int scheduleId) - { - return List(apiContext, userId, monetaryAccountId, scheduleId, new Dictionary()); - } - /// /// public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, int scheduleId, IDictionary customHeaders) + int monetaryAccountId, int scheduleId, 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, monetaryAccountId, scheduleId), - customHeaders); + urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/SchedulePayment.cs b/BunqSdk/Model/Generated/SchedulePayment.cs index 82bf35a..cba57a3 100644 --- a/BunqSdk/Model/Generated/SchedulePayment.cs +++ b/BunqSdk/Model/Generated/SchedulePayment.cs @@ -45,17 +45,13 @@ public class SchedulePayment : BunqModel [JsonProperty(PropertyName = "schedule")] public Schedule Schedule { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId) - { - return Create(apiContext, requestMap, userId, monetaryAccountId, new Dictionary()); - } - /// /// 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), @@ -64,17 +60,13 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int schedulePaymentId) - { - return Delete(apiContext, userId, monetaryAccountId, schedulePaymentId, new Dictionary()); - } - /// /// public static BunqResponse Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int schedulePaymentId, IDictionary customHeaders) + int schedulePaymentId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Delete(string.Format(ENDPOINT_URL_DELETE, userId, monetaryAccountId, schedulePaymentId), @@ -83,54 +75,43 @@ public static BunqResponse Delete(ApiContext apiContext, int userId, int return new BunqResponse(null, responseRaw.Headers); } - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int schedulePaymentId) - { - return Get(apiContext, userId, monetaryAccountId, schedulePaymentId, new Dictionary()); - } - /// /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int schedulePaymentId, IDictionary customHeaders) + int schedulePaymentId, 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, schedulePaymentId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId) - { - return List(apiContext, userId, monetaryAccountId, new Dictionary()); - } - /// /// public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - 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, monetaryAccountId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } - public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int schedulePaymentId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, schedulePaymentId, - new Dictionary()); - } - /// /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int schedulePaymentId, IDictionary customHeaders) + int userId, int monetaryAccountId, int schedulePaymentId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap)); var responseRaw = diff --git a/BunqSdk/Model/Generated/SchedulePaymentBatch.cs b/BunqSdk/Model/Generated/SchedulePaymentBatch.cs index b3f7e58..bc86712 100644 --- a/BunqSdk/Model/Generated/SchedulePaymentBatch.cs +++ b/BunqSdk/Model/Generated/SchedulePaymentBatch.cs @@ -43,17 +43,13 @@ public class SchedulePaymentBatch : BunqModel [JsonProperty(PropertyName = "schedule")] public Schedule Schedule { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId) - { - return Create(apiContext, requestMap, userId, monetaryAccountId, new Dictionary()); - } - /// /// 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), @@ -62,18 +58,14 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int schedulePaymentBatchId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, schedulePaymentBatchId, - new Dictionary()); - } - /// /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int schedulePaymentBatchId, IDictionary customHeaders) + int userId, int monetaryAccountId, int schedulePaymentBatchId, + IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap)); var responseRaw = @@ -83,18 +75,13 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int schedulePaymentBatchId) - { - return Delete(apiContext, userId, monetaryAccountId, schedulePaymentBatchId, - new Dictionary()); - } - /// /// public static BunqResponse Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int schedulePaymentBatchId, IDictionary customHeaders) + int schedulePaymentBatchId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Delete(string.Format(ENDPOINT_URL_DELETE, userId, monetaryAccountId, schedulePaymentBatchId), diff --git a/BunqSdk/Model/Generated/ScheduleUser.cs b/BunqSdk/Model/Generated/ScheduleUser.cs index 70fb130..ed9b19f 100644 --- a/BunqSdk/Model/Generated/ScheduleUser.cs +++ b/BunqSdk/Model/Generated/ScheduleUser.cs @@ -19,11 +19,6 @@ public class ScheduleUser : BunqModel /// private const string OBJECT_TYPE = "ScheduleUser"; - public static BunqResponse> List(ApiContext apiContext, int userId) - { - return List(apiContext, userId, new Dictionary()); - } - /// /// Get a collection of scheduled definition for all accessible monetary accounts of the user. You can add the /// parameter type to filter the response. When @@ -31,10 +26,13 @@ public static BunqResponse> List(ApiContext apiContext, int u /// object that relate to these definitions are returned. /// 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/Session.cs b/BunqSdk/Model/Generated/Session.cs index a5fe80c..2b59eba 100644 --- a/BunqSdk/Model/Generated/Session.cs +++ b/BunqSdk/Model/Generated/Session.cs @@ -19,17 +19,14 @@ public class Session : BunqModel /// private const string OBJECT_TYPE = "Session"; - public static BunqResponse Delete(ApiContext apiContext, int sessionId) - { - return Delete(apiContext, sessionId, new Dictionary()); - } - /// /// Deletes the current session. No response is returned for this request. /// public static BunqResponse Delete(ApiContext apiContext, int sessionId, - IDictionary customHeaders) + IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Delete(string.Format(ENDPOINT_URL_DELETE, sessionId), customHeaders); diff --git a/BunqSdk/Model/Generated/ShareInviteBankAmountUsed.cs b/BunqSdk/Model/Generated/ShareInviteBankAmountUsed.cs index cc37772..4430fc9 100644 --- a/BunqSdk/Model/Generated/ShareInviteBankAmountUsed.cs +++ b/BunqSdk/Model/Generated/ShareInviteBankAmountUsed.cs @@ -22,19 +22,15 @@ public class ShareInviteBankAmountUsed : BunqModel /// private const string OBJECT_TYPE = "ShareInviteBankAmountUsed"; - public static BunqResponse Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int shareInviteBankInquiryId, int shareInviteBankAmountUsedId) - { - return Delete(apiContext, userId, monetaryAccountId, shareInviteBankInquiryId, shareInviteBankAmountUsedId, - new Dictionary()); - } - /// /// Reset the available budget for a bank account share. To be called without any ID at the end of the path. /// public static BunqResponse Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int shareInviteBankInquiryId, int shareInviteBankAmountUsedId, IDictionary customHeaders) + int shareInviteBankInquiryId, int shareInviteBankAmountUsedId, + IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Delete( diff --git a/BunqSdk/Model/Generated/ShareInviteBankInquiry.cs b/BunqSdk/Model/Generated/ShareInviteBankInquiry.cs index a5065a7..088489d 100644 --- a/BunqSdk/Model/Generated/ShareInviteBankInquiry.cs +++ b/BunqSdk/Model/Generated/ShareInviteBankInquiry.cs @@ -105,19 +105,15 @@ public class ShareInviteBankInquiry : BunqModel [JsonProperty(PropertyName = "id")] public int? Id { 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 share inquiry for a monetary account, specifying the permission the other bunq user will have /// on it. /// 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), @@ -126,42 +122,32 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Get(ApiContext apiContext, int userId, int monetaryAccountId, - int shareInviteBankInquiryId) - { - return Get(apiContext, userId, monetaryAccountId, shareInviteBankInquiryId, - new Dictionary()); - } - /// /// Get the details of a specific share inquiry. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int shareInviteBankInquiryId, IDictionary customHeaders) + int shareInviteBankInquiryId, 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, shareInviteBankInquiryId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse Update(ApiContext apiContext, - IDictionary requestMap, int userId, int monetaryAccountId, int shareInviteBankInquiryId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, shareInviteBankInquiryId, - new Dictionary()); - } - /// /// Update the details of a share. This includes updating status (revoking or cancelling it), granted permission /// and validity period of this share. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, int userId, int monetaryAccountId, int shareInviteBankInquiryId, - 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 = @@ -171,21 +157,19 @@ public static BunqResponse Update(ApiContext apiContext, return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId) - { - return List(apiContext, userId, monetaryAccountId, new Dictionary()); - } - /// /// Get a list with all the share inquiries for a monetary account, only if the requesting user has permission /// to change the details of the various ones. /// public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, IDictionary customHeaders) + int monetaryAccountId, 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, monetaryAccountId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); diff --git a/BunqSdk/Model/Generated/ShareInviteBankResponse.cs b/BunqSdk/Model/Generated/ShareInviteBankResponse.cs index f13133f..0be463a 100644 --- a/BunqSdk/Model/Generated/ShareInviteBankResponse.cs +++ b/BunqSdk/Model/Generated/ShareInviteBankResponse.cs @@ -89,38 +89,30 @@ public class ShareInviteBankResponse : BunqModel [JsonProperty(PropertyName = "description")] public string Description { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int userId, - int shareInviteBankResponseId) - { - return Get(apiContext, userId, shareInviteBankResponseId, new Dictionary()); - } - /// /// Return the details of a specific share a user was invited to. /// public static BunqResponse Get(ApiContext apiContext, int userId, - int shareInviteBankResponseId, IDictionary customHeaders) + int shareInviteBankResponseId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, shareInviteBankResponseId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse Update(ApiContext apiContext, - IDictionary requestMap, int userId, int shareInviteBankResponseId) - { - return Update(apiContext, requestMap, userId, shareInviteBankResponseId, new Dictionary()); - } - /// /// Accept or reject a share a user was invited to. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, int userId, int shareInviteBankResponseId, - 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.Put(string.Format(ENDPOINT_URL_UPDATE, userId, shareInviteBankResponseId), @@ -129,19 +121,17 @@ public static BunqResponse Update(ApiContext apiContext return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId) - { - return List(apiContext, userId, new Dictionary()); - } - /// /// Return all the shares a user was invited to. /// 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/Tab.cs b/BunqSdk/Model/Generated/Tab.cs index 618623b..f7eb08a 100644 --- a/BunqSdk/Model/Generated/Tab.cs +++ b/BunqSdk/Model/Generated/Tab.cs @@ -35,42 +35,35 @@ public class Tab : BunqModel [JsonProperty(PropertyName = "TabUsageMultiple")] public TabUsageMultiple TabUsageMultiple { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUuid) - { - return Get(apiContext, userId, monetaryAccountId, cashRegisterId, tabUuid, - new Dictionary()); - } - /// /// Get a specific tab. This returns a TabUsageSingle or TabUsageMultiple. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUuid, IDictionary customHeaders) + int cashRegisterId, string tabUuid, 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, tabUuid), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw); } - public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId) - { - return List(apiContext, userId, monetaryAccountId, cashRegisterId, new Dictionary()); - } - /// /// Get a collection of tabs. /// public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, IDictionary customHeaders) + int cashRegisterId, 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, monetaryAccountId, cashRegisterId), + apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId, cashRegisterId), urlParams, customHeaders); return FromJsonList(responseRaw); diff --git a/BunqSdk/Model/Generated/TabAttachmentTab.cs b/BunqSdk/Model/Generated/TabAttachmentTab.cs index 06c8748..75c3c63 100644 --- a/BunqSdk/Model/Generated/TabAttachmentTab.cs +++ b/BunqSdk/Model/Generated/TabAttachmentTab.cs @@ -45,20 +45,17 @@ public class TabAttachmentTab : BunqModel [JsonProperty(PropertyName = "attachment")] public Attachment Attachment { get; private set; } - public static BunqResponse Get(ApiContext apiContext, string tabUuid, int tabAttachmentTabId) - { - return Get(apiContext, tabUuid, tabAttachmentTabId, new Dictionary()); - } - /// /// Get a specific attachment. The header of the response contains the content-type of the attachment. /// public static BunqResponse Get(ApiContext apiContext, string tabUuid, int tabAttachmentTabId, - 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, tabUuid, tabAttachmentTabId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/TabAttachmentTabContent.cs b/BunqSdk/Model/Generated/TabAttachmentTabContent.cs index 9d6c57a..8f277ba 100644 --- a/BunqSdk/Model/Generated/TabAttachmentTabContent.cs +++ b/BunqSdk/Model/Generated/TabAttachmentTabContent.cs @@ -20,19 +20,17 @@ public class TabAttachmentTabContent : BunqModel /// private const string OBJECT_TYPE = "TabAttachmentTabContent"; - public static BunqResponse List(ApiContext apiContext, string tabUuid, int attachmentId) - { - return List(apiContext, tabUuid, attachmentId, new Dictionary()); - } - /// /// Get the raw content of a specific attachment. /// public static BunqResponse List(ApiContext apiContext, string tabUuid, int attachmentId, - 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, tabUuid, attachmentId), customHeaders); + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, tabUuid, attachmentId), + new Dictionary(), customHeaders); return new BunqResponse(responseRaw.BodyBytes, responseRaw.Headers); } diff --git a/BunqSdk/Model/Generated/TabItemShop.cs b/BunqSdk/Model/Generated/TabItemShop.cs index 7c2bbd6..98d90b6 100644 --- a/BunqSdk/Model/Generated/TabItemShop.cs +++ b/BunqSdk/Model/Generated/TabItemShop.cs @@ -85,20 +85,15 @@ public class TabItemShop : BunqModel [JsonProperty(PropertyName = "amount")] public Amount Amount { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int cashRegisterId, string tabUuid) - { - return Create(apiContext, requestMap, userId, monetaryAccountId, cashRegisterId, tabUuid, - new Dictionary()); - } - /// /// Create a new TabItem for a given Tab. /// public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, int userId, int monetaryAccountId, int cashRegisterId, string tabUuid, - 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 = @@ -108,20 +103,15 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int cashRegisterId, string tabUuid, int tabItemShopId) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, cashRegisterId, tabUuid, tabItemShopId, - new Dictionary()); - } - /// /// Modify a TabItem from a given Tab. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, int userId, int monetaryAccountId, int cashRegisterId, string tabUuid, int tabItemShopId, - 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 = @@ -132,19 +122,14 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUuid, int tabItemShopId) - { - return Delete(apiContext, userId, monetaryAccountId, cashRegisterId, tabUuid, tabItemShopId, - new Dictionary()); - } - /// /// Delete a specific TabItem from a Tab. This request returns an empty response. /// public static BunqResponse Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUuid, int tabItemShopId, IDictionary customHeaders) + int cashRegisterId, string tabUuid, int tabItemShopId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Delete( @@ -154,45 +139,37 @@ public static BunqResponse Delete(ApiContext apiContext, int userId, int return new BunqResponse(null, responseRaw.Headers); } - public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUuid) - { - return List(apiContext, userId, monetaryAccountId, cashRegisterId, tabUuid, - new Dictionary()); - } - /// /// Get a collection of TabItems from a given Tab. /// public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUuid, IDictionary customHeaders) + int cashRegisterId, string tabUuid, 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, monetaryAccountId, cashRegisterId, tabUuid), - customHeaders); + urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUuid, int tabItemShopId) - { - return Get(apiContext, userId, monetaryAccountId, cashRegisterId, tabUuid, tabItemShopId, - new Dictionary()); - } - /// /// Get a specific TabItem from a given Tab. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUuid, int tabItemShopId, IDictionary customHeaders) + int cashRegisterId, string tabUuid, int tabItemShopId, 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, tabUuid, tabItemShopId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/TabItemShopBatch.cs b/BunqSdk/Model/Generated/TabItemShopBatch.cs index ae173e9..b594200 100644 --- a/BunqSdk/Model/Generated/TabItemShopBatch.cs +++ b/BunqSdk/Model/Generated/TabItemShopBatch.cs @@ -34,20 +34,15 @@ public class TabItemShopBatch : BunqModel [JsonProperty(PropertyName = "tab_items")] public List TabItems { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int cashRegisterId, string tabUuid) - { - return Create(apiContext, requestMap, userId, monetaryAccountId, cashRegisterId, tabUuid, - new Dictionary()); - } - /// /// Create tab items as a batch. /// public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, int userId, int monetaryAccountId, int cashRegisterId, string tabUuid, - 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 = diff --git a/BunqSdk/Model/Generated/TabQrCodeContent.cs b/BunqSdk/Model/Generated/TabQrCodeContent.cs index 7873947..a2db3ce 100644 --- a/BunqSdk/Model/Generated/TabQrCodeContent.cs +++ b/BunqSdk/Model/Generated/TabQrCodeContent.cs @@ -21,24 +21,19 @@ public class TabQrCodeContent : BunqModel /// private const string OBJECT_TYPE = "TabQrCodeContent"; - public static BunqResponse List(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUuid) - { - return List(apiContext, userId, monetaryAccountId, cashRegisterId, tabUuid, - new Dictionary()); - } - /// /// Returns the raw content of the QR code that links to this Tab. The raw content is the binary representation /// of a file, without any JSON wrapping. /// public static BunqResponse List(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUuid, IDictionary customHeaders) + int cashRegisterId, string tabUuid, 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, cashRegisterId, tabUuid), - customHeaders); + new Dictionary(), customHeaders); return new BunqResponse(responseRaw.BodyBytes, responseRaw.Headers); } diff --git a/BunqSdk/Model/Generated/TabResultInquiry.cs b/BunqSdk/Model/Generated/TabResultInquiry.cs index 025922a..09f9782 100644 --- a/BunqSdk/Model/Generated/TabResultInquiry.cs +++ b/BunqSdk/Model/Generated/TabResultInquiry.cs @@ -36,45 +36,38 @@ public class TabResultInquiry : BunqModel [JsonProperty(PropertyName = "payment")] public Payment Payment { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUuid, int tabResultInquiryId) - { - return Get(apiContext, userId, monetaryAccountId, cashRegisterId, tabUuid, tabResultInquiryId, - new Dictionary()); - } - /// /// Used to view a single TabResultInquiry belonging to a tab. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUuid, int tabResultInquiryId, IDictionary customHeaders) + int cashRegisterId, string tabUuid, int tabResultInquiryId, + 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, tabUuid, - tabResultInquiryId), customHeaders); + tabResultInquiryId), new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, int cashRegisterId, string tabUuid) - { - return List(apiContext, userId, monetaryAccountId, cashRegisterId, tabUuid, - new Dictionary()); - } - /// /// Used to view a list of TabResultInquiry objects belonging to a tab. /// public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, int cashRegisterId, string tabUuid, IDictionary customHeaders) + int monetaryAccountId, int cashRegisterId, string tabUuid, 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, monetaryAccountId, cashRegisterId, tabUuid), - customHeaders); + urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/TabResultResponse.cs b/BunqSdk/Model/Generated/TabResultResponse.cs index c7d6e1e..db44cd5 100644 --- a/BunqSdk/Model/Generated/TabResultResponse.cs +++ b/BunqSdk/Model/Generated/TabResultResponse.cs @@ -34,40 +34,34 @@ public class TabResultResponse : BunqModel [JsonProperty(PropertyName = "payment")] public Payment Payment { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int tabResultResponseId) - { - return Get(apiContext, userId, monetaryAccountId, tabResultResponseId, new Dictionary()); - } - /// /// Used to view a single TabResultResponse belonging to a tab. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int tabResultResponseId, IDictionary customHeaders) + int tabResultResponseId, 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, tabResultResponseId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId) - { - return List(apiContext, userId, monetaryAccountId, new Dictionary()); - } - /// /// Used to view a list of TabResultResponse objects belonging to a tab. /// public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, IDictionary customHeaders) + int monetaryAccountId, 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, monetaryAccountId), + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); diff --git a/BunqSdk/Model/Generated/TabUsageMultiple.cs b/BunqSdk/Model/Generated/TabUsageMultiple.cs index 072fe3b..b7df45a 100644 --- a/BunqSdk/Model/Generated/TabUsageMultiple.cs +++ b/BunqSdk/Model/Generated/TabUsageMultiple.cs @@ -156,19 +156,14 @@ public class TabUsageMultiple : BunqModel [JsonProperty(PropertyName = "tab_attachment")] public List TabAttachment { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int cashRegisterId) - { - return Create(apiContext, requestMap, userId, monetaryAccountId, cashRegisterId, - new Dictionary()); - } - /// /// Create a TabUsageMultiple. On creation the status must be set to OPEN /// public static BunqResponse Create(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 = @@ -178,13 +173,6 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int cashRegisterId, string tabUsageMultipleUuid) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, cashRegisterId, tabUsageMultipleUuid, - new Dictionary()); - } - /// /// Modify a specific TabUsageMultiple. You can change the amount_total, status and visibility. Once you change /// the status to PAYABLE the TabUsageMultiple will expire after a year (default). If you've created any @@ -193,8 +181,10 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, int userId, int monetaryAccountId, int cashRegisterId, string tabUsageMultipleUuid, - 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 = @@ -205,19 +195,14 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUsageMultipleUuid) - { - return Delete(apiContext, userId, monetaryAccountId, cashRegisterId, tabUsageMultipleUuid, - new Dictionary()); - } - /// /// Close a specific TabUsageMultiple. This request returns an empty response. /// public static BunqResponse Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUsageMultipleUuid, IDictionary customHeaders) + int cashRegisterId, string tabUsageMultipleUuid, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Delete( @@ -227,43 +212,36 @@ public static BunqResponse Delete(ApiContext apiContext, int userId, int return new BunqResponse(null, responseRaw.Headers); } - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUsageMultipleUuid) - { - return Get(apiContext, userId, monetaryAccountId, cashRegisterId, tabUsageMultipleUuid, - new Dictionary()); - } - /// /// Get a specific TabUsageMultiple. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUsageMultipleUuid, IDictionary customHeaders) + int cashRegisterId, string tabUsageMultipleUuid, 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, tabUsageMultipleUuid), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, int cashRegisterId) - { - return List(apiContext, userId, monetaryAccountId, cashRegisterId, new Dictionary()); - } - /// /// Get a collection of TabUsageMultiple. /// public static BunqResponse> List(ApiContext apiContext, int userId, - int monetaryAccountId, int cashRegisterId, IDictionary customHeaders) + int monetaryAccountId, int cashRegisterId, 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, monetaryAccountId, cashRegisterId), + apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId, cashRegisterId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); diff --git a/BunqSdk/Model/Generated/TabUsageSingle.cs b/BunqSdk/Model/Generated/TabUsageSingle.cs index c25e59b..1753059 100644 --- a/BunqSdk/Model/Generated/TabUsageSingle.cs +++ b/BunqSdk/Model/Generated/TabUsageSingle.cs @@ -167,19 +167,14 @@ public class TabUsageSingle : BunqModel [JsonProperty(PropertyName = "tab_attachment")] public List TabAttachment { get; private set; } - public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int cashRegisterId) - { - return Create(apiContext, requestMap, userId, monetaryAccountId, cashRegisterId, - new Dictionary()); - } - /// /// Create a TabUsageSingle. The initial status must be OPEN /// public static BunqResponse Create(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 = @@ -189,13 +184,6 @@ public static BunqResponse Create(ApiContext apiContext, IDictionary Update(ApiContext apiContext, IDictionary requestMap, - int userId, int monetaryAccountId, int cashRegisterId, string tabUsageSingleUuid) - { - return Update(apiContext, requestMap, userId, monetaryAccountId, cashRegisterId, tabUsageSingleUuid, - new Dictionary()); - } - /// /// Modify a specific TabUsageSingle. You can change the amount_total, status and visibility. Once you change /// the status to WAITING_FOR_PAYMENT the TabUsageSingle will expire after 5 minutes (default) or up to 1 hour @@ -203,8 +191,10 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, int userId, int monetaryAccountId, int cashRegisterId, string tabUsageSingleUuid, - 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 = @@ -215,19 +205,14 @@ public static BunqResponse Update(ApiContext apiContext, IDictionary Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUsageSingleUuid) - { - return Delete(apiContext, userId, monetaryAccountId, cashRegisterId, tabUsageSingleUuid, - new Dictionary()); - } - /// /// Cancel a specific TabUsageSingle. This request returns an empty response. /// public static BunqResponse Delete(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUsageSingleUuid, IDictionary customHeaders) + int cashRegisterId, string tabUsageSingleUuid, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Delete( @@ -237,43 +222,36 @@ public static BunqResponse Delete(ApiContext apiContext, int userId, int return new BunqResponse(null, responseRaw.Headers); } - public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUsageSingleUuid) - { - return Get(apiContext, userId, monetaryAccountId, cashRegisterId, tabUsageSingleUuid, - new Dictionary()); - } - /// /// Get a specific TabUsageSingle. /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, string tabUsageSingleUuid, IDictionary customHeaders) + int cashRegisterId, string tabUsageSingleUuid, 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, tabUsageSingleUuid), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId) - { - return List(apiContext, userId, monetaryAccountId, cashRegisterId, new Dictionary()); - } - /// /// Get a collection of TabUsageSingle. /// public static BunqResponse> List(ApiContext apiContext, int userId, int monetaryAccountId, - int cashRegisterId, IDictionary customHeaders) + int cashRegisterId, 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, monetaryAccountId, cashRegisterId), + apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, monetaryAccountId, cashRegisterId), urlParams, customHeaders); return FromJsonList(responseRaw, OBJECT_TYPE); diff --git a/BunqSdk/Model/Generated/TokenQrRequestIdeal.cs b/BunqSdk/Model/Generated/TokenQrRequestIdeal.cs index 1b1cd31..83f2c05 100644 --- a/BunqSdk/Model/Generated/TokenQrRequestIdeal.cs +++ b/BunqSdk/Model/Generated/TokenQrRequestIdeal.cs @@ -154,18 +154,14 @@ public class TokenQrRequestIdeal : BunqModel [JsonProperty(PropertyName = "eligible_whitelist_id")] public int? EligibleWhitelistId { get; private set; } - public static BunqResponse Create(ApiContext apiContext, - IDictionary requestMap, int userId) - { - return Create(apiContext, requestMap, userId, new Dictionary()); - } - /// /// Create a request from an ideal transaction. /// public static BunqResponse Create(ApiContext apiContext, - IDictionary requestMap, int userId, IDictionary customHeaders) + 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); diff --git a/BunqSdk/Model/Generated/User.cs b/BunqSdk/Model/Generated/User.cs index cb8cbd3..3abc4e0 100644 --- a/BunqSdk/Model/Generated/User.cs +++ b/BunqSdk/Model/Generated/User.cs @@ -37,35 +37,32 @@ public class User : BunqModel [JsonProperty(PropertyName = "UserCompany")] public UserCompany UserCompany { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int userId) - { - return Get(apiContext, userId, new Dictionary()); - } - /// /// Get a specific user. /// public static BunqResponse Get(ApiContext apiContext, int userId, - 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), customHeaders); + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId), new Dictionary(), + customHeaders); return FromJson(responseRaw); } - public static BunqResponse> List(ApiContext apiContext) - { - return List(apiContext, new Dictionary()); - } - /// /// Get a collection of all available users. /// - public static BunqResponse> List(ApiContext apiContext, IDictionary customHeaders) + public static BunqResponse> List(ApiContext apiContext, 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(ENDPOINT_URL_LISTING, customHeaders); + var responseRaw = apiClient.Get(ENDPOINT_URL_LISTING, urlParams, customHeaders); return FromJsonList(responseRaw); } diff --git a/BunqSdk/Model/Generated/UserCompany.cs b/BunqSdk/Model/Generated/UserCompany.cs index 51c480b..197ff23 100644 --- a/BunqSdk/Model/Generated/UserCompany.cs +++ b/BunqSdk/Model/Generated/UserCompany.cs @@ -19,7 +19,6 @@ public class UserCompany : BunqModel public const string FIELD_NAME = "name"; public const string FIELD_PUBLIC_NICK_NAME = "public_nick_name"; public const string FIELD_AVATAR_UUID = "avatar_uuid"; - public const string FIELD_ADDRESS = "address"; public const string FIELD_ADDRESS_MAIN = "address_main"; public const string FIELD_ADDRESS_POSTAL = "address_postal"; public const string FIELD_LANGUAGE = "language"; @@ -154,6 +153,12 @@ public class UserCompany : BunqModel [JsonProperty(PropertyName = "language")] public string Language { get; private set; } + /// + /// The country as an ISO 3166-1 alpha-2 country code.. + /// + [JsonProperty(PropertyName = "country")] + public string Country { get; private set; } + /// /// The person's preferred region. Formatted as a ISO 639-1 language code plus a ISO 3166-1 alpha-2 country /// code, seperated by an underscore. @@ -198,35 +203,47 @@ public class UserCompany : BunqModel [JsonProperty(PropertyName = "notification_filters")] public List NotificationFilters { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int userCompanyId) - { - return Get(apiContext, userCompanyId, new Dictionary()); - } + /// + /// The customer profile of the company. + /// + [JsonProperty(PropertyName = "customer")] + public Customer Customer { get; private set; } + + /// + /// The customer limits of the company. + /// + [JsonProperty(PropertyName = "customer_limit")] + public CustomerLimit CustomerLimit { get; private set; } + + /// + /// The subscription of the company. + /// + [JsonProperty(PropertyName = "billing_contract")] + public List BillingContract { get; private set; } /// /// Get a specific company. /// public static BunqResponse Get(ApiContext apiContext, int userCompanyId, - 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, userCompanyId), customHeaders); + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userCompanyId), + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userCompanyId) - { - return Update(apiContext, requestMap, userCompanyId, new Dictionary()); - } - /// /// Modify a specific company's data. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userCompanyId, IDictionary customHeaders) + int userCompanyId, 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.Put(string.Format(ENDPOINT_URL_UPDATE, userCompanyId), requestBytes, diff --git a/BunqSdk/Model/Generated/UserCredentialPasswordIp.cs b/BunqSdk/Model/Generated/UserCredentialPasswordIp.cs index f55ecbf..636141e 100644 --- a/BunqSdk/Model/Generated/UserCredentialPasswordIp.cs +++ b/BunqSdk/Model/Generated/UserCredentialPasswordIp.cs @@ -65,36 +65,30 @@ public class UserCredentialPasswordIp : BunqModel [JsonProperty(PropertyName = "permitted_device")] public PermittedDevice PermittedDevice { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int userId, - int userCredentialPasswordIpId) - { - return Get(apiContext, userId, userCredentialPasswordIpId, new Dictionary()); - } - /// /// public static BunqResponse Get(ApiContext apiContext, int userId, - int userCredentialPasswordIpId, IDictionary customHeaders) + int userCredentialPasswordIpId, IDictionary customHeaders = null) { + if (customHeaders == null) customHeaders = new Dictionary(); + var apiClient = new ApiClient(apiContext); var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, userCredentialPasswordIpId), - customHeaders); + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse> List(ApiContext apiContext, int userId) - { - return List(apiContext, userId, new Dictionary()); - } - /// /// 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/UserLight.cs b/BunqSdk/Model/Generated/UserLight.cs index ba9904a..baf0b55 100644 --- a/BunqSdk/Model/Generated/UserLight.cs +++ b/BunqSdk/Model/Generated/UserLight.cs @@ -19,7 +19,6 @@ public class UserLight : BunqModel public const string FIELD_LAST_NAME = "last_name"; public const string FIELD_PUBLIC_NICK_NAME = "public_nick_name"; public const string FIELD_COUNTER_BANK_IBAN = "counter_bank_iban"; - public const string FIELD_ADDRESS = "address"; public const string FIELD_ADDRESS_MAIN = "address_main"; public const string FIELD_ADDRESS_POSTAL = "address_postal"; public const string FIELD_AVATAR_UUID = "avatar_uuid"; @@ -249,19 +248,17 @@ public class UserLight : BunqModel [JsonProperty(PropertyName = "notification_filters")] public List NotificationFilters { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int userLightId) - { - return Get(apiContext, userLightId, new Dictionary()); - } - /// /// Get a specific bunq light user. /// public static BunqResponse Get(ApiContext apiContext, int userLightId, - 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, userLightId), customHeaders); + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userLightId), + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } diff --git a/BunqSdk/Model/Generated/UserPerson.cs b/BunqSdk/Model/Generated/UserPerson.cs index 0302cf4..1f866a4 100644 --- a/BunqSdk/Model/Generated/UserPerson.cs +++ b/BunqSdk/Model/Generated/UserPerson.cs @@ -20,7 +20,6 @@ public class UserPerson : BunqModel public const string FIELD_MIDDLE_NAME = "middle_name"; public const string FIELD_LAST_NAME = "last_name"; public const string FIELD_PUBLIC_NICK_NAME = "public_nick_name"; - public const string FIELD_ADDRESS = "address"; public const string FIELD_ADDRESS_MAIN = "address_main"; public const string FIELD_ADDRESS_POSTAL = "address_postal"; public const string FIELD_AVATAR_UUID = "avatar_uuid"; @@ -245,35 +244,29 @@ public class UserPerson : BunqModel [JsonProperty(PropertyName = "notification_filters")] public List NotificationFilters { get; private set; } - public static BunqResponse Get(ApiContext apiContext, int userPersonId) - { - return Get(apiContext, userPersonId, new Dictionary()); - } - /// /// Get a specific person. /// public static BunqResponse Get(ApiContext apiContext, int userPersonId, - 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, userPersonId), customHeaders); + var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userPersonId), + new Dictionary(), customHeaders); return FromJson(responseRaw, OBJECT_TYPE); } - public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userPersonId) - { - return Update(apiContext, requestMap, userPersonId, new Dictionary()); - } - /// /// Modify a specific person object's data. /// public static BunqResponse Update(ApiContext apiContext, IDictionary requestMap, - int userPersonId, IDictionary customHeaders) + int userPersonId, 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.Put(string.Format(ENDPOINT_URL_UPDATE, userPersonId), requestBytes, From 852accef197f14152472bd925ab4db13251b682b Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Mon, 4 Sep 2017 20:01:50 +0200 Subject: [PATCH 02/19] Added git attributes. --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes 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 From e1394dcbc2477e4a3735d665c71acae7a5956d23 Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 09:26:34 +0200 Subject: [PATCH 03/19] address minor styling issues [#17] --- BunqSdk/Http/Pagination.cs | 2 +- BunqSdk/Json/PaginationConverter.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BunqSdk/Http/Pagination.cs b/BunqSdk/Http/Pagination.cs index 512f389..32ca9fa 100644 --- a/BunqSdk/Http/Pagination.cs +++ b/BunqSdk/Http/Pagination.cs @@ -12,7 +12,7 @@ public class Pagination "Could not generate previous page URL params: there is no previous page."; /// - /// URL Param constants. + /// URL param constants. /// public const string PARAM_OLDER_ID = "older_id"; public const string PARAM_NEWER_ID = "newer_id"; diff --git a/BunqSdk/Json/PaginationConverter.cs b/BunqSdk/Json/PaginationConverter.cs index cafb6b2..2231d87 100644 --- a/BunqSdk/Json/PaginationConverter.cs +++ b/BunqSdk/Json/PaginationConverter.cs @@ -27,7 +27,7 @@ public class PaginationConverter : JsonConverter private const int INDEX_PARAM_VALUE = 1; /// - /// Base dummy URL to hack though the incomplete relative URI functionality of dotnetcore. + /// Base dummy URL to hack through the incomplete relative URI functionality of dotnetcore. /// private const string URI_BASE_DUMMY = "https://example.com"; From 95746f3935297f94e112d2d8b435d465e44b68cb Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 15:30:28 +0200 Subject: [PATCH 04/19] refactor pagination; add pagination test [#17] --- BunqSdk.Samples/PaymentListSample.cs | 2 +- BunqSdk.Tests/Http/PaginationTest.cs | 221 +++++++++++++++++++++++++++ BunqSdk/Http/Pagination.cs | 39 +++-- 3 files changed, 246 insertions(+), 16 deletions(-) create mode 100644 BunqSdk.Tests/Http/PaginationTest.cs diff --git a/BunqSdk.Samples/PaymentListSample.cs b/BunqSdk.Samples/PaymentListSample.cs index 3f864fc..1be874d 100644 --- a/BunqSdk.Samples/PaymentListSample.cs +++ b/BunqSdk.Samples/PaymentListSample.cs @@ -40,7 +40,7 @@ public void Run() PrintPayments(paymentResponse.Value); var pagination = paymentResponse.Pagination; - if (pagination.HasPreviousItem()) + if (pagination.HasPreviousPage()) { Console.WriteLine(MESSAGE_SECOND_LATEST_PAGE_IDS); var previousPaymentResponse = Payment.List(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID, diff --git a/BunqSdk.Tests/Http/PaginationTest.cs b/BunqSdk.Tests/Http/PaginationTest.cs new file mode 100644 index 0000000..376554e --- /dev/null +++ b/BunqSdk.Tests/Http/PaginationTest.cs @@ -0,0 +1,221 @@ +using System.Collections.Generic; +using Bunq.Sdk.Context; +using Bunq.Sdk.Exception; +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 PaginationTest : 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.GetCounterAliasOther(); + + /// + /// 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; + + /// + /// 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 AMOUNT_IN_EUR = "0.01"; + private const string FIELD_CURRENCY = "EUR"; + private const string FIELD_PAYMENT_DESCRIPTION = "C# test Payment"; + + /// + /// API context to use for the test API calls. + /// + private static readonly ApiContext API_CONTEXT = GetApiContext(); + + [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 urlParamsCountOnlyExpected = new Dictionary + { + {Pagination.PARAM_COUNT, PAGINATION_COUNT_CUSTOM.ToString()}, + {Pagination.PARAM_OLDER_ID, PAGINATION_OLDER_ID_CUSTOM.ToString()} + }; + + Assert.Equal(urlParamsCountOnlyExpected, pagination.UrlParamsPreviousPage); + } + + [Fact] + public void TestGetUrlParamsNextPageNewer() + { + var pagination = CreatePaginationWithAllPropertiesSet(); + var urlParamsCountOnlyExpected = new Dictionary + { + {Pagination.PARAM_COUNT, PAGINATION_COUNT_CUSTOM.ToString()}, + {Pagination.PARAM_NEWER_ID, PAGINATION_NEWER_ID_CUSTOM.ToString()} + }; + + Assert.Equal(urlParamsCountOnlyExpected, pagination.UrlParamsNextPage); + } + + [Fact] + public void TestGetUrlParamsNextPageFuture() + { + var pagination = CreatePaginationWithNoNextPageAssured(); + var urlParamsCountOnlyExpected = new Dictionary + { + {Pagination.PARAM_COUNT, PAGINATION_COUNT_CUSTOM.ToString()}, + {Pagination.PARAM_NEWER_ID, PAGINATION_FUTURE_ID_CUSTOM.ToString()} + }; + + Assert.False(pagination.HasNextPageAssured()); + Assert.Equal(urlParamsCountOnlyExpected, pagination.UrlParamsNextPage); + } + + private static Pagination CreatePaginationWithNoNextPageAssured() + { + var pagination = CreatePaginationWithAllPropertiesSet(); + pagination.NewerId = null; + + return pagination; + } + + [Fact] + public void TestGetUrlParamsPreviousPageFromPaginationWithNoPreviousPage() + { + var pagination = CreatePaginationWithNoPreviousPage(); + + Assert.False(pagination.HasPreviousPage()); + Assert.Throws(() => pagination.UrlParamsPreviousPage); + } + + private static Pagination CreatePaginationWithNoPreviousPage() + { + var pagination = CreatePaginationWithAllPropertiesSet(); + pagination.OlderId = null; + + return pagination; + } + + [Fact] + public void TestGetUrlParamsPreviousPageFromPaginationWithNoNextPage() + { + var pagination = CreatePaginationWithNoNextPage(); + + Assert.Throws(() => pagination.UrlParamsNextPage); + } + + private static Pagination CreatePaginationWithNoNextPage() + { + var pagination = CreatePaginationWithNoNextPageAssured(); + pagination.FutureId = null; + + return pagination; + } + + [Fact] + public void TestApiScenarioPaymentListingWithPagination() + { + EnsureEnoughPayments(); + var paymentsExpected = new HashSet(GetPaymentsRequired()); + var paginationCountOnly = new Pagination + { + Count = PAYMENT_LISTING_PAGE_SIZE + }; + + var paymentResponseLatest = ListPayments(paginationCountOnly.UrlParamsCountOnly); + var paginationLatest = paymentResponseLatest.Pagination; + var paymentResponsePrevious = ListPayments(paginationLatest.UrlParamsPreviousPage); + var paginationPrevious = paymentResponsePrevious.Pagination; + var paymentResponsePreviousNext = ListPayments(paginationPrevious.UrlParamsNextPage); + + var paymentsActual = new HashSet(); + paymentsActual.UnionWith(paymentResponsePreviousNext.Value); + paymentsActual.UnionWith(paymentResponsePrevious.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 List 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(AMOUNT_IN_EUR, FIELD_CURRENCY)}, + {Payment.FIELD_DESCRIPTION, FIELD_PAYMENT_DESCRIPTION}, + {Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_OTHER} + }; + + Payment.Create(API_CONTEXT, requestMap, USER_ID, MONETARY_ACCOUNT_ID); + } + } +} diff --git a/BunqSdk/Http/Pagination.cs b/BunqSdk/Http/Pagination.cs index 32ca9fa..0361f23 100644 --- a/BunqSdk/Http/Pagination.cs +++ b/BunqSdk/Http/Pagination.cs @@ -9,7 +9,8 @@ public class Pagination /// Error constants. /// private const string ERROR_NO_PREVIOUS_PAGE = - "Could not generate previous page URL params: there is 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. @@ -19,13 +20,6 @@ public class Pagination public const string PARAM_FUTURE_ID = "future_id"; public const string PARAM_COUNT = "count"; - /// - /// 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"; - public int? OlderId { get; set; } public int? NewerId { get; set; } public int? FutureId { get; set; } @@ -38,6 +32,8 @@ public IDictionary UrlParamsNextPage { get { + AssertHasNextPage(); + var urlParams = new Dictionary(); urlParams[PARAM_NEWER_ID] = NextId.ToString(); AddCountToParamsIfNeeded(urlParams); @@ -46,6 +42,14 @@ public IDictionary UrlParamsNextPage } } + private void AssertHasNextPage() + { + if (NextId == null) + { + throw new BunqException(ERROR_NO_NEXT_PAGE); + } + } + private void AddCountToParamsIfNeeded(IDictionary urlParams) { if (Count != null) @@ -56,10 +60,10 @@ private void AddCountToParamsIfNeeded(IDictionary urlParams) private int? NextId { - get { return HasNextItemAssured() ? NewerId : FutureId; } + get { return HasNextPageAssured() ? NewerId : FutureId; } } - public bool HasNextItemAssured() + public bool HasNextPageAssured() { return NewerId != null; } @@ -85,10 +89,7 @@ public IDictionary UrlParamsPreviousPage { get { - if (!HasPreviousItem()) - { - throw new BunqException(ERROR_NO_PREVIOUS_PAGE); - } + AssertHasPreviousPage(); var urlParams = new Dictionary(); urlParams[PARAM_OLDER_ID] = OlderId.ToString(); @@ -98,7 +99,15 @@ public IDictionary UrlParamsPreviousPage } } - public bool HasPreviousItem() + private void AssertHasPreviousPage() + { + if (!HasPreviousPage()) + { + throw new BunqException(ERROR_NO_PREVIOUS_PAGE); + } + } + + public bool HasPreviousPage() { return OlderId != null; } From 7b74c5c5a048b67d17e015fafee93f78610fc8c5 Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 15:33:29 +0200 Subject: [PATCH 05/19] split tests into unit test and scenario test [#17] --- BunqSdk.Tests/Http/PaginationScenarioTest.cs | 108 +++++++++++++++++++ BunqSdk.Tests/Http/PaginationTest.cs | 95 ---------------- 2 files changed, 108 insertions(+), 95 deletions(-) create mode 100644 BunqSdk.Tests/Http/PaginationScenarioTest.cs diff --git a/BunqSdk.Tests/Http/PaginationScenarioTest.cs b/BunqSdk.Tests/Http/PaginationScenarioTest.cs new file mode 100644 index 0000000..f9fbb34 --- /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.GetCounterAliasOther(); + + /// + /// 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 AMOUNT_IN_EUR = "0.01"; + private const string FIELD_CURRENCY = "EUR"; + private const string FIELD_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 HashSet(GetPaymentsRequired()); + var paginationCountOnly = new Pagination + { + Count = PAYMENT_LISTING_PAGE_SIZE + }; + + var paymentResponseLatest = ListPayments(paginationCountOnly.UrlParamsCountOnly); + var paginationLatest = paymentResponseLatest.Pagination; + var paymentResponsePrevious = ListPayments(paginationLatest.UrlParamsPreviousPage); + var paginationPrevious = paymentResponsePrevious.Pagination; + var paymentResponsePreviousNext = ListPayments(paginationPrevious.UrlParamsNextPage); + + var paymentsActual = new HashSet(); + paymentsActual.UnionWith(paymentResponsePreviousNext.Value); + paymentsActual.UnionWith(paymentResponsePrevious.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 List 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(AMOUNT_IN_EUR, FIELD_CURRENCY)}, + {Payment.FIELD_DESCRIPTION, FIELD_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 index 376554e..d1ba633 100644 --- a/BunqSdk.Tests/Http/PaginationTest.cs +++ b/BunqSdk.Tests/Http/PaginationTest.cs @@ -1,10 +1,6 @@ using System.Collections.Generic; -using Bunq.Sdk.Context; using Bunq.Sdk.Exception; 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 @@ -15,13 +11,6 @@ namespace Bunq.Sdk.Tests.Http /// public class PaginationTest : 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.GetCounterAliasOther(); - /// /// Values of pagination properties for testing. /// @@ -30,25 +19,6 @@ public class PaginationTest : BunqSdkTestBase private const int PAGINATION_FUTURE_ID_CUSTOM = 3; private const int PAGINATION_COUNT_CUSTOM = 5; - /// - /// 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 AMOUNT_IN_EUR = "0.01"; - private const string FIELD_CURRENCY = "EUR"; - private const string FIELD_PAYMENT_DESCRIPTION = "C# test Payment"; - - /// - /// API context to use for the test API calls. - /// - private static readonly ApiContext API_CONTEXT = GetApiContext(); - [Fact] public void TestGetUrlParamsCountOnly() { @@ -152,70 +122,5 @@ private static Pagination CreatePaginationWithNoNextPage() return pagination; } - - [Fact] - public void TestApiScenarioPaymentListingWithPagination() - { - EnsureEnoughPayments(); - var paymentsExpected = new HashSet(GetPaymentsRequired()); - var paginationCountOnly = new Pagination - { - Count = PAYMENT_LISTING_PAGE_SIZE - }; - - var paymentResponseLatest = ListPayments(paginationCountOnly.UrlParamsCountOnly); - var paginationLatest = paymentResponseLatest.Pagination; - var paymentResponsePrevious = ListPayments(paginationLatest.UrlParamsPreviousPage); - var paginationPrevious = paymentResponsePrevious.Pagination; - var paymentResponsePreviousNext = ListPayments(paginationPrevious.UrlParamsNextPage); - - var paymentsActual = new HashSet(); - paymentsActual.UnionWith(paymentResponsePreviousNext.Value); - paymentsActual.UnionWith(paymentResponsePrevious.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 List 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(AMOUNT_IN_EUR, FIELD_CURRENCY)}, - {Payment.FIELD_DESCRIPTION, FIELD_PAYMENT_DESCRIPTION}, - {Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_OTHER} - }; - - Payment.Create(API_CONTEXT, requestMap, USER_ID, MONETARY_ACCOUNT_ID); - } } } From 58e48f9364484d732b844e5e26658c81a49dcd97 Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 15:58:21 +0200 Subject: [PATCH 06/19] remove unneeded inheritance [#17] --- BunqSdk.Tests/Http/PaginationTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BunqSdk.Tests/Http/PaginationTest.cs b/BunqSdk.Tests/Http/PaginationTest.cs index d1ba633..900b945 100644 --- a/BunqSdk.Tests/Http/PaginationTest.cs +++ b/BunqSdk.Tests/Http/PaginationTest.cs @@ -9,7 +9,7 @@ namespace Bunq.Sdk.Tests.Http /// Tests: /// Pagination /// - public class PaginationTest : BunqSdkTestBase + public class PaginationTest { /// /// Values of pagination properties for testing. From 48bcef2507dd0a0c4f8c15d4eb9bfa64749d1e13 Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 16:02:31 +0200 Subject: [PATCH 07/19] fix variable names [#17] --- BunqSdk.Tests/Http/PaginationTest.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BunqSdk.Tests/Http/PaginationTest.cs b/BunqSdk.Tests/Http/PaginationTest.cs index 900b945..5ae5a58 100644 --- a/BunqSdk.Tests/Http/PaginationTest.cs +++ b/BunqSdk.Tests/Http/PaginationTest.cs @@ -46,40 +46,40 @@ private static Pagination CreatePaginationWithAllPropertiesSet() public void TestGetUrlParamsPreviousPage() { var pagination = CreatePaginationWithAllPropertiesSet(); - var urlParamsCountOnlyExpected = new Dictionary + var urlParamsPreviousPageExpected = new Dictionary { {Pagination.PARAM_COUNT, PAGINATION_COUNT_CUSTOM.ToString()}, {Pagination.PARAM_OLDER_ID, PAGINATION_OLDER_ID_CUSTOM.ToString()} }; - Assert.Equal(urlParamsCountOnlyExpected, pagination.UrlParamsPreviousPage); + Assert.Equal(urlParamsPreviousPageExpected, pagination.UrlParamsPreviousPage); } [Fact] public void TestGetUrlParamsNextPageNewer() { var pagination = CreatePaginationWithAllPropertiesSet(); - var urlParamsCountOnlyExpected = new Dictionary + var urlParamsNextPageExpected = new Dictionary { {Pagination.PARAM_COUNT, PAGINATION_COUNT_CUSTOM.ToString()}, {Pagination.PARAM_NEWER_ID, PAGINATION_NEWER_ID_CUSTOM.ToString()} }; - Assert.Equal(urlParamsCountOnlyExpected, pagination.UrlParamsNextPage); + Assert.Equal(urlParamsNextPageExpected, pagination.UrlParamsNextPage); } [Fact] public void TestGetUrlParamsNextPageFuture() { var pagination = CreatePaginationWithNoNextPageAssured(); - var urlParamsCountOnlyExpected = new Dictionary + 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(urlParamsCountOnlyExpected, pagination.UrlParamsNextPage); + Assert.Equal(urlParamsNextPageExpected, pagination.UrlParamsNextPage); } private static Pagination CreatePaginationWithNoNextPageAssured() From 66935d683e21f7a652bffed56d6691be41748daf Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 16:04:21 +0200 Subject: [PATCH 08/19] add missing assertions [#17] --- BunqSdk.Tests/Http/PaginationTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BunqSdk.Tests/Http/PaginationTest.cs b/BunqSdk.Tests/Http/PaginationTest.cs index 5ae5a58..218535e 100644 --- a/BunqSdk.Tests/Http/PaginationTest.cs +++ b/BunqSdk.Tests/Http/PaginationTest.cs @@ -52,6 +52,7 @@ public void TestGetUrlParamsPreviousPage() {Pagination.PARAM_OLDER_ID, PAGINATION_OLDER_ID_CUSTOM.ToString()} }; + Assert.True(pagination.HasPreviousPage()); Assert.Equal(urlParamsPreviousPageExpected, pagination.UrlParamsPreviousPage); } @@ -65,6 +66,7 @@ public void TestGetUrlParamsNextPageNewer() {Pagination.PARAM_NEWER_ID, PAGINATION_NEWER_ID_CUSTOM.ToString()} }; + Assert.True(pagination.HasNextPageAssured()); Assert.Equal(urlParamsNextPageExpected, pagination.UrlParamsNextPage); } From 527317b400e30bf5c25e93f3ce636e8901a0b143 Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 16:15:17 +0200 Subject: [PATCH 09/19] Add missing tests [#17] --- BunqSdk.Tests/Http/PaginationTest.cs | 67 +++++++++++++++++++--------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/BunqSdk.Tests/Http/PaginationTest.cs b/BunqSdk.Tests/Http/PaginationTest.cs index 218535e..e59a137 100644 --- a/BunqSdk.Tests/Http/PaginationTest.cs +++ b/BunqSdk.Tests/Http/PaginationTest.cs @@ -56,6 +56,20 @@ public void TestGetUrlParamsPreviousPage() 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() { @@ -70,10 +84,25 @@ public void TestGetUrlParamsNextPageNewer() 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 = CreatePaginationWithNoNextPageAssured(); + var pagination = CreatePaginationWithAllPropertiesSet(); + pagination.NewerId = null; var urlParamsNextPageExpected = new Dictionary { {Pagination.PARAM_COUNT, PAGINATION_COUNT_CUSTOM.ToString()}, @@ -84,45 +113,39 @@ public void TestGetUrlParamsNextPageFuture() Assert.Equal(urlParamsNextPageExpected, pagination.UrlParamsNextPage); } - private static Pagination CreatePaginationWithNoNextPageAssured() + [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()} + }; - return pagination; + Assert.False(pagination.HasNextPageAssured()); + Assert.Equal(urlParamsNextPageExpected, pagination.UrlParamsNextPage); } [Fact] public void TestGetUrlParamsPreviousPageFromPaginationWithNoPreviousPage() - { - var pagination = CreatePaginationWithNoPreviousPage(); - - Assert.False(pagination.HasPreviousPage()); - Assert.Throws(() => pagination.UrlParamsPreviousPage); - } - - private static Pagination CreatePaginationWithNoPreviousPage() { var pagination = CreatePaginationWithAllPropertiesSet(); pagination.OlderId = null; - return pagination; + Assert.False(pagination.HasPreviousPage()); + Assert.Throws(() => pagination.UrlParamsPreviousPage); } [Fact] - public void TestGetUrlParamsPreviousPageFromPaginationWithNoNextPage() - { - var pagination = CreatePaginationWithNoNextPage(); - - Assert.Throws(() => pagination.UrlParamsNextPage); - } - - private static Pagination CreatePaginationWithNoNextPage() + public void TestGetUrlParamsNextPageFromPaginationWithNoNextPage() { - var pagination = CreatePaginationWithNoNextPageAssured(); + var pagination = CreatePaginationWithAllPropertiesSet(); + pagination.NewerId = null; pagination.FutureId = null; - return pagination; + Assert.Throws(() => pagination.UrlParamsNextPage); } } } From 19830d0e56d9791dc8ef8eb4ee7e869ce9211033 Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 17:48:32 +0200 Subject: [PATCH 10/19] fix return type [#17] --- BunqSdk.Tests/Http/PaginationScenarioTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BunqSdk.Tests/Http/PaginationScenarioTest.cs b/BunqSdk.Tests/Http/PaginationScenarioTest.cs index f9fbb34..8a38cbd 100644 --- a/BunqSdk.Tests/Http/PaginationScenarioTest.cs +++ b/BunqSdk.Tests/Http/PaginationScenarioTest.cs @@ -78,7 +78,7 @@ private static int GetPaymentsMissingCount() return PAYMENT_REQUIRED_COUNT_MINIMUM - GetPaymentsRequired().Count; } - private static List GetPaymentsRequired() + private static IList GetPaymentsRequired() { var pagination = new Pagination { From 561ff383b4e6d5c7d0ec700d67d59923ca27ddad Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 21:10:52 +0200 Subject: [PATCH 11/19] fix constant names [#17] --- BunqSdk.Tests/Http/PaginationScenarioTest.cs | 10 +++++----- BunqSdk.Tests/Model/Generated/PaymentTest.cs | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/BunqSdk.Tests/Http/PaginationScenarioTest.cs b/BunqSdk.Tests/Http/PaginationScenarioTest.cs index 8a38cbd..05bf58d 100644 --- a/BunqSdk.Tests/Http/PaginationScenarioTest.cs +++ b/BunqSdk.Tests/Http/PaginationScenarioTest.cs @@ -31,9 +31,9 @@ public class PaginationScenarioTest : BunqSdkTestBase /// /// Constants for payment creation. /// - 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 AMOUNT_EUR = "0.01"; + private const string CURRENCY = "EUR"; + private const string PAYMENT_DESCRIPTION = "C# test Payment"; /// /// API context to use for the test API calls. @@ -97,8 +97,8 @@ private static void CreatePayment() { 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(AMOUNT_EUR, CURRENCY)}, + {Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION}, {Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_OTHER} }; diff --git a/BunqSdk.Tests/Model/Generated/PaymentTest.cs b/BunqSdk.Tests/Model/Generated/PaymentTest.cs index bd7eb7a..00b41f6 100644 --- a/BunqSdk.Tests/Model/Generated/PaymentTest.cs +++ b/BunqSdk.Tests/Model/Generated/PaymentTest.cs @@ -15,9 +15,9 @@ 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 AMOUNT_EUR = "0.01"; + private const string 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(); @@ -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(AMOUNT_EUR, 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(AMOUNT_EUR, CURRENCY)}, + {Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION}, {Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_SELF} }; From 7d64bd7ffeb8c9308adc37ae1708c46a8d0515c1 Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 21:12:41 +0200 Subject: [PATCH 12/19] fix field name [#17] --- BunqSdk.Tests/Model/Generated/PaymentChatTest.cs | 4 ++-- BunqSdk.Tests/Model/Generated/RequestInquiryTest.cs | 4 ++-- BunqSdk.Tests/Model/Generated/TabUsageSingleTest.cs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/BunqSdk.Tests/Model/Generated/PaymentChatTest.cs b/BunqSdk.Tests/Model/Generated/PaymentChatTest.cs index e01bfdf..ce3cd92 100644 --- a/BunqSdk.Tests/Model/Generated/PaymentChatTest.cs +++ b/BunqSdk.Tests/Model/Generated/PaymentChatTest.cs @@ -17,7 +17,7 @@ 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"; @@ -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/RequestInquiryTest.cs b/BunqSdk.Tests/Model/Generated/RequestInquiryTest.cs index 7b7ebdb..c0dd15a 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"; @@ -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); From 17eeb67f99a5880f67b7968fee8cb08151f35b59 Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 21:40:32 +0200 Subject: [PATCH 13/19] add missing generated code [#17] --- BunqSdk/Model/Generated/Card.cs | 6 ++++++ BunqSdk/Model/Generated/CustomerLimit.cs | 6 ++++++ BunqSdk/Model/Generated/DeviceServer.cs | 9 ++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/BunqSdk/Model/Generated/Card.cs b/BunqSdk/Model/Generated/Card.cs index 983704a..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. diff --git a/BunqSdk/Model/Generated/CustomerLimit.cs b/BunqSdk/Model/Generated/CustomerLimit.cs index 37ba240..9cb5f65 100644 --- a/BunqSdk/Model/Generated/CustomerLimit.cs +++ b/BunqSdk/Model/Generated/CustomerLimit.cs @@ -38,6 +38,12 @@ public class CustomerLimit : BunqModel [JsonProperty(PropertyName = "limit_card_debit_mastercard")] public int? LimitCardDebitMastercard { get; private set; } + /// + /// The limit of free replacement cards. + /// + [JsonProperty(PropertyName = "limit_card_debit_replacement")] + public int? LimitCardDebitReplacement { get; private set; } + /// /// Get all limits for the authenticated user. /// diff --git a/BunqSdk/Model/Generated/DeviceServer.cs b/BunqSdk/Model/Generated/DeviceServer.cs index 8894405..3208c0b 100644 --- a/BunqSdk/Model/Generated/DeviceServer.cs +++ b/BunqSdk/Model/Generated/DeviceServer.cs @@ -69,9 +69,12 @@ public class DeviceServer : BunqModel public string Status { get; private set; } /// - /// Create a new DeviceServer. Provide the Installation token in the "X-Bunq-Client-Authentication" header. And - /// sign this request with the key of which you used the public part to create the Installation. Your API key - /// will be bound to the ip address of this DeviceServer. + /// Create a new DeviceServer providing the installation token in the header and signing the request with the + /// private part of the key you used to create the installation. The API Key that you are using will be bound to + /// the IP address of the DeviceServer which you have created.

Using a Wildcard API Key gives you the + /// freedom to make API calls even if the IP address has changed after the POST device-server.

Find out + /// more at this link https://bunq.com/en/apikey-dynamic-ip. ///
public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, IDictionary customHeaders = null) From 4362799d509a7f85d87eb1b763aaeb310ccde2e0 Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 22:29:25 +0200 Subject: [PATCH 14/19] use lists for pagination scenario test [#17] --- BunqSdk.Tests/Http/PaginationScenarioTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BunqSdk.Tests/Http/PaginationScenarioTest.cs b/BunqSdk.Tests/Http/PaginationScenarioTest.cs index 05bf58d..581dd45 100644 --- a/BunqSdk.Tests/Http/PaginationScenarioTest.cs +++ b/BunqSdk.Tests/Http/PaginationScenarioTest.cs @@ -44,7 +44,7 @@ public class PaginationScenarioTest : BunqSdkTestBase public void TestApiScenarioPaymentListingWithPagination() { EnsureEnoughPayments(); - var paymentsExpected = new HashSet(GetPaymentsRequired()); + var paymentsExpected = new List(GetPaymentsRequired()); var paginationCountOnly = new Pagination { Count = PAYMENT_LISTING_PAGE_SIZE @@ -56,9 +56,9 @@ public void TestApiScenarioPaymentListingWithPagination() var paginationPrevious = paymentResponsePrevious.Pagination; var paymentResponsePreviousNext = ListPayments(paginationPrevious.UrlParamsNextPage); - var paymentsActual = new HashSet(); - paymentsActual.UnionWith(paymentResponsePreviousNext.Value); - paymentsActual.UnionWith(paymentResponsePrevious.Value); + var paymentsActual = new List(); + paymentsActual.AddRange(paymentResponsePreviousNext.Value); + paymentsActual.AddRange(paymentResponsePrevious.Value); var paymentsExpectedSerialized = BunqJsonConvert.SerializeObject(paymentsExpected); var paymentsActualSerialized = BunqJsonConvert.SerializeObject(paymentsActual); From f86772a50fe219947203971a412e744726dcc5de Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 22:42:45 +0200 Subject: [PATCH 15/19] allow multiple IPs in config [#17] --- BunqSdk.Tests/BunqSdkTestBase.cs | 7 +++--- BunqSdk.Tests/Config.cs | 26 +++++++++++++++++---- BunqSdk.Tests/Resources/config.example.json | 2 +- 3 files changed, 26 insertions(+), 9 deletions(-) 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..89ee40b 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"; @@ -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/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", From b5bdbb0e571369259a577234c67d8be958ca9404 Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Tue, 5 Sep 2017 23:15:20 +0200 Subject: [PATCH 16/19] fix variable names [#17] --- BunqSdk.Tests/Http/PaginationScenarioTest.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/BunqSdk.Tests/Http/PaginationScenarioTest.cs b/BunqSdk.Tests/Http/PaginationScenarioTest.cs index 581dd45..43d826d 100644 --- a/BunqSdk.Tests/Http/PaginationScenarioTest.cs +++ b/BunqSdk.Tests/Http/PaginationScenarioTest.cs @@ -50,15 +50,15 @@ public void TestApiScenarioPaymentListingWithPagination() Count = PAYMENT_LISTING_PAGE_SIZE }; - var paymentResponseLatest = ListPayments(paginationCountOnly.UrlParamsCountOnly); - var paginationLatest = paymentResponseLatest.Pagination; - var paymentResponsePrevious = ListPayments(paginationLatest.UrlParamsPreviousPage); - var paginationPrevious = paymentResponsePrevious.Pagination; - var paymentResponsePreviousNext = ListPayments(paginationPrevious.UrlParamsNextPage); + 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(paymentResponsePreviousNext.Value); - paymentsActual.AddRange(paymentResponsePrevious.Value); + paymentsActual.AddRange(responsePreviousNext.Value); + paymentsActual.AddRange(responsePrevious.Value); var paymentsExpectedSerialized = BunqJsonConvert.SerializeObject(paymentsExpected); var paymentsActualSerialized = BunqJsonConvert.SerializeObject(paymentsActual); From 5c7a2cf9554d0cef6bde7095fdcfb72f7e7a32f3 Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Wed, 6 Sep 2017 11:45:52 +0200 Subject: [PATCH 17/19] fix method names [#17] --- BunqSdk.Tests/Config.cs | 4 ++-- BunqSdk.Tests/Http/PaginationScenarioTest.cs | 2 +- BunqSdk.Tests/Model/Generated/PaymentChatTest.cs | 2 +- BunqSdk.Tests/Model/Generated/PaymentTest.cs | 4 ++-- BunqSdk.Tests/Model/Generated/RequestInquiryTest.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/BunqSdk.Tests/Config.cs b/BunqSdk.Tests/Config.cs index 89ee40b..a2077a9 100644 --- a/BunqSdk.Tests/Config.cs +++ b/BunqSdk.Tests/Config.cs @@ -42,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(); @@ -50,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(); diff --git a/BunqSdk.Tests/Http/PaginationScenarioTest.cs b/BunqSdk.Tests/Http/PaginationScenarioTest.cs index 43d826d..9e7cea5 100644 --- a/BunqSdk.Tests/Http/PaginationScenarioTest.cs +++ b/BunqSdk.Tests/Http/PaginationScenarioTest.cs @@ -19,7 +19,7 @@ public class PaginationScenarioTest : BunqSdkTestBase /// 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.GetCounterAliasOther(); + private static readonly Pointer COUNTER_PARTY_OTHER = Config.GetCounterPartyAliasOther(); /// /// Constants for scenario testing. diff --git a/BunqSdk.Tests/Model/Generated/PaymentChatTest.cs b/BunqSdk.Tests/Model/Generated/PaymentChatTest.cs index ce3cd92..add8425 100644 --- a/BunqSdk.Tests/Model/Generated/PaymentChatTest.cs +++ b/BunqSdk.Tests/Model/Generated/PaymentChatTest.cs @@ -24,7 +24,7 @@ public class PaymentChatTest : BunqSdkTestBase 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. diff --git a/BunqSdk.Tests/Model/Generated/PaymentTest.cs b/BunqSdk.Tests/Model/Generated/PaymentTest.cs index 00b41f6..ff80fd9 100644 --- a/BunqSdk.Tests/Model/Generated/PaymentTest.cs +++ b/BunqSdk.Tests/Model/Generated/PaymentTest.cs @@ -21,8 +21,8 @@ public class PaymentTest : BunqSdkTestBase 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. diff --git a/BunqSdk.Tests/Model/Generated/RequestInquiryTest.cs b/BunqSdk.Tests/Model/Generated/RequestInquiryTest.cs index c0dd15a..2daca50 100644 --- a/BunqSdk.Tests/Model/Generated/RequestInquiryTest.cs +++ b/BunqSdk.Tests/Model/Generated/RequestInquiryTest.cs @@ -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. From ff2a6b849f1bac609ef0283358cd3bbe2dcf1ea9 Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Wed, 6 Sep 2017 12:00:52 +0200 Subject: [PATCH 18/19] fix constant names [#17] --- BunqSdk.Tests/Http/PaginationScenarioTest.cs | 6 +++--- BunqSdk.Tests/Model/Generated/PaymentTest.cs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/BunqSdk.Tests/Http/PaginationScenarioTest.cs b/BunqSdk.Tests/Http/PaginationScenarioTest.cs index 9e7cea5..ea69a90 100644 --- a/BunqSdk.Tests/Http/PaginationScenarioTest.cs +++ b/BunqSdk.Tests/Http/PaginationScenarioTest.cs @@ -31,8 +31,8 @@ public class PaginationScenarioTest : BunqSdkTestBase /// /// Constants for payment creation. /// - private const string AMOUNT_EUR = "0.01"; - private const string CURRENCY = "EUR"; + private const string PAYMENT_AMOUNT_EUR = "0.01"; + private const string PAYMENT_CURRENCY = "EUR"; private const string PAYMENT_DESCRIPTION = "C# test Payment"; /// @@ -97,7 +97,7 @@ private static void CreatePayment() { var requestMap = new Dictionary { - {Payment.FIELD_AMOUNT, new Amount(AMOUNT_EUR, CURRENCY)}, + {Payment.FIELD_AMOUNT, new Amount(PAYMENT_AMOUNT_EUR, PAYMENT_CURRENCY)}, {Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION}, {Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_OTHER} }; diff --git a/BunqSdk.Tests/Model/Generated/PaymentTest.cs b/BunqSdk.Tests/Model/Generated/PaymentTest.cs index ff80fd9..b01be02 100644 --- a/BunqSdk.Tests/Model/Generated/PaymentTest.cs +++ b/BunqSdk.Tests/Model/Generated/PaymentTest.cs @@ -15,8 +15,8 @@ public class PaymentTest : BunqSdkTestBase /// /// Config values. /// - private const string AMOUNT_EUR = "0.01"; - private const string CURRENCY = "EUR"; + 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(); @@ -39,7 +39,7 @@ public void TestMakePaymentToOtherUser() { var requestMap = new Dictionary { - {Payment.FIELD_AMOUNT, new Amount(AMOUNT_EUR, CURRENCY)}, + {Payment.FIELD_AMOUNT, new Amount(PAYMENT_AMOUNT_EUR, PAYMENT_CURRENCY)}, {Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION}, {Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_OTHER} }; @@ -57,7 +57,7 @@ public void TestMakePaymentToOtherAccount() { var requestMap = new Dictionary { - {Payment.FIELD_AMOUNT, new Amount(AMOUNT_EUR, CURRENCY)}, + {Payment.FIELD_AMOUNT, new Amount(PAYMENT_AMOUNT_EUR, PAYMENT_CURRENCY)}, {Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION}, {Payment.FIELD_COUNTERPARTY_ALIAS, COUNTER_PARTY_SELF} }; From dbc08952fbd4eb5d07b8e8413a016c9276444bac Mon Sep 17 00:00:00 2001 From: Daniil Belyakov Date: Wed, 6 Sep 2017 21:28:42 +0200 Subject: [PATCH 19/19] bump up version to 0.11.0 --- BunqSdk/BunqSdk.csproj | 2 +- BunqSdk/Http/ApiClient.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/Http/ApiClient.cs b/BunqSdk/Http/ApiClient.cs index 58ab0eb..fcd185a 100644 --- a/BunqSdk/Http/ApiClient.cs +++ b/BunqSdk/Http/ApiClient.cs @@ -40,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";