View Source ExNylas.Webhooks (ExNylas v0.9.0)

Interface for Nylas webhook.

Nylas docs

Summary

Functions

Fetch all webhook(s) matching the provided query (the SDK will handle paging).

Fetch all webhook(s) matching the provided query (the SDK will handle paging).

Create and validate a webhook, use create/update to send to Nylas.

Create and validate a webhook, use create/update to send to Nylas.

Create a(n) webhook.

Create a(n) webhook.

Delete a(n) webhook.

Delete a(n) webhook.

Find a(n) webhook.

Find a(n) webhook.

Get the first webhook.

Get the first webhook.

Fetch webhook(s), optionally provide query params.

Fetch webhook(s), optionally provide query params.

Get a mock webhook payload.

Get a mock webhook payload.

Rotate a webhook secret.

Rotate a webhook secret.

Send a test webhook event.

Functions

@spec all(ExNylas.Connection.t(), Keyword.t() | map()) ::
  {:ok, [struct()]} | {:error, ExNylas.Response.t()}

Fetch all webhook(s) matching the provided query (the SDK will handle paging).

The second argument can be a keyword list of options + query parameters to pass to the Nylas API (map is also supported). Options supports:

  • :send_to - a single arity function to send each page of results (default is nil, e.g. results will be accumulated and returned as a list)
  • :delay - the number of milliseconds to wait between each page request (default is 0; strongly recommended to avoid rate limiting)
  • :query - a keyword list or map of query parameters to pass to the Nylas API (default is an empty list)

Examples

iex> opts = [send_to: &IO.inspect/1, delay: 3_000, query: [key: "value"]]
iex> {:ok, result} = ExNylas.Webhooks.all(conn, opts)
@spec all!(ExNylas.Connection.t(), Keyword.t() | map()) :: [struct()]

Fetch all webhook(s) matching the provided query (the SDK will handle paging).

The second argument can be a keyword list of options + query parameters to pass to the Nylas API (map is also supported). Options supports:

  • :send_to - a single arity function to send each page of results (default is nil, e.g. results will be accumulated and returned as a list)
  • :delay - the number of milliseconds to wait between each page request (default is 0; strongly recommended to avoid rate limiting)
  • :query - a keyword list or map of query parameters to pass to the Nylas API (default is an empty list)

Examples

iex> opts = [send_to: &IO.inspect/1, delay: 3_000, query: [key: "value"]]
iex> result = ExNylas.Webhooks.all!(conn, opts)
@spec build(map() | struct()) :: {:ok, struct()} | {:error, Ecto.Changeset.t()}

Create and validate a webhook, use create/update to send to Nylas.

Examples

iex> {:ok, result} = ExNylas.Webhooks.build(payload)
@spec build!(map() | struct()) :: struct()

Create and validate a webhook, use create/update to send to Nylas.

Examples

iex> result = ExNylas.Webhooks.build!(payload)
Link to this function

create(conn, body, params \\ [])

View Source
@spec create(ExNylas.Connection.t(), map(), Keyword.t() | map()) ::
  {:ok, ExNylas.Response.t()} | {:error, ExNylas.Response.t()}

Create a(n) webhook.

Examples

iex> {:ok, result} = ExNylas.Webhooks.create(conn, body, params)
Link to this function

create!(conn, body, params \\ [])

View Source
@spec create!(ExNylas.Connection.t(), map(), Keyword.t() | map()) ::
  ExNylas.Response.t()

Create a(n) webhook.

Examples

iex> result = ExNylas.Webhooks.create(conn, body, params)
Link to this function

delete(conn, id, params \\ [])

View Source
@spec delete(ExNylas.Connection.t(), String.t(), Keyword.t() | map()) ::
  {:ok, ExNylas.Response.t()} | {:error, ExNylas.Response.t()}

Delete a(n) webhook.

Examples

iex> {:ok, result} = ExNylas.Webhooks.delete(conn, id, params)
Link to this function

delete!(conn, id, params \\ [])

View Source

Delete a(n) webhook.

Examples

iex> result = ExNylas.Webhooks.delete!(conn, id, params)
Link to this function

find(conn, id, params \\ [])

View Source
@spec find(ExNylas.Connection.t(), String.t(), Keyword.t() | map()) ::
  {:ok, ExNylas.Response.t()} | {:error, ExNylas.Response.t()}

Find a(n) webhook.

Examples

iex> {:ok, result} = ExNylas.Webhooks.find(conn, id, params)
Link to this function

find!(conn, id, params \\ [])

View Source

Find a(n) webhook.

Examples

iex> result = ExNylas.Webhooks.find!(conn, id, params)
Link to this function

first(conn, params \\ [])

View Source
@spec first(ExNylas.Connection.t(), Keyword.t() | map()) ::
  {:ok, ExNylas.Response.t()} | {:error, ExNylas.Response.t()}

Get the first webhook.

Examples

iex> {:ok, result} = ExNylas.Webhooks.first(conn, params)
Link to this function

first!(conn, params \\ [])

View Source

Get the first webhook.

Examples

iex> result = ExNylas.Webhooks.first!(conn, params)
Link to this function

list(conn, params \\ [])

View Source
@spec list(ExNylas.Connection.t(), Keyword.t() | map()) ::
  {:ok, ExNylas.Response.t()} | {:error, ExNylas.Response.t()}

Fetch webhook(s), optionally provide query params.

Examples

iex> {:ok, result} = ExNylas.Webhooks.list(conn, params)
Link to this function

list!(conn, params \\ [])

View Source

Fetch webhook(s), optionally provide query params.

Examples

iex> result = ExNylas.Webhooks.list!(conn, params)
Link to this function

mock_payload(conn, trigger)

View Source
@spec mock_payload(ExNylas.Connection.t(), String.t()) ::
  {:ok, ExNylas.Response.t()} | {:error, ExNylas.Response.t()}

Get a mock webhook payload.

Examples

iex> {:ok, payload} = ExNylas.Webhooks.mock_payload(conn, trigger)
Link to this function

mock_payload!(conn, trigger)

View Source
@spec mock_payload!(ExNylas.Connection.t(), String.t()) :: ExNylas.Response.t()

Get a mock webhook payload.

Examples

iex> payload = ExNylas.Webhooks.mock_payload(conn, trigger)
Link to this function

rotate_secret(conn, webhook_id)

View Source
@spec rotate_secret(ExNylas.Connection.t(), String.t()) ::
  {:ok, ExNylas.Response.t()} | {:error, ExNylas.Response.t()}

Rotate a webhook secret.

Examples

iex> {:ok, webhook} = ExNylas.Webhooks.rotate_secret(conn, webhook_id)
Link to this function

rotate_secret!(conn, webhook_id)

View Source
@spec rotate_secret!(ExNylas.Connection.t(), String.t()) :: ExNylas.Response.t()

Rotate a webhook secret.

Examples

iex> webhook = ExNylas.Webhooks.rotate_secret(conn, webhook_id)
Link to this function

send_test_event(conn, trigger, webhook_url)

View Source
@spec send_test_event(ExNylas.Connection.t(), String.t(), String.t()) ::
  {:ok, ExNylas.Response.t()} | {:error, ExNylas.Response.t()}

Send a test webhook event.

Examples

iex> {:ok, res} = ExNylas.Webhooks.send_test_event(conn, trigger, webhook_url)
Link to this function

send_test_event!(conn, trigger, webhook_url)

View Source
@spec send_test_event!(ExNylas.Connection.t(), String.t(), String.t()) ::
  ExNylas.Response.t()

Send a test webhook event.

Examples

iex> res = ExNylas.Webhooks.send_test_event(conn, trigger, webhook_url)
Link to this function

update(conn, id, changeset, params \\ [])

View Source
@spec update(ExNylas.Connection.t(), String.t(), map(), Keyword.t() | map()) ::
  {:ok, ExNylas.Response.t()} | {:error, ExNylas.Response.t()}

Update a webhook.

Examples

iex> {:ok, result} = ExNylas.Webhooks.update(conn, id, body, params)
Link to this function

update!(conn, id, changeset, params \\ [])

View Source
@spec update!(ExNylas.Connection.t(), String.t(), map(), Keyword.t() | map()) ::
  ExNylas.Response.t()

Update a webhook.

Examples

iex> result = ExNylas.Webhooks.update!(conn, id, body, params)