-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from bunq/feature/cvc_endpoint
Added cvc_endpoint. #35
- Loading branch information
Showing
7 changed files
with
114 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// Endpoint for generating and retrieving a new CVC2 code. | ||
/// </summary> | ||
public class CardGeneratedCvc2 : BunqModel | ||
{ | ||
/// <summary> | ||
/// Endpoint constants. | ||
/// </summary> | ||
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"; | ||
|
||
/// <summary> | ||
/// Object type. | ||
/// </summary> | ||
private const string OBJECT_TYPE = "CardGeneratedCvc2"; | ||
|
||
/// <summary> | ||
/// The cvc2 code. | ||
/// </summary> | ||
[JsonProperty(PropertyName = "cvc2")] | ||
public string Cvc2 { get; private set; } | ||
|
||
/// <summary> | ||
/// The status of the cvc2. Can be AVAILABLE, USED, EXPIRED, BLOCKED. | ||
/// </summary> | ||
[JsonProperty(PropertyName = "status")] | ||
public string Status { get; private set; } | ||
|
||
/// <summary> | ||
/// Expiry time of the cvc2. | ||
/// </summary> | ||
[JsonProperty(PropertyName = "expiry_time")] | ||
public string ExpiryTime { get; private set; } | ||
|
||
/// <summary> | ||
/// Generate a new CVC2 code for a card. | ||
/// </summary> | ||
public static BunqResponse<CardGeneratedCvc2> Create(ApiContext apiContext, IDictionary<string, object> requestMap, int userId, int cardId, IDictionary<string, string> customHeaders = null) | ||
{ | ||
if (customHeaders == null) customHeaders = new Dictionary<string, string>(); | ||
|
||
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<CardGeneratedCvc2>(responseRaw, OBJECT_TYPE); | ||
} | ||
|
||
/// <summary> | ||
/// Get the details for a specific generated CVC2 code. | ||
/// </summary> | ||
public static BunqResponse<CardGeneratedCvc2> Get(ApiContext apiContext, int userId, int cardId, int cardGeneratedCvc2Id, IDictionary<string, string> customHeaders = null) | ||
{ | ||
if (customHeaders == null) customHeaders = new Dictionary<string, string>(); | ||
|
||
var apiClient = new ApiClient(apiContext); | ||
var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, cardId, cardGeneratedCvc2Id), new Dictionary<string, string>(), customHeaders); | ||
|
||
return FromJson<CardGeneratedCvc2>(responseRaw, OBJECT_TYPE); | ||
} | ||
|
||
/// <summary> | ||
/// Get all generated CVC2 codes for a card. | ||
/// </summary> | ||
public static BunqResponse<List<CardGeneratedCvc2>> List(ApiContext apiContext, int userId, int cardId, IDictionary<string, string> urlParams = null, IDictionary<string, string> customHeaders = null) | ||
{ | ||
if (urlParams == null) urlParams = new Dictionary<string, string>(); | ||
if (customHeaders == null) customHeaders = new Dictionary<string, string>(); | ||
|
||
var apiClient = new ApiClient(apiContext); | ||
var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, cardId), urlParams, customHeaders); | ||
|
||
return FromJsonList<CardGeneratedCvc2>(responseRaw, OBJECT_TYPE); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters