OpenApiTypesense.Client behaviour (OpenApiTypesense v1.0.4)
View SourceHttp client for Typesense server.
Summary
Callbacks
A callback function for custom HTTP client
Types
@type response() :: {:ok, any()} | {:error, OpenApiTypesense.ApiResponse.t()} | {:error, String.t()} | {:error, list()} | :error
Callbacks
Functions
@spec api_key() :: String.t() | nil
Returns the Typesense's API key
Warning
Even if api_key is hidden in Connection struct, this
function will still return the key and accessible inside
shell (assuming bad actors [pun unintended :/] can get in as well).
Command for making http requests.
On using this function
Functions e.g. OpenApiTypesense.Health.health don't need to explicitly pass
a connection unless you want to use custom connection. See
README for more details or OpenApiTypesense.Connection module.
Options
:body: Payload for passing as request body (defaults tonil).:url: Request path.:method: Request method (e.g.:get,:post,:put,:patch,:delete). Defaults to:get.:query: Request query params (defaults to%{}).
Examples
iex> connection = %OpenApiTypesense.Connection{
...> host: "localhost",
...> api_key: "some_api_key",
...> port: "8108",
...> scheme: "http"
...> }
iex> opts = %{
...> url: "/health",
...> method: :get
...> }
iex> Client.request(connection, opts)
{:ok, %OpenApiTypesense.HealthStatus{ok: true}}