module Network.JSONApi.Pagination (
Pagination (..)
, PageNum (..)
, PageSize (..)
, ResourceCount (..)
) where
import Data.Aeson ((.=), ToJSON, object, toJSON)
import Network.JSONApi.Meta (MetaObject (..))
data Pagination = Pagination {
getPaginationPageSize :: PageSize
, getPaginationPageNum :: PageNum
, getPaginationResourceCount :: ResourceCount
}
instance ToJSON Pagination where
toJSON (Pagination (PageSize size) (PageNum num) (ResourceCount count)) =
object [
"pageSize" .= size
, "currentPage" .= num
, "totalDocuments" .= count
]
instance MetaObject Pagination where
typeName _ = "pagination"
newtype PageSize = PageSize {
getPageSize :: Int
} deriving Show
newtype PageNum = PageNum {
getPageNum :: Int
} deriving Show
newtype ResourceCount = ResourceCount {
getResourceCount :: Int
} deriving Show