Atex.DID.Document.Service
(atex v0.9.1)
View Source
Struct and schema for a service entry in a DID document.
Each service entry describes a network endpoint associated with the DID subject.
In atproto, the most relevant service is the PDS (Personal Data Server), identified
by the #atproto_pds fragment and type "AtprotoPersonalDataServer".
Fields
:id- URI identifying the service, typically a DID fragment (e.g."#atproto_pds"or the fully-qualified form"did:plc:abc123#atproto_pds").:type- Service type string or list of type strings.:service_endpoint- The endpoint URI, a map of URIs, or a list of either.
Summary
Functions
Validates and builds a Service struct from a map (snake_case or camelCase keys).
Converts a Service struct to a camelCase map suitable for JSON serialisation.
Types
Functions
@spec new(map()) :: {:ok, t()} | {:error, Peri.Error.t()}
Validates and builds a Service struct from a map (snake_case or camelCase keys).
Returns {:ok, t()} on success, or {:error, Peri.Error.t()} on validation failure.
Examples
iex> Atex.DID.Document.Service.new(%{
...> "id" => "#atproto_pds",
...> "type" => "AtprotoPersonalDataServer",
...> "serviceEndpoint" => "https://pds.example.com"
...> })
{:ok, %Atex.DID.Document.Service{
id: "#atproto_pds",
type: "AtprotoPersonalDataServer",
service_endpoint: "https://pds.example.com"
}}
Converts a Service struct to a camelCase map suitable for JSON serialisation.
Examples
iex> svc = %Atex.DID.Document.Service{
...> id: "#atproto_pds",
...> type: "AtprotoPersonalDataServer",
...> service_endpoint: "https://pds.example.com"
...> }
iex> Atex.DID.Document.Service.to_json(svc)
%{
"id" => "#atproto_pds",
"type" => "AtprotoPersonalDataServer",
"serviceEndpoint" => "https://pds.example.com"
}