module TD.Data.ChatPermissions
( ChatPermissions(..)
, defaultChatPermissions
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data ChatPermissions
= ChatPermissions
{ ChatPermissions -> Maybe Bool
can_send_basic_messages :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_send_audios :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_send_documents :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_send_photos :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_send_videos :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_send_video_notes :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_send_voice_notes :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_send_polls :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_send_other_messages :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_add_link_previews :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_change_info :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_invite_users :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_pin_messages :: Maybe Bool
, ChatPermissions -> Maybe Bool
can_create_topics :: Maybe Bool
}
deriving (ChatPermissions -> ChatPermissions -> Bool
(ChatPermissions -> ChatPermissions -> Bool)
-> (ChatPermissions -> ChatPermissions -> Bool)
-> Eq ChatPermissions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatPermissions -> ChatPermissions -> Bool
== :: ChatPermissions -> ChatPermissions -> Bool
$c/= :: ChatPermissions -> ChatPermissions -> Bool
/= :: ChatPermissions -> ChatPermissions -> Bool
Eq, Int -> ChatPermissions -> ShowS
[ChatPermissions] -> ShowS
ChatPermissions -> String
(Int -> ChatPermissions -> ShowS)
-> (ChatPermissions -> String)
-> ([ChatPermissions] -> ShowS)
-> Show ChatPermissions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatPermissions -> ShowS
showsPrec :: Int -> ChatPermissions -> ShowS
$cshow :: ChatPermissions -> String
show :: ChatPermissions -> String
$cshowList :: [ChatPermissions] -> ShowS
showList :: [ChatPermissions] -> ShowS
Show)
instance I.ShortShow ChatPermissions where
shortShow :: ChatPermissions -> String
shortShow ChatPermissions
{ can_send_basic_messages :: ChatPermissions -> Maybe Bool
can_send_basic_messages = Maybe Bool
can_send_basic_messages_
, can_send_audios :: ChatPermissions -> Maybe Bool
can_send_audios = Maybe Bool
can_send_audios_
, can_send_documents :: ChatPermissions -> Maybe Bool
can_send_documents = Maybe Bool
can_send_documents_
, can_send_photos :: ChatPermissions -> Maybe Bool
can_send_photos = Maybe Bool
can_send_photos_
, can_send_videos :: ChatPermissions -> Maybe Bool
can_send_videos = Maybe Bool
can_send_videos_
, can_send_video_notes :: ChatPermissions -> Maybe Bool
can_send_video_notes = Maybe Bool
can_send_video_notes_
, can_send_voice_notes :: ChatPermissions -> Maybe Bool
can_send_voice_notes = Maybe Bool
can_send_voice_notes_
, can_send_polls :: ChatPermissions -> Maybe Bool
can_send_polls = Maybe Bool
can_send_polls_
, can_send_other_messages :: ChatPermissions -> Maybe Bool
can_send_other_messages = Maybe Bool
can_send_other_messages_
, can_add_link_previews :: ChatPermissions -> Maybe Bool
can_add_link_previews = Maybe Bool
can_add_link_previews_
, can_change_info :: ChatPermissions -> Maybe Bool
can_change_info = Maybe Bool
can_change_info_
, can_invite_users :: ChatPermissions -> Maybe Bool
can_invite_users = Maybe Bool
can_invite_users_
, can_pin_messages :: ChatPermissions -> Maybe Bool
can_pin_messages = Maybe Bool
can_pin_messages_
, can_create_topics :: ChatPermissions -> Maybe Bool
can_create_topics = Maybe Bool
can_create_topics_
}
= String
"ChatPermissions"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"can_send_basic_messages" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_send_basic_messages_
, String
"can_send_audios" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_send_audios_
, String
"can_send_documents" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_send_documents_
, String
"can_send_photos" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_send_photos_
, String
"can_send_videos" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_send_videos_
, String
"can_send_video_notes" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_send_video_notes_
, String
"can_send_voice_notes" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_send_voice_notes_
, String
"can_send_polls" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_send_polls_
, String
"can_send_other_messages" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_send_other_messages_
, String
"can_add_link_previews" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_add_link_previews_
, String
"can_change_info" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_change_info_
, String
"can_invite_users" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_invite_users_
, String
"can_pin_messages" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_pin_messages_
, String
"can_create_topics" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_create_topics_
]
instance AT.FromJSON ChatPermissions where
parseJSON :: Value -> Parser ChatPermissions
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
"chatPermissions" -> Value -> Parser ChatPermissions
parseChatPermissions Value
v
String
_ -> Parser ChatPermissions
forall a. Monoid a => a
mempty
where
parseChatPermissions :: A.Value -> AT.Parser ChatPermissions
parseChatPermissions :: Value -> Parser ChatPermissions
parseChatPermissions = String
-> (Object -> Parser ChatPermissions)
-> Value
-> Parser ChatPermissions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatPermissions" ((Object -> Parser ChatPermissions)
-> Value -> Parser ChatPermissions)
-> (Object -> Parser ChatPermissions)
-> Value
-> Parser ChatPermissions
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Bool
can_send_basic_messages_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_send_basic_messages"
Maybe Bool
can_send_audios_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_send_audios"
Maybe Bool
can_send_documents_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_send_documents"
Maybe Bool
can_send_photos_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_send_photos"
Maybe Bool
can_send_videos_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_send_videos"
Maybe Bool
can_send_video_notes_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_send_video_notes"
Maybe Bool
can_send_voice_notes_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_send_voice_notes"
Maybe Bool
can_send_polls_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_send_polls"
Maybe Bool
can_send_other_messages_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_send_other_messages"
Maybe Bool
can_add_link_previews_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_add_link_previews"
Maybe Bool
can_change_info_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_change_info"
Maybe Bool
can_invite_users_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_invite_users"
Maybe Bool
can_pin_messages_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_pin_messages"
Maybe Bool
can_create_topics_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_create_topics"
ChatPermissions -> Parser ChatPermissions
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatPermissions -> Parser ChatPermissions)
-> ChatPermissions -> Parser ChatPermissions
forall a b. (a -> b) -> a -> b
$ ChatPermissions
{ can_send_basic_messages :: Maybe Bool
can_send_basic_messages = Maybe Bool
can_send_basic_messages_
, can_send_audios :: Maybe Bool
can_send_audios = Maybe Bool
can_send_audios_
, can_send_documents :: Maybe Bool
can_send_documents = Maybe Bool
can_send_documents_
, can_send_photos :: Maybe Bool
can_send_photos = Maybe Bool
can_send_photos_
, can_send_videos :: Maybe Bool
can_send_videos = Maybe Bool
can_send_videos_
, can_send_video_notes :: Maybe Bool
can_send_video_notes = Maybe Bool
can_send_video_notes_
, can_send_voice_notes :: Maybe Bool
can_send_voice_notes = Maybe Bool
can_send_voice_notes_
, can_send_polls :: Maybe Bool
can_send_polls = Maybe Bool
can_send_polls_
, can_send_other_messages :: Maybe Bool
can_send_other_messages = Maybe Bool
can_send_other_messages_
, can_add_link_previews :: Maybe Bool
can_add_link_previews = Maybe Bool
can_add_link_previews_
, can_change_info :: Maybe Bool
can_change_info = Maybe Bool
can_change_info_
, can_invite_users :: Maybe Bool
can_invite_users = Maybe Bool
can_invite_users_
, can_pin_messages :: Maybe Bool
can_pin_messages = Maybe Bool
can_pin_messages_
, can_create_topics :: Maybe Bool
can_create_topics = Maybe Bool
can_create_topics_
}
parseJSON Value
_ = Parser ChatPermissions
forall a. Monoid a => a
mempty
instance AT.ToJSON ChatPermissions where
toJSON :: ChatPermissions -> Value
toJSON ChatPermissions
{ can_send_basic_messages :: ChatPermissions -> Maybe Bool
can_send_basic_messages = Maybe Bool
can_send_basic_messages_
, can_send_audios :: ChatPermissions -> Maybe Bool
can_send_audios = Maybe Bool
can_send_audios_
, can_send_documents :: ChatPermissions -> Maybe Bool
can_send_documents = Maybe Bool
can_send_documents_
, can_send_photos :: ChatPermissions -> Maybe Bool
can_send_photos = Maybe Bool
can_send_photos_
, can_send_videos :: ChatPermissions -> Maybe Bool
can_send_videos = Maybe Bool
can_send_videos_
, can_send_video_notes :: ChatPermissions -> Maybe Bool
can_send_video_notes = Maybe Bool
can_send_video_notes_
, can_send_voice_notes :: ChatPermissions -> Maybe Bool
can_send_voice_notes = Maybe Bool
can_send_voice_notes_
, can_send_polls :: ChatPermissions -> Maybe Bool
can_send_polls = Maybe Bool
can_send_polls_
, can_send_other_messages :: ChatPermissions -> Maybe Bool
can_send_other_messages = Maybe Bool
can_send_other_messages_
, can_add_link_previews :: ChatPermissions -> Maybe Bool
can_add_link_previews = Maybe Bool
can_add_link_previews_
, can_change_info :: ChatPermissions -> Maybe Bool
can_change_info = Maybe Bool
can_change_info_
, can_invite_users :: ChatPermissions -> Maybe Bool
can_invite_users = Maybe Bool
can_invite_users_
, can_pin_messages :: ChatPermissions -> Maybe Bool
can_pin_messages = Maybe Bool
can_pin_messages_
, can_create_topics :: ChatPermissions -> Maybe Bool
can_create_topics = Maybe Bool
can_create_topics_
}
= [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
"chatPermissions"
, Key
"can_send_basic_messages" 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_send_basic_messages_
, Key
"can_send_audios" 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_send_audios_
, Key
"can_send_documents" 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_send_documents_
, Key
"can_send_photos" 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_send_photos_
, Key
"can_send_videos" 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_send_videos_
, Key
"can_send_video_notes" 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_send_video_notes_
, Key
"can_send_voice_notes" 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_send_voice_notes_
, Key
"can_send_polls" 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_send_polls_
, Key
"can_send_other_messages" 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_send_other_messages_
, Key
"can_add_link_previews" 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_add_link_previews_
, Key
"can_change_info" 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_change_info_
, Key
"can_invite_users" 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_invite_users_
, Key
"can_pin_messages" 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_pin_messages_
, Key
"can_create_topics" 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_create_topics_
]
defaultChatPermissions :: ChatPermissions
defaultChatPermissions :: ChatPermissions
defaultChatPermissions =
ChatPermissions
{ can_send_basic_messages :: Maybe Bool
can_send_basic_messages = Maybe Bool
forall a. Maybe a
Nothing
, can_send_audios :: Maybe Bool
can_send_audios = Maybe Bool
forall a. Maybe a
Nothing
, can_send_documents :: Maybe Bool
can_send_documents = Maybe Bool
forall a. Maybe a
Nothing
, can_send_photos :: Maybe Bool
can_send_photos = Maybe Bool
forall a. Maybe a
Nothing
, can_send_videos :: Maybe Bool
can_send_videos = Maybe Bool
forall a. Maybe a
Nothing
, can_send_video_notes :: Maybe Bool
can_send_video_notes = Maybe Bool
forall a. Maybe a
Nothing
, can_send_voice_notes :: Maybe Bool
can_send_voice_notes = Maybe Bool
forall a. Maybe a
Nothing
, can_send_polls :: Maybe Bool
can_send_polls = Maybe Bool
forall a. Maybe a
Nothing
, can_send_other_messages :: Maybe Bool
can_send_other_messages = Maybe Bool
forall a. Maybe a
Nothing
, can_add_link_previews :: Maybe Bool
can_add_link_previews = Maybe Bool
forall a. Maybe a
Nothing
, can_change_info :: Maybe Bool
can_change_info = Maybe Bool
forall a. Maybe a
Nothing
, can_invite_users :: Maybe Bool
can_invite_users = Maybe Bool
forall a. Maybe a
Nothing
, can_pin_messages :: Maybe Bool
can_pin_messages = Maybe Bool
forall a. Maybe a
Nothing
, can_create_topics :: Maybe Bool
can_create_topics = Maybe Bool
forall a. Maybe a
Nothing
}