AshHooks.Provider.Event (AshHooks v3.3.0)

Copy Markdown View Source

A verified webhook returned by a configured provider's default handler.

Its type is the fixed atom :webhook; the sender's event names remain in the payload, never converted into atoms. Override parse_event_type/1 and handle_event/2 in your provider to classify events and perform idempotent business actions.

Summary

Functions

Wraps a verified, decoded payload and the host's classified event type in an event. Returns {:ok, event} without performing verification or business effects. The caller owns type and payload validation. A provider can delegate handle_event/2 here when it only needs to return the event.

Classifies a decoded map or list as :webhook without creating atoms from sender-controlled names. Other values return {:error, :malformed_payload}. Use this as a provider's parse_event_type/1 callback when the host does not need domain-specific classification.

Types

t()

@type t() :: %AshHooks.Provider.Event{payload: map() | list(), type: atom()}

Functions

build(type, payload)

@spec build(atom(), map() | list()) :: {:ok, t()}

Wraps a verified, decoded payload and the host's classified event type in an event. Returns {:ok, event} without performing verification or business effects. The caller owns type and payload validation. A provider can delegate handle_event/2 here when it only needs to return the event.

parse(payload)

@spec parse(term()) :: {:ok, :webhook} | {:error, :malformed_payload}

Classifies a decoded map or list as :webhook without creating atoms from sender-controlled names. Other values return {:error, :malformed_payload}. Use this as a provider's parse_event_type/1 callback when the host does not need domain-specific classification.