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.WebAppOpenParameters as WebAppOpenParameters

-- | 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 WebAppOpenParameters
parameters      :: Maybe WebAppOpenParameters.WebAppOpenParameters -- ^ Parameters to use to open the Web App
    }
  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_
      , parameters :: GetMainWebApp -> Maybe WebAppOpenParameters
parameters      = Maybe WebAppOpenParameters
parameters_
      }
        = 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
"parameters"      String -> Maybe WebAppOpenParameters -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe WebAppOpenParameters
parameters_
          ]

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_
      , parameters :: GetMainWebApp -> 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
"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
"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_
          ]

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
    , parameters :: Maybe WebAppOpenParameters
parameters      = Maybe WebAppOpenParameters
forall a. Maybe a
Nothing
    }