Provides a type alias and functions to handle decoded Json API documents.
JsonApi.Internal.Document.Document meta data
The Document
represents the global Json API document.
This version of the Document
is retrieved via JsonApi.Decode.
functions.
It allows you to retrieve information about the decoded Document
and the decoded
Resource
(s)
Example of json api document:
{
"data": [
// resources ...
],
"meta": {
"redirect": true
},
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "http://self"
}
}
With a resource and a meta with the following type aliases:
type alias Post =
{ id : String
, name : String
}
type alias Meta =
{ redirect : Bool
}
The decoded Document
will have the following type Document Meta Post
if it contains
only one resource, or Document Meta (List Post)
if it contains several resources.
JsonApi.Internal.Document.NoMeta
NoMeta
is a type of meta
object from a Json API Document
that means
there is no meta to be decoded in this Document
.
JsonApi.Internal.Document.NoData
NoData
is a type of resource that means there is no data
object or array in
the json api document.
jsonApiVersion : Document meta data -> String
Retrieves the Json API version.
The default version is 1.0
meta : Document meta data -> meta
Retrieves the meta
object of the Document
if it exists or a NoMeta
object.
resource : Document meta data -> data
Retrieves the resource or the List
of resources in this Document
.
links : Document meta data -> Dict String String
Retrieves the root links of the document.