Humaans.BankAccounts (Humaans v0.5.1)

Copy Markdown View Source

This module provides functions for managing bank account resources in the Humaans API.

Summary

Functions

Creates a new bank_account.

Deletes a specific bank_account by ID.

Lists all bank_accounts.

Retrieves a specific bank_account by ID.

Updates a specific bank_account by ID.

Types

delete_response()

@type delete_response() ::
  {:ok, %{id: String.t(), deleted: bool()}} | {:error, Humaans.Error.t()}

list_response()

@type list_response() ::
  {:ok,
   [
     %Humaans.Resources.BankAccount{
       account_number: term(),
       bank_name: term(),
       created_at: term(),
       id: term(),
       name_on_account: term(),
       person_id: term(),
       routing_number: term(),
       sort_code: term(),
       swift_code: term(),
       updated_at: term()
     }
   ]}
  | {:error, Humaans.Error.t()}

response()

@type response() ::
  {:ok,
   %Humaans.Resources.BankAccount{
     account_number: term(),
     bank_name: term(),
     created_at: term(),
     id: term(),
     name_on_account: term(),
     person_id: term(),
     routing_number: term(),
     sort_code: term(),
     swift_code: term(),
     updated_at: term()
   }}
  | {:error, Humaans.Error.t()}

Functions

create(client, params)

@spec create(client :: map(), params :: map() | keyword()) ::
  {:ok, Humaans.Resources.BankAccount.t()} | {:error, Humaans.Error.t()}

Creates a new bank_account.

Parameters

  • client - Client created with Humaans.new/1
  • params - Map of attributes for the new bank_account

Examples

client = Humaans.new(access_token: "your_access_token")
params = %{personId: "person_abc", bankName: "Barclays", accountNumber: "12345678", sortCode: "20-00-00"}
{:ok, bank_account} = Humaans.BankAccounts.create(client, params)

delete(client, id)

@spec delete(client :: map(), id :: String.t()) ::
  {:ok, %{id: String.t(), deleted: boolean()}} | {:error, Humaans.Error.t()}

Deletes a specific bank_account by ID.

Parameters

  • client - Client created with Humaans.new/1
  • id - String ID of the bank_account to delete

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, %{id: "bank_account_id", deleted: true}} = Humaans.BankAccounts.delete(client, "bank_account_id")

list(client, params \\ %{})

@spec list(client :: map(), params :: map() | keyword()) ::
  {:ok, [Humaans.Resources.BankAccount.t()]} | {:error, Humaans.Error.t()}

Lists all bank_accounts.

Returns a list of bank_accounts matching the optional filter params.

Parameters

  • client - Client created with Humaans.new/1
  • params - Optional map of filter parameters (default: %{})

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, bank_accounts} = Humaans.BankAccounts.list(client)
{:ok, bank_accounts} = Humaans.BankAccounts.list(client, %{})

retrieve(client, id)

@spec retrieve(client :: map(), id :: String.t()) ::
  {:ok, Humaans.Resources.BankAccount.t()} | {:error, Humaans.Error.t()}

Retrieves a specific bank_account by ID.

Parameters

  • client - Client created with Humaans.new/1
  • id - String ID of the bank_account to retrieve

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, bank_account} = Humaans.BankAccounts.retrieve(client, "bank_account_id")

update(client, id, params)

@spec update(client :: map(), id :: String.t(), params :: map() | keyword()) ::
  {:ok, Humaans.Resources.BankAccount.t()} | {:error, Humaans.Error.t()}

Updates a specific bank_account by ID.

Parameters

  • client - Client created with Humaans.new/1
  • id - String ID of the bank_account to update
  • params - Map of attributes to update

Examples

client = Humaans.new(access_token: "your_access_token")
params = %{bankName: "HSBC"}
{:ok, bank_account} = Humaans.BankAccounts.update(client, "bank_account_id", params)