LemonGateway.Transports.Webhook.Request (lemon_gateway v0.1.0)

View Source

Request parsing, authentication, and metadata helpers for the webhook transport.

Summary

Functions

authorize_request(conn, payload, integration, webhook_config)

@spec authorize_request(Plug.Conn.t(), map(), map(), map()) ::
  :ok | {:error, :unauthorized}

fetch(map, key)

@spec fetch(term(), atom() | binary()) :: term()

int_value(value, default)

@spec int_value(term(), term()) :: integer() | term()

normalize_blank(value)

@spec normalize_blank(term()) :: term()

normalize_payload(payload)

@spec normalize_payload(map()) ::
  {:ok,
   %{
     prompt: binary(),
     prompt_text: binary() | nil,
     attachments: list(),
     metadata: map()
   }}
  | {:error, :unprocessable_entity}

request_metadata(conn)

@spec request_metadata(Plug.Conn.t()) :: map()

resolve_callback_url(payload, integration, webhook_config)

@spec resolve_callback_url(map(), map(), map()) :: binary() | nil

resolve_callback_wait_timeout_ms(integration, webhook_config, default_timeout_ms)

@spec resolve_callback_wait_timeout_ms(map(), map(), pos_integer()) :: pos_integer()

secure_compare(expected, provided)

@spec secure_compare(binary() | nil, binary() | nil) :: boolean()

validate_callback_url(callback_url, allow_private_hosts, opts \\ [])

@spec validate_callback_url(binary() | nil, boolean(), keyword()) ::
  {:ok, binary() | nil} | {:error, :invalid_callback_url}