View Source ExNylas.Drafts (ExNylas v0.9.0)

Interface for Nylas Drafts.

Nylas docs

Summary

Functions

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

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

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

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

Create a draft. 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.

Create a draft. 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.

Delete a(n) draft.

Delete a(n) draft.

Find a(n) draft.

Get the first draft.

Get the first draft.

Fetch draft(s), optionally provide query params.

Fetch draft(s), optionally provide query params.

Send a draft.

Send a draft.

Update a draft.

Update a draft. 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.

Update a draft. 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.

Functions

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

Fetch all draft(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.Drafts.all(conn, opts)
@spec all!(ExNylas.Connection.t(), Keyword.t() | map()) :: [struct()]

Fetch all draft(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.Drafts.all!(conn, opts)
@spec build(map() | struct()) :: {:ok, struct()} | {:error, Ecto.Changeset.t()}

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

Examples

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

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

Examples

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

create(conn, draft, attachments \\ [])

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

Create a draft. 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, draft} = ExNylas.Drafts.create(conn, draft, ["path_to_attachment"])
Link to this function

create!(conn, draft, attachments \\ [])

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

Create a draft. 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> draft = ExNylas.Drafts.create!(conn, draft, ["path_to_attachment"])
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) draft.

Examples

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

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

View Source

Delete a(n) draft.

Examples

iex> result = ExNylas.Drafts.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) draft.

Examples

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

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

View Source

Find a(n) draft.

Examples

iex> result = ExNylas.Drafts.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 draft.

Examples

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

first!(conn, params \\ [])

View Source

Get the first draft.

Examples

iex> result = ExNylas.Drafts.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 draft(s), optionally provide query params.

Examples

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

list!(conn, params \\ [])

View Source

Fetch draft(s), optionally provide query params.

Examples

iex> result = ExNylas.Drafts.list!(conn, params)
@spec send(ExNylas.Connection.t(), String.t()) ::
  {:ok, ExNylas.Response.t()} | {:error, ExNylas.Response.t()}

Send a draft.

Examples

iex> {:ok, sent_draft} = ExNylas.Drafts.send(conn, draft_id)

Send a draft.

Examples

iex> sent_draft = ExNylas.Drafts.send!(conn, draft_id)
Link to this function

update(conn, id, changeset)

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

Update a draft.

To add attachments greater than 3MB, use update/4 or update!/4.

Examples

iex> {:ok, draft} = ExNylas.Drafts.update(conn, id, changeset)
Link to this function

update(conn, id, changeset, attachments)

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

Update a draft. 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.

To remove all attachments from a draft, use update/3 or update!/3.

Examples

iex> {:ok, draft} = ExNylas.Drafts.update(conn, id, changeset, ["path_to_attachment"])
Link to this function

update!(conn, id, changeset)

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

Update a draft.

To add attachments greater than 3MB, use update/4 or update!/4.

Examples

iex> draft = ExNylas.Drafts.update!(conn, id, changeset)
Link to this function

update!(conn, id, changeset, attachments)

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

Update a draft. 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.

To remove all attachments from a draft, use update/3 or update!/3.

Examples

iex> draft = ExNylas.Drafts.update!(conn, id, changeset, ["path_to_attachment"])