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
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" => []}}
Fetches a list of items from the specified collection. Possible collections are :pages
, :images
and :documents
.
Options
:base_url
- (required) The root url of the server:offset
- The number of items to skip during pagination, default 0 (see https://docs.wagtail.org/en/latest/advanced_topics/api/v2/usage.html#pagination):limit
- The number of items to fetch during pagination, default 20 (see https://docs.wagtail.org/en/latest/advanced_topics/api/v2/usage.html#pagination):req_opts
- List of options to pass to Req.get when executing the request:extra_params
- A list of tuples for additional parameters to be added to the query e.g.[{"locale", "fr"}]
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}}