Skip to content

Commit 588158f

Browse files
authored
Merge pull request #157 from WinkPascal/develop
bunq Update 28 | Update object naming, fix parsing and fix tests
2 parents f807e16 + 1a48b01 commit 588158f

File tree

316 files changed

+5606
-2866
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

316 files changed

+5606
-2866
lines changed

.gitignore

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,6 @@
1-
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
2-
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
3-
4-
# User-specific stuff:
5-
.idea/**/workspace.xml
6-
.idea/**/tasks.xml
7-
.idea/dictionaries
8-
9-
# Sensitive or high-churn files:
10-
.idea/**/dataSources/
11-
.idea/**/dataSources.ids
12-
.idea/**/dataSources.xml
13-
.idea/**/dataSources.local.xml
14-
.idea/**/sqlDataSources.xml
15-
.idea/**/dynamic.xml
16-
.idea/**/uiDesigner.xml
17-
18-
# Gradle:
19-
.idea/**/gradle.xml
20-
.idea/**/libraries
21-
221
# CMake
232
cmake-build-debug/
243

25-
# Mongo Explorer plugin:
26-
.idea/**/mongoSettings.xml
27-
284
## File-based project format:
295
*.iws
306

@@ -33,15 +9,9 @@ cmake-build-debug/
339
# IntelliJ
3410
/out/
3511

36-
# mpeltonen/sbt-idea plugin
37-
.idea_modules/
38-
3912
# JIRA plugin
4013
atlassian-ide-plugin.xml
4114

42-
# Cursive Clojure plugin
43-
.idea/replstate.xml
44-
4515
# Crashlytics plugin (for Android Studio and IntelliJ)
4616
com_crashlytics_export_strings.xml
4717
crashlytics.properties
@@ -265,5 +235,11 @@ bunq.conf
265235
**/Tmp/
266236
bunq-test.conf
267237
config.json
268-
.idea/.idea.BunqSdk/.idea/preferred-vcs.xml
269-
.idea/.idea.BunqSdk/.idea/indexLayout.xml
238+
239+
/BunqSdk.Tests/Resources/bunq-psd2-test.conf
240+
/BunqSdk.Tests/Resources/bunq-oauth-test.conf
241+
/BunqSdk.Tests/Resources/credentials.pfx
242+
/BunqSdk.Tests/Resources/chain.cert
243+
/BunqSdk.Tests/Resources/key.pem
244+
245+
.idea

BunqSdk.Tests/BunqSdk.Tests.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<PropertyGroup>
33
<RootNamespace>Bunq.Sdk.Tests</RootNamespace>
44
<LangVersion>default</LangVersion>
5-
<AssemblyName>BunqSdk.Tests.xunit.runner.json</AssemblyName>
6-
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<AssemblyName>BunqSdk.Tests</AssemblyName>
6+
<TargetFramework>net9.0</TargetFramework>
77
</PropertyGroup>
88
<ItemGroup>
99
<ProjectReference Include="..\BunqSdk\BunqSdk.csproj" />
@@ -26,7 +26,6 @@
2626
<Folder Include="Resources\NotificationUrlJsons" />
2727
</ItemGroup>
2828
<ItemGroup>
29-
<None Remove="Resources\chain.cert" />
3029
<None Remove="Resources\bunq-psd2-test.conf" />
3130
</ItemGroup>
3231
</Project>

BunqSdk.Tests/BunqSdkTestBase.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class BunqSdkTestBase
6868
private const string SpendingMoneyAmount = "50.00";
6969
private const string SpendingMoneyRequestDescription = "sdk c# test, thanks daddy.";
7070

71-
protected static MonetaryAccountBank SecondMonetaryAccountBank;
71+
protected static MonetaryAccountBankApiObject SecondMonetaryAccountBank;
7272

7373
/// <summary>
7474
/// Gets an Api Context, re-creates if needed and returns it.
@@ -78,7 +78,7 @@ protected static void SetUpTestCase()
7878
SetUpApiContext();
7979
SecondMonetaryAccountBank = SetUpSecondMonetaryAccount();
8080
RequestSpendingMoney();
81-
Thread.Sleep(500); // ensure requests are auto accepted.
81+
Thread.Sleep(1000); // Ensure requests are auto accepted.
8282
BunqContext.UserContext.RefreshUserContext();
8383
}
8484

@@ -102,7 +102,7 @@ protected static ApiContext SetUpApiContext()
102102
return apiContext;
103103
}
104104

105-
private static SandboxUserPerson GenerateNewSandboxUserPerson()
105+
private static SandboxUserPersonApiObject GenerateNewSandboxUserPerson()
106106
{
107107
var httpClient = new HttpClient();
108108
httpClient.DefaultRequestHeaders.Add("X-Bunq-Client-Request-Id", "unique");
@@ -118,42 +118,42 @@ private static SandboxUserPerson GenerateNewSandboxUserPerson()
118118
var responseString = requestTask.Result.Content.ReadAsStringAsync().Result;
119119
var responseJson = BunqJsonConvert.DeserializeObject<JObject>(responseString);
120120

121-
return BunqJsonConvert.DeserializeObject<SandboxUserPerson>(
121+
return BunqJsonConvert.DeserializeObject<SandboxUserPersonApiObject>(
122122
responseJson.First.First.First.First.First.ToString()
123123
);
124124
}
125125

126-
private static MonetaryAccountBank SetUpSecondMonetaryAccount()
126+
private static MonetaryAccountBankApiObject SetUpSecondMonetaryAccount()
127127
{
128-
var createdMonetaryAccountId = MonetaryAccountBank.Create(PaymentCurrency, MonetaryAccountDescription);
128+
var createdMonetaryAccountId = MonetaryAccountBankApiObject.Create(PaymentCurrency, MonetaryAccountDescription);
129129

130-
return MonetaryAccountBank.Get(createdMonetaryAccountId.Value).Value;
130+
return MonetaryAccountBankApiObject.Get(createdMonetaryAccountId.Value).Value;
131131
}
132132

133133
private static void RequestSpendingMoney()
134134
{
135-
RequestInquiry.Create(
136-
new Amount(SpendingMoneyAmount, PaymentCurrency),
137-
new Pointer(PointerTypeEmail, EmailSuggarDaddy),
135+
RequestInquiryApiObject.Create(
136+
new AmountObject(SpendingMoneyAmount, PaymentCurrency),
137+
new PointerObject(PointerTypeEmail, EmailSuggarDaddy),
138138
SpendingMoneyRequestDescription,
139139
false
140140
);
141141

142-
RequestInquiry.Create(
143-
new Amount(SpendingMoneyAmount, PaymentCurrency),
144-
new Pointer(PointerTypeEmail, EmailSuggarDaddy),
142+
RequestInquiryApiObject.Create(
143+
new AmountObject(SpendingMoneyAmount, PaymentCurrency),
144+
new PointerObject(PointerTypeEmail, EmailSuggarDaddy),
145145
SpendingMoneyRequestDescription,
146146
false,
147147
SecondMonetaryAccountBank.Id
148148
);
149149
}
150150

151-
protected static Pointer GetPointerBravo()
151+
protected static PointerObject GetPointerBravo()
152152
{
153-
return new Pointer(PointerTypeEmail, EmailBravo);
153+
return new PointerObject(PointerTypeEmail, EmailBravo);
154154
}
155155

156-
protected static Pointer GetAlias()
156+
protected static PointerObject GetAlias()
157157
{
158158
var userContext = BunqContext.UserContext;
159159

BunqSdk.Tests/Config.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,21 @@ public class Config
3434
private const string FIELD_COUNTER_ALIAS = "Alias";
3535
private const string FIELD_COUNTER_TYPE = "Type";
3636
private const string FIELD_TAB_USAGE_SINGLE = "TabUsageSingleTest";
37-
private const string FIELD_CASH_REGISTER_ID = "CASH_REGISTER_ID";
38-
39-
public static int GetCashRegisterId()
40-
{
41-
return GetConfig()[FIELD_TAB_USAGE_SINGLE][FIELD_CASH_REGISTER_ID].ToObject<int>();
42-
}
43-
44-
public static Pointer GetCounterPartyAliasOther()
37+
38+
public static PointerObject GetCounterPartyAliasOther()
4539
{
4640
var alias = GetConfig()[FIELD_COUNTER_PARTY_OTHER][FIELD_COUNTER_ALIAS].ToString();
4741
var type = GetConfig()[FIELD_COUNTER_PARTY_OTHER][FIELD_COUNTER_TYPE].ToString();
4842

49-
return new Pointer(type, alias);
43+
return new PointerObject(type, alias);
5044
}
5145

52-
public static Pointer GetCounterPartyAliasSelf()
46+
public static PointerObject GetCounterPartyAliasSelf()
5347
{
5448
var alias = GetConfig()[FIELD_COUNTER_PARTY_SELF][FIELD_COUNTER_ALIAS].ToString();
5549
var type = GetConfig()[FIELD_COUNTER_PARTY_SELF][FIELD_COUNTER_TYPE].ToString();
5650

57-
return new Pointer(type, alias);
51+
return new PointerObject(type, alias);
5852
}
5953

6054
public static int GetSecondMonetaryAccountId()

BunqSdk.Tests/Context/Psd2ApiContextTest.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace Bunq.Sdk.Tests.Context
1111
{
1212
[TestCaseOrderer("Bunq.Sdk.Tests.Util.TestPriorityOrderer", "Psd2ApiContextTest")]
13-
public class Psd2ApiContextTest : IClassFixture<Psd2ApiContextTest>
13+
public class Psd2ApiContextTest : BunqSdkTestBase, IClassFixture<Psd2ApiContextTest>
1414
{
1515
/// <summary>
1616
/// File constants.
@@ -48,13 +48,15 @@ public void TestCreatePsd2Context()
4848
[Fact, TestPriority(0)]
4949
public void TestCreateOauthClient()
5050
{
51+
SetUpApiContext();
52+
5153
if (File.Exists(FILE_TEST_OAUTH))
5254
{
5355
return;
5456
}
5557

56-
int clientId = OauthClient.Create().Value;
57-
OauthClient oauthClient = OauthClient.Get(clientId).Value;
58+
int clientId = OauthClientApiObject.Create().Value;
59+
OauthClientApiObject oauthClient = OauthClientApiObject.Get(clientId).Value;
5860
Assert.NotNull(oauthClient);
5961

6062
File.WriteAllText(

BunqSdk.Tests/Http/PaginationScenarioTest.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Threading;
23
using Bunq.Sdk.Http;
34
using Bunq.Sdk.Json;
45
using Bunq.Sdk.Model.Generated.Endpoint;
@@ -26,19 +27,24 @@ public void TestApiScenarioPaymentListingWithPagination()
2627
SetUpTestCase();
2728

2829
EnsureEnoughPayments();
29-
var paymentsExpected = new List<Payment>(GetPaymentsRequired());
30+
var paymentsExpected = new List<PaymentApiObject>(GetPaymentsRequired());
3031
var paginationCountOnly = new Pagination
3132
{
3233
Count = PaymentListingPageSize
3334
};
34-
35+
36+
Thread.Sleep(1000); // Ensure request won't get rate limited.
3537
var responseLatest = ListPayments(paginationCountOnly.UrlParamsCountOnly);
38+
39+
Thread.Sleep(1000); // Ensure request won't get rate limited.
3640
var paginationLatest = responseLatest.Pagination;
3741
var responsePrevious = ListPayments(paginationLatest.UrlParamsPreviousPage);
42+
43+
Thread.Sleep(1000); // Ensure request won't get rate limited.
3844
var paginationPrevious = responsePrevious.Pagination;
3945
var responsePreviousNext = ListPayments(paginationPrevious.UrlParamsNextPage);
4046

41-
var paymentsActual = new List<Payment>();
47+
var paymentsActual = new List<PaymentApiObject>();
4248
paymentsActual.AddRange(responsePreviousNext.Value);
4349
paymentsActual.AddRange(responsePrevious.Value);
4450
var paymentsExpectedSerialized = BunqJsonConvert.SerializeObject(paymentsExpected);
@@ -51,6 +57,7 @@ private static void EnsureEnoughPayments()
5157
{
5258
for (var i = NumberZero; i < GetPaymentsMissingCount(); ++i)
5359
{
60+
Thread.Sleep(1000); // Time out to prevent rate limiting.
5461
CreatePayment();
5562
}
5663
}
@@ -60,7 +67,7 @@ private static int GetPaymentsMissingCount()
6067
return PaymentRequiredCountMinimum - GetPaymentsRequired().Count;
6168
}
6269

63-
private static IList<Payment> GetPaymentsRequired()
70+
private static IList<PaymentApiObject> GetPaymentsRequired()
6471
{
6572
var pagination = new Pagination
6673
{
@@ -70,14 +77,14 @@ private static IList<Payment> GetPaymentsRequired()
7077
return ListPayments(pagination.UrlParamsCountOnly).Value;
7178
}
7279

73-
private static BunqResponse<List<Payment>> ListPayments(IDictionary<string, string> urlParams)
80+
private static BunqResponse<List<PaymentApiObject>> ListPayments(IDictionary<string, string> urlParams)
7481
{
75-
return Payment.List(urlParams: urlParams);
82+
return PaymentApiObject.List(urlParams: urlParams);
7683
}
7784

7885
private static void CreatePayment()
7986
{
80-
Payment.Create(new Amount(PaymentAmountEur, PaymentCurrency), GetPointerBravo(), PaymentDescription);
87+
PaymentApiObject.Create(new AmountObject(PaymentAmountEur, PaymentCurrency), GetPointerBravo(), PaymentDescription);
8188
}
8289
}
8390
}

BunqSdk.Tests/Http/ResponseIdOnNotFoundRequestTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public void TestBadRequestWithResponseId()
1212
SetUpTestCase();
1313

1414
var caughtException = Assert.Throws<NotFoundException>(
15-
() => Payment.Get(0)
15+
() => PaymentApiObject.Get(0)
1616
);
1717

1818
Assert.NotNull(caughtException.ResponseId);

BunqSdk.Tests/Model/Core/NotificationFilterTest.cs

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ public void TestNotificationFilterUrlMonetaryAccount()
2929
{
3030
SetUpApiContext();
3131

32-
NotificationFilterUrl notificationFilter = GetNotificationFilterUrl();
33-
List<NotificationFilterUrl> allCreatedNotificationFilter = NotificationFilterUrlMonetaryAccountInternal
32+
NotificationFilterUrlObject notificationFilter = GetNotificationFilterUrl();
33+
List<NotificationFilterUrlObject> allCreatedNotificationFilter = NotificationFilterUrlMonetaryAccountInternal
3434
.CreateWithListResponse(
3535
GetPrimaryMonetaryAccount().Id.Value,
36-
new List<NotificationFilterUrl>() {notificationFilter}
36+
new List<NotificationFilterUrlObject>() {notificationFilter}
3737
).Value;
3838

3939
Assert.True(allCreatedNotificationFilter.Count == 1);
@@ -47,10 +47,10 @@ public void TestNotificationFilterUrlUser()
4747
{
4848
SetUpApiContext();
4949

50-
NotificationFilterUrl notificationFilter = GetNotificationFilterUrl();
51-
List<NotificationFilterUrl> allCreatedNotificationFilter = NotificationFilterUrlUserInternal
50+
NotificationFilterUrlObject notificationFilter = GetNotificationFilterUrl();
51+
List<NotificationFilterUrlObject> allCreatedNotificationFilter = NotificationFilterUrlUserInternal
5252
.CreateWithListResponse(
53-
new List<NotificationFilterUrl>() {notificationFilter}
53+
new List<NotificationFilterUrlObject>() {notificationFilter}
5454
).Value;
5555

5656
Assert.True(allCreatedNotificationFilter.Count == 1);
@@ -64,50 +64,26 @@ public void TestNotificationFilterPushUser()
6464
{
6565
SetUpApiContext();
6666

67-
NotificationFilterPush notificationFilter = GetNotificationFilterPush();
68-
List<NotificationFilterPush> allCreatedNotificationFilter = NotificationFilterPushUserInternal
67+
NotificationFilterPushObject notificationFilter = GetNotificationFilterPush();
68+
List<NotificationFilterPushObject> allCreatedNotificationFilter = NotificationFilterPushUserInternal
6969
.CreateWithListResponse(
70-
new List<NotificationFilterPush>() {notificationFilter}
70+
new List<NotificationFilterPushObject>() {notificationFilter}
7171
).Value;
7272

73-
Assert.True(allCreatedNotificationFilter.Count == 1);
74-
}
75-
76-
/// <summary>
77-
/// Test clear all filters.
78-
/// </summary>
79-
[Fact]
80-
public void TestNotificationFilterClear()
81-
{
82-
SetUpApiContext();
83-
84-
List<NotificationFilterPush> allCreatedNotificationFilterPushUser =
85-
NotificationFilterPushUserInternal.CreateWithListResponse().Value;
86-
List<NotificationFilterUrl> allCreatedNotificationFilterUrlUser =
87-
NotificationFilterUrlUserInternal.CreateWithListResponse().Value;
88-
List<NotificationFilterUrl> allCreatedNotificationFilterUrlMonetaryAccount =
89-
NotificationFilterUrlMonetaryAccountInternal.CreateWithListResponse().Value;
90-
91-
Assert.Empty(allCreatedNotificationFilterPushUser);
92-
Assert.Empty(allCreatedNotificationFilterUrlUser);
93-
Assert.Empty(allCreatedNotificationFilterUrlMonetaryAccount);
94-
95-
Assert.StrictEqual(0, NotificationFilterPushUserInternal.List().Value.Count);
96-
Assert.StrictEqual(0, NotificationFilterUrlUserInternal.List().Value.Count);
97-
Assert.StrictEqual(0, NotificationFilterUrlMonetaryAccountInternal.List().Value.Count);
73+
Assert.True(allCreatedNotificationFilter.Count > 1);
9874
}
9975

100-
private NotificationFilterUrl GetNotificationFilterUrl()
76+
private NotificationFilterUrlObject GetNotificationFilterUrl()
10177
{
102-
return new NotificationFilterUrl(FILTER_CATEGORY_MUTATION, FILTER_CALLBACK_URL);
78+
return new NotificationFilterUrlObject(FILTER_CATEGORY_MUTATION, FILTER_CALLBACK_URL);
10379
}
10480

105-
private NotificationFilterPush GetNotificationFilterPush()
81+
private NotificationFilterPushObject GetNotificationFilterPush()
10682
{
107-
return new NotificationFilterPush(FILTER_CATEGORY_MUTATION);
83+
return new NotificationFilterPushObject(FILTER_CATEGORY_MUTATION);
10884
}
10985

110-
private MonetaryAccountBank GetPrimaryMonetaryAccount()
86+
private MonetaryAccountBankApiObject GetPrimaryMonetaryAccount()
11187
{
11288
return BunqContext.UserContext.PrimaryMonetaryAccountBank;
11389
}

0 commit comments

Comments
 (0)