{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards   #-}
{-# LANGUAGE StrictData        #-}
module GitHub.Types.Base.ReviewCommentLinks where

import           Data.Aeson                (FromJSON (..), ToJSON (..), object)
import           Data.Aeson.Types          (Value (..), (.:), (.=))
import           Test.QuickCheck.Arbitrary (Arbitrary (..))

import           GitHub.Types.Base.Link

------------------------------------------------------------------------------
-- ReviewCommentLinks

data ReviewCommentLinks = ReviewCommentLinks
    { ReviewCommentLinks -> Link
reviewCommentLinksHtml        :: Link
    , ReviewCommentLinks -> Link
reviewCommentLinksSelf        :: Link
    , ReviewCommentLinks -> Link
reviewCommentLinksPullRequest :: Link
    } deriving (ReviewCommentLinks -> ReviewCommentLinks -> Bool
(ReviewCommentLinks -> ReviewCommentLinks -> Bool)
-> (ReviewCommentLinks -> ReviewCommentLinks -> Bool)
-> Eq ReviewCommentLinks
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReviewCommentLinks -> ReviewCommentLinks -> Bool
$c/= :: ReviewCommentLinks -> ReviewCommentLinks -> Bool
== :: ReviewCommentLinks -> ReviewCommentLinks -> Bool
$c== :: ReviewCommentLinks -> ReviewCommentLinks -> Bool
Eq, Int -> ReviewCommentLinks -> ShowS
[ReviewCommentLinks] -> ShowS
ReviewCommentLinks -> String
(Int -> ReviewCommentLinks -> ShowS)
-> (ReviewCommentLinks -> String)
-> ([ReviewCommentLinks] -> ShowS)
-> Show ReviewCommentLinks
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReviewCommentLinks] -> ShowS
$cshowList :: [ReviewCommentLinks] -> ShowS
show :: ReviewCommentLinks -> String
$cshow :: ReviewCommentLinks -> String
showsPrec :: Int -> ReviewCommentLinks -> ShowS
$cshowsPrec :: Int -> ReviewCommentLinks -> ShowS
Show, ReadPrec [ReviewCommentLinks]
ReadPrec ReviewCommentLinks
Int -> ReadS ReviewCommentLinks
ReadS [ReviewCommentLinks]
(Int -> ReadS ReviewCommentLinks)
-> ReadS [ReviewCommentLinks]
-> ReadPrec ReviewCommentLinks
-> ReadPrec [ReviewCommentLinks]
-> Read ReviewCommentLinks
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReviewCommentLinks]
$creadListPrec :: ReadPrec [ReviewCommentLinks]
readPrec :: ReadPrec ReviewCommentLinks
$creadPrec :: ReadPrec ReviewCommentLinks
readList :: ReadS [ReviewCommentLinks]
$creadList :: ReadS [ReviewCommentLinks]
readsPrec :: Int -> ReadS ReviewCommentLinks
$creadsPrec :: Int -> ReadS ReviewCommentLinks
Read)


instance FromJSON ReviewCommentLinks where
    parseJSON :: Value -> Parser ReviewCommentLinks
parseJSON (Object Object
x) = Link -> Link -> Link -> ReviewCommentLinks
ReviewCommentLinks
        (Link -> Link -> Link -> ReviewCommentLinks)
-> Parser Link -> Parser (Link -> Link -> ReviewCommentLinks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
x Object -> Key -> Parser Link
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"html"
        Parser (Link -> Link -> ReviewCommentLinks)
-> Parser Link -> Parser (Link -> ReviewCommentLinks)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Link
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"self"
        Parser (Link -> ReviewCommentLinks)
-> Parser Link -> Parser ReviewCommentLinks
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Link
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"pull_request"

    parseJSON Value
_ = String -> Parser ReviewCommentLinks
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"ReviewCommentLinks"


instance ToJSON ReviewCommentLinks where
    toJSON :: ReviewCommentLinks -> Value
toJSON ReviewCommentLinks{Link
reviewCommentLinksPullRequest :: Link
reviewCommentLinksSelf :: Link
reviewCommentLinksHtml :: Link
reviewCommentLinksPullRequest :: ReviewCommentLinks -> Link
reviewCommentLinksSelf :: ReviewCommentLinks -> Link
reviewCommentLinksHtml :: ReviewCommentLinks -> Link
..} = [Pair] -> Value
object
        [ Key
"html"         Key -> Link -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Link
reviewCommentLinksHtml
        , Key
"self"         Key -> Link -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Link
reviewCommentLinksSelf
        , Key
"pull_request" Key -> Link -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Link
reviewCommentLinksPullRequest
        ]


instance Arbitrary ReviewCommentLinks where
    arbitrary :: Gen ReviewCommentLinks
arbitrary = Link -> Link -> Link -> ReviewCommentLinks
ReviewCommentLinks
        (Link -> Link -> Link -> ReviewCommentLinks)
-> Gen Link -> Gen (Link -> Link -> ReviewCommentLinks)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Link
forall a. Arbitrary a => Gen a
arbitrary
        Gen (Link -> Link -> ReviewCommentLinks)
-> Gen Link -> Gen (Link -> ReviewCommentLinks)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Link
forall a. Arbitrary a => Gen a
arbitrary
        Gen (Link -> ReviewCommentLinks)
-> Gen Link -> Gen ReviewCommentLinks
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Link
forall a. Arbitrary a => Gen a
arbitrary