Qronomnom.Hooks (Qronomnom v0.1.1)

Functions for interacting with Hooks resource.

Link to this section Summary

Functions

Creates a hook. Note that the value of :event in the hook map must be one of the strings specified by Qrono: either "bookings.created" or "bookings.updated".

Destroys a hook.

Lists hooks.

Shows a single hook.

Updates a hook. Note that the value of :event in the hook map must be one of the strings specified by Qrono: either "bookings.created" or "bookings.updated".

Link to this section Types

Specs

hook_type() :: %{target_url: String.t(), event: String.t()}

Link to this section Functions

Link to this function

create(client, hook_data)

Specs

create(Tesla.Client.t(), hook_type()) :: {:error, any()} | {:ok, hook_type()}

Creates a hook. Note that the value of :event in the hook map must be one of the strings specified by Qrono: either "bookings.created" or "bookings.updated".

Examples

iex> Qronomnom.client(%{api_key: "MY_KEY"}) |> Qronomnom.Hooks.create(%{
      target_url: "https://my_project.dev/webhooks_listener",
      event: "bookings.created"
})
{:ok, %{hook_id: 1, ...}}
Link to this function

destroy(client, hook_id)

Specs

destroy(Tesla.Client.t(), integer()) :: {:error | :ok, %{}}

Destroys a hook.

Examples

iex> Qronomnom.client(%{api_key: "MY_KEY"}) |> Qronomnom.Hooks.destroy(1)
{:ok, %{hook_id: 1, ...}}

Specs

index(Tesla.Client.t()) :: {:error, any()} | {:ok, hook_type()}

Lists hooks.

Examples

iex> Qronomnom.client(%{api_key: "MY_KEY"}) |> Qronomnom.Hooks.index()
{:ok, [%{hook_id: 1}, %{hook_id: 2}]}
Link to this function

show(client, hook_id)

Specs

show(Tesla.Client.t(), integer()) :: {:error, any()} | {:ok, hook_type()}

Shows a single hook.

Examples

iex> Qronomnom.client(%{api_key: "MY_KEY"}) |> Qronomnom.Hooks.show(1)
{:ok, %{hook_id: 1}}
Link to this function

update(client, hook_id, hook_data)

Specs

update(Tesla.Client.t(), integer(), hook_type()) ::
  {:error, any()} | {:ok, hook_type()}

Updates a hook. Note that the value of :event in the hook map must be one of the strings specified by Qrono: either "bookings.created" or "bookings.updated".

Examples

iex> Qronomnom.client(%{api_key: "MY_KEY"}) |> Qronomnom.Hooks.update(1, %{
      target_url: "https://my_project.dev/webhooks_listener_2",
      event: "bookings.created"
})
{:ok, %{hook_id: 1, ...}}