{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE StandaloneDeriving #-}

module Hercules.API.Paging where

import Hercules.API.Prelude

-- To be used in newtypes only; otherwise the schema will have colliding
-- PagedResponse types.
data PagedResponse a = PagedResponse
  { -- | The items you requested, up to some limit.
    forall a. PagedResponse a -> [a]
items :: [a],
    -- | Whether more items would be returned if it wasn't for the limit.
    forall a. PagedResponse a -> Bool
more :: Bool
  }
  deriving ((forall x. PagedResponse a -> Rep (PagedResponse a) x)
-> (forall x. Rep (PagedResponse a) x -> PagedResponse a)
-> Generic (PagedResponse a)
forall x. Rep (PagedResponse a) x -> PagedResponse a
forall x. PagedResponse a -> Rep (PagedResponse a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (PagedResponse a) x -> PagedResponse a
forall a x. PagedResponse a -> Rep (PagedResponse a) x
$cto :: forall a x. Rep (PagedResponse a) x -> PagedResponse a
$cfrom :: forall a x. PagedResponse a -> Rep (PagedResponse a) x
Generic, Int -> PagedResponse a -> ShowS
[PagedResponse a] -> ShowS
PagedResponse a -> String
(Int -> PagedResponse a -> ShowS)
-> (PagedResponse a -> String)
-> ([PagedResponse a] -> ShowS)
-> Show (PagedResponse a)
forall a. Show a => Int -> PagedResponse a -> ShowS
forall a. Show a => [PagedResponse a] -> ShowS
forall a. Show a => PagedResponse a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PagedResponse a] -> ShowS
$cshowList :: forall a. Show a => [PagedResponse a] -> ShowS
show :: PagedResponse a -> String
$cshow :: forall a. Show a => PagedResponse a -> String
showsPrec :: Int -> PagedResponse a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> PagedResponse a -> ShowS
Show, PagedResponse a -> PagedResponse a -> Bool
(PagedResponse a -> PagedResponse a -> Bool)
-> (PagedResponse a -> PagedResponse a -> Bool)
-> Eq (PagedResponse a)
forall a. Eq a => PagedResponse a -> PagedResponse a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PagedResponse a -> PagedResponse a -> Bool
$c/= :: forall a. Eq a => PagedResponse a -> PagedResponse a -> Bool
== :: PagedResponse a -> PagedResponse a -> Bool
$c== :: forall a. Eq a => PagedResponse a -> PagedResponse a -> Bool
Eq, PagedResponse a -> ()
(PagedResponse a -> ()) -> NFData (PagedResponse a)
forall a. NFData a => PagedResponse a -> ()
forall a. (a -> ()) -> NFData a
rnf :: PagedResponse a -> ()
$crnf :: forall a. NFData a => PagedResponse a -> ()
NFData, [PagedResponse a] -> Encoding
[PagedResponse a] -> Value
PagedResponse a -> Encoding
PagedResponse a -> Value
(PagedResponse a -> Value)
-> (PagedResponse a -> Encoding)
-> ([PagedResponse a] -> Value)
-> ([PagedResponse a] -> Encoding)
-> ToJSON (PagedResponse a)
forall a. ToJSON a => [PagedResponse a] -> Encoding
forall a. ToJSON a => [PagedResponse a] -> Value
forall a. ToJSON a => PagedResponse a -> Encoding
forall a. ToJSON a => PagedResponse a -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [PagedResponse a] -> Encoding
$ctoEncodingList :: forall a. ToJSON a => [PagedResponse a] -> Encoding
toJSONList :: [PagedResponse a] -> Value
$ctoJSONList :: forall a. ToJSON a => [PagedResponse a] -> Value
toEncoding :: PagedResponse a -> Encoding
$ctoEncoding :: forall a. ToJSON a => PagedResponse a -> Encoding
toJSON :: PagedResponse a -> Value
$ctoJSON :: forall a. ToJSON a => PagedResponse a -> Value
ToJSON, Value -> Parser [PagedResponse a]
Value -> Parser (PagedResponse a)
(Value -> Parser (PagedResponse a))
-> (Value -> Parser [PagedResponse a])
-> FromJSON (PagedResponse a)
forall a. FromJSON a => Value -> Parser [PagedResponse a]
forall a. FromJSON a => Value -> Parser (PagedResponse a)
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [PagedResponse a]
$cparseJSONList :: forall a. FromJSON a => Value -> Parser [PagedResponse a]
parseJSON :: Value -> Parser (PagedResponse a)
$cparseJSON :: forall a. FromJSON a => Value -> Parser (PagedResponse a)
FromJSON)

deriving instance ToSchema a => ToSchema (PagedResponse a)