@@ -15,7 +15,7 @@
1515{-# LANGUAGE ViewPatterns #-}
1616
1717-- Module : Network.PagerDuty.Internal.Types
18−-- Copyright : (c) 2013-2015 Brendan Hay <brendan.g.hay@gmail.com>
18+-- Copyright : (c) 2013-2014 Brendan Hay <brendan.g.hay@gmail.com>
1919-- License : This Source Code Form is subject to the terms of
2020-- the Mozilla Public License, v. 2.0.
2121-- A copy of the MPL can be found in the LICENSE file or
@@ -27,33 +27,32 @@
2727module Network.PagerDuty.Internal.Types where
2828
2929import Control.Applicative
30−import Control.Lens hiding ((.=), Empty)
30+import Control.Lens hiding ((.=))
3131import Control.Monad.IO.Class
32−import Data.Aeson hiding (Error, Key)
33−import qualified Data.Aeson.KeyMap as Map
32+import Data.Aeson hiding (Error)
3433import Data.Aeson.Types (Parser)
3534import Data.ByteString (ByteString)
3635import qualified Data.ByteString.Char8 as BS
3736import Data.ByteString.Conversion hiding (List)
3837import Data.Default.Class
3938import 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 (UTCTime, TimeZone, formatTime, utc, timeZoneName)
46+import Data.Time
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
5453
5554newtype CSV a = CSV [a]
56− deriving (Eq, Show, Semigroup, Monoid)
55+ deriving (Eq, Show, Monoid)
5756
5857makePrisms ''CSV
5958
@@ -70,7 +69,7 @@ instance ToByteString a => ToJSON (CSV a) where
7069 toJSON = String . Text.decodeUtf8 . toByteString'
7170
7271newtype List a = L [a]
73− deriving (Eq, Show, Semigroup, Monoid)
72+ deriving (Eq, Show, Monoid)
7473
7574deriveJSON ''List
7675makePrisms ''List
@@ -106,7 +105,7 @@ instance ToJSON Date where
106105
107106instance ToByteString Date where
108107 builder (D d) = builder
109− (formatTime defaultTimeLocale ("%Y-%m-%dT%XZ") d)
108+ (formatTime defaultTimeLocale (iso8601DateFormat $ Just "%XZ") d)
110109
111110instance QueryValues Date
112111
@@ -133,8 +132,8 @@ data Security = Basic | Token
133132 deriving (Eq, Show)
134133
135134data Auth (a :: Security) where
136− AuthBasic :: ByteString -> ByteString -> Auth 'Basic
137− AuthToken :: ByteString -> Auth 'Token
135+ AuthBasic :: ByteString -> ByteString -> Auth Basic
136+ AuthToken :: ByteString -> Auth Token
138137
139138deriving instance Eq (Auth a)
140139deriving instance Show (Auth a)
@@ -279,13 +278,8 @@ data Pager = Pager
279278
280279makeLenses ''Pager
281280
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
281+instance FromJSON a => FromJSON (a, Maybe Pager) where
282+ parseJSON = withObject "paginated" $ \o -> (,)
289283 <$> parseJSON (Object o)
290284 <*> optional (parse o)
291285 where
@@ -310,13 +304,11 @@ data Path where
310304 Path :: Path
311305 Seg :: ToByteString a => a -> Path
312306
313−instance Semigroup Path where
314− x <> Path = x
315− Path <> y = y
316− Seg x <> Seg y = Seg (builder x <> "/" <> builder y)
317−
318307instance Monoid Path where
319− mempty = Path
308+ mempty = Path
309+ mappend x Path = x
310+ mappend Path y = y
311+ mappend (Seg x) (Seg y) = Seg (builder x <> "/" <> builder y)
320312
321313instance IsString Path where
322314 fromString = Seg