Safe Haskell | None |
---|---|
Language | Haskell2010 |
Module representing a JSON-API resource object.
Specification: http://jsonapi.org/format/#document-resource-objects
Synopsis
- newtype PageNum = PageNum {
- getPageNum :: Int
- newtype PageSize = PageSize {
- getPageSize :: Int
- data Resource a = Resource {}
- newtype ResourceCount = ResourceCount {}
- 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 Text -> PageSize -> PageNum -> ResourceCount -> Links
- mkRelationship :: Maybe Identifier -> Maybe Links -> Maybe Relationship
- mkRelationships :: Relationship -> Relationships
- showLink :: ResourcefulEntity e => e -> Links
Documentation
PageNum | |
|
We can specify limits on the number of rows we would like back from the database
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
newtype ResourceCount Source #
Instances
Show ResourceCount Source # | |
Defined in Network.JSONApi.Resource showsPrec :: Int -> ResourceCount -> ShowS # show :: ResourceCount -> String # showList :: [ResourceCount] -> ShowS # |
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 Text -> PageSize -> PageNum -> ResourceCount -> 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