Packages

Production-grade Elixir client for the Lithic API (card issuing & fintech)

Current section

Files

Jump to
lithic lib lithic resources card_bulk_orders.ex
Raw

lib/lithic/resources/card_bulk_orders.ex

defmodule Lithic.Resources.CardBulkOrders do
@moduledoc "Card bulk orders — order, track, and manage batches of physical cards."
alias Lithic.{Client, Page}
@path "/card_bulk_orders"
@spec create(map(), keyword()) :: {:ok, map()} | {:error, Lithic.Error.t()}
def create(params, opts \\ []), do: Client.post(client(opts), @path, params)
@spec get(String.t(), keyword()) :: {:ok, map()} | {:error, Lithic.Error.t()}
def get(token, opts \\ []), do: Client.get(client(opts), "#{@path}/#{token}")
@spec list(keyword()) :: {:ok, Page.t(map())} | {:error, Lithic.Error.t()}
def list(opts \\ []) do
{params, client_opts} = split_params(opts)
c = client(client_opts)
case Client.get(c, @path, params: params) do
{:ok, body} -> {:ok, Page.from_response(body, c, @path, params)}
{:error, _} = error -> error
end
end
@spec update(String.t(), map(), keyword()) :: {:ok, map()} | {:error, Lithic.Error.t()}
def update(token, params, opts \\ []), do: Client.patch(client(opts), "#{@path}/#{token}", params)
@spec client(keyword()) :: Client.t()
defp client(opts), do: Keyword.get(opts, :client, Client.new())
defp split_params(opts), do: Keyword.split(opts, [:client])
end