From ae0c3f8c20865128ff95ffec0eec12948e9eeae7 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Thu, 1 Mar 2018 16:38:56 +0100 Subject: [PATCH 1/2] Regenerated code. (bunq/sdk_csharp#76) --- BunqSdk/Model/Generated/Endpoint/CardDebit.cs | 1 - .../Generated/Endpoint/MasterCardAction.cs | 11 ++++ .../Generated/Endpoint/RequestResponse.cs | 2 +- .../Endpoint/TokenQrRequestSofort.cs | 61 +++++++++++++++++++ .../Model/Generated/Endpoint/UserCompany.cs | 22 +++++++ .../Model/Generated/Endpoint/UserPerson.cs | 2 + .../Generated/Object/CardPinAssignment.cs | 6 +- 7 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 BunqSdk/Model/Generated/Endpoint/TokenQrRequestSofort.cs diff --git a/BunqSdk/Model/Generated/Endpoint/CardDebit.cs b/BunqSdk/Model/Generated/Endpoint/CardDebit.cs index b4637460..234d9ef2 100644 --- a/BunqSdk/Model/Generated/Endpoint/CardDebit.cs +++ b/BunqSdk/Model/Generated/Endpoint/CardDebit.cs @@ -27,7 +27,6 @@ public class CardDebit : BunqModel /// public const string FIELD_SECOND_LINE = "second_line"; public const string FIELD_NAME_ON_CARD = "name_on_card"; - 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"; diff --git a/BunqSdk/Model/Generated/Endpoint/MasterCardAction.cs b/BunqSdk/Model/Generated/Endpoint/MasterCardAction.cs index 2382f82a..538dba05 100644 --- a/BunqSdk/Model/Generated/Endpoint/MasterCardAction.cs +++ b/BunqSdk/Model/Generated/Endpoint/MasterCardAction.cs @@ -171,6 +171,12 @@ public class MasterCardAction : BunqModel [JsonProperty(PropertyName = "eligible_whitelist_id")] public int? EligibleWhitelistId { get; private set; } + /// + /// The secure code id for this mastercard action or null. + /// + [JsonProperty(PropertyName = "secure_code_id")] + public int? SecureCodeId { get; private set; } + /// /// public static BunqResponse Get(ApiContext apiContext, int userId, int monetaryAccountId, int masterCardActionId, IDictionary customHeaders = null) @@ -321,6 +327,11 @@ public override bool IsAllFieldNull() return false; } + if (this.SecureCodeId != null) + { + return false; + } + return true; } diff --git a/BunqSdk/Model/Generated/Endpoint/RequestResponse.cs b/BunqSdk/Model/Generated/Endpoint/RequestResponse.cs index b533b076..d3c59694 100644 --- a/BunqSdk/Model/Generated/Endpoint/RequestResponse.cs +++ b/BunqSdk/Model/Generated/Endpoint/RequestResponse.cs @@ -138,7 +138,7 @@ public class RequestResponse : BunqModel public Geolocation Geolocation { get; private set; } /// - /// The type of the RequestInquiry. Can be DIRECT_DEBIT, DIRECT_DEBIT_B2B, IDEAL or INTERNAL. + /// The type of the RequestInquiry. Can be DIRECT_DEBIT, DIRECT_DEBIT_B2B, IDEAL, SOFORT or INTERNAL. /// [JsonProperty(PropertyName = "type")] public string Type { get; private set; } diff --git a/BunqSdk/Model/Generated/Endpoint/TokenQrRequestSofort.cs b/BunqSdk/Model/Generated/Endpoint/TokenQrRequestSofort.cs new file mode 100644 index 00000000..03769bfd --- /dev/null +++ b/BunqSdk/Model/Generated/Endpoint/TokenQrRequestSofort.cs @@ -0,0 +1,61 @@ +using Bunq.Sdk.Context; +using Bunq.Sdk.Http; +using Bunq.Sdk.Json; +using Bunq.Sdk.Model.Core; +using Newtonsoft.Json; +using System.Collections.Generic; +using System.Text; +using System; + +namespace Bunq.Sdk.Model.Generated.Endpoint +{ + /// + /// Using this call you can create a SOFORT Request assigned to your User by providing the Token of the request. + /// + public class TokenQrRequestSofort : BunqModel + { + /// + /// Endpoint constants. + /// + private const string ENDPOINT_URL_CREATE = "user/{0}/token-qr-request-sofort"; + + /// + /// Field constants. + /// + public const string FIELD_TOKEN = "token"; + + /// + /// Object type. + /// + private const string OBJECT_TYPE_POST = "RequestResponse"; + + /// + /// Create a request from an SOFORT transaction. + /// + 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_POST); + } + + + /// + /// + public override bool IsAllFieldNull() + { + return true; + } + + /// + /// + public static TokenQrRequestSofort CreateFromJsonString(string json) + { + return BunqModel.CreateFromJsonString(json); + } + } +} diff --git a/BunqSdk/Model/Generated/Endpoint/UserCompany.cs b/BunqSdk/Model/Generated/Endpoint/UserCompany.cs index 025b2f5d..2935ef91 100644 --- a/BunqSdk/Model/Generated/Endpoint/UserCompany.cs +++ b/BunqSdk/Model/Generated/Endpoint/UserCompany.cs @@ -195,6 +195,18 @@ public class UserCompany : BunqModel [JsonProperty(PropertyName = "session_timeout")] public int? SessionTimeout { get; private set; } + /// + /// Card ids used for centralized card limits. + /// + [JsonProperty(PropertyName = "card_ids")] + public List CardIds { get; private set; } + + /// + /// The centralized limits for user's cards. + /// + [JsonProperty(PropertyName = "card_limits")] + public List CardLimits { get; private set; } + /// /// The amount the company can pay in the session without asking for credentials. /// @@ -377,6 +389,16 @@ public override bool IsAllFieldNull() return false; } + if (this.CardIds != null) + { + return false; + } + + if (this.CardLimits != null) + { + return false; + } + if (this.DailyLimitWithoutConfirmationLogin != null) { return false; diff --git a/BunqSdk/Model/Generated/Endpoint/UserPerson.cs b/BunqSdk/Model/Generated/Endpoint/UserPerson.cs index 08c708b3..b93212ed 100644 --- a/BunqSdk/Model/Generated/Endpoint/UserPerson.cs +++ b/BunqSdk/Model/Generated/Endpoint/UserPerson.cs @@ -50,6 +50,8 @@ public class UserPerson : BunqModel public const string FIELD_SUB_STATUS = "sub_status"; public const string FIELD_LEGAL_GUARDIAN_ALIAS = "legal_guardian_alias"; public const string FIELD_SESSION_TIMEOUT = "session_timeout"; + public const string FIELD_CARD_IDS = "card_ids"; + public const string FIELD_CARD_LIMITS = "card_limits"; public const string FIELD_DAILY_LIMIT_WITHOUT_CONFIRMATION_LOGIN = "daily_limit_without_confirmation_login"; public const string FIELD_COUNTER_BANK_IBAN = "counter_bank_iban"; public const string FIELD_NOTIFICATION_FILTERS = "notification_filters"; diff --git a/BunqSdk/Model/Generated/Object/CardPinAssignment.cs b/BunqSdk/Model/Generated/Object/CardPinAssignment.cs index b220ade4..38a31b27 100644 --- a/BunqSdk/Model/Generated/Object/CardPinAssignment.cs +++ b/BunqSdk/Model/Generated/Object/CardPinAssignment.cs @@ -24,11 +24,13 @@ public class CardPinAssignment : BunqModel /// The ID of the monetary account to assign to this pin for the card. /// [JsonProperty(PropertyName = "monetary_account_id")] - public string MonetaryAccountId { get; set; } + public int? MonetaryAccountId { get; set; } - public CardPinAssignment(string type) + public CardPinAssignment(string type, string pinCode, int? monetaryAccountId) { Type = type; + PinCode = pinCode; + MonetaryAccountId = monetaryAccountId; } From 5b255274078707fa2efefcc3dce16163d7f72cdb Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Thu, 1 Mar 2018 16:39:07 +0100 Subject: [PATCH 2/2] Fixed broken tests. (bunq/sdk_csharp#76) --- BunqSdk.Samples/CardDebitSample.cs | 12 ++++++++++-- .../Model/Generated/Endpoint/CardDebitTest.cs | 11 +++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/BunqSdk.Samples/CardDebitSample.cs b/BunqSdk.Samples/CardDebitSample.cs index f78d124e..98e91060 100644 --- a/BunqSdk.Samples/CardDebitSample.cs +++ b/BunqSdk.Samples/CardDebitSample.cs @@ -14,16 +14,24 @@ public class CardDebitSample : ISample private const string POINTER_TYPE_EMAIL = "EMAIL"; private const string EMAIL_YOUR_COMPANY = "at@at.at"; // Put your user email here private const string POINTER_NAME_TEST = "test pointer"; + private const string CARD_PIN_ASSIGNMENT_TYPE_PRIMARY = "PRIMARY"; private const int USER_ITEM_ID = 0; // Put your user ID here + private const int MONETARY_ACCOUNT_ID = 0; // Put your monetaryAccount ID here public void Run() { var apiContext = ApiContext.Restore(); + var cardPinAssignment = new CardPinAssignment( + CARD_PIN_ASSIGNMENT_TYPE_PRIMARY, + PIN_CODE, + MONETARY_ACCOUNT_ID + ); + var allCardPinAssignments = new List {cardPinAssignment}; var requestMap = new Dictionary { {CardDebit.FIELD_NAME_ON_CARD, NAME_YOUR_COMPANY}, {CardDebit.FIELD_SECOND_LINE, GenerateRandomSecondLine()}, - {CardDebit.FIELD_PIN_CODE, PIN_CODE}, + {CardDebit.FIELD_PIN_CODE_ASSIGNMENT, allCardPinAssignments}, { CardDebit.FIELD_ALIAS, new Pointer(POINTER_TYPE_EMAIL, EMAIL_YOUR_COMPANY) {Name = POINTER_NAME_TEST} @@ -40,4 +48,4 @@ private static string GenerateRandomSecondLine() return random.Next(0, (int) Math.Pow(10, 21) - 1).ToString(); } } -} +} \ No newline at end of file diff --git a/BunqSdk.Tests/Model/Generated/Endpoint/CardDebitTest.cs b/BunqSdk.Tests/Model/Generated/Endpoint/CardDebitTest.cs index a2c432bc..ae3618fd 100644 --- a/BunqSdk.Tests/Model/Generated/Endpoint/CardDebitTest.cs +++ b/BunqSdk.Tests/Model/Generated/Endpoint/CardDebitTest.cs @@ -17,6 +17,8 @@ public class CardDebitTest : BunqSdkTestBase /// /// Config values. /// + private const string CARD_PIN_ASSIGNMENT_TYPE_PRIMARY = "PRIMARY"; + private const string PIN_CODE = "4045"; private const int INDEX_FIRST = 0; private const int NONNEGATIVE_INTEGER_MINIMUM = 0; @@ -37,11 +39,16 @@ public class CardDebitTest : BunqSdkTestBase [Fact] public void TestOrderNewMaestroCard() { + var cardPinAssignment = new CardPinAssignment( + CARD_PIN_ASSIGNMENT_TYPE_PRIMARY, + PIN_CODE, + Config.GetMonetarytAccountId()); + var allCardPinAssignments = new List {cardPinAssignment}; var cardDebitMap = new Dictionary { {CardDebit.FIELD_ALIAS, GetAlias()}, {CardDebit.FIELD_NAME_ON_CARD, GetAnAllowedName()}, - {CardDebit.FIELD_PIN_CODE, PIN_CODE}, + {CardDebit.FIELD_PIN_CODE_ASSIGNMENT, allCardPinAssignments}, {CardDebit.FIELD_SECOND_LINE, GenerateRandomSecondLine()} }; var cardDebit = CardDebit.Create(API_CONTEXT, cardDebitMap, USER_ID).Value; @@ -73,4 +80,4 @@ private static Pointer GetAlias() return User.Get(API_CONTEXT, USER_ID).Value.UserCompany.Alias[INDEX_FIRST]; } } -} +} \ No newline at end of file