# Transfer Methods

The following endpoints are use to manage and retrieve the transfer methods on the system.

* `DELETE /transfer-methods/:id`
* `GET /transfer-methods/:id`
* `GET /transfer-methods`
* `POST /transfer-methods`

## Introduction <a href="#user-content-introduction" id="user-content-introduction"></a>

This API provides transfer method management functionalities.

### Transfer methods <a href="#user-content-transfer-methods" id="user-content-transfer-methods"></a>

#### Transfer method entity model <a href="#user-content-transfer-method-entity-model" id="user-content-transfer-method-entity-model"></a>

| Name              |    Type    | Description                                    | Constraints                                |
| ----------------- | :--------: | ---------------------------------------------- | ------------------------------------------ |
| appId             |  `String`  | Application ID. Format: `uuid`.                |                                            |
| createdAt         | `DateTime` | Transfer method created at date.               | `Not Null`                                 |
| deletedAt         | `DateTime` | Transfer method deleted at date.               |                                            |
| externalReference |  `String`  | Transfer method external reference.            |                                            |
| id                |  `String`  | Transfer method identifier. Format: `uuid`.    | `Not Null`                                 |
| identityId        |  `String`  | Transfer method identity owner. Format: `uuid` |                                            |
| metadata          |  `Object`  | Transfer method metadata.                      |                                            |
| type              |  `String`  | Transfer method type.                          | Enum:\[`ach`, `internationalWire`, `wire`] |
| updatedAt         | `DateTime` | Transfer method updated at date.               | `Not Null`                                 |

### Remove a transfer method

`DELETE /transfer-methods/:id`

Delete transfer method by id.

**Response Options**

**400 Bad Request**

* validation\_failed
  * If id is invalid.

**404 Not Found**

* transfer\_method\_not\_found

**204 OK**

Request example:

```
DELETE <hostname>/transfer-methods/e7941059-74c6-4b3f-b029-d3aa03d1ea44
```

### Get a transfer method

`GET /transfer-methods/:id`

Get transfer method by id.

**Response Options**

**400 Bad Request**

* validation\_failed
  * If id is invalid.

**404 Not Found**

* transfer\_method\_not\_found

**200 OK**

Request example:

```
GET <hostname>/transfer-methods/e7941059-74c6-4b3f-b029-d3aa03d1ea44
```

Response example:

```
{
  "data": {
    "appId": "e7941059-74c6-4b3f-b029-d3aa03d1ea44",
    "createdAt": "2020-10-28T17:40:55.501Z",
    "deletedAt": null,
    "externalReference": null,
    "id": "e7941059-74c6-4b3f-b029-d3aa03d1ea44",
    "identityId": "e7941059-74c6-4b3f-b029-d3aa03d1ea44",
    "metadata": {
      "bankName": "Royal bank",
      "swiftCode": "BKBKESMMXXX",
      "bankAccountName": "foobar",
      "bankAccountNumber": "GB94BARC10201530093459"
    },
    "type": "internationalWire",
    "updatedAt": "2020-10-28T17:40:55.501Z"
  }
}
```

### Get all transfer methods

`GET /transfer-methods`

Get transfer methods list.

**Available filters**

| Name              |       Type       | Example                            |
| ----------------- | :--------------: | ---------------------------------- |
| externalReference | `default,in,nin` | `filter[externalReference]=foobar` |
| id                | `default,in,nin` | `filter[id]=foobar`                |
| identityId        | `default,in,nin` | `filter[identityId]=foobar`        |
| type              | `default,in,nin` | `filter[type]=in:foobar`           |

**Available sorts**

| Name      | Example                                                            |
| --------- | ------------------------------------------------------------------ |
| createdAt | <p><code>sort=createdAt</code><br><code>sort=-createdAt</code></p> |
| updatedAt | <p><code>sort=updatedAt</code><br><code>sort=-updatedAt</code></p> |

**Paginate options**

| Name   | Description                                             | Example          |
| ------ | ------------------------------------------------------- | ---------------- |
| size   | Defines the number of results per page. Default = 30.   | `page[size]=2`   |
| number | Defines the number of the page to retrieve. Default = 1 | `page[number]=2` |
| all    | Return all identities without pagination                | `all=true`       |

**Response Options**

**200 OK**

Request example:

```
GET <hostname>/transfer-methods
```

Response example:

```
{
  "data": [{
    "appId": "e7941059-74c6-4b3f-b029-d3aa03d1ea44",
    "createdAt": "2020-10-28T17:40:55.501Z",
    "deletedAt": null,
    "externalReference": null,
    "id": "e7941059-74c6-4b3f-b029-d3aa03d1ea44",
    "identityId": "e7941059-74c6-4b3f-b029-d3aa03d1ea44",
    "metadata": {
      "bankName": "Royal bank",
      "swiftCode": "BKBKESMMXXX",
      "bankAccountName": "foobar",
      "bankAccountNumber": "GB94BARC10201530093459"
    },
    "type": "internationalWire",
    "updatedAt": "2020-10-28T17:40:55.501Z"
  }],
  "total": 1
}
```

### Create a new transfer method

`POST /transfer-methods`

Creates a transfer method.

**Request Parameters**

**Body parameters for type internationalWire**

| Name              |   Type   | Description                             | Constraints         | Required |
| ----------------- | :------: | --------------------------------------- | ------------------- | :------: |
| bankAccountName   | `String` | Bank account name amount.               | `Not null`          |  `true`  |
| bankAccountNumber | `String` | Bank account number.                    | Valid IBAN          |  `true`  |
| bankName          | `String` | Bank name.                              | `Not null`          |  `true`  |
| identityId        | `String` | Identity identification. Format: `uuid` |                     |  `true`  |
| swiftCode         | `String` | Swift code.                             | Valid swift code.   |  `true`  |
| type              | `String` | Transfer method.                        | `internationalWire` |  `true`  |

**Body parameters for type wire**

| Name              |   Type   | Description                             | Constraints              | Required |
| ----------------- | :------: | --------------------------------------- | ------------------------ | :------: |
| bankAccountName   | `String` | Bank account name amount.               | `Not null`               |  `true`  |
| bankAccountNumber | `String` | Bank account number.                    | Valid US acccount number |  `true`  |
| identityId        | `String` | Identity identification. Format: `uuid` |                          |  `true`  |
| routingNumber     | `String` | Routing number.                         | Valid routing number.    |  `true`  |
| type              | `String` | Transfer method.                        | `wire`                   |  `true`  |

**Body parameters for type ach**

| Name             |   Type   | Description                             | Constraints | Required |
| ---------------- | :------: | --------------------------------------- | ----------- | :------: |
| plaidAccessToken | `String` | Plaid access token.                     | `Not null`  |  `true`  |
| plaidAccountId   | `String` | Plaid account id.                       | `Not null`  |  `true`  |
| identityId       | `String` | Identity identification. Format: `uuid` |             |  `true`  |
| type             | `String` | Transfer method.                        | `ach`       |  `true`  |

**Body parameters for type pix**

| Name       |   Type   | Description                             | Constraints | Required |
| ---------- | :------: | --------------------------------------- | ----------- | :------: |
| document   | `String` | Document id.                            | `Not null`  |  `true`  |
| identityId | `String` | Identity identification. Format: `uuid` |             |  `true`  |
| type       | `String` | Transfer method.                        | `pix`       |  `true`  |

**Response Options**

**400 Bad Request**

* validation\_failed
  * If the required parameters are not provided.
  * If additional parameters are provided.
  * If some of the parameters type is invalid.
  * If some of the parameters constraints is not respected.

**200 OK**

Request example:

```
POST <hostname>/transfer-methods

{
  "bankAccountName": "foobar",
  "bankAccountNumber": "GB94BARC10201530093459",
  "bankName": "Royal bank",
  "identityId": "87e5d63a-c92a-4f2f-a869-bb7119d0f0a0",
  "swiftCode": "BKBKESMMXXX" ,
  "type": "internationalWire"
}
```

Response example:

```
{
  "data": {
    "appId": "e86755c5-f997-443e-992c-67f2866278aa",
    "createdAt": "2022-06-09T18:08:27.604Z",
    "deletedAt": null,
    "externalReference": "76559632-442a-4a78-89e3-b4960cf0cd73",
    "id": "8471e769-5bc3-4531-a320-bdcab1ceea50",
    "identityId": "87e5d63a-c92a-4f2f-a869-bb7119d0f0a0",
    "metadata": {
      "bankName": "Royal bank",
      "swiftCode": "BKBKESMMXXX",
      "bankAccountName": "foobar",
      "bankAccountNumber": "GB94BARC10201530093459"
    },
    "type": "internationalWire",
    "updatedAt": "2022-06-09T18:08:29.211Z"
  }
}
```
