ExNylas.Drafts (ExNylas v0.11.0)

Copy Markdown View Source

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

all(conn, opts \\ [])

@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)

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)

build(payload)

@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)

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)

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

@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"])

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

@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"])

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) draft.

Examples

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

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

Delete a(n) draft.

Examples

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

Examples

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

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

Find a(n) draft.

Examples

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

Examples

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

first!(conn, params \\ [])

Get the first draft.

Examples

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

list(conn, params \\ [])

@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)

list!(conn, params \\ [])

Fetch draft(s), optionally provide query params.

Examples

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

send(conn, draft_id)

@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!(conn, draft_id)

Send a draft.

Examples

iex> sent_draft = ExNylas.Drafts.send!(conn, draft_id)

update(conn, id, changeset)

@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)

update(conn, id, changeset, attachments)

@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"])

update!(conn, id, changeset)

@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)

update!(conn, id, changeset, attachments)

@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"])