View Source Plausible.HelpScout (Plausible v0.0.1)

HelpScout callback API logic.

Summary

Types

@type signature_error() :: :bad_signature | :missing_signature

Functions

Link to this function

get_details_for_customer(customer_id)

View Source
@spec get_details_for_customer(String.t()) :: {:ok, map()} | {:error, any()}
Link to this function

get_details_for_emails(emails, customer_id)

View Source
@spec get_details_for_emails([String.t()], String.t()) ::
  {:ok, map()} | {:error, any()}
Link to this function

search_users(term, customer_id)

View Source
@spec search_users(String.t(), String.t()) :: [map()]
Link to this function

validate_signature(conn)

View Source
@spec validate_signature(Plug.Conn.t()) :: :ok | {:error, signature_error()}

Validates signature against secret key configured for the HelpScout application.

NOTE: HelpScout signature generation procedure at https://developer.helpscout.com/apps/guides/signature-validation/ fails to mention that it's implicitly dependent on request params order getting preserved. PHP arrays are ordered maps, so they provide this guarantee. Here, on the other hand, we have to determine the original order of the keys directly from the query string and serialize params to JSON using wrapper struct, informing Jason to put the values in the serialized object in this particular order matching query string.