OpenPayments.Types.GrantResponse (open_payments_elixir v1.0.0)

Copy Markdown View Source

A response to an initial grant request, with typed nested protocol data.

Required continue contains a Continuation. Exactly one of interact (InteractionResponse) or access_token (AccessToken) must be present, representing pending interaction or immediate approval. These are initial response rules; subject-only and wait-only continuation results are different response contracts.

Optional subject is decoded as Subject, following the Node SDK's grant model and the initial schema's permission for extra fields. Subject alone does not replace the required initial-response branch. All recognized fields are validated when present, including explicit-null rejection; remaining JSON data is retained in extensions.

Inspection omits payload values. Explicit map/JSON exports include tokens, callback values, subject identifiers and card results. This codec makes no requests, verifies no callbacks and does not establish permission to use a resource. Predicates report typed branch shape; use validate/1 to revalidate modified structs. to_map/1 converts shape without validating it.

Summary

Functions

Reports immediate access-token approval shape without revalidating nested values.

Decodes an initial grant response and validates its typed fields and branch.

Reports pending-interaction branch shape without revalidating nested values.

Converts to protocol fields, including sensitive values, without validating.

Revalidates every typed child, the initial-response branch and extensions.

Types

t()

@type t() :: %OpenPayments.Types.GrantResponse{
  access_token: OpenPayments.Types.AccessToken.t() | nil,
  continue: OpenPayments.Types.Continuation.t(),
  extensions: %{optional(String.t()) => term()},
  interact: OpenPayments.Types.InteractionResponse.t() | nil,
  subject: OpenPayments.Types.Subject.t() | nil
}

Functions

approved?(grant_response)

@spec approved?(t()) :: boolean()

Reports immediate access-token approval shape without revalidating nested values.

from_map(data)

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

Decodes an initial grant response and validates its typed fields and branch.

pending?(grant_response)

@spec pending?(t()) :: boolean()

Reports pending-interaction branch shape without revalidating nested values.

to_map(response)

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

Converts to protocol fields, including sensitive values, without validating.

validate(response)

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

Revalidates every typed child, the initial-response branch and extensions.