OpenPayments.Types.OutgoingLimits (open_payments_elixir v1.0.0)

Copy Markdown View Source

Limits under which a grant can authorize outgoing payments.

Supports no amount, a typed debit_amount, or a typed receive_amount. Debit and receive amounts are mutually exclusive, matching Node's grant-request validation in addition to the permissive schema branches. Optional receiver follows the schema's URI format and HTTP(S) incoming-payment URL pattern. Optional interval is a string: its ISO 8601 description supplies no pattern or format validator, so this codec preserves it without parsing recurrence.

Omitted fields become nil; explicit JSON nulls are rejected. Empty limits are allowed. Additional JSON fields are retained in extensions. URI/interval spelling and amount strings are preserved. No network requests, budget tracking or interval calculations occur. Inspection omits amounts and extension metadata.

Struct literals can bypass validation. Call validate/1 after constructing or modifying a struct; to_map/1 converts its shape without validating it.

Summary

Functions

Decodes limits with at most one amount, keeping permitted JSON extensions.

Converts to protocol fields, omitting nil values, without validating.

Validates a struct, treating nil fields as omitted.

Types

t()

@type t() :: %OpenPayments.Types.OutgoingLimits{
  debit_amount: OpenPayments.Types.Amount.t() | nil,
  extensions: %{optional(String.t()) => term()},
  interval: String.t() | nil,
  receive_amount: OpenPayments.Types.Amount.t() | nil,
  receiver: String.t() | nil
}

Functions

from_map(data)

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

Decodes limits with at most one amount, keeping permitted JSON extensions.

to_map(limits)

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

Converts to protocol fields, omitting nil values, without validating.

validate(limits)

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

Validates a struct, treating nil fields as omitted.