Noizu.Slack.Client (Noizu.Slack v0.1.0)

Copy Markdown View Source

Explicit connection configuration, passed as the first argument to every Web API call.

client = Noizu.Slack.Client.new()
{:ok, %{"user_id" => _}} = Noizu.Slack.Auth.test(client)

Precedence

  • :token — opts[:token] → Application.get_env(:noizu_slack, :client)[:token] → System.get_env("SLACK_BOT_TOKEN").
  • every other field — opts → application env → default.

Options

  • :token — bot (xoxb-) or user (xoxp-) token. May be nil at construction; required at request time ({:error, %Error{tag: :config}} otherwise).
  • :base_url — Web API root. Default "https://slack.com/api".
  • :user_agent — User-Agent header. Default "noizu_slack/0.1.0 (+https://github.com/noizu-labs-sdks/elixir-slack)".
  • :req_options — keyword merged into every Req.request/1 (e.g. plug: {Req.Test, MyStub}, receive_timeout:). The library's own method, url, auth header and retry: false stay authoritative.
  • :retry — keyword: :max_attempts (default 3, total attempts), :base_backoff_ms (default 500, used when no Retry-After is sent), :max_retry_after_ms (default 30_000, clamp on server-supplied delays), :sleep_fn (default &Process.sleep/1, test hook).

The Inspect implementation redacts the token.

Summary

Functions

The default User-Agent header value.

Builds a client. See the module doc for option precedence.

Types

t()

@type t() :: %Noizu.Slack.Client{
  base_url: String.t(),
  req_options: keyword(),
  retry: keyword(),
  token: String.t() | nil,
  user_agent: String.t()
}

Functions

default_user_agent()

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

The default User-Agent header value.

new(opts \\ [])

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

Builds a client. See the module doc for option precedence.