OpenPayments.Types.OutgoingPaymentGrantSpentAmounts (open_payments_elixir v1.0.0)

Copy Markdown View Source

Spent amounts for the current outgoing-payment grant or recurring interval.

Both spent_receive_amount and spent_debit_amount are required. Each is a typed Amount or nil for explicit JSON null, matching the pinned grant-spent endpoint and Node's response type. Missing map fields are invalid. Unlike optional spent fields on creation responses, nil here is always exported as null.

Permitted additional JSON fields remain in extensions. Amount decimal spelling, asset data and nested extensions are preserved. The codec does not replace null with zero, infer grant existence or budget, compare assets/values, interpret recurring intervals, track spending or make requests/payments. The server determines the grant and current interval associated with the presented token.

Inspection hides all payload data. Explicit map/JSON exports include amounts and extensions; errors retain safe field paths without rejected data or unknown names. Validate modified structs with validate/1; to_map/1 converts without validating.

Summary

Functions

Decodes both required amount-or-null fields and preserves JSON extensions.

Exports both protocol fields, including explicit nulls, without validating.

Revalidates both nullable typed amounts and reserved-field-safe JSON extensions.

Types

t()

@type t() :: %OpenPayments.Types.OutgoingPaymentGrantSpentAmounts{
  extensions: %{optional(String.t()) => term()},
  spent_debit_amount: OpenPayments.Types.Amount.t() | nil,
  spent_receive_amount: OpenPayments.Types.Amount.t() | nil
}

Functions

from_map(data)

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

Decodes both required amount-or-null fields and preserves JSON extensions.

to_map(response)

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

Exports both protocol fields, including explicit nulls, without validating.

validate(response)

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

Revalidates both nullable typed amounts and reserved-field-safe JSON extensions.