View Source ExPipedrive.Client (ex_pipedrive v0.1.0)
Builds authenticated Tesla clients for the Pipedrive API.
Centralizes base URL / api_domain handling. Pass either a full URL
(https://company.pipedrive.com) or a host (company.pipedrive.com);
versioned paths (/api/v2, /api/v1) are owned by ExPipedrive.Request.
API token auth
By default, API tokens are sent via the x-api-token header (compatible with
Pipedrive API v1 and v2). Legacy query-param auth (?api_token=...) is
available only via auth: :query for transitional v1 callers and should not
be used for new code.
OAuth
Prefer from_token/2 with an ExPipedrive.Oauth.Token bundle. Use
ExPipedrive.Oauth.ensure_fresh/4 (and a TokenStore) before building a
client when tokens may be near expiry. from_oauth/4 remains a one-shot
refresh helper for scripts.
Retries, telemetry, and middleware
By default clients include:
ExPipedrive.Middleware.Telemetry—[:ex_pipedrive, :request, …]events (no logging; attach your own handlers)ExPipedrive.Middleware.Retry— 429 / 502–504 / transport retries withRetry-Afterawareness
Options on new/3 and from_token/2:
:retry—true(default),false, or keyword opts for the retry middleware:telemetry—true(default),false, or keyword opts (:metadata, …):middleware— extra Tesla middleware list (innermost, closest to adapter):adapter— optional Tesla adapter (tests)
Summary
Functions
Normalizes an api_domain or base URL to an absolute URL without a trailing slash.
Builds a Tesla client by refreshing an OAuth access token once.
Builds a Tesla client from an OAuth Token (Bearer + api_domain).
Ensures the token is fresh (refreshing if needed), optionally persists it, and builds a Tesla client.
Builds a Tesla client authenticated with a Pipedrive API token.
Types
@type auth_mode() :: :header | :query
Functions
Normalizes an api_domain or base URL to an absolute URL without a trailing slash.
from_oauth(refresh_token, client_id, client_secret, api_domain, opts \\ [])
View Source@spec from_oauth(String.t(), String.t(), String.t(), String.t(), keyword()) :: {:ok, Tesla.Client.t()} | {:error, term()}
Builds a Tesla client by refreshing an OAuth access token once.
Returns {:ok, client} or {:error, reason} from the token refresh.
Prefer from_token/2 / from_token_store/4 when you already hold a Token.
@spec from_token( ExPipedrive.Oauth.Token.t(), keyword() ) :: Tesla.Client.t()
Builds a Tesla client from an OAuth Token (Bearer + api_domain).
Does not refresh. Call Oauth.ensure_fresh/4 first when needed.
Accepts the same :retry, :telemetry, :middleware, and :adapter
options as new/3.
@spec from_token_store(ExPipedrive.Oauth.Token.t(), String.t(), String.t(), keyword()) :: {:ok, Tesla.Client.t(), ExPipedrive.Oauth.Token.t()} | {:error, term()}
Ensures the token is fresh (refreshing if needed), optionally persists it, and builds a Tesla client.
Options:
:store/:store_id— when both set, saves the (possibly refreshed) token:skew_seconds,:adapter, and otherOauth.ensure_fresh/4options- plus
from_token/2middleware options (:retry,:telemetry,:middleware)
@spec new(String.t(), String.t(), keyword()) :: Tesla.Client.t()
Builds a Tesla client authenticated with a Pipedrive API token.
Options
:auth—:header(default) sendsx-api-token;:queryis isolated legacy v1 query-param auth (api_token) for transitional use only.:retry—true(default),false, or keyword options forExPipedrive.Middleware.Retry:telemetry—true(default),false, or keyword options forExPipedrive.Middleware.Telemetry:middleware— additional Tesla middleware (after core stack):adapter— optional Tesla adapter (used in tests).