Atex.XRPC.Client behaviour (atex v0.6.0)

View Source

Behaviour that defines the interface for XRPC clients.

This behaviour allows different types of clients (login-based, OAuth-based, etc.) to implement authentication and request handling while maintaining a consistent interface.

Implementations must handle token refresh internally when requests fail due to expired tokens, and return both the result and potentially updated client state.

Summary

Callbacks

Perform an authenticated HTTP GET request on an XRPC resource.

Perform an authenticated HTTP POST request on an XRPC resource.

Types

client()

@type client() :: struct()

request_opts()

@type request_opts() :: keyword()

request_result()

@type request_result() ::
  {:ok, Req.Response.t(), client()} | {:error, any(), client()}

Callbacks

get(client, t, request_opts)

@callback get(client(), String.t(), request_opts()) :: request_result()

Perform an authenticated HTTP GET request on an XRPC resource.

Implementations should handle token refresh if the request fails due to expired authentication, returning both the response and the (potentially updated) client.

post(client, t, request_opts)

@callback post(client(), String.t(), request_opts()) :: request_result()

Perform an authenticated HTTP POST request on an XRPC resource.

Implementations should handle token refresh if the request fails due to expired authentication, returning both the response and the (potentially updated) client.