summaryrefslogtreecommitdiff
path: root/haskell/src/SpaceTraders/APIClient/Pagination.hs
diff options
context:
space:
mode:
authorJulien Dessaux2023-07-11 21:55:55 +0200
committerJulien Dessaux2023-07-11 21:56:35 +0200
commit7bd1c116c26d0c2147aa787b04f6e7de85d44133 (patch)
tree8d831b852eeb37a2d8e4c09062c0ed7c9b441d19 /haskell/src/SpaceTraders/APIClient/Pagination.hs
parent[haskell] Refactored JSON parsing code (diff)
downloadspacetraders-7bd1c116c26d0c2147aa787b04f6e7de85d44133.tar.gz
spacetraders-7bd1c116c26d0c2147aa787b04f6e7de85d44133.tar.bz2
spacetraders-7bd1c116c26d0c2147aa787b04f6e7de85d44133.zip
[haskell] Implemented pagination and systems list api call
Diffstat (limited to '')
-rw-r--r--haskell/src/SpaceTraders/APIClient/Pagination.hs19
1 files changed, 19 insertions, 0 deletions
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