module TD.Data.ChatMemberStatus
(ChatMemberStatus(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
import qualified TD.Data.ChatAdministratorRights as ChatAdministratorRights
import qualified TD.Data.ChatPermissions as ChatPermissions
data ChatMemberStatus
= ChatMemberStatusCreator
{ ChatMemberStatus -> Maybe Text
custom_title :: Maybe T.Text
, ChatMemberStatus -> Maybe Bool
is_anonymous :: Maybe Bool
, ChatMemberStatus -> Maybe Bool
is_member :: Maybe Bool
}
| ChatMemberStatusAdministrator
{ custom_title :: Maybe T.Text
, ChatMemberStatus -> Maybe Bool
can_be_edited :: Maybe Bool
, ChatMemberStatus -> Maybe ChatAdministratorRights
rights :: Maybe ChatAdministratorRights.ChatAdministratorRights
}
| ChatMemberStatusMember
{ ChatMemberStatus -> Maybe Int
member_until_date :: Maybe Int
}
| ChatMemberStatusRestricted
{ is_member :: Maybe Bool
, ChatMemberStatus -> Maybe Int
restricted_until_date :: Maybe Int
, ChatMemberStatus -> Maybe ChatPermissions
permissions :: Maybe ChatPermissions.ChatPermissions
}
| ChatMemberStatusLeft
| ChatMemberStatusBanned
{ ChatMemberStatus -> Maybe Int
banned_until_date :: Maybe Int
}
deriving (ChatMemberStatus -> ChatMemberStatus -> Bool
(ChatMemberStatus -> ChatMemberStatus -> Bool)
-> (ChatMemberStatus -> ChatMemberStatus -> Bool)
-> Eq ChatMemberStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatMemberStatus -> ChatMemberStatus -> Bool
== :: ChatMemberStatus -> ChatMemberStatus -> Bool
$c/= :: ChatMemberStatus -> ChatMemberStatus -> Bool
/= :: ChatMemberStatus -> ChatMemberStatus -> Bool
Eq, Int -> ChatMemberStatus -> ShowS
[ChatMemberStatus] -> ShowS
ChatMemberStatus -> String
(Int -> ChatMemberStatus -> ShowS)
-> (ChatMemberStatus -> String)
-> ([ChatMemberStatus] -> ShowS)
-> Show ChatMemberStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatMemberStatus -> ShowS
showsPrec :: Int -> ChatMemberStatus -> ShowS
$cshow :: ChatMemberStatus -> String
show :: ChatMemberStatus -> String
$cshowList :: [ChatMemberStatus] -> ShowS
showList :: [ChatMemberStatus] -> ShowS
Show)
instance I.ShortShow ChatMemberStatus where
shortShow :: ChatMemberStatus -> String
shortShow ChatMemberStatusCreator
{ custom_title :: ChatMemberStatus -> Maybe Text
custom_title = Maybe Text
custom_title_
, is_anonymous :: ChatMemberStatus -> Maybe Bool
is_anonymous = Maybe Bool
is_anonymous_
, is_member :: ChatMemberStatus -> Maybe Bool
is_member = Maybe Bool
is_member_
}
= String
"ChatMemberStatusCreator"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"custom_title" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
custom_title_
, String
"is_anonymous" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_anonymous_
, String
"is_member" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_member_
]
shortShow ChatMemberStatusAdministrator
{ custom_title :: ChatMemberStatus -> Maybe Text
custom_title = Maybe Text
custom_title_
, can_be_edited :: ChatMemberStatus -> Maybe Bool
can_be_edited = Maybe Bool
can_be_edited_
, rights :: ChatMemberStatus -> Maybe ChatAdministratorRights
rights = Maybe ChatAdministratorRights
rights_
}
= String
"ChatMemberStatusAdministrator"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"custom_title" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
custom_title_
, String
"can_be_edited" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_be_edited_
, String
"rights" String -> Maybe ChatAdministratorRights -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatAdministratorRights
rights_
]
shortShow ChatMemberStatusMember
{ member_until_date :: ChatMemberStatus -> Maybe Int
member_until_date = Maybe Int
member_until_date_
}
= String
"ChatMemberStatusMember"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"member_until_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
member_until_date_
]
shortShow ChatMemberStatusRestricted
{ is_member :: ChatMemberStatus -> Maybe Bool
is_member = Maybe Bool
is_member_
, restricted_until_date :: ChatMemberStatus -> Maybe Int
restricted_until_date = Maybe Int
restricted_until_date_
, permissions :: ChatMemberStatus -> Maybe ChatPermissions
permissions = Maybe ChatPermissions
permissions_
}
= String
"ChatMemberStatusRestricted"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"is_member" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_member_
, String
"restricted_until_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
restricted_until_date_
, String
"permissions" String -> Maybe ChatPermissions -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatPermissions
permissions_
]
shortShow ChatMemberStatus
ChatMemberStatusLeft
= String
"ChatMemberStatusLeft"
shortShow ChatMemberStatusBanned
{ banned_until_date :: ChatMemberStatus -> Maybe Int
banned_until_date = Maybe Int
banned_until_date_
}
= String
"ChatMemberStatusBanned"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"banned_until_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
banned_until_date_
]
instance AT.FromJSON ChatMemberStatus where
parseJSON :: Value -> Parser ChatMemberStatus
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"chatMemberStatusCreator" -> Value -> Parser ChatMemberStatus
parseChatMemberStatusCreator Value
v
String
"chatMemberStatusAdministrator" -> Value -> Parser ChatMemberStatus
parseChatMemberStatusAdministrator Value
v
String
"chatMemberStatusMember" -> Value -> Parser ChatMemberStatus
parseChatMemberStatusMember Value
v
String
"chatMemberStatusRestricted" -> Value -> Parser ChatMemberStatus
parseChatMemberStatusRestricted Value
v
String
"chatMemberStatusLeft" -> ChatMemberStatus -> Parser ChatMemberStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ChatMemberStatus
ChatMemberStatusLeft
String
"chatMemberStatusBanned" -> Value -> Parser ChatMemberStatus
parseChatMemberStatusBanned Value
v
String
_ -> Parser ChatMemberStatus
forall a. Monoid a => a
mempty
where
parseChatMemberStatusCreator :: A.Value -> AT.Parser ChatMemberStatus
parseChatMemberStatusCreator :: Value -> Parser ChatMemberStatus
parseChatMemberStatusCreator = String
-> (Object -> Parser ChatMemberStatus)
-> Value
-> Parser ChatMemberStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatMemberStatusCreator" ((Object -> Parser ChatMemberStatus)
-> Value -> Parser ChatMemberStatus)
-> (Object -> Parser ChatMemberStatus)
-> Value
-> Parser ChatMemberStatus
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
custom_title_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"custom_title"
Maybe Bool
is_anonymous_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_anonymous"
Maybe Bool
is_member_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_member"
ChatMemberStatus -> Parser ChatMemberStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatMemberStatus -> Parser ChatMemberStatus)
-> ChatMemberStatus -> Parser ChatMemberStatus
forall a b. (a -> b) -> a -> b
$ ChatMemberStatusCreator
{ custom_title :: Maybe Text
custom_title = Maybe Text
custom_title_
, is_anonymous :: Maybe Bool
is_anonymous = Maybe Bool
is_anonymous_
, is_member :: Maybe Bool
is_member = Maybe Bool
is_member_
}
parseChatMemberStatusAdministrator :: A.Value -> AT.Parser ChatMemberStatus
parseChatMemberStatusAdministrator :: Value -> Parser ChatMemberStatus
parseChatMemberStatusAdministrator = String
-> (Object -> Parser ChatMemberStatus)
-> Value
-> Parser ChatMemberStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatMemberStatusAdministrator" ((Object -> Parser ChatMemberStatus)
-> Value -> Parser ChatMemberStatus)
-> (Object -> Parser ChatMemberStatus)
-> Value
-> Parser ChatMemberStatus
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
custom_title_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"custom_title"
Maybe Bool
can_be_edited_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_be_edited"
Maybe ChatAdministratorRights
rights_ <- Object
o Object -> Key -> Parser (Maybe ChatAdministratorRights)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"rights"
ChatMemberStatus -> Parser ChatMemberStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatMemberStatus -> Parser ChatMemberStatus)
-> ChatMemberStatus -> Parser ChatMemberStatus
forall a b. (a -> b) -> a -> b
$ ChatMemberStatusAdministrator
{ custom_title :: Maybe Text
custom_title = Maybe Text
custom_title_
, can_be_edited :: Maybe Bool
can_be_edited = Maybe Bool
can_be_edited_
, rights :: Maybe ChatAdministratorRights
rights = Maybe ChatAdministratorRights
rights_
}
parseChatMemberStatusMember :: A.Value -> AT.Parser ChatMemberStatus
parseChatMemberStatusMember :: Value -> Parser ChatMemberStatus
parseChatMemberStatusMember = String
-> (Object -> Parser ChatMemberStatus)
-> Value
-> Parser ChatMemberStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatMemberStatusMember" ((Object -> Parser ChatMemberStatus)
-> Value -> Parser ChatMemberStatus)
-> (Object -> Parser ChatMemberStatus)
-> Value
-> Parser ChatMemberStatus
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
member_until_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"member_until_date"
ChatMemberStatus -> Parser ChatMemberStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatMemberStatus -> Parser ChatMemberStatus)
-> ChatMemberStatus -> Parser ChatMemberStatus
forall a b. (a -> b) -> a -> b
$ ChatMemberStatusMember
{ member_until_date :: Maybe Int
member_until_date = Maybe Int
member_until_date_
}
parseChatMemberStatusRestricted :: A.Value -> AT.Parser ChatMemberStatus
parseChatMemberStatusRestricted :: Value -> Parser ChatMemberStatus
parseChatMemberStatusRestricted = String
-> (Object -> Parser ChatMemberStatus)
-> Value
-> Parser ChatMemberStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatMemberStatusRestricted" ((Object -> Parser ChatMemberStatus)
-> Value -> Parser ChatMemberStatus)
-> (Object -> Parser ChatMemberStatus)
-> Value
-> Parser ChatMemberStatus
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Bool
is_member_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_member"
Maybe Int
restricted_until_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"restricted_until_date"
Maybe ChatPermissions
permissions_ <- Object
o Object -> Key -> Parser (Maybe ChatPermissions)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"permissions"
ChatMemberStatus -> Parser ChatMemberStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatMemberStatus -> Parser ChatMemberStatus)
-> ChatMemberStatus -> Parser ChatMemberStatus
forall a b. (a -> b) -> a -> b
$ ChatMemberStatusRestricted
{ is_member :: Maybe Bool
is_member = Maybe Bool
is_member_
, restricted_until_date :: Maybe Int
restricted_until_date = Maybe Int
restricted_until_date_
, permissions :: Maybe ChatPermissions
permissions = Maybe ChatPermissions
permissions_
}
parseChatMemberStatusBanned :: A.Value -> AT.Parser ChatMemberStatus
parseChatMemberStatusBanned :: Value -> Parser ChatMemberStatus
parseChatMemberStatusBanned = String
-> (Object -> Parser ChatMemberStatus)
-> Value
-> Parser ChatMemberStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatMemberStatusBanned" ((Object -> Parser ChatMemberStatus)
-> Value -> Parser ChatMemberStatus)
-> (Object -> Parser ChatMemberStatus)
-> Value
-> Parser ChatMemberStatus
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
banned_until_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"banned_until_date"
ChatMemberStatus -> Parser ChatMemberStatus
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatMemberStatus -> Parser ChatMemberStatus)
-> ChatMemberStatus -> Parser ChatMemberStatus
forall a b. (a -> b) -> a -> b
$ ChatMemberStatusBanned
{ banned_until_date :: Maybe Int
banned_until_date = Maybe Int
banned_until_date_
}
parseJSON Value
_ = Parser ChatMemberStatus
forall a. Monoid a => a
mempty
instance AT.ToJSON ChatMemberStatus where
toJSON :: ChatMemberStatus -> Value
toJSON ChatMemberStatusCreator
{ custom_title :: ChatMemberStatus -> Maybe Text
custom_title = Maybe Text
custom_title_
, is_anonymous :: ChatMemberStatus -> Maybe Bool
is_anonymous = Maybe Bool
is_anonymous_
, is_member :: ChatMemberStatus -> Maybe Bool
is_member = Maybe Bool
is_member_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"chatMemberStatusCreator"
, Key
"custom_title" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
custom_title_
, Key
"is_anonymous" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_anonymous_
, Key
"is_member" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_member_
]
toJSON ChatMemberStatusAdministrator
{ custom_title :: ChatMemberStatus -> Maybe Text
custom_title = Maybe Text
custom_title_
, can_be_edited :: ChatMemberStatus -> Maybe Bool
can_be_edited = Maybe Bool
can_be_edited_
, rights :: ChatMemberStatus -> Maybe ChatAdministratorRights
rights = Maybe ChatAdministratorRights
rights_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"chatMemberStatusAdministrator"
, Key
"custom_title" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
custom_title_
, Key
"can_be_edited" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
can_be_edited_
, Key
"rights" Key -> Maybe ChatAdministratorRights -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatAdministratorRights
rights_
]
toJSON ChatMemberStatusMember
{ member_until_date :: ChatMemberStatus -> Maybe Int
member_until_date = Maybe Int
member_until_date_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"chatMemberStatusMember"
, Key
"member_until_date" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
member_until_date_
]
toJSON ChatMemberStatusRestricted
{ is_member :: ChatMemberStatus -> Maybe Bool
is_member = Maybe Bool
is_member_
, restricted_until_date :: ChatMemberStatus -> Maybe Int
restricted_until_date = Maybe Int
restricted_until_date_
, permissions :: ChatMemberStatus -> Maybe ChatPermissions
permissions = Maybe ChatPermissions
permissions_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"chatMemberStatusRestricted"
, Key
"is_member" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_member_
, Key
"restricted_until_date" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
restricted_until_date_
, Key
"permissions" Key -> Maybe ChatPermissions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatPermissions
permissions_
]
toJSON ChatMemberStatus
ChatMemberStatusLeft
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"chatMemberStatusLeft"
]
toJSON ChatMemberStatusBanned
{ banned_until_date :: ChatMemberStatus -> Maybe Int
banned_until_date = Maybe Int
banned_until_date_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"chatMemberStatusBanned"
, Key
"banned_until_date" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
banned_until_date_
]