@@ -52,8 +52,6 @@ import Network.PagerDuty.Internal.Query
52import Network.PagerDuty.Internal.TH
52import Network.PagerDuty.Internal.TH
53import System.Locale
53import System.Locale
55−-- FIXME: Verify IncidentId/IncidentKey .. *Id/*Key are actually different or needed
57newtype CSV a = CSV [a]
55newtype CSV a = CSV [a]
58 deriving (Eq, Show, Monoid)
56 deriving (Eq, Show, Monoid)
@@ -142,7 +140,10 @@ deriving instance Eq (Auth a)
142deriving instance Show (Auth a)
140deriving instance Show (Auth a)
144newtype SubDomain = SubDomain { subDomain :: ByteString }
142newtype SubDomain = SubDomain { subDomain :: ByteString }
145− deriving (Eq, Show, IsString)
143+ deriving (Eq, Show, IsString, ToByteString)
145+mkSubDomain :: ByteString -> SubDomain
146+mkSubDomain = SubDomain
147domain :: SubDomain -> ByteString
148domain :: SubDomain -> ByteString
148domain (SubDomain s)
149domain (SubDomain s)
@@ -179,7 +180,7 @@ prod :: SubDomain -> Auth s -> Manager -> Env s
179prod d a m = Env d a m None
180prod d a m = Env d a m None
181newtype Code = Code Integer
182newtype Code = Code Integer
182− deriving (Eq, Show)
183+ deriving (Eq, Show, Num)
184deriveJSON ''Code
185deriveJSON ''Code
@@ -385,13 +386,13 @@ class Paginate a where
385 next :: Request a s b -> Maybe Pager -> Maybe (Request a s b)
386 next :: Request a s b -> Maybe Pager -> Maybe (Request a s b)
386 next rq = maybe Nothing go
387 next rq = maybe Nothing go
388− go x | x^.pgTotal == 0 = Nothing
389+ go x | x ^. pgTotal == 0 = Nothing
389− | otherwise = Just $
390+ | otherwise = Just $
390− rq & pager ?~ (x & pgOffset +~ x^.pgTotal)
391+ rq & pager ?~ (x & pgOffset +~ x ^. pgTotal)
391 & query %~ (add . clear)
392 & query %~ (add . clear)
393 add :: Query -> Query
394 add :: Query -> Query
394− add = maybe id ((:) . (k,) . Just . Text.encodeUtf8) (x^.pgQuery)
395+ add = maybe id ((:) . (k,) . Just . Text.encodeUtf8) (x ^. pgQuery)
396 clear :: Query -> Query
397 clear :: Query -> Query
397 clear = deleteBy ((==) `on` fst) (k, Nothing)
398 clear = deleteBy ((==) `on` fst) (k, Nothing)
@@ -402,6 +403,9 @@ class Paginate a where
402newtype Key (a :: Symbol) = Key Text
403newtype Key (a :: Symbol) = Key Text
403 deriving (Eq, Show, IsString)
404 deriving (Eq, Show, IsString)
406+mkKey :: Text -> Key a
405instance FromJSON (Key a) where
409instance FromJSON (Key a) where
406 parseJSON = withText "key" (return . Key)
410 parseJSON = withText "key" (return . Key)
@@ -422,6 +426,9 @@ type IncidentKey = Key "incident"
422newtype Id (a :: Symbol) = Id Text
426newtype Id (a :: Symbol) = Id Text
423 deriving (Eq, Show, IsString)
427 deriving (Eq, Show, IsString)
425instance FromJSON (Id a) where
432instance FromJSON (Id a) where
426 parseJSON = withText "id" (return . Id)
433 parseJSON = withText "id" (return . Id)
@@ -469,7 +476,10 @@ instance QueryLike Empty where
469 toQuery = const []
476 toQuery = const []
471newtype Address = Address Text
478newtype Address = Address Text
472− deriving (Eq, Show)
479+ deriving (Eq, Show, IsString)
481+mkAddress :: Text -> Address
474deriveJSON ''Address
484deriveJSON ''Address
475makePrisms ''Address
485makePrisms ''Address