@@ -15,7 +15,7 @@
15{-# LANGUAGE ViewPatterns #-}
15{-# LANGUAGE ViewPatterns #-}
17-- Module : Network.PagerDuty.Internal.Types
17-- 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>
19-- License : This Source Code Form is subject to the terms of
19-- License : This Source Code Form is subject to the terms of
20-- the Mozilla Public License, v. 2.0.
20-- the Mozilla Public License, v. 2.0.
21-- A copy of the MPL can be found in the LICENSE file or
21-- A copy of the MPL can be found in the LICENSE file or
@@ -27,33 +27,32 @@
27module Network.PagerDuty.Internal.Types where
27module Network.PagerDuty.Internal.Types where
29import Control.Applicative
29import Control.Applicative
30−import Control.Lens hiding ((.=), Empty)
30+import Control.Lens hiding ((.=))
31import Control.Monad.IO.Class
31import Control.Monad.IO.Class
32−import Data.Aeson hiding (Error, Key)
32+import Data.Aeson hiding (Error)
33−import qualified Data.Aeson.KeyMap as Map
34import Data.Aeson.Types (Parser)
33import Data.Aeson.Types (Parser)
35import Data.ByteString (ByteString)
34import Data.ByteString (ByteString)
36import qualified Data.ByteString.Char8 as BS
35import qualified Data.ByteString.Char8 as BS
37import Data.ByteString.Conversion hiding (List)
36import Data.ByteString.Conversion hiding (List)
38import Data.Default.Class
37import Data.Default.Class
39import Data.Function (on)
38import Data.Function (on)
39+import qualified Data.HashMap.Strict as Map
40import Data.List (deleteBy, intersperse)
40import Data.List (deleteBy, intersperse)
41import Data.Monoid
41import Data.Monoid
42import Data.String
42import Data.String
43import Data.Text (Text)
43import Data.Text (Text)
44import qualified Data.Text as Text
44import qualified Data.Text as Text
45import qualified Data.Text.Encoding as Text
45import qualified Data.Text.Encoding as Text
46−import Data.Time (UTCTime, TimeZone, formatTime, utc, timeZoneName)
46+import Data.Time
47import GHC.TypeLits
47import GHC.TypeLits
48import Network.HTTP.Client (Manager)
48import Network.HTTP.Client (Manager)
49import Network.HTTP.Types
49import Network.HTTP.Types
50import Network.HTTP.Types.QueryLike
50import Network.HTTP.Types.QueryLike
51import Network.PagerDuty.Internal.Query
51import Network.PagerDuty.Internal.Query
52import Network.PagerDuty.Internal.TH
52import Network.PagerDuty.Internal.TH
53−import Data.Time.Locale.Compat
55newtype CSV a = CSV [a]
54newtype CSV a = CSV [a]
56− deriving (Eq, Show, Semigroup, Monoid)
55+ deriving (Eq, Show, Monoid)
58makePrisms ''CSV
57makePrisms ''CSV
@@ -70,7 +69,7 @@ instance ToByteString a => ToJSON (CSV a) where
70 toJSON = String . Text.decodeUtf8 . toByteString'
69 toJSON = String . Text.decodeUtf8 . toByteString'
72newtype List a = L [a]
71newtype List a = L [a]
73− deriving (Eq, Show, Semigroup, Monoid)
72+ deriving (Eq, Show, Monoid)
75deriveJSON ''List
74deriveJSON ''List
76makePrisms ''List
75makePrisms ''List
@@ -106,7 +105,7 @@ instance ToJSON Date where
107instance ToByteString Date where
106instance ToByteString Date where
108 builder (D d) = builder
107 builder (D d) = builder
109− (formatTime defaultTimeLocale ("%Y-%m-%dT%XZ") d)
108+ (formatTime defaultTimeLocale (iso8601DateFormat $ Just "%XZ") d)
111instance QueryValues Date
110instance QueryValues Date
@@ -133,8 +132,8 @@ data Security = Basic | Token
133 deriving (Eq, Show)
132 deriving (Eq, Show)
135data Auth (a :: Security) where
134data Auth (a :: Security) where
136− AuthBasic :: ByteString -> ByteString -> Auth 'Basic
135+ AuthBasic :: ByteString -> ByteString -> Auth Basic
137− AuthToken :: ByteString -> Auth 'Token
136+ AuthToken :: ByteString -> Auth Token
139deriving instance Eq (Auth a)
138deriving instance Eq (Auth a)
140deriving instance Show (Auth a)
139deriving instance Show (Auth a)
@@ -279,13 +278,8 @@ data Pager = Pager
280makeLenses ''Pager
279makeLenses ''Pager
282−data Page a = Page
281+instance FromJSON a => FromJSON (a, Maybe Pager) where
284− , _pgPager :: Maybe Pager
287−instance FromJSON a => FromJSON (Page a) where
288− parseJSON = withObject "paginated" $ \o -> Page
282+ parseJSON = withObject "paginated" $ \o -> (,)
289 <$> parseJSON (Object o)
283 <$> parseJSON (Object o)
290 <*> optional (parse o)
284 <*> optional (parse o)
@@ -310,13 +304,11 @@ data Path where
310 Path :: Path
304 Path :: Path
311 Seg :: ToByteString a => a -> Path
305 Seg :: ToByteString a => a -> Path
313−instance Semigroup Path where
316− Seg x <> Seg y = Seg (builder x <> "/" <> builder y)
318instance Monoid Path where
307instance Monoid Path where
319− mempty = Path
308+ mempty = Path
311+ mappend (Seg x) (Seg y) = Seg (builder x <> "/" <> builder y)
321instance IsString Path where
313instance IsString Path where
322 fromString = Seg
314 fromString = Seg