{-# LANGUAGE DeriveGeneric #-}
module Telegram.Bot.API.Types.ChatMemberUpdated where

import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.Time.Clock.POSIX (POSIXTime)
import GHC.Generics (Generic)

import Telegram.Bot.API.Types.Chat
import Telegram.Bot.API.Types.ChatInviteLink
import Telegram.Bot.API.Types.ChatMember
import Telegram.Bot.API.Types.User
import Telegram.Bot.API.Internal.Utils

-- ** 'ChatMemberUpdated'

-- | This object represents changes in the status of a chat member.
data ChatMemberUpdated = ChatMemberUpdated
  { ChatMemberUpdated -> Chat
chatMemberUpdatedChat          :: Chat                 -- ^ Chat the user belongs to.
  , ChatMemberUpdated -> User
chatMemberUpdatedFrom          :: User                 -- ^ Performer of the action, which resulted in the change.
  , ChatMemberUpdated -> POSIXTime
chatMemberUpdatedDate          :: POSIXTime            -- ^ Date the change was done in Unix time.
  , ChatMemberUpdated -> ChatMember
chatMemberUpdatedOldChatMember :: ChatMember           -- ^ Previous information about the chat member.
  , ChatMemberUpdated -> ChatMember
chatMemberUpdatedNewChatMember :: ChatMember           -- ^ New information about the chat member.
  , ChatMemberUpdated -> Maybe ChatInviteLink
chatMemberUpdatedInviteLink    :: Maybe ChatInviteLink -- ^ Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
  }
  deriving (forall x. Rep ChatMemberUpdated x -> ChatMemberUpdated
forall x. ChatMemberUpdated -> Rep ChatMemberUpdated x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChatMemberUpdated x -> ChatMemberUpdated
$cfrom :: forall x. ChatMemberUpdated -> Rep ChatMemberUpdated x
Generic, Int -> ChatMemberUpdated -> ShowS
[ChatMemberUpdated] -> ShowS
ChatMemberUpdated -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChatMemberUpdated] -> ShowS
$cshowList :: [ChatMemberUpdated] -> ShowS
show :: ChatMemberUpdated -> String
$cshow :: ChatMemberUpdated -> String
showsPrec :: Int -> ChatMemberUpdated -> ShowS
$cshowsPrec :: Int -> ChatMemberUpdated -> ShowS
Show)

instance ToJSON   ChatMemberUpdated where toJSON :: ChatMemberUpdated -> Value
toJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON
instance FromJSON ChatMemberUpdated where parseJSON :: Value -> Parser ChatMemberUpdated
parseJSON = forall a (d :: Meta) (f :: * -> *).
(Generic a, GFromJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
Value -> Parser a
gparseJSON