1+ using System . Collections . Generic ;
2+ using Dapi . Response ;
3+ using Dapi . Types ;
4+
5+ namespace Dapi . Products {
6+
7+ public class ACH {
8+ private string appSecret { get ; }
9+
10+ public ACH ( string appSecret ) {
11+ this . appSecret = appSecret ;
12+ }
13+
14+
15+ public CreateACHPullResponse createACHPull ( ACHPull transfer , string accessToken , string userSecret , string operationID , UserInput [ ] userInputs ) {
16+ // Create the request body of this call
17+ var reqBody = new CreateACHPullRequest ( transfer , appSecret , userSecret , operationID , userInputs ) ;
18+
19+ // Construct the headers needed for this request
20+ var headers = new List < KeyValuePair < string , string > > ( ) ;
21+ headers . Add ( new KeyValuePair < string , string > ( "Authorization" , "Bearer " + accessToken ) ) ;
22+
23+ // Make the request and get the response
24+ var respBody = DapiRequest . Do < CreateACHPullRequest , CreateACHPullResponse > ( reqBody , reqBody . action , headers ) ;
25+
26+ // return the data if it's valid, otherwise return an error response
27+ return respBody ?? new CreateACHPullResponse ( "UNEXPECTED_RESPONSE" , "Unexpected response body" ) ;
28+ }
29+
30+ public getACHPullResponse getACHPull ( string accessToken , string userSecret , string operationID , UserInput [ ] userInputs ) {
31+ // Create the request body of this call
32+ var reqBody = new getACHPullRequest ( appSecret , userSecret , operationID , userInputs ) ;
33+
34+ // Construct the headers needed for this request
35+ var headers = new List < KeyValuePair < string , string > > ( ) ;
36+ headers . Add ( new KeyValuePair < string , string > ( "Authorization" , "Bearer " + accessToken ) ) ;
37+
38+ // Make the request and get the response
39+ var respBody = DapiRequest . Do < getACHPullRequest , getACHPullResponse > ( reqBody , reqBody . action , headers ) ;
40+
41+ // return the data if it's valid, otherwise return an error response
42+ return respBody ?? new getACHPullResponse ( "UNEXPECTED_RESPONSE" , "Unexpected response body" ) ;
43+ }
44+
45+ public class ACHPull {
46+ public string senderID { get ; }
47+ public float amount { get ; }
48+ public string description { get ; }
49+
50+ /// <summary>
51+ /// Create an object that holds the info for a transfer from a bank that requires the receiver to be already
52+ /// registered as a beneficiary to perform a transaction.
53+ /// </summary>
54+ ///
55+ /// <param name="senderID">
56+ /// the id of the account which the money should be sent from.
57+ /// retrieved from one of the accounts array returned from the getAccounts method.
58+ /// </param>
59+ /// <param name="amount">
60+ /// the amount of money which should be sent.
61+ /// </param>
62+ /// <param name="description">
63+ /// the id of the beneficiary which the money should be sent to.
64+ /// retrieved from one of the beneficiaries array returned from the getBeneficiaries method.
65+ /// </param>
66+ public ACHPull ( string senderID , float amount , string description ) {
67+ this . senderID = senderID ;
68+ this . amount = amount ;
69+ this . description = description ;
70+ }
71+ }
72+
73+ private class CreateACHPullRequest : DapiRequest . BaseRequest {
74+ internal string action => "/ach/pull/create" ;
75+
76+ public string senderID { get ; }
77+ public float amount { get ; }
78+ public string description { get ; }
79+
80+ public CreateACHPullRequest ( ACHPull transfer , string appSecret , string userSecret , string operationID , UserInput [ ] userInputs ) :
81+ base ( appSecret , userSecret , operationID , userInputs ) {
82+ this . senderID = transfer . senderID ;
83+ this . amount = transfer . amount ;
84+ this . description = transfer . description ;
85+ }
86+ }
87+
88+ private class GetACHPullRequest : DapiRequest . BaseRequest {
89+ internal string action => "/ach/pull/get" ;
90+
91+ public GetACHPullRequest ( string appSecret , string userSecret , string operationID , UserInput [ ] userInputs ) :
92+ base ( appSecret , userSecret , operationID , userInputs ) {
93+ }
94+ }
95+ }
96+ }
0 commit comments