# `TigerBeetlex.CDC.Event`
[🔗](https://github.com/rbino/tigerbeetlex/blob/0.16.78/lib/tigerbeetlex/cdc/event.ex#L1)

A struct representing TigerBeetle CDC event, see
[Change Data Capture](https://docs.tigerbeetle.com/operating/cdc/#message-content).

Also check out the [guide](change_data_capture.html) to consume CDC data using Broadway.

# `t`

```elixir
@type t() :: %TigerBeetlex.CDC.Event{
  credit_account: TigerBeetlex.CDC.Account.t(),
  debit_account: TigerBeetlex.CDC.Account.t(),
  ledger: non_neg_integer(),
  timestamp: non_neg_integer(),
  transfer: TigerBeetlex.CDC.Transfer.t(),
  type: TigerBeetlex.Types.event_type()
}
```

# `cast!`

```elixir
@spec cast!(%{required(binary()) =&gt; term()}) :: t() | no_return()
```

Creates a `TigerBeetlex.CDC.Event` struct from its JSON map representation.

This converts all keys to atom, parses all integers, converts all binary IDs and creates
flags structs from their integer representation.

Since the format is expected to be well defined, the function raises if it can't cast.

Note that the TigerBeetle CDC message payload is a string, you have to decode it to a map
(using, e.g. Jason) before you pass it to this function.

## Examples

    alias TigerBeetlex.CDC.Event

    message_body
    |> Jason.decode!()
    |> Event.cast!()

    #=> %TigerBeetlex.CDC.Event{type: :single_phase, transfer: %TigerBeetlex.CDC.Transfer{}, ...}

---

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