ExNylas.Messages (ExNylas v0.11.0)

Copy Markdown View Source

Interface for Nylas messages.

Nylas docs

Summary

Functions

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

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

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

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

Clean a message.

Clean a message.

Delete a(n) message.

Delete a(n) message.

Find a(n) message.

Find a(n) message.

Get the first message.

Get the first message.

Fetch message(s), optionally provide query params.

Fetch message(s), optionally provide query params.

Send a message. Attachments must be either a list of file paths or a list of tuples with the content-id and file path. The latter of which is needed in order to attach inline images.

Send a message. Attachments must be either a list of file paths or a list of tuples with the content-id and file path. The latter of which is needed in order to attach inline images.

Send a message using raw MIME format.

Send a message using raw MIME format.

Functions

all(conn, opts \\ [])

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

Fetch all message(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.Messages.all(conn, opts)

all!(conn, opts \\ [])

@spec all!(ExNylas.Connection.t(), Keyword.t() | map()) :: [struct()]

Fetch all message(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.Messages.all!(conn, opts)

build(payload)

@spec build(map() | struct()) :: {:ok, struct()} | {:error, Ecto.Changeset.t()}

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

Examples

iex> {:ok, result} = ExNylas.Messages.build(payload)

build!(payload)

@spec build!(map() | struct()) :: struct()

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

Examples

iex> result = ExNylas.Messages.build!(payload)

clean(conn, payload)

@spec clean(ExNylas.Connection.t(), map()) ::
  {:ok, ExNylas.Response.t()} | {:error, ExNylas.Response.t()}

Clean a message.

Examples

iex> {:ok, message} = ExNylas.Messages.clean(conn, payload)

clean!(conn, payload)

@spec clean!(ExNylas.Connection.t(), map()) :: ExNylas.Response.t()

Clean a message.

Examples

iex> message = ExNylas.Messages.clean!(conn, payload)

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

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

Delete a(n) message.

Examples

iex> {:ok, result} = ExNylas.Messages.delete(conn, id, params)

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

Delete a(n) message.

Examples

iex> result = ExNylas.Messages.delete!(conn, id, params)

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

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

Find a(n) message.

Examples

iex> {:ok, result} = ExNylas.Messages.find(conn, id, params)

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

Find a(n) message.

Examples

iex> result = ExNylas.Messages.find!(conn, id, params)

first(conn, params \\ [])

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

Get the first message.

Examples

iex> {:ok, result} = ExNylas.Messages.first(conn, params)

first!(conn, params \\ [])

Get the first message.

Examples

iex> result = ExNylas.Messages.first!(conn, params)

list(conn, params \\ [])

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

Fetch message(s), optionally provide query params.

Examples

iex> {:ok, result} = ExNylas.Messages.list(conn, params)

list!(conn, params \\ [])

Fetch message(s), optionally provide query params.

Examples

iex> result = ExNylas.Messages.list!(conn, params)

send(conn, message, attachments \\ [])

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

Send a message. Attachments must be either a list of file paths or a list of tuples with the content-id and file path. The latter of which is needed in order to attach inline images.

Examples

iex> {:ok, sent_message} = ExNylas.Messages.send(conn, message, ["path_to_attachment"])

send!(conn, message, attachments \\ [])

@spec send!(ExNylas.Connection.t(), map(), list()) :: ExNylas.Response.t()

Send a message. Attachments must be either a list of file paths or a list of tuples with the content-id and file path. The latter of which is needed in order to attach inline images.

Examples

iex> sent_message = ExNylas.Messages.send!(conn, message, ["path_to_attachment"])

send_raw(conn, mime)

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

Send a message using raw MIME format.

Examples

iex> {:ok, sent_message} = ExNylas.Messages.send_raw(conn, mime)

send_raw!(conn, mime)

@spec send_raw!(ExNylas.Connection.t(), String.t()) :: ExNylas.Response.t()

Send a message using raw MIME format.

Examples

iex> sent_message = ExNylas.Messages.send_raw!(conn, mime)

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

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

Update a(n) message.

Examples

iex> {:ok, result} = ExNylas.Messages.update(conn, id, body, params)

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

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

Update a(n) message.

Examples

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