Elixir ATProtocol ingestion and sync library.
1defmodule Drinkup.Tap.Event.Identity do
2 @moduledoc """
3 Struct for identity events from Tap.
4
5 Represents handle or status changes for a DID.
6 """
7
8 use TypedStruct
9
10 typedstruct enforce: true do
11 field :id, integer()
12 field :did, String.t()
13 field :handle, String.t() | nil
14 field :is_active, boolean()
15 field :status, String.t()
16 end
17
18 @spec from(map()) :: t()
19 def from(%{
20 "id" => id,
21 "type" => "identity",
22 "identity" =>
23 %{
24 "did" => did,
25 "is_active" => is_active,
26 "status" => status
27 } = identity_data
28 }) do
29 handle = Map.get(identity_data, "handle")
30
31 %__MODULE__{
32 id: id,
33 did: did,
34 handle: handle,
35 is_active: is_active,
36 status: status
37 }
38 end
39end