{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE StrictData #-} module GitHub.Types.Events.MemberEvent 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 import GitHub.Types.Event data MemberEvent = MemberEvent { MemberEvent -> Maybe Installation memberEventInstallation :: Maybe Installation , MemberEvent -> Organization memberEventOrganization :: Organization , MemberEvent -> Repository memberEventRepository :: Repository , MemberEvent -> User memberEventSender :: User , MemberEvent -> Text memberEventAction :: Text } deriving (MemberEvent -> MemberEvent -> Bool (MemberEvent -> MemberEvent -> Bool) -> (MemberEvent -> MemberEvent -> Bool) -> Eq MemberEvent forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: MemberEvent -> MemberEvent -> Bool $c/= :: MemberEvent -> MemberEvent -> Bool == :: MemberEvent -> MemberEvent -> Bool $c== :: MemberEvent -> MemberEvent -> Bool Eq, Int -> MemberEvent -> ShowS [MemberEvent] -> ShowS MemberEvent -> String (Int -> MemberEvent -> ShowS) -> (MemberEvent -> String) -> ([MemberEvent] -> ShowS) -> Show MemberEvent forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [MemberEvent] -> ShowS $cshowList :: [MemberEvent] -> ShowS show :: MemberEvent -> String $cshow :: MemberEvent -> String showsPrec :: Int -> MemberEvent -> ShowS $cshowsPrec :: Int -> MemberEvent -> ShowS Show, ReadPrec [MemberEvent] ReadPrec MemberEvent Int -> ReadS MemberEvent ReadS [MemberEvent] (Int -> ReadS MemberEvent) -> ReadS [MemberEvent] -> ReadPrec MemberEvent -> ReadPrec [MemberEvent] -> Read MemberEvent forall a. (Int -> ReadS a) -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a readListPrec :: ReadPrec [MemberEvent] $creadListPrec :: ReadPrec [MemberEvent] readPrec :: ReadPrec MemberEvent $creadPrec :: ReadPrec MemberEvent readList :: ReadS [MemberEvent] $creadList :: ReadS [MemberEvent] readsPrec :: Int -> ReadS MemberEvent $creadsPrec :: Int -> ReadS MemberEvent Read) instance Event MemberEvent where typeName :: TypeName MemberEvent typeName = Text -> TypeName MemberEvent forall a. Text -> TypeName a TypeName Text "MemberEvent" eventName :: EventName MemberEvent eventName = Text -> EventName MemberEvent forall a. Text -> EventName a EventName Text "member" instance FromJSON MemberEvent where parseJSON :: Value -> Parser MemberEvent parseJSON (Object Object x) = Maybe Installation -> Organization -> Repository -> User -> Text -> MemberEvent MemberEvent (Maybe Installation -> Organization -> Repository -> User -> Text -> MemberEvent) -> Parser (Maybe Installation) -> Parser (Organization -> Repository -> User -> Text -> MemberEvent) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Object x Object -> Key -> Parser (Maybe Installation) forall a. FromJSON a => Object -> Key -> Parser (Maybe a) .:? Key "installation" Parser (Organization -> Repository -> User -> Text -> MemberEvent) -> Parser Organization -> Parser (Repository -> User -> Text -> MemberEvent) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Object x Object -> Key -> Parser Organization forall a. FromJSON a => Object -> Key -> Parser a .: Key "organization" Parser (Repository -> User -> Text -> MemberEvent) -> Parser Repository -> Parser (User -> Text -> MemberEvent) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Object x Object -> Key -> Parser Repository forall a. FromJSON a => Object -> Key -> Parser a .: Key "repository" Parser (User -> Text -> MemberEvent) -> Parser User -> Parser (Text -> MemberEvent) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Object x Object -> Key -> Parser User forall a. FromJSON a => Object -> Key -> Parser a .: Key "sender" Parser (Text -> MemberEvent) -> Parser Text -> Parser MemberEvent 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 "action" parseJSON Value _ = String -> Parser MemberEvent forall (m :: * -> *) a. MonadFail m => String -> m a fail String "MemberEvent" instance ToJSON MemberEvent where toJSON :: MemberEvent -> Value toJSON MemberEvent{Maybe Installation Text Organization User Repository memberEventAction :: Text memberEventSender :: User memberEventRepository :: Repository memberEventOrganization :: Organization memberEventInstallation :: Maybe Installation memberEventAction :: MemberEvent -> Text memberEventSender :: MemberEvent -> User memberEventRepository :: MemberEvent -> Repository memberEventOrganization :: MemberEvent -> Organization memberEventInstallation :: MemberEvent -> Maybe Installation ..} = [Pair] -> Value object [ Key "installation" Key -> Maybe Installation -> Pair forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv .= Maybe Installation memberEventInstallation , Key "organization" Key -> Organization -> Pair forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv .= Organization memberEventOrganization , Key "repository" Key -> Repository -> Pair forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv .= Repository memberEventRepository , Key "sender" Key -> User -> Pair forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv .= User memberEventSender , Key "action" Key -> Text -> Pair forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv .= Text memberEventAction ] instance Arbitrary MemberEvent where arbitrary :: Gen MemberEvent arbitrary = Maybe Installation -> Organization -> Repository -> User -> Text -> MemberEvent MemberEvent (Maybe Installation -> Organization -> Repository -> User -> Text -> MemberEvent) -> Gen (Maybe Installation) -> Gen (Organization -> Repository -> User -> Text -> MemberEvent) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Gen (Maybe Installation) forall a. Arbitrary a => Gen a arbitrary Gen (Organization -> Repository -> User -> Text -> MemberEvent) -> Gen Organization -> Gen (Repository -> User -> Text -> MemberEvent) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Gen Organization forall a. Arbitrary a => Gen a arbitrary Gen (Repository -> User -> Text -> MemberEvent) -> Gen Repository -> Gen (User -> Text -> MemberEvent) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Gen Repository forall a. Arbitrary a => Gen a arbitrary Gen (User -> Text -> MemberEvent) -> Gen User -> Gen (Text -> MemberEvent) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Gen User forall a. Arbitrary a => Gen a arbitrary Gen (Text -> MemberEvent) -> Gen Text -> Gen MemberEvent forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Gen Text forall a. Arbitrary a => Gen a arbitrary