# `WalletPasses.Google.Api`
[🔗](https://gitlab.com/phinnaeus/wallet_passes/blob/main/lib/wallet_passes/google/api.ex#L1)

Google Wallet API client for wallet passes.

Uses the Google Wallet REST API to create, update, and manage
pass objects and classes across all supported types (event tickets,
boarding passes, loyalty cards, offers, and generic passes).

# `build_class_object`

Builds a Google Wallet class object map from configuration.

## Options

  * `:id` - Class ID suffix (required)
  * `:issuer_name` - Issuer name (required)
  * `:event_name` - Title/name for the class (required). Maps to type-specific field:
    `eventName` for event tickets, `programName` for loyalty, `title` for offers, etc.
  * `:pass_type` - Pass type atom (optional, defaults to `:event_ticket`)
  * `:start_date` - Start date as ISO 8601 string (optional)
  * `:end_date` - End date as ISO 8601 string (optional)
  * `:location_name` - Venue name (optional)
  * `:location_address` - Venue address (optional)
  * `:enable_smart_tap` - Enable Smart Tap / NFC for this class (optional, boolean)
  * `:redemption_issuers` - List of redemption issuer IDs authorized for Smart Tap (optional)
  * `:latitude` - Venue latitude (optional)
  * `:longitude` - Venue longitude (optional)
  * `:logo_uri` - Logo image URI (optional)

# `build_pass_object`

Builds a Google Wallet pass object map from PassData and Visual.

The object type is determined by `pass_data.pass_type`.

# `create_object`

Creates a pass object on Google's servers.

If the object already exists (409), updates it instead.
The object type is determined by `pass_data.pass_type`.
Returns `{:ok, object_id}` on success.

# `create_or_update_class`

Creates or updates a pass class on Google's servers.

Attempts to update first; falls back to insert on 404.
Pass type defaults to `:event_ticket` when not specified.

# `ensure_class`

Ensures a class exists on Google's servers, creating it if necessary.

The first call within a VM lifetime calls `create_or_update_class/2`.
Subsequent calls for the same class_id are no-ops, tracked via the
`TokenCache` ETS table with key `{:class_ensured, class_id}`.

Returns `:ok` on success, `{:error, reason}` on failure.

# `get_access_token`

Gets a cached Google OAuth2 access token, refreshing if expired.

Emits `[:wallet_passes, :google, :token_exchange, :start|:stop]` events
with metadata `%{cached: boolean()}`.

# `update_object`

Updates an existing pass object on Google's servers.

The object type is determined by `pass_data.pass_type`.
Returns `{:ok, object_id}` on success.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
