DodoPayments.Operation (dodo_payments v0.1.0)

Copy Markdown View Source

Wire-level description of a Dodo Payments operation.

Operations are data rather than transport code. Keeping the catalogue explicit gives the request engine one authoritative place to make authentication, replay, remote-consequence, pagination and decoding decisions. Replayability answers whether an identical request may be repeated; consequence classification answers whether an ambiguous result needs reconciliation.

Summary

Functions

Returns every operation in stable catalogue order.

Returns an operation, raising for an SDK-internal unknown identifier.

Validates input, expands path variables and separates query/body data.

Expands {name} variables using URL-encoded values from the input map.

Types

auth()

@type auth() :: :merchant | :public

item_schema()

@type item_schema() :: module() | {:enum, atom()} | nil

pagination()

@type pagination() ::
  nil | %{kind: :page_number, initial: non_neg_integer()} | %{kind: :cursor}

replay()

@type replay() :: :safe | :never | {:idempotent_by, [atom() | [atom()]]}

response_mode()

@type response_mode() :: :json | :empty | :binary | :pdf | :csv

t()

@type t() :: %DodoPayments.Operation{
  auth: auth(),
  body_field: atom() | nil,
  consequential: boolean(),
  id: atom(),
  input: :none | :body | :query,
  item_schema: item_schema(),
  method: :get | :post | :put | :patch | :delete,
  pagination: pagination(),
  path: String.t(),
  path_params: [atom()],
  reconciliation: String.t() | nil,
  replay: replay(),
  required: [atom()],
  response_mode: response_mode(),
  response_schema: module() | nil,
  success_statuses: [pos_integer()],
  validator: atom() | nil
}

Functions

all()

@spec all() :: [t()]

Returns every operation in stable catalogue order.

fetch!(id)

@spec fetch!(atom()) :: t()

Returns an operation, raising for an SDK-internal unknown identifier.

prepare(operation, params \\ %{})

@spec prepare(t(), map() | nil) ::
  {:ok, %{path: String.t(), body: map() | nil, query: map()}}
  | {:error, Exception.t()}

Validates input, expands path variables and separates query/body data.

render_path(operation, params)

@spec render_path(t(), map()) :: {:ok, String.t()} | {:error, Exception.t()}

Expands {name} variables using URL-encoded values from the input map.