AshScim.Encoder (ash_scim v0.1.0)

Copy Markdown View Source

Encodes Ash records into SCIM 2.0 JSON-shaped maps using the mappings declared in the resource's scim section.

The result is a plain map suitable for Jason.encode!/1. List-response envelopes are the responsibility of the router; this module concerns itself only with single-resource encoding.

Summary

Functions

Encode a single Ash record as a SCIM resource.

Wrap a list of encoded resources in a SCIM ListResponse envelope.

Types

opts()

@type opts() :: [{:base_url, String.t()}]

Functions

encode(record, opts \\ [])

@spec encode(Ash.Resource.Record.t(), opts()) :: %{required(String.t()) => term()}

Encode a single Ash record as a SCIM resource.

Options:

  • :base_url — used to build meta.location. If omitted, meta.location is not emitted.

list_response(resources, opts \\ [])

@spec list_response([%{required(String.t()) => term()}], keyword()) :: %{
  required(String.t()) => term()
}

Wrap a list of encoded resources in a SCIM ListResponse envelope.

total_results should reflect the unfiltered/unpaginated count when pagination is in play; for the simple case, pass length(resources).