Tink.Client (Tink v0.1.1)

Copy Markdown View Source

HTTP client for making requests to the Tink API with built-in caching.

This module handles authentication, request building, and response parsing for all Tink API endpoints. It automatically caches GET requests for improved performance.

Cache Key Design

Cache keys are built from the full URL including query parameters, so different paginated or filtered requests produce independent cache entries:

"user_abc:data:v2:accounts?pageSize=10&pageToken=ABC"  own entry
"user_abc:data:v2:accounts?pageSize=10&pageToken=XYZ"  own entry

Summary

Functions

Performs a DELETE request and invalidates user cache on success.

Performs a GET request with automatic caching.

Performs a PATCH request and invalidates user cache on success.

Performs a POST request and invalidates user cache on success.

Performs a PUT request and invalidates user cache on success.

Types

t()

@type t() :: %Tink.Client{
  access_token: String.t() | nil,
  adapter: module(),
  base_url: String.t(),
  cache: boolean(),
  client_id: String.t(),
  client_secret: String.t(),
  timeout: integer(),
  user_id: String.t() | nil
}

Functions

delete(client, url, opts \\ [])

@spec delete(t(), String.t(), keyword()) :: {:ok, map()} | {:error, Tink.Error.t()}

Performs a DELETE request and invalidates user cache on success.

get(client, url, opts \\ [])

@spec get(t(), String.t(), keyword()) :: {:ok, map()} | {:error, Tink.Error.t()}

Performs a GET request with automatic caching.

GET requests are cached based on the resource type with appropriate TTLs. Cache can be disabled per-request via opts: [cache: false].

patch(client, url, body, opts \\ [])

@spec patch(t(), String.t(), term(), keyword()) ::
  {:ok, map()} | {:error, Tink.Error.t()}

Performs a PATCH request and invalidates user cache on success.

post(client, url, body, opts \\ [])

@spec post(t(), String.t(), term(), keyword()) ::
  {:ok, map()} | {:error, Tink.Error.t()}

Performs a POST request and invalidates user cache on success.

put(client, url, body, opts \\ [])

@spec put(t(), String.t(), term(), keyword()) ::
  {:ok, map()} | {:error, Tink.Error.t()}

Performs a PUT request and invalidates user cache on success.