module TD.Query.OpenWebApp
(OpenWebApp(..)
, defaultOpenWebApp
) 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.InputMessageReplyTo as InputMessageReplyTo
import qualified TD.Data.WebAppOpenParameters as WebAppOpenParameters
data OpenWebApp
= OpenWebApp
{ OpenWebApp -> Maybe Int
chat_id :: Maybe Int
, OpenWebApp -> Maybe Int
bot_user_id :: Maybe Int
, OpenWebApp -> Maybe Text
url :: Maybe T.Text
, OpenWebApp -> Maybe Int
message_thread_id :: Maybe Int
, OpenWebApp -> Maybe InputMessageReplyTo
reply_to :: Maybe InputMessageReplyTo.InputMessageReplyTo
, OpenWebApp -> Maybe WebAppOpenParameters
parameters :: Maybe WebAppOpenParameters.WebAppOpenParameters
}
deriving (OpenWebApp -> OpenWebApp -> Bool
(OpenWebApp -> OpenWebApp -> Bool)
-> (OpenWebApp -> OpenWebApp -> Bool) -> Eq OpenWebApp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OpenWebApp -> OpenWebApp -> Bool
== :: OpenWebApp -> OpenWebApp -> Bool
$c/= :: OpenWebApp -> OpenWebApp -> Bool
/= :: OpenWebApp -> OpenWebApp -> Bool
Eq, Int -> OpenWebApp -> ShowS
[OpenWebApp] -> ShowS
OpenWebApp -> String
(Int -> OpenWebApp -> ShowS)
-> (OpenWebApp -> String)
-> ([OpenWebApp] -> ShowS)
-> Show OpenWebApp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OpenWebApp -> ShowS
showsPrec :: Int -> OpenWebApp -> ShowS
$cshow :: OpenWebApp -> String
show :: OpenWebApp -> String
$cshowList :: [OpenWebApp] -> ShowS
showList :: [OpenWebApp] -> ShowS
Show)
instance I.ShortShow OpenWebApp where
shortShow :: OpenWebApp -> String
shortShow
OpenWebApp
{ chat_id :: OpenWebApp -> Maybe Int
chat_id = Maybe Int
chat_id_
, bot_user_id :: OpenWebApp -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
, url :: OpenWebApp -> Maybe Text
url = Maybe Text
url_
, message_thread_id :: OpenWebApp -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
, reply_to :: OpenWebApp -> Maybe InputMessageReplyTo
reply_to = Maybe InputMessageReplyTo
reply_to_
, parameters :: OpenWebApp -> Maybe WebAppOpenParameters
parameters = Maybe WebAppOpenParameters
parameters_
}
= String
"OpenWebApp"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
, String
"bot_user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
bot_user_id_
, String
"url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
url_
, String
"message_thread_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_thread_id_
, String
"reply_to" String -> Maybe InputMessageReplyTo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputMessageReplyTo
reply_to_
, String
"parameters" String -> Maybe WebAppOpenParameters -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe WebAppOpenParameters
parameters_
]
instance AT.ToJSON OpenWebApp where
toJSON :: OpenWebApp -> Value
toJSON
OpenWebApp
{ chat_id :: OpenWebApp -> Maybe Int
chat_id = Maybe Int
chat_id_
, bot_user_id :: OpenWebApp -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
, url :: OpenWebApp -> Maybe Text
url = Maybe Text
url_
, message_thread_id :: OpenWebApp -> Maybe Int
message_thread_id = Maybe Int
message_thread_id_
, reply_to :: OpenWebApp -> Maybe InputMessageReplyTo
reply_to = Maybe InputMessageReplyTo
reply_to_
, parameters :: OpenWebApp -> Maybe WebAppOpenParameters
parameters = Maybe WebAppOpenParameters
parameters_
}
= [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
"openWebApp"
, Key
"chat_id" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
chat_id_
, Key
"bot_user_id" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
bot_user_id_
, Key
"url" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
url_
, Key
"message_thread_id" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
message_thread_id_
, Key
"reply_to" Key -> Maybe InputMessageReplyTo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputMessageReplyTo
reply_to_
, Key
"parameters" Key -> Maybe WebAppOpenParameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe WebAppOpenParameters
parameters_
]
defaultOpenWebApp :: OpenWebApp
defaultOpenWebApp :: OpenWebApp
defaultOpenWebApp =
OpenWebApp
{ chat_id :: Maybe Int
chat_id = Maybe Int
forall a. Maybe a
Nothing
, bot_user_id :: Maybe Int
bot_user_id = Maybe Int
forall a. Maybe a
Nothing
, url :: Maybe Text
url = Maybe Text
forall a. Maybe a
Nothing
, message_thread_id :: Maybe Int
message_thread_id = Maybe Int
forall a. Maybe a
Nothing
, reply_to :: Maybe InputMessageReplyTo
reply_to = Maybe InputMessageReplyTo
forall a. Maybe a
Nothing
, parameters :: Maybe WebAppOpenParameters
parameters = Maybe WebAppOpenParameters
forall a. Maybe a
Nothing
}