From 38a939e593119f916bb5e1bab5bbce7db3a477e3 Mon Sep 17 00:00:00 2001 From: Kevin Hellemun Date: Wed, 25 Oct 2017 15:49:51 +0200 Subject: [PATCH] Added cvc_endpoint. #35 --- BunqSdk/Model/Generated/Endpoint/Card.cs | 6 ++ BunqSdk/Model/Generated/Endpoint/CardDebit.cs | 6 ++ .../Generated/Endpoint/CardGeneratedCvc2.cs | 90 +++++++++++++++++++ .../Model/Generated/Endpoint/CashRegister.cs | 7 +- .../Generated/Endpoint/MonetaryAccountBank.cs | 2 +- .../Model/Generated/Endpoint/UserCompany.cs | 4 +- .../Model/Generated/Endpoint/UserPerson.cs | 4 +- 7 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 BunqSdk/Model/Generated/Endpoint/CardGeneratedCvc2.cs diff --git a/BunqSdk/Model/Generated/Endpoint/Card.cs b/BunqSdk/Model/Generated/Endpoint/Card.cs index 6691a7f..a167ffb 100644 --- a/BunqSdk/Model/Generated/Endpoint/Card.cs +++ b/BunqSdk/Model/Generated/Endpoint/Card.cs @@ -65,6 +65,12 @@ public class Card : BunqModel [JsonProperty(PropertyName = "public_uuid")] public string PublicUuid { get; private set; } + /// + /// The type of the card. Can be MAESTRO, MASTERCARD. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + /// /// The second line of text on the card /// diff --git a/BunqSdk/Model/Generated/Endpoint/CardDebit.cs b/BunqSdk/Model/Generated/Endpoint/CardDebit.cs index 0cc406d..79a2fec 100644 --- a/BunqSdk/Model/Generated/Endpoint/CardDebit.cs +++ b/BunqSdk/Model/Generated/Endpoint/CardDebit.cs @@ -62,6 +62,12 @@ public class CardDebit : BunqModel [JsonProperty(PropertyName = "public_uuid")] public string PublicUuid { get; private set; } + /// + /// The type of the card. Can be MAESTRO, MASTERCARD. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + /// /// The second line of text on the card /// diff --git a/BunqSdk/Model/Generated/Endpoint/CardGeneratedCvc2.cs b/BunqSdk/Model/Generated/Endpoint/CardGeneratedCvc2.cs new file mode 100644 index 0000000..6d463bc --- /dev/null +++ b/BunqSdk/Model/Generated/Endpoint/CardGeneratedCvc2.cs @@ -0,0 +1,90 @@ +using Bunq.Sdk.Context; +using Bunq.Sdk.Http; +using Bunq.Sdk.Json; +using Bunq.Sdk.Model.Core; +using Bunq.Sdk.Security; +using Newtonsoft.Json; +using System.Collections.Generic; +using System.Text; +using System; + +namespace Bunq.Sdk.Model.Generated.Endpoint +{ + /// + /// Endpoint for generating and retrieving a new CVC2 code. + /// + public class CardGeneratedCvc2 : BunqModel + { + /// + /// Endpoint constants. + /// + private const string ENDPOINT_URL_CREATE = "user/{0}/card/{1}/generated-cvc2"; + private const string ENDPOINT_URL_READ = "user/{0}/card/{1}/generated-cvc2/{2}"; + private const string ENDPOINT_URL_LISTING = "user/{0}/card/{1}/generated-cvc2"; + + /// + /// Object type. + /// + private const string OBJECT_TYPE = "CardGeneratedCvc2"; + + /// + /// The cvc2 code. + /// + [JsonProperty(PropertyName = "cvc2")] + public string Cvc2 { get; private set; } + + /// + /// The status of the cvc2. Can be AVAILABLE, USED, EXPIRED, BLOCKED. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; private set; } + + /// + /// Expiry time of the cvc2. + /// + [JsonProperty(PropertyName = "expiry_time")] + public string ExpiryTime { get; private set; } + + /// + /// Generate a new CVC2 code for a card. + /// + public static BunqResponse Create(ApiContext apiContext, IDictionary requestMap, 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); + var responseRaw = apiClient.Post(string.Format(ENDPOINT_URL_CREATE, userId, cardId), requestBytes, customHeaders); + + return FromJson(responseRaw, OBJECT_TYPE); + } + + /// + /// Get the details for a specific generated CVC2 code. + /// + public static BunqResponse Get(ApiContext apiContext, int userId, int cardId, int cardGeneratedCvc2Id, 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, cardGeneratedCvc2Id), new Dictionary(), customHeaders); + + return FromJson(responseRaw, OBJECT_TYPE); + } + + /// + /// Get all generated CVC2 codes for a card. + /// + public static BunqResponse> List(ApiContext apiContext, int userId, int cardId, 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, cardId), urlParams, customHeaders); + + return FromJsonList(responseRaw, OBJECT_TYPE); + } + } +} diff --git a/BunqSdk/Model/Generated/Endpoint/CashRegister.cs b/BunqSdk/Model/Generated/Endpoint/CashRegister.cs index 290c4bd..30d3496 100644 --- a/BunqSdk/Model/Generated/Endpoint/CashRegister.cs +++ b/BunqSdk/Model/Generated/Endpoint/CashRegister.cs @@ -11,8 +11,11 @@ namespace Bunq.Sdk.Model.Generated.Endpoint { /// - /// CashRegisters act as an point of sale. They have a specific name and avatar, and optionally a location. A - /// CashRegister is used to create Tabs. A CashRegister can have an QR code that links to one of its Tabs. + /// CashRegisters are virtual points of sale. They have a specific name and avatar, and optionally, a + /// location.
With a CashRegister you can create a Tab and then use a QR code to receive payments.
Check out + /// our Quickstart example to learn how you can easily create Tab + /// payments.

Notification filters can be set on a CashRegister to receive callbacks. For more + /// information check the dedicated callbacks page. ///
public class CashRegister : BunqModel { diff --git a/BunqSdk/Model/Generated/Endpoint/MonetaryAccountBank.cs b/BunqSdk/Model/Generated/Endpoint/MonetaryAccountBank.cs index 1083389..0be1c17 100644 --- a/BunqSdk/Model/Generated/Endpoint/MonetaryAccountBank.cs +++ b/BunqSdk/Model/Generated/Endpoint/MonetaryAccountBank.cs @@ -15,7 +15,7 @@ namespace Bunq.Sdk.Model.Generated.Endpoint /// MonetaryAccountBanks and update specific fields of an existing MonetaryAccountBank. Examples of fields that can /// be updated are the description, the daily limit and the avatar of the account.

Notification filters can /// be set on a monetary account level to receive callbacks. For more information check the dedicated callbacks page. + /// href="/api/1/page/callbacks">dedicated callbacks page. /// public class MonetaryAccountBank : BunqModel { diff --git a/BunqSdk/Model/Generated/Endpoint/UserCompany.cs b/BunqSdk/Model/Generated/Endpoint/UserCompany.cs index 4c1717c..487e468 100644 --- a/BunqSdk/Model/Generated/Endpoint/UserCompany.cs +++ b/BunqSdk/Model/Generated/Endpoint/UserCompany.cs @@ -11,7 +11,9 @@ namespace Bunq.Sdk.Model.Generated.Endpoint { /// - /// Show the authenticated user, if it is a company. + /// With UserCompany you can retrieve information regarding the authenticated UserCompany and update specific + /// fields.

Notification filters can be set on a UserCompany level to receive callbacks. For more + /// information check the dedicated callbacks page. ///
public class UserCompany : BunqModel { diff --git a/BunqSdk/Model/Generated/Endpoint/UserPerson.cs b/BunqSdk/Model/Generated/Endpoint/UserPerson.cs index c16e6cc..3f1e521 100644 --- a/BunqSdk/Model/Generated/Endpoint/UserPerson.cs +++ b/BunqSdk/Model/Generated/Endpoint/UserPerson.cs @@ -11,7 +11,9 @@ namespace Bunq.Sdk.Model.Generated.Endpoint { /// - /// Show the authenticated user, if it is a person. + /// With UserPerson you can retrieve information regarding the authenticated UserPerson and update specific + /// fields.

Notification filters can be set on a UserPerson level to receive callbacks. For more + /// information check the dedicated callbacks page. ///
public class UserPerson : BunqModel {