Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,61 @@ In addition to the fields described in the BaseResponse, it has the following fi

---


#### DapiApp.createACHPull

Method is used to initiate a new ACH pull create.

##### Method Description

```c#
public CreateACHPullResponse createACHPull(ACHPull transfer, string accessToken, string userSecret, string operationID, UserInput[] userInputs)

```

##### Input Parameters

| Parameter | Type | Description |
|---|---|---|
| **transfer** <br> _REQUIRED_ | `ACH.ACHPull` | An object that contains info about the transfer that should be initiated. |
| **accessToken** <br> _REQUIRED_ | `string` | Access Token obtained using the `exchangeToken` method. |
| **userSecret** <br> _REQUIRED_ | `string` | The `userSecret` from a user’s successful log in to **Connect**. |
| **operationID** <br> _OPTIONAL_ | `string` | The `operationID` from a previous call's response. <br> Required only when resuming a previous call that responded with `user_input_required` status, to provided user inputs. |
| **userInputs** <br> _OPTIONAL_ | `UserInput[]` | Array of `UserInput` object, that are needed to complete this operation. <br> Required only if a previous call responded with `user_input_required` status. <br><br> You can read more about user inputs specification on [Specify User Input](https://dapi-api.readme.io/docs/specify-user-input) |

##### Response

Method returns only the fields defined in the BaseResponse.

---


#### DapiApp.getACHPull

Method is used to initiate a new get ACH pull.

##### Method Description

```c#
public GetACHPullResponse getACHPull(string accessToken, string userSecret, string operationID, UserInput[] userInputs)

```

##### Input Parameters

| Parameter | Type | Description |
|---|---|---|
| **accessToken** <br> _REQUIRED_ | `string` | Access Token obtained using the `exchangeToken` method. |
| **userSecret** <br> _REQUIRED_ | `string` | The `userSecret` from a user’s successful log in to **Connect**. |
| **operationID** <br> _OPTIONAL_ | `string` | The `operationID` from a previous call's response. <br> Required only when resuming a previous call that responded with `user_input_required` status, to provided user inputs. |
| **userInputs** <br> _OPTIONAL_ | `UserInput[]` | Array of `UserInput` object, that are needed to complete this operation. <br> Required only if a previous call responded with `user_input_required` status. <br><br> You can read more about user inputs specification on [Specify User Input](https://dapi-api.readme.io/docs/specify-user-input) |

##### Response

In addition to the fields described in the BaseResponse, it has the following fields, which will only be returned if the status is `done`:

| Parameter | Type | Description |
|---|---|---|
| transfer | `ACHPullTransferInfo` | ACH transfer details returned by the bank. |

---
77 changes: 77 additions & 0 deletions src/Dapi/DapiApp.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ public class DapiApp {
private readonly Data d;
private readonly Payment p;
private readonly Metadata m;
private readonly ACH c;

public DapiApp(string appSecret) {
this.appSecret = appSecret;
this.a = new Auth(appSecret);
this.d = new Data(appSecret);
this.p = new Payment(appSecret);
this.c = new ACH(appSecret);
this.m = new Metadata(appSecret);
}

Expand Down Expand Up @@ -504,6 +506,81 @@ public GetAccountsMetadataResponse getAccountsMetadata(string accessToken, strin
return this.m.getAccountsMetadata(accessToken, userSecret, operationID, userInputs);
}

/// <summary>
/// createACHPull talks to the CreateACHPull endpoint of Dapi, with this DapiApp's appSecret.
/// </summary>
///
/// <param name="transfer">
/// the details of the transfer that should be initiate.
/// </param>
/// <param name="accessToken">
/// retrieved from the ExchangeToken process.
/// </param>
/// <param name="userSecret">
/// retrieved from the user login.
/// </param>
/// <param name="operationID">
/// retrieved from the previous call's response.
/// </param>
/// <param name="userInputs">
/// built from the previous call's response, and the required user input.
/// </param>
public CreateACHPullResponse createACHPull(ACH.PullTransfer transfer, string accessToken, string userSecret, string operationID, UserInput[] userInputs) {
return this.c.createACHPull(transfer, accessToken, userSecret, operationID, userInputs);
}

/// <summary>
/// createACHPull talks to the CreateACHPull endpoint of Dapi, with this DapiApp's appSecret.
/// </summary>
/// <param name="accessToken">
/// retrieved from the ExchangeToken process.
/// </param>
/// <param name="userSecret">
/// retrieved from the user login.
/// </param>
/// <param name="operationID">
/// retrieved from the previous call's response.
/// </param>
/// <param name="userInputs">
/// built from the previous call's response, and the required user input.
/// </param>
public GetACHPullResponse getACHPull(string accessToken, string userSecret, string operationID, UserInput[] userInputs) {
return this.c.getACHPull(accessToken, userSecret, operationID, userInputs);
}

/// <summary>
/// createACHPull talks to the CreateACHPull endpoint of Dapi, with this DapiApp's appSecret.
/// </summary>
///
/// <param name="transfer">
/// the details of the transfer that should be initiate.
/// </param>
/// <param name="accessToken">
/// retrieved from the ExchangeToken process.
/// </param>
/// <param name="userSecret">
/// retrieved from the user login.
/// </param>
public CreateACHPullResponse createACHPull(ACH.PullTransfer transfer, string accessToken, string userSecret) {
return this.c.createACHPull(transfer, accessToken, userSecret, "", null);
}

/// <summary>
/// createACHPull talks to the CreateACHPull endpoint of Dapi, with this DapiApp's appSecret.
/// </summary>
/// <param name="accessToken">
/// retrieved from the ExchangeToken process.
/// </param>
/// <param name="userSecret">
/// retrieved from the user login.
/// </param>
/// <param name="operationID">
/// retrieved from the previous call's response.
/// </param>
public GetACHPullResponse getACHPull(string accessToken, string userSecret, string operationID) {
return this.c.getACHPull(accessToken, userSecret, operationID, null);
}

/// <summary>
/// handleSDKRequest injects this {@link DapiApp}'s appSecret in the passed request body, bodyJson, and then
/// forwards the request to Dapi, with the passed headers, headersMap, and returns the RAW response got.
Expand Down
89 changes: 89 additions & 0 deletions src/Dapi/Products/ACH.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System.Collections.Generic;
using Dapi.Response;
using Dapi.Types;

namespace Dapi.Products {
public class ACH {
private string appSecret { get; }

public ACH(string appSecret) {
this.appSecret = appSecret;
}

public CreateACHPullResponse createACHPull(PullTransfer transfer, string accessToken, string userSecret, string operationID, UserInput[] userInputs) {
// Create the request body of this call
var reqBody = new CreateACHPullRequest(transfer, appSecret, userSecret, operationID, userInputs);

// Construct the headers needed for this request
var headers = new List<KeyValuePair<string, string>>();
headers.Add(new KeyValuePair<string, string>("Authorization", "Bearer " + accessToken));

// Make the request and get the response
var respBody = DapiRequest.Do<CreateACHPullRequest, CreateACHPullResponse>(reqBody, reqBody.action, headers);

// return the data if it's valid, otherwise return an error response
return respBody ?? new CreateACHPullResponse("UNEXPECTED_RESPONSE", "Unexpected response body");
}

public GetACHPullResponse getACHPull(string accessToken, string userSecret, string operationID, UserInput[] userInputs) {
// Create the request body of this call
var reqBody = new GetACHPullRequest(appSecret, userSecret, operationID, userInputs);

// Construct the headers needed for this request
var headers = new List<KeyValuePair<string, string>>();
headers.Add(new KeyValuePair<string, string>("Authorization", "Bearer " + accessToken));

// Make the request and get the response
var respBody = DapiRequest.Do<GetACHPullRequest, GetACHPullResponse>(reqBody, reqBody.action, headers);

// return the data if it's valid, otherwise return an error response
return respBody ?? new GetACHPullResponse("UNEXPECTED_RESPONSE", "Unexpected response body");
}

public class PullTransfer {
public string senderID { get; }
public float amount { get; }
public string description { get; }

/// <summary>
/// Create an object that holds the info for a transfer from a bank that requires the receiver to be already
/// registered as a beneficiary to perform a transaction.
/// </summary>
/// <param name="senderID">
/// the id of the account which the money should be sent from.
/// retrieved from one of the accounts array returned from the getAccounts method.
/// </param>
/// <param name="amount">
/// the amount of money which should be sent.
/// </param>
/// <param name="description">
/// the id of the beneficiary which the money should be sent to.
/// retrieved from one of the beneficiaries array returned from the getBeneficiaries method.
/// </param>
public PullTransfer(string senderID, float amount, string description) {
this.senderID = senderID;
this.amount = amount;
this.description = description;
}
}

private class CreateACHPullRequest : DapiRequest.BaseRequest {
internal string action => "/ach/pull/create";

public PullTransfer transfer { get; }

public CreateACHPullRequest(PullTransfer transfer, string appSecret, string userSecret, string operationID, UserInput[] userInputs) :
base(appSecret, userSecret, operationID, userInputs) {
this.transfer = transfer;
}
}

private class GetACHPullRequest : DapiRequest.BaseRequest {
internal string action => "/ach/pull/get";

public GetACHPullRequest(string appSecret, string userSecret, string operationID, UserInput[] userInputs) :
base(appSecret, userSecret, operationID, userInputs) {
}
}
}
}
Empty file modified src/Dapi/Products/Payment.cs
100644 → 100755
Empty file.
23 changes: 23 additions & 0 deletions src/Dapi/Response/CreateACHPullResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Dapi.Types;
using Newtonsoft.Json;

namespace Dapi.Response {
public class CreateACHPullResponse : BaseResponse {

/// <summary>
/// This is used only to automate the deserialization of the get response.
/// This is a private constructor to this lib.
/// </summary>
[JsonConstructor]
internal CreateACHPullResponse(APIStatus status, bool success, string operationID, UserInput[] userInputs, string type, string msg) :
base(status, success, operationID, userInputs, type, msg) {
}

/// <summary>
/// This is used to construct an error response from the reading of the got response.
/// This is a private constructor to this lib.
/// </summary>
internal CreateACHPullResponse(string errType, string errMsg) : base(errType, errMsg) {
}
}
}
25 changes: 25 additions & 0 deletions src/Dapi/Response/GetACHPullResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Dapi.Types;
using Newtonsoft.Json;

namespace Dapi.Response {
public class GetACHPullResponse : BaseResponse {
public ACHPullTransferInfo transfer { get; }

/// <summary>
/// This is used only to automate the deserialization of the get response.
/// This is a private constructor to this lib.
/// </summary>
[JsonConstructor]
internal GetACHPullResponse(ACHPullTransferInfo transfer, string reference, APIStatus status, bool success, string operationID, UserInput[] userInputs, string type, string msg) :
base(status, success, operationID, userInputs, type, msg) {
this.transfer = transfer;
}

/// <summary>
/// This is used to construct an error response from the reading of the got response.
/// This is a private constructor to this lib.
/// </summary>
internal GetACHPullResponse(string errType, string errMsg) : base(errType, errMsg) {
}
}
}
13 changes: 13 additions & 0 deletions src/Dapi/Types/ACHGetTransfer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Dapi.Types {
public class ACHPullTransferInfo {
public float amount { get; }
public Currency currency { get; }
public string status { get; }

public ACHPullTransferInfo(float amount, Currency currency, string status) {
this.amount = amount;
this.currency = currency;
this.status = status;
}
}
}