Noizu.WhatsApp.Client (Noizu.WhatsApp v0.1.0)

Copy Markdown View Source

Explicit connection configuration, passed as the first argument to every resource call (or omitted — a default client is built from the environment).

client = Noizu.WhatsApp.Client.new(token: System.fetch_env!("WHATSAPP_ACCESS_TOKEN"))
{:ok, resp} = Noizu.WhatsApp.Messages.send_text(client, "+14155551234", "hi")

Precedence

Each field follows opts -> Application.get_env(:noizu_whatsapp, :client) -> environment variable:

  • :token — WHATSAPP_ACCESS_TOKEN (bearer auth). May be nil at construction; requests needing it fail with tag: :config.
  • :phone_number_id — WHATSAPP_PHONE_NUMBER_ID (messages/media root).
  • :waba_id — WHATSAPP_BUSINESS_ACCOUNT_ID (template listing).

Summary

Functions

Default Graph API root (https://graph.facebook.com).

Default Graph API version (v21.0).

Builds a client struct. See the module doc for option details.

Types

t()

@type t() :: %Noizu.WhatsApp.Client{
  base_url: String.t(),
  graph_version: String.t(),
  phone_number_id: String.t() | nil,
  req_options: keyword(),
  retry: keyword(),
  token: String.t() | nil,
  waba_id: String.t() | nil
}

Functions

default_base_url()

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

Default Graph API root (https://graph.facebook.com).

default_graph_version()

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

Default Graph API version (v21.0).

new(opts \\ [])

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

Builds a client struct. See the module doc for option details.