WalletPasses.PassData (wallet_passes v0.12.0)

Copy Markdown View Source

Platform-agnostic representation of wallet pass content.

Contains shared data consumed by both Apple and Google pass builders. Platform-specific visual configuration lives in WalletPasses.Apple.Visual and WalletPasses.Google.Visual (passed separately).

expiration_date vs end_date

These fields are independent and serve different audiences:

  • end_date (a Date.t()) is informational — it renders a human-readable range via format_date_range/1 (e.g. "July 4–6, 2026") and has no effect on pass validity.
  • expiration_date (a DateTime.t()) is behavioral — the operating system uses it to automatically dim the pass and mark it expired once the instant passes. It maps to Apple's top-level expirationDate and Google's validTimeInterval.end. Leave it nil (the default) to emit nothing.

They often coincide for an event ticket but legitimately diverge — e.g. a ticket that stays valid through a grace period after the event ends. The library never derives one from the other.

Use expiration_date for expiry known when the pass is issued; use WalletPasses.expire_pass/1 for expiry decided after issuance (refund, fraud). See the lifecycle guide for details.

Summary

Functions

Returns the barcode message, falling back to serial_number if not set.

Formats start_date..end_date as a human-readable range.

Creates a new PassData struct from keyword options.

Types

field()

@type field() :: {key :: String.t(), label :: String.t(), value :: String.t()}

t()

@type t() :: %WalletPasses.PassData{
  auxiliary_fields: [field()],
  back_fields: [field()],
  barcode_alt_text: String.t() | nil,
  barcode_format: :qr | :code_128,
  barcode_message: String.t() | nil,
  description: String.t() | nil,
  end_date: Date.t() | nil,
  event_name: String.t() | nil,
  expiration_date: DateTime.t() | nil,
  header_fields: [field()],
  holder_name: String.t() | nil,
  latitude: float() | nil,
  location_address: String.t() | nil,
  location_name: String.t() | nil,
  longitude: float() | nil,
  nfc_encryption_public_key: String.t() | nil,
  nfc_message: String.t() | nil,
  nfc_requires_authentication: boolean() | nil,
  organization_name: String.t() | nil,
  pass_type: WalletPasses.PassType.t(),
  primary_fields: [field()],
  secondary_fields: [field()],
  serial_number: String.t(),
  start_date: Date.t() | nil,
  timezone: String.t() | nil,
  transit_type: :air | :boat | :bus | :train | :generic | nil
}

Functions

barcode_value(pass_data)

Returns the barcode message, falling back to serial_number if not set.

format_date_range(pass_data)

Formats start_date..end_date as a human-readable range.

new(opts \\ [])

Creates a new PassData struct from keyword options.