Tink.Users (Tink v0.1.1)

Copy Markdown View Source

Users API with cache invalidation on mutations.

User operations that modify state automatically invalidate the cache.

Summary

Functions

Creates an authorization grant for a user.

Creates a new Tink user.

Deletes a credential and invalidates user cache.

Deletes a Tink user and invalidates all their cached data.

Gets a specific credential with short-term caching.

Gets a user access token from an authorization code.

Lists credentials for a user with short-term caching (30 seconds).

Refreshes a credential and invalidates user cache.

Functions

create_authorization(client, params)

@spec create_authorization(Tink.Client.t(), map()) ::
  {:ok, map()} | {:error, Tink.Error.t()}

Creates an authorization grant for a user.

No caching — this is an authorization operation.

create_user(client, params)

@spec create_user(Tink.Client.t(), map()) :: {:ok, map()} | {:error, Tink.Error.t()}

Creates a new Tink user.

This is a mutation operation - no caching, but doesn't invalidate either since the user is new.

delete_credential(client, credential_id)

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

Deletes a credential and invalidates user cache.

Returns {:ok, map()} on success (the response body) or {:error, error} on failure. Cache invalidation is handled automatically by Client.delete/3.

delete_user(client, user_id)

@spec delete_user(Tink.Client.t(), String.t()) :: :ok | {:error, Tink.Error.t()}

Deletes a Tink user and invalidates all their cached data.

get_credential(client, credential_id)

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

Gets a specific credential with short-term caching.

get_user_access_token(client, code)

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

Gets a user access token from an authorization code.

No caching — this is an authentication operation.

list_credentials(client)

@spec list_credentials(Tink.Client.t()) :: {:ok, map()} | {:error, Tink.Error.t()}

Lists credentials for a user with short-term caching (30 seconds).

Credential status changes frequently during authentication, so cache is short.

refresh_credential(client, credential_id)

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

Refreshes a credential and invalidates user cache.

Triggers a data refresh from the bank. Cache is invalidated automatically by Client.post/4 on success; no extra invalidation is needed here.