@@ -29,31 +29,31 @@ module Network.PagerDuty.Internal.Types where
2929import Control.Applicative
3030import Control.Lens hiding ((.=), Empty)
3131import Control.Monad.IO.Class
32−import Data.Aeson hiding (Error)
32+import Data.Aeson hiding (Error, Key)
33+import qualified Data.Aeson.KeyMap as Map
3334import Data.Aeson.Types (Parser)
3435import Data.ByteString (ByteString)
3536import qualified Data.ByteString.Char8 as BS
3637import Data.ByteString.Conversion hiding (List)
3738import Data.Default.Class
3839import Data.Function (on)
39−import qualified Data.HashMap.Strict as Map
4040import Data.List (deleteBy, intersperse)
4141import Data.Monoid
4242import Data.String
4343import Data.Text (Text)
4444import qualified Data.Text as Text
4545import qualified Data.Text.Encoding as Text
46−import Data.Time
46+import Data.Time (UTCTime, TimeZone, formatTime, utc, timeZoneName)
4747import GHC.TypeLits
4848import Network.HTTP.Client (Manager)
4949import Network.HTTP.Types
5050import Network.HTTP.Types.QueryLike
5151import Network.PagerDuty.Internal.Query
5252import Network.PagerDuty.Internal.TH
53−import Data.Time.Locale.Compat ()
53+import Data.Time.Locale.Compat
5454
5555newtype CSV a = CSV [a]
56− deriving (Eq, Show, Monoid)
56+ deriving (Eq, Show, Semigroup, Monoid)
5757
5858makePrisms ''CSV
5959
@@ -70,7 +70,7 @@ instance ToByteString a => ToJSON (CSV a) where
7070 toJSON = String . Text.decodeUtf8 . toByteString'
7171
7272newtype List a = L [a]
73− deriving (Eq, Show, Monoid)
73+ deriving (Eq, Show, Semigroup, Monoid)
7474
7575deriveJSON ''List
7676makePrisms ''List
@@ -279,8 +279,13 @@ data Pager = Pager
279279
280280makeLenses ''Pager
281281
282−instance FromJSON a => FromJSON (a, Maybe Pager) where
283− parseJSON = withObject "paginated" $ \o -> (,)
282+data Page a = Page
283+ { _pgItem :: a
284+ , _pgPager :: Maybe Pager
285+ }
286+
287+instance FromJSON a => FromJSON (Page a) where
288+ parseJSON = withObject "paginated" $ \o -> Page
284289 <$> parseJSON (Object o)
285290 <*> optional (parse o)
286291 where
@@ -305,11 +310,13 @@ data Path where
305310 Path :: Path
306311 Seg :: ToByteString a => a -> Path
307312
313+instance Semigroup Path where
314+ x <> Path = x
315+ Path <> y = y
316+ Seg x <> Seg y = Seg (builder x <> "/" <> builder y)
317+
308318instance Monoid Path where
309− mempty = Path
310− mappend x Path = x
311− mappend Path y = y
312− mappend (Seg x) (Seg y) = Seg (builder x <> "/" <> builder y)
319+ mempty = Path
313320
314321instance IsString Path where
315322 fromString = Seg