Skip to content

Commit afcef2a

Browse files
committed
#5 Introduce BunqResponse
1 parent b38b89c commit afcef2a

File tree

83 files changed

+1056
-924
lines changed

Some content is hidden

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

83 files changed

+1056
-924
lines changed

BunqSdk.Samples/AttachmentPublicSample.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public void Run()
2424
{ApiClient.HEADER_ATTACHMENT_DESCRIPTION, DESCRIPTION_TEST_JPG_ATTACHMENT}
2525
};
2626
var requestBytes = File.ReadAllBytes(PATH_ATTACHMENT_IN);
27-
var uuid = AttachmentPublic.Create(apiContext, requestBytes, customHeaders);
28-
var responseBytes = AttachmentPublicContent.List(apiContext, uuid);
27+
var uuid = AttachmentPublic.Create(apiContext, requestBytes, customHeaders).Value;
28+
var responseBytes = AttachmentPublicContent.List(apiContext, uuid).Value;
2929
var fileOut = new FileInfo(PATH_ATTACHMENT_OUT);
3030
fileOut.Directory.Create();
3131
File.WriteAllBytes(fileOut.FullName, responseBytes);

BunqSdk.Samples/CustomerStatementExportSample.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ public void Run()
5252
{CustomerStatementExport.FIELD_DATE_END, dateEnd.ToString(FORMAT_DATE_STATEMENT)},
5353
};
5454

55-
var userId = User.List(apiContext)[INDEX_FIRST].UserCompany.Id;
55+
var userId = User.List(apiContext).Value[INDEX_FIRST].UserCompany.Id;
5656

5757
if (userId != null)
5858
{
5959
var userIdInt = (int) userId;
60-
var monetaryAccountId = MonetaryAccountBank.List(apiContext, userIdInt)[INDEX_FIRST].Id;
60+
var monetaryAccountId = MonetaryAccountBank.List(apiContext, userIdInt).Value[INDEX_FIRST].Id;
6161

6262
if (monetaryAccountId != null)
6363
{
6464
var monetaryAccountIdInt = (int) monetaryAccountId;
6565
var customerStatementId = CustomerStatementExport.Create(apiContext, customerStatementMap,
66-
userIdInt, monetaryAccountIdInt);
66+
userIdInt, monetaryAccountIdInt).Value;
6767

6868
CustomerStatementExport.Delete(apiContext, userIdInt, monetaryAccountIdInt, customerStatementId);
6969
}

BunqSdk.Samples/MonetaryAccountSample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class MonetaryAccountSample : ISample
1313
public void Run()
1414
{
1515
var apiContext = ApiContext.Restore();
16-
var monetaryAccount = MonetaryAccount.Get(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID);
16+
var monetaryAccount = MonetaryAccount.Get(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID).Value;
1717
Console.WriteLine(monetaryAccount.MonetaryAccountBank);
1818
}
1919
}

BunqSdk.Samples/PaymentBatchSample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void Run()
4040
};
4141

4242
var paymentBatchId = PaymentBatch.Create(apiContext, paymentBatchMap, USER_ITEM_ID,
43-
MONETARY_ACCOUNT_ITEM_ID);
43+
MONETARY_ACCOUNT_ITEM_ID).Value;
4444

4545
Console.WriteLine(PaymentBatch.Get(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID, paymentBatchId));
4646
}

BunqSdk.Samples/PaymentListSample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class PaymentListSample : ISample
1313
public void Run()
1414
{
1515
var apiContext = ApiContext.Restore();
16-
var paymentList = Payment.List(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID);
16+
var paymentList = Payment.List(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID).Value;
1717

1818
foreach (var payment in paymentList)
1919
{

BunqSdk.Samples/PaymentSample.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ public void Run()
3030
{Payment.FIELD_DESCRIPTION, PAYMENT_DESCRIPTION}
3131
};
3232

33-
var paymentId = Payment.Create(apiContext, paymentMap, USER_ITEM_ID,
34-
MONETARY_ACCOUNT_ITEM_ID);
33+
var paymentId = Payment.Create(apiContext, paymentMap, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID).Value;
3534

3635
Console.WriteLine(Payment.Get(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID, paymentId));
3736
}

BunqSdk.Samples/RequestSample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void Run()
2828
{RequestInquiry.FIELD_DESCRIPTION, REQUEST_DESCRIPTION},
2929
{RequestInquiry.FIELD_ALLOW_BUNQME, true}
3030
};
31-
var requestId = RequestInquiry.Create(apiContext, requestMap, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID);
31+
var requestId = RequestInquiry.Create(apiContext, requestMap, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID).Value;
3232
Console.WriteLine(RequestInquiry.Get(apiContext, USER_ITEM_ID, MONETARY_ACCOUNT_ITEM_ID, requestId));
3333

3434
var requestUpdateMap = new Dictionary<string, object> {{RequestInquiry.FIELD_STATUS, STATUS_REVOKED}};

BunqSdk.Samples/UserListSample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class UserListSample : ISample
1010
public void Run()
1111
{
1212
var apiContext = ApiContext.Restore();
13-
var users = User.List(apiContext);
13+
var users = User.List(apiContext).Value;
1414

1515
apiContext.Save();
1616

BunqSdk.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ Global
1515
Release|Any CPU = Release|Any CPU
1616
EndGlobalSection
1717
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18-
{24F716E7-76C3-4EE4-A69C-2D02B7F08F65}.Release|Any CPU.ActiveCfg = Release|Any CPU
19-
{24F716E7-76C3-4EE4-A69C-2D02B7F08F65}.Release|Any CPU.Build.0 = Release|Any CPU
2018
{24F716E7-76C3-4EE4-A69C-2D02B7F08F65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2119
{24F716E7-76C3-4EE4-A69C-2D02B7F08F65}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{24F716E7-76C3-4EE4-A69C-2D02B7F08F65}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{24F716E7-76C3-4EE4-A69C-2D02B7F08F65}.Release|Any CPU.Build.0 = Release|Any CPU
2222
{D79B92DC-AEF3-42B9-8813-7171FE20A974}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2323
{D79B92DC-AEF3-42B9-8813-7171FE20A974}.Debug|Any CPU.Build.0 = Debug|Any CPU
2424
{D79B92DC-AEF3-42B9-8813-7171FE20A974}.Release|Any CPU.ActiveCfg = Release|Any CPU

BunqSdk/Context/ApiContext.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Bunq.Sdk.Model.Generated;
99
using Bunq.Sdk.Security;
1010
using Newtonsoft.Json;
11-
using DeviceServer = Bunq.Sdk.Model.DeviceServer;
1211

1312
namespace Bunq.Sdk.Context
1413
{
@@ -112,21 +111,31 @@ private void InitializeInstallationContext()
112111
{
113112
var keyPairClient = SecurityUtils.GenerateKeyPair();
114113
var publicKeyFormattedString = SecurityUtils.GetPublicKeyFormattedString(keyPairClient);
115-
var installation = Installation.Create(this, publicKeyFormattedString);
116-
InstallationContext = new InstallationContext(installation, keyPairClient);
114+
var installationResponse = Installation.Create(this, publicKeyFormattedString);
115+
InstallationContext = new InstallationContext(installationResponse.Value, keyPairClient);
117116
}
118117

119118
private void RegisterDevice(string deviceDescription, IList<string> permittedIps)
120119
{
121-
DeviceServer.Create(this, deviceDescription, permittedIps);
120+
DeviceServer.Create(this, GenerateRequestBodyBytes(deviceDescription, permittedIps));
121+
}
122+
123+
private IDictionary<string, object> GenerateRequestBodyBytes(string description, IList<string> permittedIps)
124+
{
125+
return new Dictionary<string, object>
126+
{
127+
{DeviceServer.FIELD_DESCRIPTION, description},
128+
{DeviceServer.FIELD_SECRET, ApiKey},
129+
{DeviceServer.FIELD_PERMITTED_IPS, permittedIps}
130+
};
122131
}
123132

124133
/// <summary>
125134
/// Create a new session and its data in a SessionContext.
126135
/// </summary>
127136
private void InitializeSessionContext()
128137
{
129-
SessionContext = new SessionContext(SessionServer.Create(this));
138+
SessionContext = new SessionContext(SessionServer.Create(this).Value);
130139
}
131140

132141
/// <summary>

0 commit comments

Comments
 (0)