{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
module GitHub.Types.Base.Milestone where
import Data.Aeson (FromJSON (..), ToJSON (..), object)
import Data.Aeson.Types (Value (..), (.:), (.=))
import Data.Text (Text)
import Test.QuickCheck.Arbitrary (Arbitrary (..))
import GitHub.Types.Base.DateTime
import GitHub.Types.Base.User
data Milestone = Milestone
{ Milestone -> User
milestoneCreator :: User
, Milestone -> Int
milestoneClosedIssues :: Int
, Milestone -> Text
milestoneState :: Text
, Milestone -> Maybe Text
milestoneDueOn :: Maybe Text
, Milestone -> Text
milestoneUrl :: Text
, Milestone -> DateTime
milestoneUpdatedAt :: DateTime
, Milestone -> DateTime
milestoneCreatedAt :: DateTime
, Milestone -> Int
milestoneId :: Int
, Milestone -> Text
milestoneNodeId :: Text
, Milestone -> Text
milestoneTitle :: Text
, Milestone -> Maybe DateTime
milestoneClosedAt :: Maybe DateTime
, Milestone -> Int
milestoneNumber :: Int
, Milestone -> Maybe Text
milestoneDescription :: Maybe Text
, Milestone -> Text
milestoneLabelsUrl :: Text
, Milestone -> Text
milestoneHtmlUrl :: Text
, Milestone -> Int
milestoneOpenIssues :: Int
} deriving (Milestone -> Milestone -> Bool
(Milestone -> Milestone -> Bool)
-> (Milestone -> Milestone -> Bool) -> Eq Milestone
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Milestone -> Milestone -> Bool
$c/= :: Milestone -> Milestone -> Bool
== :: Milestone -> Milestone -> Bool
$c== :: Milestone -> Milestone -> Bool
Eq, Int -> Milestone -> ShowS
[Milestone] -> ShowS
Milestone -> String
(Int -> Milestone -> ShowS)
-> (Milestone -> String)
-> ([Milestone] -> ShowS)
-> Show Milestone
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Milestone] -> ShowS
$cshowList :: [Milestone] -> ShowS
show :: Milestone -> String
$cshow :: Milestone -> String
showsPrec :: Int -> Milestone -> ShowS
$cshowsPrec :: Int -> Milestone -> ShowS
Show, ReadPrec [Milestone]
ReadPrec Milestone
Int -> ReadS Milestone
ReadS [Milestone]
(Int -> ReadS Milestone)
-> ReadS [Milestone]
-> ReadPrec Milestone
-> ReadPrec [Milestone]
-> Read Milestone
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Milestone]
$creadListPrec :: ReadPrec [Milestone]
readPrec :: ReadPrec Milestone
$creadPrec :: ReadPrec Milestone
readList :: ReadS [Milestone]
$creadList :: ReadS [Milestone]
readsPrec :: Int -> ReadS Milestone
$creadsPrec :: Int -> ReadS Milestone
Read)
instance FromJSON Milestone where
parseJSON :: Value -> Parser Milestone
parseJSON (Object Object
x) = User
-> Int
-> Text
-> Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone
Milestone
(User
-> Int
-> Text
-> Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Parser User
-> Parser
(Int
-> Text
-> Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
x Object -> Key -> Parser User
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"creator"
Parser
(Int
-> Text
-> Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Parser Int
-> Parser
(Text
-> Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"closed_issues"
Parser
(Text
-> Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Parser Text
-> Parser
(Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"state"
Parser
(Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Parser (Maybe Text)
-> Parser
(Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"due_on"
Parser
(Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Parser Text
-> Parser
(DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"url"
Parser
(DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Parser DateTime
-> Parser
(DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser DateTime
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"updated_at"
Parser
(DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Parser DateTime
-> Parser
(Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser DateTime
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"created_at"
Parser
(Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Parser Int
-> Parser
(Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id"
Parser
(Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Parser Text
-> Parser
(Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"node_id"
Parser
(Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Parser Text
-> Parser
(Maybe DateTime
-> Int -> Maybe Text -> Text -> Text -> Int -> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"title"
Parser
(Maybe DateTime
-> Int -> Maybe Text -> Text -> Text -> Int -> Milestone)
-> Parser (Maybe DateTime)
-> Parser (Int -> Maybe Text -> Text -> Text -> Int -> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser (Maybe DateTime)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"closed_at"
Parser (Int -> Maybe Text -> Text -> Text -> Int -> Milestone)
-> Parser Int
-> Parser (Maybe Text -> Text -> Text -> Int -> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"number"
Parser (Maybe Text -> Text -> Text -> Int -> Milestone)
-> Parser (Maybe Text) -> Parser (Text -> Text -> Int -> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"description"
Parser (Text -> Text -> Int -> Milestone)
-> Parser Text -> Parser (Text -> Int -> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"labels_url"
Parser (Text -> Int -> Milestone)
-> Parser Text -> Parser (Int -> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"html_url"
Parser (Int -> Milestone) -> Parser Int -> Parser Milestone
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"open_issues"
parseJSON Value
_ = String -> Parser Milestone
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Milestone"
instance ToJSON Milestone where
toJSON :: Milestone -> Value
toJSON Milestone{Int
Maybe Text
Maybe DateTime
Text
DateTime
User
milestoneOpenIssues :: Int
milestoneHtmlUrl :: Text
milestoneLabelsUrl :: Text
milestoneDescription :: Maybe Text
milestoneNumber :: Int
milestoneClosedAt :: Maybe DateTime
milestoneTitle :: Text
milestoneNodeId :: Text
milestoneId :: Int
milestoneCreatedAt :: DateTime
milestoneUpdatedAt :: DateTime
milestoneUrl :: Text
milestoneDueOn :: Maybe Text
milestoneState :: Text
milestoneClosedIssues :: Int
milestoneCreator :: User
milestoneOpenIssues :: Milestone -> Int
milestoneHtmlUrl :: Milestone -> Text
milestoneLabelsUrl :: Milestone -> Text
milestoneDescription :: Milestone -> Maybe Text
milestoneNumber :: Milestone -> Int
milestoneClosedAt :: Milestone -> Maybe DateTime
milestoneTitle :: Milestone -> Text
milestoneNodeId :: Milestone -> Text
milestoneId :: Milestone -> Int
milestoneCreatedAt :: Milestone -> DateTime
milestoneUpdatedAt :: Milestone -> DateTime
milestoneUrl :: Milestone -> Text
milestoneDueOn :: Milestone -> Maybe Text
milestoneState :: Milestone -> Text
milestoneClosedIssues :: Milestone -> Int
milestoneCreator :: Milestone -> User
..} = [Pair] -> Value
object
[ Key
"creator" Key -> User -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= User
milestoneCreator
, Key
"closed_issues" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
milestoneClosedIssues
, Key
"state" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
milestoneState
, Key
"due_on" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
milestoneDueOn
, Key
"url" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
milestoneUrl
, Key
"updated_at" Key -> DateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DateTime
milestoneUpdatedAt
, Key
"created_at" Key -> DateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DateTime
milestoneCreatedAt
, Key
"id" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
milestoneId
, Key
"node_id" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
milestoneNodeId
, Key
"title" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
milestoneTitle
, Key
"closed_at" Key -> Maybe DateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe DateTime
milestoneClosedAt
, Key
"number" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
milestoneNumber
, Key
"description" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
milestoneDescription
, Key
"labels_url" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
milestoneLabelsUrl
, Key
"html_url" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
milestoneHtmlUrl
, Key
"open_issues" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
milestoneOpenIssues
]
instance Arbitrary Milestone where
arbitrary :: Gen Milestone
arbitrary = User
-> Int
-> Text
-> Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone
Milestone
(User
-> Int
-> Text
-> Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Gen User
-> Gen
(Int
-> Text
-> Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen User
forall a. Arbitrary a => Gen a
arbitrary
Gen
(Int
-> Text
-> Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Gen Int
-> Gen
(Text
-> Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Int
forall a. Arbitrary a => Gen a
arbitrary
Gen
(Text
-> Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Gen Text
-> Gen
(Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Text
forall a. Arbitrary a => Gen a
arbitrary
Gen
(Maybe Text
-> Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Gen (Maybe Text)
-> Gen
(Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Maybe Text)
forall a. Arbitrary a => Gen a
arbitrary
Gen
(Text
-> DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Gen Text
-> Gen
(DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Text
forall a. Arbitrary a => Gen a
arbitrary
Gen
(DateTime
-> DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Gen DateTime
-> Gen
(DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen DateTime
forall a. Arbitrary a => Gen a
arbitrary
Gen
(DateTime
-> Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Gen DateTime
-> Gen
(Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen DateTime
forall a. Arbitrary a => Gen a
arbitrary
Gen
(Int
-> Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Gen Int
-> Gen
(Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Int
forall a. Arbitrary a => Gen a
arbitrary
Gen
(Text
-> Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Gen Text
-> Gen
(Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Text
forall a. Arbitrary a => Gen a
arbitrary
Gen
(Text
-> Maybe DateTime
-> Int
-> Maybe Text
-> Text
-> Text
-> Int
-> Milestone)
-> Gen Text
-> Gen
(Maybe DateTime
-> Int -> Maybe Text -> Text -> Text -> Int -> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Text
forall a. Arbitrary a => Gen a
arbitrary
Gen
(Maybe DateTime
-> Int -> Maybe Text -> Text -> Text -> Int -> Milestone)
-> Gen (Maybe DateTime)
-> Gen (Int -> Maybe Text -> Text -> Text -> Int -> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Maybe DateTime)
forall a. Arbitrary a => Gen a
arbitrary
Gen (Int -> Maybe Text -> Text -> Text -> Int -> Milestone)
-> Gen Int -> Gen (Maybe Text -> Text -> Text -> Int -> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Int
forall a. Arbitrary a => Gen a
arbitrary
Gen (Maybe Text -> Text -> Text -> Int -> Milestone)
-> Gen (Maybe Text) -> Gen (Text -> Text -> Int -> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Maybe Text)
forall a. Arbitrary a => Gen a
arbitrary
Gen (Text -> Text -> Int -> Milestone)
-> Gen Text -> Gen (Text -> Int -> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Text
forall a. Arbitrary a => Gen a
arbitrary
Gen (Text -> Int -> Milestone)
-> Gen Text -> Gen (Int -> Milestone)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Text
forall a. Arbitrary a => Gen a
arbitrary
Gen (Int -> Milestone) -> Gen Int -> Gen Milestone
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Int
forall a. Arbitrary a => Gen a
arbitrary