Layr8.REST (layr8 v0.2.6)

Copy Markdown View Source

Internal HTTP client for the Layr8 cloud-node REST API.

Uses Req for HTTP requests. Authentication is via x-api-key header.

Not intended for direct use; accessed through Layr8.Credentials and Layr8.Presentations.

Summary

Functions

Issues a GET request to path and returns the decoded response.

Creates a new REST client.

Issues a JSON POST request to path with body and returns the decoded response.

Types

t()

@type t() :: %Layr8.REST{api_key: String.t(), base_url: String.t()}

Functions

get(client, path)

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

Issues a GET request to path and returns the decoded response.

Returns {:ok, map()} on success or {:error, term()} on failure.

new(base_url, api_key)

@spec new(String.t(), String.t()) :: t()

Creates a new REST client.

Parameters

  • base_url — HTTP base URL of the cloud-node (e.g. "https://node.example.com")
  • api_key — API key for authentication

post(client, path, body)

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

Issues a JSON POST request to path with body and returns the decoded response.

Returns {:ok, map()} on success or {:error, term()} on failure.