ExNylas.Grants (ExNylas v0.11.0)

Copy Markdown View Source

Interface for Nylas grants.

Nylas docs

Summary

Functions

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

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

Delete a(n) grant.

Delete a(n) grant.

Find a(n) grant.

Get the first grant.

Get the first grant.

Fetch grant(s), optionally provide query params.

Fetch grant(s), optionally provide query params.

Get a grant using the current access token.

Get a grant using the current access token.

Refresh a grant's access token using its refresh token.

Refresh a grant's access token using its refresh token.

Functions

all(conn, opts \\ [])

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

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

all!(conn, opts \\ [])

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

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

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

Examples

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

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

Delete a(n) grant.

Examples

iex> result = ExNylas.Grants.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) grant.

Examples

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

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

Find a(n) grant.

Examples

iex> result = ExNylas.Grants.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 grant.

Examples

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

first!(conn, params \\ [])

Get the first grant.

Examples

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

list(conn, params \\ [])

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

Fetch grant(s), optionally provide query params.

Examples

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

list!(conn, params \\ [])

Fetch grant(s), optionally provide query params.

Examples

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

me(conn)

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

Get a grant using the current access token.

Examples

iex> {:ok, result} = ExNylas.Grants.me(conn)

me!(conn)

Get a grant using the current access token.

Examples

iex> result = ExNylas.Grants.me!(conn)

refresh(conn, refresh_token)

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

Refresh a grant's access token using its refresh token.

OAuth 2.0 access tokens expire after one hour. When the access token expires, you can use the refresh token to get a new access token.

Examples

iex> {:ok, result} = ExNylas.Grants.refresh(conn, "refresh-token")

refresh!(conn, refresh_token)

Refresh a grant's access token using its refresh token.

OAuth 2.0 access tokens expire after one hour. This function will raise an error if the refresh operation fails.

Examples

iex> result = ExNylas.Grants.refresh!(conn, "refresh-token")