Safe Haskell | None |
---|---|
Language | Haskell2010 |
Module representing a JSON-API resource object.
Specification: http://jsonapi.org/format/#document-resource-objects
Synopsis
- data Resource a = Resource {}
- data Relationships
- class (ToJSON a, FromJSON a) => ResourcefulEntity a where
- resourceIdentifier :: a -> Text
- resourceType :: a -> Text
- resourceLinks :: a -> Maybe Links
- resourceMetaData :: a -> Maybe Meta
- resourceRelationships :: a -> Maybe Relationships
- fromResource :: Resource a -> a
- toResource :: a -> Resource a
- data Relationship
- indexLinks :: ResourcefulEntity e => e -> Maybe Int -> Maybe Int -> Maybe Int -> Links
- mkRelationship :: Maybe Identifier -> Maybe Links -> Maybe Relationship
- mkRelationships :: Relationship -> Relationships
- showLink :: ResourcefulEntity e => e -> Links
Documentation
Type representing a JSON-API resource object.
A Resource supplies standardized data and metadata about a resource.
Specification: http://jsonapi.org/format/#document-resource-objects
Resource | |
|
Instances
data Relationships Source #
Instances
class (ToJSON a, FromJSON a) => ResourcefulEntity a where Source #
A typeclass for decorating an entity with JSON API properties
resourceIdentifier :: a -> Text Source #
resourceType :: a -> Text Source #
resourceLinks :: a -> Maybe Links Source #
resourceMetaData :: a -> Maybe Meta Source #
resourceRelationships :: a -> Maybe Relationships Source #
fromResource :: Resource a -> a Source #
toResource :: a -> Resource a Source #
data Relationship Source #
A type representing the Relationship between 2 entities
A Relationship provides basic information for fetching further information about a related resource.
Specification: http://jsonapi.org/format/#document-resource-object-relationships
Instances
indexLinks :: ResourcefulEntity e => e -> Maybe Int -> Maybe Int -> Maybe Int -> Links Source #
Helper function to beuild relative links for a collection of resources of type ResourceEntity.
This helper function assumes that the first page is always page 0.
mkRelationship :: Maybe Identifier -> Maybe Links -> Maybe Relationship Source #
Constructor function for creating a Relationship record
A relationship must contain either an Identifier or a Links record
showLink :: ResourcefulEntity e => e -> Links Source #
Helper function to build relative links for a single resource of type ResourceEntity