module TD.Query.GetWebAppUrl
  (GetWebAppUrl(..)
  , defaultGetWebAppUrl
  ) 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 an HTTPS URL of a Web App to open from the side menu, a keyboardButtonTypeWebApp button, or an inlineQueryResultsButtonTypeWebApp button. Returns 'TD.Data.HttpUrl.HttpUrl'
data GetWebAppUrl
  = GetWebAppUrl
    { GetWebAppUrl -> Maybe Int
bot_user_id      :: Maybe Int                             -- ^ Identifier of the target bot
    , GetWebAppUrl -> Maybe Text
url              :: Maybe T.Text                          -- ^ The URL from a keyboardButtonTypeWebApp button, inlineQueryResultsButtonTypeWebApp button, or an empty string when the bot is opened from the side menu
    , GetWebAppUrl -> Maybe ThemeParameters
theme            :: Maybe ThemeParameters.ThemeParameters -- ^ Preferred Web App theme; pass null to use the default theme
    , GetWebAppUrl -> Maybe Text
application_name :: Maybe T.Text                          -- ^ Short name of the current application; 0-64 English letters, digits, and underscores
    }
  deriving (GetWebAppUrl -> GetWebAppUrl -> Bool
(GetWebAppUrl -> GetWebAppUrl -> Bool)
-> (GetWebAppUrl -> GetWebAppUrl -> Bool) -> Eq GetWebAppUrl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetWebAppUrl -> GetWebAppUrl -> Bool
== :: GetWebAppUrl -> GetWebAppUrl -> Bool
$c/= :: GetWebAppUrl -> GetWebAppUrl -> Bool
/= :: GetWebAppUrl -> GetWebAppUrl -> Bool
Eq, Int -> GetWebAppUrl -> ShowS
[GetWebAppUrl] -> ShowS
GetWebAppUrl -> String
(Int -> GetWebAppUrl -> ShowS)
-> (GetWebAppUrl -> String)
-> ([GetWebAppUrl] -> ShowS)
-> Show GetWebAppUrl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetWebAppUrl -> ShowS
showsPrec :: Int -> GetWebAppUrl -> ShowS
$cshow :: GetWebAppUrl -> String
show :: GetWebAppUrl -> String
$cshowList :: [GetWebAppUrl] -> ShowS
showList :: [GetWebAppUrl] -> ShowS
Show)

instance I.ShortShow GetWebAppUrl where
  shortShow :: GetWebAppUrl -> String
shortShow
    GetWebAppUrl
      { bot_user_id :: GetWebAppUrl -> Maybe Int
bot_user_id      = Maybe Int
bot_user_id_
      , url :: GetWebAppUrl -> Maybe Text
url              = Maybe Text
url_
      , theme :: GetWebAppUrl -> Maybe ThemeParameters
theme            = Maybe ThemeParameters
theme_
      , application_name :: GetWebAppUrl -> Maybe Text
application_name = Maybe Text
application_name_
      }
        = String
"GetWebAppUrl"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ 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
"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 GetWebAppUrl where
  toJSON :: GetWebAppUrl -> Value
toJSON
    GetWebAppUrl
      { bot_user_id :: GetWebAppUrl -> Maybe Int
bot_user_id      = Maybe Int
bot_user_id_
      , url :: GetWebAppUrl -> Maybe Text
url              = Maybe Text
url_
      , theme :: GetWebAppUrl -> Maybe ThemeParameters
theme            = Maybe ThemeParameters
theme_
      , application_name :: GetWebAppUrl -> 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
"getWebAppUrl"
          , 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
"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_
          ]

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