# `Accrue.Webhook.Event`
[🔗](https://github.com/szTheory/accrue/blob/accrue-v0.3.0/lib/accrue/webhook/event.ex#L1)

Lean event struct passed to webhook handlers (D2-29).

Deliberately does NOT include the raw Stripe object -- handlers
call `Accrue.Processor.retrieve_*(event.object_id)` for canonical state.
This forces WH-10 compliance (re-fetch current state) by shape.

The `type` field is kept as a `String.t()` in the struct. Conversion
to atom for pattern-matching dispatch happens at the handler call site
in Plan 04, using `String.to_existing_atom/1` with a bounded allow-list.

# `t`

```elixir
@type t() :: %Accrue.Webhook.Event{
  created_at: DateTime.t() | nil,
  livemode: boolean(),
  object_id: String.t() | nil,
  processor: atom(),
  processor_event_id: String.t(),
  type: String.t()
}
```

# `from_stripe`

```elixir
@spec from_stripe(LatticeStripe.Event.t(), atom()) :: t()
```

Projects a `%LatticeStripe.Event{}` struct into an `%Accrue.Webhook.Event{}`.

Extracts the object ID from `data["object"]["id"]` (string keys, as
returned by `LatticeStripe.Event.from_map/1`).

# `from_webhook_event`

```elixir
@spec from_webhook_event(Accrue.Webhook.WebhookEvent.t()) :: t()
```

Projects a persisted `%Accrue.Webhook.WebhookEvent{}` DB row into an
`%Accrue.Webhook.Event{}`.

Used by `Accrue.Webhook.DispatchWorker` to build the lean event struct
from the stored row (different from `from_stripe/2` which projects from
a live `LatticeStripe.Event`).

---

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