View Source ExWagtailContentClient (ex_wagtail_content_client v0.2.0)

Documentation for ExWagtailContentClient.

Summary

Functions

Fetches the detail of a resource specified by the complete detail url.

Fetches a list of items from the specified collection. Possible collections are :pages, :images and :documents.

Functions

detail(detail_url, opts \\ [])

Fetches the detail of a resource specified by the complete detail url.

Options

- `:clean_fields` - List of fields to be sanitized, default: `["body"]`
- `:clean_block_types` - List of content block types to be sanitized, default: `["paragraph"]`
- `:req_opts` - List of options to pass to Req.get when executing the request

Sanitizing fields removes all but basic html blocks using https://github.com/rrrene/html_sanitize_ex by calling HtmlSanitizeEx.basic_html(value).

Examples

iex> ExWagtailContentClient.detail "https://iamkonstantin.eu/api/v2/pages/45/"
{:ok, %{"body" => []}}

list(resource, opts \\ [])

Fetches a list of items from the specified collection. Possible collections are :pages, :images and :documents.

Options

Examples

iex> ExWagtailContentClient.list :pages, base_url: "https://iamkonstantin.eu"
{:ok, [%{"id" => 1, ...}], %{"total_count" => 38}, %{pagination}}

iex> ExWagtailContentClient.list :pages, base_url: "https://iamkonstantin.eu", extra_params: [{"locale", "fr"}]
{:ok, [%{"id" => 1, ...}], %{"total_count" => 38}, %{pagination}}

iex> ExWagtailContentClient.list :pages, base_url: "https://doesntexist"
{:error, %Req.TransportError{reason: :nxdomain}}