From 7bd1c116c26d0c2147aa787b04f6e7de85d44133 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Tue, 11 Jul 2023 21:55:55 +0200 Subject: [haskell] Implemented pagination and systems list api call --- haskell/src/SpaceTraders/APIClient/Pagination.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 haskell/src/SpaceTraders/APIClient/Pagination.hs (limited to 'haskell/src/SpaceTraders/APIClient/Pagination.hs') diff --git a/haskell/src/SpaceTraders/APIClient/Pagination.hs b/haskell/src/SpaceTraders/APIClient/Pagination.hs new file mode 100644 index 0000000..bb9bcd1 --- /dev/null +++ b/haskell/src/SpaceTraders/APIClient/Pagination.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE OverloadedStrings #-} + +module SpaceTraders.APIClient.Pagination + ( Pagination(..) + , nextPage + ) where + +import Data.Aeson +import GHC.Generics + +data Pagination = Pagination { limit :: Int + , page :: Int + , total :: Int + } deriving (FromJSON, Generic, Show) + +nextPage :: Pagination -> Pagination +nextPage (Pagination l p t) = Pagination l (p + 1) t -- cgit v1.2.3