module TD.Query.GetMainWebApp
  (GetMainWebApp(..)
  , defaultGetMainWebApp
  ) 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.ThemeParameters as ThemeParameters

-- | Returns information needed to open the main Web App of a bot. Returns 'TD.Data.MainWebApp.MainWebApp'
data GetMainWebApp
  = GetMainWebApp
    { GetMainWebApp -> Maybe Int
chat_id          :: Maybe Int                             -- ^ Identifier of the chat in which the Web App is opened; pass 0 if none
    , GetMainWebApp -> Maybe Int
bot_user_id      :: Maybe Int                             -- ^ Identifier of the target bot
    , GetMainWebApp -> Maybe Text
start_parameter  :: Maybe T.Text                          -- ^ Start parameter from internalLinkTypeMainWebApp
    , GetMainWebApp -> Maybe ThemeParameters
theme            :: Maybe ThemeParameters.ThemeParameters -- ^ Preferred Web App theme; pass null to use the default theme
    , GetMainWebApp -> Maybe Text
application_name :: Maybe T.Text                          -- ^ Short name of the current application; 0-64 English letters, digits, and underscores
    }
  deriving (GetMainWebApp -> GetMainWebApp -> Bool
(GetMainWebApp -> GetMainWebApp -> Bool)
-> (GetMainWebApp -> GetMainWebApp -> Bool) -> Eq GetMainWebApp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetMainWebApp -> GetMainWebApp -> Bool
== :: GetMainWebApp -> GetMainWebApp -> Bool
$c/= :: GetMainWebApp -> GetMainWebApp -> Bool
/= :: GetMainWebApp -> GetMainWebApp -> Bool
Eq, Int -> GetMainWebApp -> ShowS
[GetMainWebApp] -> ShowS
GetMainWebApp -> String
(Int -> GetMainWebApp -> ShowS)
-> (GetMainWebApp -> String)
-> ([GetMainWebApp] -> ShowS)
-> Show GetMainWebApp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetMainWebApp -> ShowS
showsPrec :: Int -> GetMainWebApp -> ShowS
$cshow :: GetMainWebApp -> String
show :: GetMainWebApp -> String
$cshowList :: [GetMainWebApp] -> ShowS
showList :: [GetMainWebApp] -> ShowS
Show)

instance I.ShortShow GetMainWebApp where
  shortShow :: GetMainWebApp -> String
shortShow
    GetMainWebApp
      { chat_id :: GetMainWebApp -> Maybe Int
chat_id          = Maybe Int
chat_id_
      , bot_user_id :: GetMainWebApp -> Maybe Int
bot_user_id      = Maybe Int
bot_user_id_
      , start_parameter :: GetMainWebApp -> Maybe Text
start_parameter  = Maybe Text
start_parameter_
      , theme :: GetMainWebApp -> Maybe ThemeParameters
theme            = Maybe ThemeParameters
theme_
      , application_name :: GetMainWebApp -> Maybe Text
application_name = Maybe Text
application_name_
      }
        = String
"GetMainWebApp"
          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
"start_parameter"  String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
start_parameter_
          , String
"theme"            String -> Maybe ThemeParameters -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ThemeParameters
theme_
          , String
"application_name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
application_name_
          ]

instance AT.ToJSON GetMainWebApp where
  toJSON :: GetMainWebApp -> Value
toJSON
    GetMainWebApp
      { chat_id :: GetMainWebApp -> Maybe Int
chat_id          = Maybe Int
chat_id_
      , bot_user_id :: GetMainWebApp -> Maybe Int
bot_user_id      = Maybe Int
bot_user_id_
      , start_parameter :: GetMainWebApp -> Maybe Text
start_parameter  = Maybe Text
start_parameter_
      , theme :: GetMainWebApp -> Maybe ThemeParameters
theme            = Maybe ThemeParameters
theme_
      , application_name :: GetMainWebApp -> Maybe Text
application_name = Maybe Text
application_name_
      }
        = [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
"getMainWebApp"
          , 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
"start_parameter"  Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
start_parameter_
          , Key
"theme"            Key -> Maybe ThemeParameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ThemeParameters
theme_
          , Key
"application_name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
application_name_
          ]

defaultGetMainWebApp :: GetMainWebApp
defaultGetMainWebApp :: GetMainWebApp
defaultGetMainWebApp =
  GetMainWebApp
    { 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
    , start_parameter :: Maybe Text
start_parameter  = Maybe Text
forall a. Maybe a
Nothing
    , theme :: Maybe ThemeParameters
theme            = Maybe ThemeParameters
forall a. Maybe a
Nothing
    , application_name :: Maybe Text
application_name = Maybe Text
forall a. Maybe a
Nothing
    }