# Transactions

## List transactions by organization

`transactions().list(TransactionListParamsparams, RequestOptionsrequestOptions = RequestOptions.none()) : TransactionListResponse`

**get** `/api/v1/transactions`

List transactions by organization

### Parameters

- `params: TransactionListParams`

  - `organizationId: String`

  - `page: Optional<Long>`

  - `perPage: Optional<Long>`

### Returns

- `class TransactionListResponse:`

  - `data: List<Data>`

    - `id: String`

    - `amount: Long`

      Amount in minor units

    - `createdAt: LocalDateTime`

    - `currency: String`

    - `fromAccountId: String`

    - `organizationId: String`

    - `status: Status`

      - `PENDING("pending")`

      - `POSTED("posted")`

      - `FAILED("failed")`

    - `toAccountId: String`

    - `transactionKind: TransactionKind`

      - `DEPOSIT("deposit")`

      - `WITHDRAW("withdraw")`

      - `TRANSFER("transfer")`

    - `updatedAt: LocalDateTime`

    - `environment: Optional<String>`

    - `failureReason: Optional<String>`

    - `idempotencyKey: Optional<String>`

  - `pagination: Pagination`

    - `page: Long`

    - `perPage: Long`

    - `totalCount: Long`

    - `totalPages: Long`

### Example

```kotlin
package com.rails.api.example

import com.rails.api.client.RailsClient
import com.rails.api.client.okhttp.RailsOkHttpClient
import com.rails.api.models.transactions.TransactionListParams
import com.rails.api.models.transactions.TransactionListResponse

fun main() {
    val client: RailsClient = RailsOkHttpClient.fromEnv()

    val params: TransactionListParams = TransactionListParams.builder()
        .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
        .build()
    val transactions: TransactionListResponse = client.transactions().list(params)
}
```

#### Response

```json
{
  "data": [
    {
      "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "amount": 0,
      "created_at": "2019-12-27T18:11:19.117Z",
      "currency": "currency",
      "from_account_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "organization_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "status": "pending",
      "to_account_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "transaction_kind": "deposit",
      "updated_at": "2019-12-27T18:11:19.117Z",
      "environment": "environment",
      "failure_reason": "failure_reason",
      "idempotency_key": "idempotency_key"
    }
  ],
  "pagination": {
    "page": 1,
    "per_page": 1,
    "total_count": 0,
    "total_pages": 0
  }
}
```

## List account transactions

`transactions().listByAccount(TransactionListByAccountParamsparams = TransactionListByAccountParams.none(), RequestOptionsrequestOptions = RequestOptions.none()) : List<Transaction>`

**get** `/api/v1/accounts/{account_id}/transactions`

List account transactions

### Parameters

- `params: TransactionListByAccountParams`

  - `accountId: Optional<String>`

  - `limit: Optional<Long>`

### Example

```kotlin
package com.rails.api.example

import com.rails.api.client.RailsClient
import com.rails.api.client.okhttp.RailsOkHttpClient
import com.rails.api.models.Transaction
import com.rails.api.models.transactions.TransactionListByAccountParams

fun main() {
    val client: RailsClient = RailsOkHttpClient.fromEnv()

    val transactions: List<Transaction> = client.transactions().listByAccount("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
}
```

#### Response

```json
[
  {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "account_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "amount": "amount",
    "balance_after": "balance_after",
    "created_at": "2019-12-27T18:11:19.117Z",
    "currency": "currency",
    "status": "pending",
    "transaction_type": "deposit",
    "updated_at": "2019-12-27T18:11:19.117Z",
    "description": "description",
    "external_recipient_id": "external_recipient_id",
    "recipient_account_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "reference_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
  }
]
```

## Retrieve transaction

`transactions().retrieve(TransactionRetrieveParamsparams = TransactionRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none()) : Transaction`

**get** `/api/v1/transactions/{id}`

Retrieve transaction

### Parameters

- `params: TransactionRetrieveParams`

  - `id: Optional<String>`

### Returns

- `class Transaction:`

  - `id: String`

  - `accountId: String`

  - `amount: String`

  - `balanceAfter: String`

  - `createdAt: LocalDateTime`

  - `currency: String`

  - `status: Status`

    - `PENDING("pending")`

    - `COMPLETED("completed")`

    - `FAILED("failed")`

    - `CANCELLED("cancelled")`

  - `transactionType: TransactionType`

    - `DEPOSIT("deposit")`

    - `WITHDRAWAL("withdrawal")`

    - `TRANSFER("transfer")`

    - `RECURRING_PAYMENT("recurring_payment")`

    - `SAVINGS_WITHDRAW("savings_withdraw")`

  - `updatedAt: LocalDateTime`

  - `description: Optional<String>`

  - `externalRecipientId: Optional<String>`

  - `recipientAccountId: Optional<String>`

  - `referenceId: Optional<String>`

### Example

```kotlin
package com.rails.api.example

import com.rails.api.client.RailsClient
import com.rails.api.client.okhttp.RailsOkHttpClient
import com.rails.api.models.Transaction
import com.rails.api.models.transactions.TransactionRetrieveParams

fun main() {
    val client: RailsClient = RailsOkHttpClient.fromEnv()

    val transaction: Transaction = client.transactions().retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
}
```

#### Response

```json
{
  "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "account_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "amount": "amount",
  "balance_after": "balance_after",
  "created_at": "2019-12-27T18:11:19.117Z",
  "currency": "currency",
  "status": "pending",
  "transaction_type": "deposit",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "description": "description",
  "external_recipient_id": "external_recipient_id",
  "recipient_account_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
  "reference_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
```
