Noizu.Dropbox.Client (Noizu Dropbox v0.1.0)

Copy Markdown View Source

Client configuration for Dropbox API calls.

Prefer building a client once and passing it via opts:

client = Noizu.Dropbox.Client.new(access_token: System.fetch_env!("DROPBOX_ACCESS_TOKEN"))
Noizu.Dropbox.Api.Users.get_current_account(client: client)

When client is omitted, a default client is built from application config (:noizu_dropbox).

Summary

Functions

Return a client acting as a team admin (Dropbox-API-Select-Admin).

Return a client acting as a team member (Dropbox-API-Select-User).

Default client from application config.

Build a client from keyword options merged over application env defaults.

Normalize API base URL (trailing slash).

Return a client with an updated access token.

Ensure the client has an access token.

Types

t()

@type t() :: %Noizu.Dropbox.Client{
  access_token: String.t() | nil,
  api_base: String.t(),
  app_key: String.t() | nil,
  app_secret: String.t() | nil,
  authorize_url: String.t(),
  content_base: String.t(),
  finch: atom(),
  notify_base: String.t(),
  oauth_base: String.t(),
  path_root: map() | String.t() | nil,
  pool_timeout: pos_integer(),
  receive_timeout: pos_integer(),
  refresh_token: String.t() | nil,
  select_admin: String.t() | nil,
  select_user: String.t() | nil
}

Functions

as_admin(client, team_member_id)

@spec as_admin(t(), String.t()) :: t()

Return a client acting as a team admin (Dropbox-API-Select-Admin).

as_user(client, member_id)

@spec as_user(t(), String.t()) :: t()

Return a client acting as a team member (Dropbox-API-Select-User).

default()

@spec default() :: t()

Default client from application config.

new(opts \\ [])

@spec new(keyword() | map()) :: t()

Build a client from keyword options merged over application env defaults.

normalize_base(base)

@spec normalize_base(String.t()) :: String.t()

Normalize API base URL (trailing slash).

put_access_token(client, token)

@spec put_access_token(t(), String.t()) :: t()

Return a client with an updated access token.

require_token(client)

@spec require_token(t()) :: {:ok, t()} | {:error, Noizu.Dropbox.Error.t()}

Ensure the client has an access token.

Returns {:ok, client} or {:error, %Noizu.Dropbox.Error{}}.