OpenPayments.Types.CreateQuote (open_payments_elixir v1.0.0)

Copy Markdown View Source

The strict payload for creating a quote using one of three amount variants.

Required wallet_address is absolute-URI data, receiver follows the shared HTTP(S) incoming-payment URI pattern, and method must be the string ilp. Supply a typed debit_amount, a typed receive_amount, or neither for a quote whose amount can be inferred from the receiver. Both amounts are forbidden, matching the pinned oneOf branches and Node's CreateQuoteArgs union.

Map input uses protocol JSON names with no additional fields. Omitted amounts become nil and are omitted on export; explicit nulls are invalid. Typed nil amounts mean omission. Neither variant is defaulted and no amount is generated. Permitted nested amount extensions and URI/decimal spelling are preserved.

The server must check that an amountless receiver has an incoming amount and enforce wallet/receiver asset compatibility and other operation permissions. This codec does not fetch those resources, resolve payment pointers, impose network request-target policies on URI data, require positive amounts, compare assets or calculate exchange rates/fees. Quote responses require both amounts and use the separate Quote type.

Inspection exposes only method. Explicit map/JSON exports include wallet, receiver and amount data. Errors retain safe field paths without rejected values or unknown names. Validate manually constructed or modified structs with validate/1; to_map/1 converts without validating. No HTTP requests occur.

Summary

Functions

Decodes a receiver-inferred, fixed-debit or fixed-receive quote request.

Exports protocol fields and present amounts without validating or adding defaults.

Revalidates the typed request, its amount variant and any nested amount.

Types

t()

@type t() :: %OpenPayments.Types.CreateQuote{
  debit_amount: OpenPayments.Types.Amount.t() | nil,
  method: String.t(),
  receive_amount: OpenPayments.Types.Amount.t() | nil,
  receiver: String.t(),
  wallet_address: String.t()
}

Functions

from_map(data)

@spec from_map(map()) :: {:ok, t()} | {:error, OpenPayments.Error.t()}

Decodes a receiver-inferred, fixed-debit or fixed-receive quote request.

to_map(request)

@spec to_map(t()) :: map()

Exports protocol fields and present amounts without validating or adding defaults.

validate(request)

@spec validate(t()) :: :ok | {:error, OpenPayments.Error.t()}

Revalidates the typed request, its amount variant and any nested amount.