json-api-lib-0.2.0.0: Utilities for generating JSON-API payloads

Safe HaskellNone
LanguageHaskell2010

Network.JSONApi.Resource

Description

Module representing a JSON-API resource object.

Specification: http://jsonapi.org/format/#document-resource-objects

Synopsis

Documentation

data Resource a Source #

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

Instances
Eq a => Eq (Resource a) Source # 
Instance details

Defined in Network.JSONApi.Resource

Methods

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

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

Show a => Show (Resource a) Source # 
Instance details

Defined in Network.JSONApi.Resource

Methods

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

show :: Resource a -> String #

showList :: [Resource a] -> ShowS #

Generic (Resource a) Source # 
Instance details

Defined in Network.JSONApi.Resource

Associated Types

type Rep (Resource a) :: Type -> Type #

Methods

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

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

ToJSON a => ToJSON (Resource a) Source # 
Instance details

Defined in Network.JSONApi.Resource

FromJSON a => FromJSON (Resource a) Source # 
Instance details

Defined in Network.JSONApi.Resource

NFData a => NFData (Resource a) Source # 
Instance details

Defined in Network.JSONApi.Resource

Methods

rnf :: Resource a -> () #

HasIdentifier (Resource a) Source # 
Instance details

Defined in Network.JSONApi.Resource

type Rep (Resource a) Source # 
Instance details

Defined in Network.JSONApi.Resource

type Rep (Resource a) = D1 (MetaData "Resource" "Network.JSONApi.Resource" "json-api-lib-0.2.0.0-CIYDoTtBA9V1pU3j2B9t69" False) (C1 (MetaCons "Resource" PrefixI True) ((S1 (MetaSel (Just "getIdentifier") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Identifier) :*: S1 (MetaSel (Just "getResource") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)) :*: (S1 (MetaSel (Just "getLinks") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Links)) :*: S1 (MetaSel (Just "getRelationships") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Relationships)))))

data Relationships Source #

Instances
Eq Relationships Source # 
Instance details

Defined in Network.JSONApi.Resource

Show Relationships Source # 
Instance details

Defined in Network.JSONApi.Resource

Generic Relationships Source # 
Instance details

Defined in Network.JSONApi.Resource

Associated Types

type Rep Relationships :: Type -> Type #

ToJSON Relationships Source # 
Instance details

Defined in Network.JSONApi.Resource

FromJSON Relationships Source # 
Instance details

Defined in Network.JSONApi.Resource

NFData Relationships Source # 
Instance details

Defined in Network.JSONApi.Resource

Methods

rnf :: Relationships -> () #

type Rep Relationships Source # 
Instance details

Defined in Network.JSONApi.Resource

type Rep Relationships = D1 (MetaData "Relationships" "Network.JSONApi.Resource" "json-api-lib-0.2.0.0-CIYDoTtBA9V1pU3j2B9t69" True) (C1 (MetaCons "Relationships" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map Text Relationship))))

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
Eq Relationship Source # 
Instance details

Defined in Network.JSONApi.Resource

Show Relationship Source # 
Instance details

Defined in Network.JSONApi.Resource

Generic Relationship Source # 
Instance details

Defined in Network.JSONApi.Resource

Associated Types

type Rep Relationship :: Type -> Type #

ToJSON Relationship Source # 
Instance details

Defined in Network.JSONApi.Resource

FromJSON Relationship Source # 
Instance details

Defined in Network.JSONApi.Resource

NFData Relationship Source # 
Instance details

Defined in Network.JSONApi.Resource

Methods

rnf :: Relationship -> () #

type Rep Relationship Source # 
Instance details

Defined in Network.JSONApi.Resource

type Rep Relationship = D1 (MetaData "Relationship" "Network.JSONApi.Resource" "json-api-lib-0.2.0.0-CIYDoTtBA9V1pU3j2B9t69" False) (C1 (MetaCons "Relationship" PrefixI True) (S1 (MetaSel (Just "_data") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Identifier)) :*: S1 (MetaSel (Just "_links") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Links))))

indexLinks :: Text -> Pagination -> 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