Skip to content

Commit 0fe0a00

Browse files
author
Kevin Hellemun
committed
Merge branch 'release/0.12.2'
2 parents 0b5b73e + c1a7b7a commit 0fe0a00

15 files changed

+210
-20
lines changed

.github/ISSUE_TEMPLATE.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Steps to reproduce:
2+
1.
3+
4+
## What should happen:
5+
1.
6+
7+
## What happens:
8+
1.
9+
10+
## Logs
11+
- Logs
12+
13+
## Extra info:
14+
- Tested on
15+

BunqSdk.Samples/BunqSdk.Samples.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<OutputType>Exe</OutputType>
44
<RootNamespace>Bunq.Sdk.Samples</RootNamespace>
55
<TargetFramework>netcoreapp1.1</TargetFramework>
6-
<LangVersion>5</LangVersion>
6+
<LangVersion>default</LangVersion>
77
</PropertyGroup>
88
<ItemGroup>
99
<ProjectReference Include="..\BunqSdk\BunqSdk.csproj" />

BunqSdk.Tests/BunqSdk.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFramework>netcoreapp1.1</TargetFramework>
44
<RootNamespace>Bunq.Sdk.Tests</RootNamespace>
5-
<LangVersion>5</LangVersion>
5+
<LangVersion>default</LangVersion>
66
<AssemblyName>BunqSdk.Tests.xunit.runner.json</AssemblyName>
77
</PropertyGroup>
88
<ItemGroup>

BunqSdk/BunqSdk.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<RuntimeFrameworkVersion>1.1.2</RuntimeFrameworkVersion>
44
<TargetFramework>netcoreapp1.1</TargetFramework>
55
<OutputType>Library</OutputType>
6-
<LangVersion>5</LangVersion>
6+
<LangVersion>default</LangVersion>
77
</PropertyGroup>
88
<PropertyGroup>
99
<AssemblyName>Bunq.Sdk</AssemblyName>
1010
<PackageId>Bunq.Sdk</PackageId>
1111
</PropertyGroup>
1212
<PropertyGroup>
13-
<VersionPrefix>0.12.0.0</VersionPrefix>
13+
<VersionPrefix>0.12.2.0</VersionPrefix>
1414
<VersionSuffix>beta</VersionSuffix>
1515
</PropertyGroup>
1616
<PropertyGroup>

BunqSdk/Context/ApiContext.cs

+13-5
Original file line numberDiff line numberDiff line change
@@ -176,19 +176,27 @@ private void DeleteSession()
176176
/// </summary>
177177
public void EnsureSessionActive()
178178
{
179-
if (SessionContext == null) return;
179+
if (!IsSessionActive())
180+
{
181+
ResetSession();
182+
}
183+
}
180184

185+
public bool IsSessionActive()
186+
{
187+
if (SessionContext == null)
188+
{
189+
return false;
190+
}
191+
181192
var timeToExpiry = SessionContext.ExpiryTime.Subtract(DateTime.Now);
182193
var timeToExpiryMinimum = new TimeSpan(
183194
TIME_UNIT_COUNT_NONE,
184195
TIME_UNIT_COUNT_NONE,
185196
TIME_TO_SESSION_EXPIRY_MINIMUM_SECONDS
186197
);
187198

188-
if (timeToExpiry < timeToExpiryMinimum)
189-
{
190-
ResetSession();
191-
}
199+
return timeToExpiry > timeToExpiryMinimum;
192200
}
193201

194202
/// <summary>

BunqSdk/Http/ApiClient.cs

+22-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ namespace Bunq.Sdk.Http
1616
{
1717
public class ApiClient
1818
{
19+
20+
/// <summary>
21+
/// Endpoints not requiring active session for the request to succeed.
22+
/// </summary>
23+
private const string DEVICE_SERVER_URL = "device-server";
24+
private const string INSTALLATION_URL = "installation";
25+
private const string SESSION_SERVER_URL = "session-server";
26+
private static readonly string[] URIS_NOT_REQUIRING_ACTIVE_SESSION = new string[]
27+
{
28+
DEVICE_SERVER_URL,
29+
INSTALLATION_URL,
30+
SESSION_SERVER_URL
31+
};
32+
1933
/// <summary>
2034
/// Header constants.
2135
/// </summary>
@@ -115,21 +129,25 @@ private BunqResponseRaw SendRequest(HttpMethod method, string uriRelative, byte[
115129
{
116130
var requestMessage = CreateHttpRequestMessage(method, uriRelative, uriParams, requestBodyBytes);
117131

118-
return SendRequest(requestMessage, customHeaders);
132+
return SendRequest(requestMessage, customHeaders, uriRelative);
119133
}
120134

121135
private BunqResponseRaw SendRequest(HttpMethod method, string uriRelative,
122136
IDictionary<string, string> uriParams, IDictionary<string, string> customHeaders)
123137
{
124138
var requestMessage = CreateHttpRequestMessage(method, uriRelative, uriParams);
125139

126-
return SendRequest(requestMessage, customHeaders);
140+
return SendRequest(requestMessage, customHeaders, uriRelative);
127141
}
128142

129143
private BunqResponseRaw SendRequest(HttpRequestMessage requestMessage,
130-
IDictionary<string, string> customHeaders)
144+
IDictionary<string, string> customHeaders, string uriRelative)
131145
{
132-
apiContext.EnsureSessionActive();
146+
if (!URIS_NOT_REQUIRING_ACTIVE_SESSION.Contains(uriRelative))
147+
{
148+
apiContext.EnsureSessionActive();
149+
}
150+
133151
SetDefaultHeaders(requestMessage);
134152
SetHeaders(requestMessage, customHeaders);
135153
SetSessionHeaders(requestMessage);

BunqSdk/Model/Generated/Endpoint/Card.cs

+6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ public class Card : BunqModel
6565
[JsonProperty(PropertyName = "public_uuid")]
6666
public string PublicUuid { get; private set; }
6767

68+
/// <summary>
69+
/// The type of the card. Can be MAESTRO, MASTERCARD.
70+
/// </summary>
71+
[JsonProperty(PropertyName = "type")]
72+
public string Type { get; private set; }
73+
6874
/// <summary>
6975
/// The second line of text on the card
7076
/// </summary>

BunqSdk/Model/Generated/Endpoint/CardDebit.cs

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ public class CardDebit : BunqModel
6262
[JsonProperty(PropertyName = "public_uuid")]
6363
public string PublicUuid { get; private set; }
6464

65+
/// <summary>
66+
/// The type of the card. Can be MAESTRO, MASTERCARD.
67+
/// </summary>
68+
[JsonProperty(PropertyName = "type")]
69+
public string Type { get; private set; }
70+
6571
/// <summary>
6672
/// The second line of text on the card
6773
/// </summary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
using Bunq.Sdk.Context;
2+
using Bunq.Sdk.Http;
3+
using Bunq.Sdk.Json;
4+
using Bunq.Sdk.Model.Core;
5+
using Bunq.Sdk.Security;
6+
using Newtonsoft.Json;
7+
using System.Collections.Generic;
8+
using System.Text;
9+
using System;
10+
11+
namespace Bunq.Sdk.Model.Generated.Endpoint
12+
{
13+
/// <summary>
14+
/// Endpoint for generating and retrieving a new CVC2 code.
15+
/// </summary>
16+
public class CardGeneratedCvc2 : BunqModel
17+
{
18+
/// <summary>
19+
/// Endpoint constants.
20+
/// </summary>
21+
private const string ENDPOINT_URL_CREATE = "user/{0}/card/{1}/generated-cvc2";
22+
private const string ENDPOINT_URL_READ = "user/{0}/card/{1}/generated-cvc2/{2}";
23+
private const string ENDPOINT_URL_LISTING = "user/{0}/card/{1}/generated-cvc2";
24+
25+
/// <summary>
26+
/// Object type.
27+
/// </summary>
28+
private const string OBJECT_TYPE = "CardGeneratedCvc2";
29+
30+
/// <summary>
31+
/// The id of the cvc code.
32+
/// </summary>
33+
[JsonProperty(PropertyName = "id")]
34+
public int? Id { get; private set; }
35+
36+
/// <summary>
37+
/// The timestamp of the cvc code's creation.
38+
/// </summary>
39+
[JsonProperty(PropertyName = "created")]
40+
public string Created { get; private set; }
41+
42+
/// <summary>
43+
/// The timestamp of the cvc code's last update.
44+
/// </summary>
45+
[JsonProperty(PropertyName = "updated")]
46+
public string Updated { get; private set; }
47+
48+
/// <summary>
49+
/// The cvc2 code.
50+
/// </summary>
51+
[JsonProperty(PropertyName = "cvc2")]
52+
public string Cvc2 { get; private set; }
53+
54+
/// <summary>
55+
/// The status of the cvc2. Can be AVAILABLE, USED, EXPIRED, BLOCKED.
56+
/// </summary>
57+
[JsonProperty(PropertyName = "status")]
58+
public string Status { get; private set; }
59+
60+
/// <summary>
61+
/// Expiry time of the cvc2.
62+
/// </summary>
63+
[JsonProperty(PropertyName = "expiry_time")]
64+
public string ExpiryTime { get; private set; }
65+
66+
/// <summary>
67+
/// Generate a new CVC2 code for a card.
68+
/// </summary>
69+
public static BunqResponse<CardGeneratedCvc2> Create(ApiContext apiContext, IDictionary<string, object> requestMap, int userId, int cardId, IDictionary<string, string> customHeaders = null)
70+
{
71+
if (customHeaders == null) customHeaders = new Dictionary<string, string>();
72+
73+
var apiClient = new ApiClient(apiContext);
74+
var requestBytes = Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(requestMap));
75+
requestBytes = SecurityUtils.Encrypt(apiContext, requestBytes, customHeaders);
76+
var responseRaw = apiClient.Post(string.Format(ENDPOINT_URL_CREATE, userId, cardId), requestBytes, customHeaders);
77+
78+
return FromJson<CardGeneratedCvc2>(responseRaw, OBJECT_TYPE);
79+
}
80+
81+
/// <summary>
82+
/// Get the details for a specific generated CVC2 code.
83+
/// </summary>
84+
public static BunqResponse<CardGeneratedCvc2> Get(ApiContext apiContext, int userId, int cardId, int cardGeneratedCvc2Id, IDictionary<string, string> customHeaders = null)
85+
{
86+
if (customHeaders == null) customHeaders = new Dictionary<string, string>();
87+
88+
var apiClient = new ApiClient(apiContext);
89+
var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_READ, userId, cardId, cardGeneratedCvc2Id), new Dictionary<string, string>(), customHeaders);
90+
91+
return FromJson<CardGeneratedCvc2>(responseRaw, OBJECT_TYPE);
92+
}
93+
94+
/// <summary>
95+
/// Get all generated CVC2 codes for a card.
96+
/// </summary>
97+
public static BunqResponse<List<CardGeneratedCvc2>> List(ApiContext apiContext, int userId, int cardId, IDictionary<string, string> urlParams = null, IDictionary<string, string> customHeaders = null)
98+
{
99+
if (urlParams == null) urlParams = new Dictionary<string, string>();
100+
if (customHeaders == null) customHeaders = new Dictionary<string, string>();
101+
102+
var apiClient = new ApiClient(apiContext);
103+
var responseRaw = apiClient.Get(string.Format(ENDPOINT_URL_LISTING, userId, cardId), urlParams, customHeaders);
104+
105+
return FromJsonList<CardGeneratedCvc2>(responseRaw, OBJECT_TYPE);
106+
}
107+
}
108+
}

BunqSdk/Model/Generated/Endpoint/CashRegister.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
namespace Bunq.Sdk.Model.Generated.Endpoint
1212
{
1313
/// <summary>
14-
/// CashRegisters act as an point of sale. They have a specific name and avatar, and optionally a location. A
15-
/// CashRegister is used to create Tabs. A CashRegister can have an QR code that links to one of its Tabs.
14+
/// CashRegisters are virtual points of sale. They have a specific name and avatar, and optionally, a
15+
/// location.<br/>With a CashRegister you can create a Tab and then use a QR code to receive payments.<br/>Check out
16+
/// our Quickstart example to learn how you can easily <a href="/api/1/page/usecase-tab-payment">create Tab
17+
/// payments</a>.<br/><br/>Notification filters can be set on a CashRegister to receive callbacks. For more
18+
/// information check the <a href="/api/1/page/callbacks">dedicated callbacks page</a>.
1619
/// </summary>
1720
public class CashRegister : BunqModel
1821
{

BunqSdk/Model/Generated/Endpoint/DraftPayment.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class DraftPayment : BunqModel
3838
private const string OBJECT_TYPE = "DraftPayment";
3939

4040
/// <summary>
41-
/// The id of the DraftPayment.
41+
/// The id of the created DrafPayment.
4242
/// </summary>
4343
[JsonProperty(PropertyName = "id")]
4444
public int? Id { get; private set; }
@@ -83,7 +83,7 @@ public class DraftPayment : BunqModel
8383
/// The Payment or PaymentBatch. This will only be present after the DraftPayment has been accepted.
8484
/// </summary>
8585
[JsonProperty(PropertyName = "object")]
86-
public BunqModel Object { get; private set; }
86+
public DraftPaymentAnchorObject Object { get; private set; }
8787

8888
/// <summary>
8989
/// Create a new DraftPayment.

BunqSdk/Model/Generated/Endpoint/MonetaryAccountBank.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Bunq.Sdk.Model.Generated.Endpoint
1515
/// MonetaryAccountBanks and update specific fields of an existing MonetaryAccountBank. Examples of fields that can
1616
/// be updated are the description, the daily limit and the avatar of the account.<br/><br/>Notification filters can
1717
/// be set on a monetary account level to receive callbacks. For more information check the <a
18-
/// href="/api/2/page/callbacks">dedicated callbacks page</a>.
18+
/// href="/api/1/page/callbacks">dedicated callbacks page</a>.
1919
/// </summary>
2020
public class MonetaryAccountBank : BunqModel
2121
{

BunqSdk/Model/Generated/Endpoint/UserCompany.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
namespace Bunq.Sdk.Model.Generated.Endpoint
1212
{
1313
/// <summary>
14-
/// Show the authenticated user, if it is a company.
14+
/// With UserCompany you can retrieve information regarding the authenticated UserCompany and update specific
15+
/// fields.<br/><br/>Notification filters can be set on a UserCompany level to receive callbacks. For more
16+
/// information check the <a href="/api/1/page/callbacks">dedicated callbacks page</a>.
1517
/// </summary>
1618
public class UserCompany : BunqModel
1719
{

BunqSdk/Model/Generated/Endpoint/UserPerson.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
namespace Bunq.Sdk.Model.Generated.Endpoint
1212
{
1313
/// <summary>
14-
/// Show the authenticated user, if it is a person.
14+
/// With UserPerson you can retrieve information regarding the authenticated UserPerson and update specific
15+
/// fields.<br/><br/>Notification filters can be set on a UserPerson level to receive callbacks. For more
16+
/// information check the <a href="/api/1/page/callbacks">dedicated callbacks page</a>.
1517
/// </summary>
1618
public class UserPerson : BunqModel
1719
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Bunq.Sdk.Model.Core;
2+
using Bunq.Sdk.Model.Generated.Endpoint;
3+
using Newtonsoft.Json;
4+
using System.Collections.Generic;
5+
6+
namespace Bunq.Sdk.Model.Generated.Object
7+
{
8+
/// <summary>
9+
/// </summary>
10+
public class DraftPaymentAnchorObject : BunqModel
11+
{
12+
/// <summary>
13+
/// </summary>
14+
[JsonProperty(PropertyName = "Payment")]
15+
public Payment Payment { get; set; }
16+
17+
/// <summary>
18+
/// </summary>
19+
[JsonProperty(PropertyName = "PaymentBatch")]
20+
public PaymentBatch PaymentBatch { get; set; }
21+
}
22+
}

0 commit comments

Comments
 (0)