Current section
Files
Jump to
Current section
Files
lib/synctera/resources/webhooks.ex
defmodule Synctera.Webhooks do
@moduledoc """
Synctera 'Webhooks' endpoints.
Code generated by scripts/generate.py from the Synctera OpenAPI spec. Do
not edit by hand — re-run `mix generate` (or `python3 scripts/generate.py`)
to regenerate.
"""
alias Synctera.{Client, Error, HTTP}
@doc """
List webhooks — List all webhooks
## Options
Query options: `:limit`, `:page_token`, `:is_enabled_only`
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec list_webhooks1(Client.t(), keyword()) :: {:ok, Synctera.JSON.json()} | {:error, Error.t()}
def list_webhooks1(client, opts \\ []) do
HTTP.request(client, :get, "/webhooks",
query: [
{"limit", Keyword.get(opts, :limit)},
{"page_token", Keyword.get(opts, :page_token)},
{"is_enabled_only", Keyword.get(opts, :is_enabled_only)}
],
body: Keyword.get(opts, :body),
idempotency_tier: :none,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `list_webhooks1/2` but returns the value directly and raises on error."
@spec list_webhooks1!(Client.t(), keyword()) :: Synctera.JSON.json()
def list_webhooks1!(client, opts) do
case list_webhooks1(client, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Create a webhook — Create a webhook
## Options
* `:body` — request body (map), required.
* `:idempotency_key` — see `Synctera.Idempotency`.
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec create_webhook1(Client.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def create_webhook1(client, opts \\ []) do
HTTP.request(client, :post, "/webhooks",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :standard,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `create_webhook1/2` but returns the value directly and raises on error."
@spec create_webhook1!(Client.t(), keyword()) :: Synctera.JSON.json()
def create_webhook1!(client, opts) do
case create_webhook1(client, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Delete a webhook — Delete a webhook
## Options
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec delete_webhook(Client.t(), String.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def delete_webhook(client, webhook_id, opts \\ []) do
HTTP.request(client, :delete, "/webhooks/#{HTTP.path_segment(webhook_id)}",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :none,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `delete_webhook/3` but returns the value directly and raises on error."
@spec delete_webhook!(Client.t(), String.t(), keyword()) :: Synctera.JSON.json()
def delete_webhook!(client, webhook_id, opts) do
case delete_webhook(client, webhook_id, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Get a webhook — Get a webhook
## Options
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec get_webhook1(Client.t(), String.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def get_webhook1(client, webhook_id, opts \\ []) do
HTTP.request(client, :get, "/webhooks/#{HTTP.path_segment(webhook_id)}",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :none,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `get_webhook1/3` but returns the value directly and raises on error."
@spec get_webhook1!(Client.t(), String.t(), keyword()) :: Synctera.JSON.json()
def get_webhook1!(client, webhook_id, opts) do
case get_webhook1(client, webhook_id, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Update a webhook — Update a webhook
## Options
* `:body` — request body (map), required.
* `:idempotency_key` — see `Synctera.Idempotency`.
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec update_webhook(Client.t(), String.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def update_webhook(client, webhook_id, opts \\ []) do
HTTP.request(client, :put, "/webhooks/#{HTTP.path_segment(webhook_id)}",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :standard,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `update_webhook/3` but returns the value directly and raises on error."
@spec update_webhook!(Client.t(), String.t(), keyword()) :: Synctera.JSON.json()
def update_webhook!(client, webhook_id, opts) do
case update_webhook(client, webhook_id, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
List webhook events — List webhook events. This response will not associate with the event
response history.
## Options
Query options: `:start_date`, `:end_date`, `:start_time`, `:end_time`, `:limit`, `:page_token`
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec list_events(Client.t(), String.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def list_events(client, webhook_id, opts \\ []) do
HTTP.request(client, :get, "/webhooks/#{HTTP.path_segment(webhook_id)}/events",
query: [
{"start_date", Keyword.get(opts, :start_date)},
{"end_date", Keyword.get(opts, :end_date)},
{"start_time", Keyword.get(opts, :start_time)},
{"end_time", Keyword.get(opts, :end_time)},
{"limit", Keyword.get(opts, :limit)},
{"page_token", Keyword.get(opts, :page_token)}
],
body: Keyword.get(opts, :body),
idempotency_tier: :none,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `list_events/3` but returns the value directly and raises on error."
@spec list_events!(Client.t(), String.t(), keyword()) :: Synctera.JSON.json()
def list_events!(client, webhook_id, opts) do
case list_events(client, webhook_id, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Get webhook event — Get webhook event by ID
## Options
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec get_event(Client.t(), String.t(), String.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def get_event(client, webhook_id, event_id, opts \\ []) do
HTTP.request(
client,
:get,
"/webhooks/#{HTTP.path_segment(webhook_id)}/events/#{HTTP.path_segment(event_id)}",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :none,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `get_event/4` but returns the value directly and raises on error."
@spec get_event!(Client.t(), String.t(), String.t(), keyword()) :: Synctera.JSON.json()
def get_event!(client, webhook_id, event_id, opts) do
case get_event(client, webhook_id, event_id, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Resend an event — Resend a webhook event
## Options
Query options: `:delay`
* `:idempotency_key` — see `Synctera.Idempotency`.
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec resend_event(Client.t(), String.t(), String.t(), keyword()) ::
{:ok, Synctera.JSON.json()} | {:error, Error.t()}
def resend_event(client, webhook_id, event_id, opts \\ []) do
HTTP.request(
client,
:post,
"/webhooks/#{HTTP.path_segment(webhook_id)}/events/#{HTTP.path_segment(event_id)}/resend",
query: [{"delay", Keyword.get(opts, :delay)}],
body: Keyword.get(opts, :body),
idempotency_tier: :standard,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `resend_event/4` but returns the value directly and raises on error."
@spec resend_event!(Client.t(), String.t(), String.t(), keyword()) :: Synctera.JSON.json()
def resend_event!(client, webhook_id, event_id, opts) do
case resend_event(client, webhook_id, event_id, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
@doc """
Trigger an event — Trigger an specific event for webhook testing purpose
## Options
* `:body` — request body (map), required.
* `:idempotency_key` — see `Synctera.Idempotency`.
* `:device_info` — a `%Synctera.DeviceInfo{}` overriding the client default.
"""
@spec trigger_event(Client.t(), keyword()) :: {:ok, Synctera.JSON.json()} | {:error, Error.t()}
def trigger_event(client, opts \\ []) do
HTTP.request(client, :post, "/webhooks/trigger",
query: [],
body: Keyword.get(opts, :body),
idempotency_tier: :standard,
idempotency_key: Keyword.get(opts, :idempotency_key),
device_info: Keyword.get(opts, :device_info)
)
end
@doc "Like `trigger_event/2` but returns the value directly and raises on error."
@spec trigger_event!(Client.t(), keyword()) :: Synctera.JSON.json()
def trigger_event!(client, opts) do
case trigger_event(client, opts) do
{:ok, value} -> value
{:error, error} -> raise error
end
end
end