WalletPasses.PassDataProvider behaviour (wallet_passes v0.8.1)

Copy Markdown View Source

Behaviour for consumers to implement pass data lookups.

The library calls this when it needs to autonomously build pass content, e.g. when Apple requests an updated pass via the callback router.

Lifecycle status decoration

Consumers can decorate back_fields for non-active statuses by calling apply_status_decoration/2 with the result of Schema.get_pass_status/1.

Summary

Functions

Prepends a {"status", "Status", LABEL} row to back_fields for non-:active statuses. Returns the PassData unchanged when status is :active. Convenience for issuers; opt-in.

Types

pass_bundle()

@type pass_bundle() :: %{
  pass_data: WalletPasses.PassData.t(),
  apple: WalletPasses.Apple.Visual.t() | nil,
  google: WalletPasses.Google.Visual.t() | nil
}

Callbacks

build_pass_data(serial_number)

@callback build_pass_data(serial_number :: String.t()) ::
  {:ok, pass_bundle()} | {:error, term()}

Functions

apply_status_decoration(pd, status)

@spec apply_status_decoration(
  WalletPasses.PassData.t(),
  :active | :voided | :expired | :completed
) ::
  WalletPasses.PassData.t()

Prepends a {"status", "Status", LABEL} row to back_fields for non-:active statuses. Returns the PassData unchanged when status is :active. Convenience for issuers; opt-in.