Skip to content

Commit 73384a7

Browse files
author
Kevin Hellemun
committed
Merge branch 'release/0.12.3'
2 parents 0fe0a00 + d7a37ae commit 73384a7

File tree

79 files changed

+3125
-410
lines changed

Some content is hidden

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

79 files changed

+3125
-410
lines changed

BunqSdk.Tests/BunqSdk.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@
1919
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2020
</Content>
2121
</ItemGroup>
22+
<ItemGroup>
23+
<Folder Include="Resources\NotificationUrlJsons" />
24+
</ItemGroup>
2225
</Project>
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
using System;
2+
using System.IO;
3+
using System.Reflection;
4+
using System.Runtime.InteropServices.ComTypes;
5+
using Bunq.Sdk.Model.Core;
6+
using Bunq.Sdk.Model.Generated.Endpoint;
7+
using Bunq.Sdk.Model.Generated.Object;
8+
using Newtonsoft.Json.Linq;
9+
using Xunit;
10+
11+
namespace Bunq.Sdk.Tests.Model.Generated.Object
12+
{
13+
public class NotificationUrlTest : BunqSdkTestBase
14+
{
15+
/// <summary>
16+
/// Getter constans.
17+
/// </summary>
18+
private const string GET_PAYMENT = "Payment";
19+
private const string GET_BUNQ_ME_TAB = "BunqMeTab";
20+
private const string GET_CHAT_MESSAGE_ANNOUNCEMENT = "ChatMessageAnnouncement";
21+
private const string GET_DRAFT_PAYMENT = "DraftPayment";
22+
private const string GET_MASTER_CARD_ACTION = "MasterCardAction";
23+
private const string GET_MONETARY_ACCOUNT_BANK = "MonetaryAccountBank";
24+
private const string GET_PAYMENT_BATCH = "PaymentBatch";
25+
private const string GET_REQUEST_INQUIRY = "RequestInquiry";
26+
private const string GET_REQUEST_RESPONSE = "RequestResponse";
27+
private const string GET_SCHEDULE_PAYMENT = "ScheduledPayment";
28+
private const string GET_SCHEDULE_INSTANCE = "ScheduledInstance";
29+
private const string GET_SHARE_INVITE_BANK_INQUIRY = "ShareInviteBankInquiry";
30+
private const string GET_SHARE_INVITE_BANK_RESPONSE = "ShareInviteBankResponse";
31+
32+
/// <summary>
33+
/// Model json paths constants.
34+
/// </summary>
35+
private const string BASE_PATH_JSON_MODEL = "../../../Resources/NotificationUrlJsons";
36+
private const string JSON_PATH_MUTATION_MODEL = BASE_PATH_JSON_MODEL + "/Mutation.json";
37+
private const string JSON_PATH_BUNQ_ME_TAB_MODEL = BASE_PATH_JSON_MODEL + "/BunqMeTab.json";
38+
private const string JSON_PATH_CHAT_MESSAGE_ANNOUNCEMENT_MODEL = BASE_PATH_JSON_MODEL +
39+
"/ChatMessageAnnouncement.json";
40+
private const string JSON_PATH_DRAFT_PAYMENT_MODEL = BASE_PATH_JSON_MODEL + "/DraftPayment.json";
41+
private const string JSON_PATH_MASTER_CARD_ACTION_MODEL = BASE_PATH_JSON_MODEL + "/MasterCardAction.json";
42+
private const string JSON_PATH_MONETARY_ACCOUNT_BANK_MODEL = BASE_PATH_JSON_MODEL + "/MonetaryAccountBank.json";
43+
private const string JSON_PATH_PAYMENT_BATCH_MODEL = BASE_PATH_JSON_MODEL + "/PaymentBatch.json";
44+
private const string JSON_PATH_REQUEST_INQUIRY_MODEL = BASE_PATH_JSON_MODEL + "/RequestInquiry.json";
45+
private const string JSON_PATH_REQUEST_RESPONSE_MODEL = BASE_PATH_JSON_MODEL + "/RequestResponse.json";
46+
private const string JSON_PATH_SCHEDULE_PAYMENT_MODEL = BASE_PATH_JSON_MODEL + "/ScheduledPayment.json";
47+
private const string JSON_PATH_SCHEDULE_INSTANCE_MODEL = BASE_PATH_JSON_MODEL + "/ScheduledInstance.json";
48+
private const string JSON_PATH_SHARE_INVITE_BANK_INQUIRY_MODEL = BASE_PATH_JSON_MODEL +
49+
"/ShareInviteBankInquiry.json";
50+
51+
private const string JSON_PATH_SHARE_INVITE_BANK_RESPONSE_MODEL = BASE_PATH_JSON_MODEL +
52+
"/ShareInviteBankResponse.json";
53+
54+
/// <summary>
55+
/// Model root key.
56+
/// </summary>
57+
private const string KEY_NOTIFICATION_URL_MODEL = "NotificationUrl";
58+
59+
private void ExecuteNotificationUrlTest(
60+
string expectedJsonFileName,
61+
Type classNameExpected,
62+
string referencedObjectPropertyName
63+
) {
64+
var jsonString = ReadJsonFromFile(expectedJsonFileName);
65+
var notificationUrl = BunqModel.CreateFromJsonString<NotificationUrl>(jsonString);
66+
67+
Assert.NotNull(notificationUrl);
68+
Assert.NotNull(notificationUrl.Object);
69+
70+
var model = notificationUrl.Object.GetType().GetProperty(referencedObjectPropertyName).GetValue(
71+
notificationUrl.Object);
72+
var referencedModel = notificationUrl.Object.GetReferencedObject();
73+
74+
Assert.NotNull(model);
75+
Assert.NotNull(referencedModel);
76+
Assert.IsType(classNameExpected, referencedModel);
77+
Assert.Equal(classNameExpected, referencedModel.GetType());
78+
}
79+
80+
private static string ReadJsonFromFile(string fileName)
81+
{
82+
var fileContentString = File.ReadAllText(fileName);
83+
var jsonObj = JObject.Parse(fileContentString);
84+
var notificationUrlObject = jsonObj[KEY_NOTIFICATION_URL_MODEL];
85+
86+
Assert.NotNull(notificationUrlObject);
87+
88+
return notificationUrlObject.ToString();
89+
}
90+
91+
[Fact]
92+
public void TestMutationModel()
93+
{
94+
ExecuteNotificationUrlTest(
95+
JSON_PATH_MUTATION_MODEL,
96+
typeof(Payment),
97+
GET_PAYMENT
98+
);
99+
}
100+
101+
[Fact]
102+
public void TestBunqMeTabModel()
103+
{
104+
ExecuteNotificationUrlTest(
105+
JSON_PATH_BUNQ_ME_TAB_MODEL,
106+
typeof(BunqMeTab),
107+
GET_BUNQ_ME_TAB
108+
);
109+
}
110+
111+
[Fact]
112+
public void TestChatMessageAnnouncementModel()
113+
{
114+
ExecuteNotificationUrlTest(
115+
JSON_PATH_CHAT_MESSAGE_ANNOUNCEMENT_MODEL,
116+
typeof(ChatMessageAnnouncement),
117+
GET_CHAT_MESSAGE_ANNOUNCEMENT
118+
);
119+
}
120+
121+
[Fact]
122+
public void TestDraftPaymentModel()
123+
{
124+
ExecuteNotificationUrlTest(
125+
JSON_PATH_DRAFT_PAYMENT_MODEL,
126+
typeof(DraftPayment),
127+
GET_DRAFT_PAYMENT
128+
);
129+
}
130+
131+
[Fact]
132+
public void TestMasterCardActionModel()
133+
{
134+
ExecuteNotificationUrlTest(
135+
JSON_PATH_MASTER_CARD_ACTION_MODEL,
136+
typeof(MasterCardAction),
137+
GET_MASTER_CARD_ACTION
138+
);
139+
}
140+
141+
[Fact]
142+
public void TestMonetaryAccountBankModel()
143+
{
144+
ExecuteNotificationUrlTest(
145+
JSON_PATH_MONETARY_ACCOUNT_BANK_MODEL,
146+
typeof(MonetaryAccountBank),
147+
GET_MONETARY_ACCOUNT_BANK
148+
);
149+
}
150+
151+
[Fact]
152+
public void TestPaymentBatchModel()
153+
{
154+
ExecuteNotificationUrlTest(
155+
JSON_PATH_PAYMENT_BATCH_MODEL,
156+
typeof(PaymentBatch),
157+
GET_PAYMENT_BATCH
158+
);
159+
}
160+
161+
[Fact]
162+
public void TestRequestInquiryModel()
163+
{
164+
ExecuteNotificationUrlTest(
165+
JSON_PATH_REQUEST_INQUIRY_MODEL,
166+
typeof(RequestInquiry),
167+
GET_REQUEST_INQUIRY
168+
);
169+
}
170+
171+
[Fact]
172+
public void TestRequestResponseModel()
173+
{
174+
ExecuteNotificationUrlTest(
175+
JSON_PATH_REQUEST_RESPONSE_MODEL,
176+
typeof(RequestResponse),
177+
GET_REQUEST_RESPONSE
178+
);
179+
}
180+
181+
[Fact]
182+
public void TestScheduledInstanceModel()
183+
{
184+
ExecuteNotificationUrlTest(
185+
JSON_PATH_SCHEDULE_INSTANCE_MODEL,
186+
typeof(ScheduleInstance),
187+
GET_SCHEDULE_INSTANCE
188+
);
189+
}
190+
191+
[Fact]
192+
public void TestScheduledPaymentModel()
193+
{
194+
ExecuteNotificationUrlTest(
195+
JSON_PATH_SCHEDULE_PAYMENT_MODEL,
196+
typeof(SchedulePayment),
197+
GET_SCHEDULE_PAYMENT
198+
);
199+
}
200+
201+
[Fact]
202+
public void TestShareInviteBankModel()
203+
{
204+
ExecuteNotificationUrlTest(
205+
JSON_PATH_SHARE_INVITE_BANK_INQUIRY_MODEL,
206+
typeof(ShareInviteBankInquiry),
207+
GET_SHARE_INVITE_BANK_INQUIRY
208+
);
209+
}
210+
211+
[Fact]
212+
public void TestShareInviteBankResponse()
213+
{
214+
ExecuteNotificationUrlTest(
215+
JSON_PATH_SHARE_INVITE_BANK_RESPONSE_MODEL,
216+
typeof(ShareInviteBankResponse),
217+
GET_SHARE_INVITE_BANK_RESPONSE
218+
);
219+
}
220+
}
221+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"NotificationUrl": {
3+
"target_url": "nope",
4+
"category": "BUNQME_TAB",
5+
"event_type": "BUNQME_TAB_CREATED",
6+
"object": {
7+
"BunqMeTab": {
8+
"id": 8,
9+
"created": "2017-11-09 11:05:42.364451",
10+
"updated": "2017-11-09 11:05:42.364451",
11+
"time_expiry": "2017-12-09 11:05:42.361442",
12+
"monetary_account_id": 32,
13+
"status": "WAITING_FOR_PAYMENT",
14+
"bunqme_tab_share_url": "https:\/\/bunq.me\/t\/4da1167c-01bc-4a91-a1e1-44a83e4fef2e",
15+
"bunqme_tab_entry": {
16+
"uuid": "4da1167c-01bc-4a91-a1e1-44a83e4fef2e",
17+
"created": "2017-11-09 11:05:42.450462",
18+
"updated": "2017-11-09 11:05:42.450462",
19+
"amount_inquired": {
20+
"currency": "EUR",
21+
"value": "5.00"
22+
},
23+
"status": "WAITING_FOR_PAYMENT",
24+
"description": "Thank you for building this awesome feature!",
25+
"alias": {
26+
"iban": "NL18BUNQ2025104340",
27+
"is_light": false,
28+
"display_name": "B.O. Varb",
29+
"avatar": {
30+
"uuid": "b0005448-e385-4d6c-baef-244c295b524f",
31+
"image": [
32+
{
33+
"attachment_public_uuid": "0c872c0e-1c98-4eea-ba75-a36c6d0a40c7",
34+
"height": 1024,
35+
"width": 1024,
36+
"content_type": "image\/png"
37+
}
38+
],
39+
"anchor_uuid": null
40+
},
41+
"label_user": {
42+
"uuid": "353f4064-96bd-49d7-ac69-f87513726c80",
43+
"display_name": "B.O. Varb",
44+
"country": "NL",
45+
"avatar": {
46+
"uuid": "ec2dc709-c8dd-4868-b3e7-601338d88881",
47+
"image": [
48+
{
49+
"attachment_public_uuid": "7444998c-ff1d-4708-afe3-7b56e33c6f89",
50+
"height": 480,
51+
"width": 480,
52+
"content_type": "image\/jpeg"
53+
}
54+
],
55+
"anchor_uuid": "353f4064-96bd-49d7-ac69-f87513726c80"
56+
},
57+
"public_nick_name": "Bravo O (nickname)"
58+
},
59+
"country": "NL"
60+
},
61+
"redirect_url": null,
62+
"merchant_available": [
63+
{
64+
"merchant_type": "IDEAL",
65+
"available": true
66+
},
67+
{
68+
"merchant_type": "SOFORT",
69+
"available": true
70+
}
71+
]
72+
},
73+
"result_inquiries": []
74+
}
75+
}
76+
}
77+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"NotificationUrl": {
3+
"target_url": "nope",
4+
"category": "BUNQME_TAB",
5+
"event_type": "BUNQME_TAB_CREATED",
6+
"object": {
7+
"ChatMessageAnnouncement": {
8+
"id": 30,
9+
"created": "2017-09-05 12:00:00.912674",
10+
"updated": "2017-09-05 12:00:00.912674",
11+
"conversation_id": 3,
12+
"content": {
13+
"ChatMessageContentText": {
14+
"text": "Hey! You have failed to pay more than five direct debits over the past 30 days. Although such things can happen, please keep in mind that we might be forced to take measures if we get a lot of complaints about it. To help prevent this we summarised some information which might prove useful.\n\nRead more here. https:\/\/www.bunq.com\/en\/direct-debits\/\n\nPlease let us know if you have any further questions, we would love to help you out!"
15+
}
16+
},
17+
"client_message_uuid": null
18+
}
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)