json-api-0.1.1.2: Utilities for generating JSON-API payloads

Safe HaskellNone
LanguageHaskell2010

Network.JSONApi.Document

Description

Contains representations of the top-level JSON-API document structure.

Synopsis

Documentation

data Document a Source #

The Document type represents the top-level JSON-API requirement.

data attribute - the resulting JSON may be either a singleton resource or a list of resources. See Resource for the construction.

For more information see: http://jsonapi.org/format/#document-top-level

Instances

Eq a => Eq (Document a) Source # 

Methods

(==) :: Document a -> Document a -> Bool #

(/=) :: Document a -> Document a -> Bool #

Show a => Show (Document a) Source # 

Methods

showsPrec :: Int -> Document a -> ShowS #

show :: Document a -> String #

showList :: [Document a] -> ShowS #

Generic (Document a) Source # 

Associated Types

type Rep (Document a) :: * -> * #

Methods

from :: Document a -> Rep (Document a) x #

to :: Rep (Document a) x -> Document a #

ToJSON a => ToJSON (Document a) Source # 
FromJSON a => FromJSON (Document a) Source # 

Methods

parseJSON :: Value -> Parser (Document a) #

type Rep (Document a) Source # 

data ResourceData a Source #

The Resource type encapsulates the underlying Resource

Included in the top-level Document, the Resource may be either a singleton resource or a list.

For more information see: http://jsonapi.org/format/#document-top-level

Constructors

Singleton (Resource a) 
List [Resource a] 

Instances

Eq a => Eq (ResourceData a) Source # 
Show a => Show (ResourceData a) Source # 
Generic (ResourceData a) Source # 

Associated Types

type Rep (ResourceData a) :: * -> * #

Methods

from :: ResourceData a -> Rep (ResourceData a) x #

to :: Rep (ResourceData a) x -> ResourceData a #

ToJSON a => ToJSON (ResourceData a) Source # 
FromJSON a => FromJSON (ResourceData a) Source # 
type Rep (ResourceData a) Source # 
type Rep (ResourceData a) = D1 (MetaData "ResourceData" "Network.JSONApi.Document" "json-api-0.1.1.2-J3OYNh9O2lm3eKT5VaEijS" False) ((:+:) (C1 (MetaCons "Singleton" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Resource a)))) (C1 (MetaCons "List" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Resource a]))))

data ErrorDocument a Source #

The ErrorDocument type represents the alternative form of the top-level JSON-API requirement.

error attribute - a descriptive object encapsulating application-specific error detail.

For more information see: http://jsonapi.org/format/#errors

Instances

data Included Source #

The Included type is an abstraction used to constrain the included section of the Document to JSON serializable Resource objects while enabling a heterogeneous list of Resource types.

No data constructors for this type are exported as we need to constrain the Value to a heterogeneous list of Resource types. See mkIncludedResource for creating Included types.

mkDocument :: ResourcefulEntity a => [a] -> Maybe Links -> Maybe Meta -> Document a Source #

Constructor function for the Document data type.

See mkCompoundDocument for constructing compound Document including 'side-loaded' resources

mkCompoundDocument :: ResourcefulEntity a => [a] -> Maybe Links -> Maybe Meta -> Included -> Document a Source #

Constructor function for the Document data type. See mkIncludedResource for constructing the Included type.

Supports building compound documents http://jsonapi.org/format/#document-compound-documents

mkIncludedResource :: ResourcefulEntity a => a -> Included Source #

Constructor function for the Document data type.

Supports building compound documents http://jsonapi.org/format/#document-compound-documents