Nuntly.Client (nuntly v0.1.0)

Copy Markdown View Source

A Req-backed client for Nuntly REST API 1.x.

Explicit client

client = Nuntly.new(api_key: "ntly_...")

Pass :api_key or set NUNTLY_API_KEY. The :base_url option defaults to https://api.nuntly.com. All remaining options are forwarded to Req.new/1, including adapters, retries, timeouts, and test plugs.

Responses

Requests return {:ok, Req.Response.t()} for every HTTP response, including non-2xx statuses, or {:error, Exception.t()} for transport failures.

Summary

Functions

Creates a Req-backed API client.

Sends an HTTP request through an existing client.

Types

t()

@type t() :: %Nuntly.Client{req: Req.Request.t()}

Functions

new(opts \\ [])

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

Creates a Req-backed API client.

Arguments

  • opts — Optional client keyword list:
    • :api_key — Bearer token. Falls back to NUNTLY_API_KEY.
    • :base_url — API base URL. Defaults to https://api.nuntly.com.
    • Remaining entries are passed unchanged to Req.new/1.

Example

client = Nuntly.Client.new(
  api_key: "ntly_...",
  receive_timeout: 10_000,
  retry: :transient
)

request(client, method, path, opts \\ [])

@spec request(t(), atom(), String.t(), keyword()) ::
  {:ok, Req.Response.t()} | {:error, Exception.t()}

Sends an HTTP request through an existing client.

Generated resource functions call this function, so most applications do not need to call it directly.

Arguments

  • client — A Nuntly.Client returned by new/1.
  • method — HTTP method atom such as :get or :post.
  • path — Path relative to the configured base URL.
  • opts — Optional Req request keyword list, such as :params, :json, or :headers.

Example

Nuntly.Client.request(client, :get, "/emails", params: %{limit: 20})