@@ -20,7 +20,7 @@ internal class DwollaBroker
20
20
internal async Task < TokenResponse > SetAuthorizationHeader ( string key , string secret )
21
21
{
22
22
var response = await _client . PostAuthAsync < TokenResponse > (
23
- new Uri ( $ "{ _client . ApiBaseAddress } /token") , new AppTokenRequest { Key = key , Secret = secret } ) ;
23
+ new Uri ( $ "{ _client . ApiBaseAddress } /token") , new AppTokenRequest { Key = key , Secret = secret } ) ;
24
24
25
25
// TODO: Securely store token in your database for reuse
26
26
if ( ! _headers . ContainsKey ( "Authorization" ) )
@@ -53,7 +53,7 @@ internal async Task<BeneficialOwnershipResponse> GetBeneficialOwnershipAsync(Uri
53
53
( await GetAsync < BeneficialOwnershipResponse > ( uri ) ) . Content ;
54
54
55
55
internal async Task < Uri > CertifyBeneficialOwnershipAsync ( Uri uri ) =>
56
- ( await PostAsync ( uri , new CertifyBeneficialOwnershipRequest { Status = "certified" } ) ) . Response . Headers . Location ;
56
+ ( await PostAsync ( uri , new CertifyBeneficialOwnershipRequest { Status = "certified" } ) ) . Response . Headers . Location ;
57
57
58
58
internal async Task < Uri > CreateCustomerAsync ( Uri uri , string firstName , string lastName , string email ) =>
59
59
await CreateCustomerAsync ( uri , new CreateCustomerRequest
@@ -83,14 +83,35 @@ internal async Task<GetCustomersResponse> GetCustomersAsync(Uri uri) =>
83
83
internal async Task < GetDocumentsResponse > GetCustomerDocumentsAsync ( Uri customerUri ) =>
84
84
( await GetAsync < GetDocumentsResponse > ( new Uri ( customerUri . AbsoluteUri + "/documents" ) ) ) . Content ;
85
85
86
- internal async Task < Uri > CreateFundingSourceAsync ( Uri uri , string routingNumber , string accountNumber , string bankAccountType , string name ) =>
87
- await CreateFundingSourceAsync ( uri , new CreateFundingSourceRequest
88
- {
89
- RoutingNumber = routingNumber ,
90
- AccountNumber = accountNumber ,
91
- BankAccountType = bankAccountType ,
92
- Name = name ,
93
- } ) ;
86
+ internal async Task < GetExchangePartnersResponse > GetExchangePartnersAsync ( ) => ( await GetAsync < GetExchangePartnersResponse > ( new Uri ( $ "{ _client . ApiBaseAddress } /exchange-partners") ) ) . Content ;
87
+
88
+ // Create an MX exchange for a customer
89
+ // Exchange-Partner ID for MX = 'bca8d065-49a5-475b-a6b4-509bc8504d22'
90
+ internal async Task < Uri > CreateExchangeAsync ( Uri uri , string token )
91
+ {
92
+ var r = await PostAsync < CreateExchangeRequest , EmptyResponse > ( uri , new CreateExchangeRequest
93
+ {
94
+ Token = token ,
95
+ Links = new Dictionary < string , Link >
96
+ {
97
+ { "exchange-partner" , new Link { Href = new Uri ( $ "{ _client . ApiBaseAddress } /exchange-partners/bca8d065-49a5-475b-a6b4-509bc8504d22") } }
98
+ } ,
99
+ } ) ;
100
+ return r . Response . Headers . Location ;
101
+ }
102
+
103
+ internal async Task < ExchangeResponse > GetExchangeAsync ( Uri uri ) => ( await GetAsync < ExchangeResponse > ( uri ) ) . Content ;
104
+
105
+ internal async Task < GetExchangesResponse > GetExchangesAsync ( Uri uri ) => ( await GetAsync < GetExchangesResponse > ( uri ) ) . Content ;
106
+
107
+ internal async Task < Uri > CreateFundingSourceAsync ( Uri uri , string routingNumber , string accountNumber , string bankAccountType , string name ) =>
108
+ await CreateFundingSourceAsync ( uri , new CreateFundingSourceRequest
109
+ {
110
+ RoutingNumber = routingNumber ,
111
+ AccountNumber = accountNumber ,
112
+ BankAccountType = bankAccountType ,
113
+ Name = name ,
114
+ } ) ;
94
115
internal async Task < Uri > CreateFundingSourceAsync ( Uri uri , CreateFundingSourceRequest request )
95
116
{
96
117
var response = await PostAsync < CreateFundingSourceRequest , EmptyResponse > ( uri , request ) ;
@@ -113,8 +134,8 @@ internal async Task<Uri> VerifyMicroDepositsAsync(string fundingSourceId, decima
113
134
( await PostAsync ( new Uri ( $ "{ _client . ApiBaseAddress } /funding-sources/{ fundingSourceId } /micro-deposits") ,
114
135
new MicroDepositsRequest
115
136
{
116
- Amount1 = new Money { Value = amount1 , Currency = "USD" } ,
117
- Amount2 = new Money { Value = amount2 , Currency = "USD" }
137
+ Amount1 = new Money { Value = amount1 , Currency = "USD" } ,
138
+ Amount2 = new Money { Value = amount2 , Currency = "USD" }
118
139
} ) ) . Response . Headers . Location ;
119
140
120
141
@@ -168,7 +189,7 @@ internal async Task<Uri> CreateTransferAsync(string sourceFundingSourceId, strin
168
189
Values = new List < string > { destinationAddenda }
169
190
}
170
191
}
171
- }
192
+ }
172
193
} ) ;
173
194
return response . Response . Headers . Location ;
174
195
}
@@ -212,7 +233,7 @@ internal async Task<MasspaymentResponse> GetMasspaymentAsync(string id) =>
212
233
( await GetAsync < MasspaymentResponse > ( new Uri ( $ "{ _client . ApiBaseAddress } /mass-payments/{ id } ") ) ) . Content ;
213
234
214
235
internal async Task < Uri > CreateWebhookSubscriptionAsync ( Uri uri , string url , string secret ) =>
215
- ( await PostAsync ( uri , new CreateWebhookSubscriptionRequest { Url = url , Secret = secret } ) ) . Response . Headers . Location ;
236
+ ( await PostAsync ( uri , new CreateWebhookSubscriptionRequest { Url = url , Secret = secret } ) ) . Response . Headers . Location ;
216
237
217
238
internal async Task DeleteWebhookSubscriptionAsync ( Uri uri ) => await DeleteAsync < object > ( uri , null ) ;
218
239
@@ -234,8 +255,8 @@ internal async Task<Uri> CreateLabelAsync(Uri uri, decimal amount) =>
234
255
{
235
256
Amount = new Money { Currency = "USD" , Value = amount }
236
257
} ) ;
237
-
238
-
258
+
259
+
239
260
internal async Task < Uri > CreateLabelAsync ( Uri uri , CreateLabelRequest request )
240
261
{
241
262
var response = await PostAsync ( uri , request ) ;
@@ -247,18 +268,18 @@ internal async Task<Label> GetLabelAsync(string id) =>
247
268
248
269
internal async Task < Label > GetLabelAsync ( Uri uri ) =>
249
270
( await GetAsync < Label > ( uri ) ) . Content ;
250
-
271
+
251
272
internal async Task < GetLabelsResponse > GetLabelsAsync ( string id ) =>
252
273
( await GetAsync < GetLabelsResponse > ( new Uri ( $ "{ _client . ApiBaseAddress } /customers/{ id } /labels") ) ) . Content ;
253
274
254
275
internal async Task < GetLabelsResponse > GetLabelsAsync ( Uri uri ) =>
255
276
( await GetAsync < GetLabelsResponse > ( uri ) ) . Content ;
256
277
257
- internal async Task DeleteLabelAsync ( string id ) =>
278
+ internal async Task DeleteLabelAsync ( string id ) =>
258
279
await DeleteAsync < object > ( new Uri ( $ "{ _client . ApiBaseAddress } /labels/{ id } ") , null ) ;
259
280
260
281
internal async Task < Uri > CreateLabelLedgerEntryAsync ( string id , decimal amount ) =>
261
- await CreateLabelLedgerEntryAsync ( new Uri ( $ "{ _client . ApiBaseAddress } /labels/{ id } /ledger-entries") ,
282
+ await CreateLabelLedgerEntryAsync ( new Uri ( $ "{ _client . ApiBaseAddress } /labels/{ id } /ledger-entries") ,
262
283
new CreateLabelLedgerEntryRequest
263
284
{
264
285
Amount = new Money { Currency = "USD" , Value = amount }
@@ -310,7 +331,7 @@ internal async Task<LabelReallocation> GetLabelReallocationAsync(string id) =>
310
331
311
332
internal async Task < LabelReallocation > GetLabelReallocationAsync ( Uri uri ) =>
312
333
( await GetAsync < LabelReallocation > ( uri ) ) . Content ;
313
-
334
+
314
335
private async Task < RestResponse < TRes > > GetAsync < TRes > ( Uri uri ) where TRes : IDwollaResponse =>
315
336
await ExecAsync ( ( ) => _client . GetAsync < TRes > ( uri , _headers ) ) ;
316
337
@@ -343,5 +364,10 @@ private static async Task<RestResponse<TRes>> ExecAsync<TRes>(Func<Task<RestResp
343
364
344
365
return r ;
345
366
}
367
+
368
+ internal Task CreateBeneficialOwnerAsync ( Uri uri , CreateExchangeRequest createExchangeRequest )
369
+ {
370
+ throw new NotImplementedException ( ) ;
371
+ }
346
372
}
347
373
}
0 commit comments