Packages

An unofficial, production-grade Elixir client for the Synctera Banking-as-a-Service API. Zero runtime dependencies, generated from Synctera's OpenAPI spec.

Current section

Files

Jump to
synctera lib synctera resources external_cards_alpha.ex
Raw

lib/synctera/resources/external_cards_alpha.ex

defmodule Synctera.ExternalCardsAlpha do
@moduledoc """
Synctera 'External Cards (alpha)' endpoints.
Code generated by scripts/generate.py from the Synctera OpenAPI spec. Do
not edit by hand — re-run `mix generate` (or `python3 scripts/generate.py`)
to regenerate.
"""
alias Synctera.{Client, Error, HTTP}
@doc """
List external cards — List external cards
## Options
Query options: `:limit`, `:page_token`, `:customer_id`, `:business_id`
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec list_external_cards(Client.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def list_external_cards(client, opts \\ []) do
HTTP.request(client, :get, "/external_cards",
query: [
{"limit", Keyword.get(opts, :limit)},
{"page_token", Keyword.get(opts, :page_token)},
{"customer_id", Keyword.get(opts, :customer_id)},
{"business_id", Keyword.get(opts, :business_id)}
],
body: Keyword.get(opts, :body),
idempotency_tier: :none,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `list_external_cards/2` but returns the value directly and raises on error."
@spec list_external_cards!(Client.t(), keyword()) :: Synctera.JSON.json()
def list_external_cards!(client, opts) do
case list_external_cards(client, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Get a external card — Get an external card
## Options
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec get_external_card(Client.t(), String.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def get_external_card(client, external_card_id, opts \\ []) do
HTTP.request(client, :get, "/external_cards/#{HTTP.path_segment(external_card_id)}",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :none,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `get_external_card/3` but returns the value directly and raises on error."
@spec get_external_card!(Client.t(), String.t(), keyword()) :: Synctera.JSON.json()
def get_external_card!(client, external_card_id, opts) do
case get_external_card(client, external_card_id, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Create external card from token — Create an external card from token - You must first tokenize
the external card using the external card iframe. You will receive a token for the external card
upon successful completion. This endpoint will persist the external card and associate it to a
customer. The customer's name and address should match that of the external card as entered in
the iframe. <br>NB: Tokens should be associated right away. Tokens not associated within 30 mins
of creation will be invalidated.</br> NB: If a valid business_id is provided, the address
verification for the external card will be done against the address of the business. Otherwise,
the address of the customer will be used. In either case, the name of the customer will be used
to match the name of the cardholder.
## Options
* `:body` — request body (map), required.
* `:idempotency_key` — see `Synctera.Idempotency`.
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec create_external_card_from_token(Client.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def create_external_card_from_token(client, opts \\ []) do
HTTP.request(client, :post, "/external_cards/tokens",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :standard,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `create_external_card_from_token/2` but returns the value directly and raises on error."
@spec create_external_card_from_token!(Client.t(), keyword()) :: Synctera.JSON.json()
def create_external_card_from_token!(client, opts) do
case create_external_card_from_token(client, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
List external transfers — List external card transfer
## Options
Query options: `:limit`, `:page_token`, `:customer_id`, `:external_card_id`,
`:originating_account_id`, `:type`
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec list_external_card_transfers(Client.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def list_external_card_transfers(client, opts \\ []) do
HTTP.request(client, :get, "/external_cards/transfers",
query: [
{"limit", Keyword.get(opts, :limit)},
{"page_token", Keyword.get(opts, :page_token)},
{"customer_id", Keyword.get(opts, :customer_id)},
{"external_card_id", Keyword.get(opts, :external_card_id)},
{"originating_account_id", Keyword.get(opts, :originating_account_id)},
{"type", Keyword.get(opts, :type)}
],
body: Keyword.get(opts, :body),
idempotency_tier: :none,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `list_external_card_transfers/2` but returns the value directly and raises on error."
@spec list_external_card_transfers!(Client.t(), keyword()) :: Synctera.JSON.json()
def list_external_card_transfers!(client, opts) do
case list_external_card_transfers(client, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Create external card transfer — Create a external card transfer
## Options
* `:body` — request body (map), required.
* `:idempotency_key` — see `Synctera.Idempotency`.
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec create_external_card_transfer(Client.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def create_external_card_transfer(client, opts \\ []) do
HTTP.request(client, :post, "/external_cards/transfers",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :ledger,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `create_external_card_transfer/2` but returns the value directly and raises on error."
@spec create_external_card_transfer!(Client.t(), keyword()) :: Synctera.JSON.json()
def create_external_card_transfer!(client, opts) do
case create_external_card_transfer(client, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Get an external card transfer — Get an external transfer
## Options
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec get_external_card_transfer(Client.t(), String.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def get_external_card_transfer(client, transfer_id, opts \\ []) do
HTTP.request(client, :get, "/external_cards/transfers/#{HTTP.path_segment(transfer_id)}",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :none,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `get_external_card_transfer/3` but returns the value directly and raises on error."
@spec get_external_card_transfer!(Client.t(), String.t(), keyword()) :: Synctera.JSON.json()
def get_external_card_transfer!(client, transfer_id, opts) do
case get_external_card_transfer(client, transfer_id, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
end