module TD.Query.GetGuardBotWebAppUrl
  (GetGuardBotWebAppUrl(..)
  , defaultGetGuardBotWebAppUrl
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.WebAppOpenParameters as WebAppOpenParameters

-- | Returns an HTTPS URL of a Web App of a guard bot to open after receiving chatJoinResultGuardBotApprovalRequired. Returns 'TD.Data.WebAppUrl.WebAppUrl'
data GetGuardBotWebAppUrl
  = GetGuardBotWebAppUrl
    { GetGuardBotWebAppUrl -> Maybe Int
query_id   :: Maybe Int                                       -- ^ Unique identifier of the join request as received in chatJoinResultGuardBotApprovalRequired
    , GetGuardBotWebAppUrl -> Maybe WebAppOpenParameters
parameters :: Maybe WebAppOpenParameters.WebAppOpenParameters -- ^ Parameters to use to open the Web App
    }
  deriving (GetGuardBotWebAppUrl -> GetGuardBotWebAppUrl -> Bool
(GetGuardBotWebAppUrl -> GetGuardBotWebAppUrl -> Bool)
-> (GetGuardBotWebAppUrl -> GetGuardBotWebAppUrl -> Bool)
-> Eq GetGuardBotWebAppUrl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetGuardBotWebAppUrl -> GetGuardBotWebAppUrl -> Bool
== :: GetGuardBotWebAppUrl -> GetGuardBotWebAppUrl -> Bool
$c/= :: GetGuardBotWebAppUrl -> GetGuardBotWebAppUrl -> Bool
/= :: GetGuardBotWebAppUrl -> GetGuardBotWebAppUrl -> Bool
Eq, Int -> GetGuardBotWebAppUrl -> ShowS
[GetGuardBotWebAppUrl] -> ShowS
GetGuardBotWebAppUrl -> String
(Int -> GetGuardBotWebAppUrl -> ShowS)
-> (GetGuardBotWebAppUrl -> String)
-> ([GetGuardBotWebAppUrl] -> ShowS)
-> Show GetGuardBotWebAppUrl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetGuardBotWebAppUrl -> ShowS
showsPrec :: Int -> GetGuardBotWebAppUrl -> ShowS
$cshow :: GetGuardBotWebAppUrl -> String
show :: GetGuardBotWebAppUrl -> String
$cshowList :: [GetGuardBotWebAppUrl] -> ShowS
showList :: [GetGuardBotWebAppUrl] -> ShowS
Show)

instance I.ShortShow GetGuardBotWebAppUrl where
  shortShow :: GetGuardBotWebAppUrl -> String
shortShow
    GetGuardBotWebAppUrl
      { query_id :: GetGuardBotWebAppUrl -> Maybe Int
query_id   = Maybe Int
query_id_
      , parameters :: GetGuardBotWebAppUrl -> Maybe WebAppOpenParameters
parameters = Maybe WebAppOpenParameters
parameters_
      }
        = String
"GetGuardBotWebAppUrl"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"query_id"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
query_id_
          , String
"parameters" String -> Maybe WebAppOpenParameters -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe WebAppOpenParameters
parameters_
          ]

instance AT.ToJSON GetGuardBotWebAppUrl where
  toJSON :: GetGuardBotWebAppUrl -> Value
toJSON
    GetGuardBotWebAppUrl
      { query_id :: GetGuardBotWebAppUrl -> Maybe Int
query_id   = Maybe Int
query_id_
      , parameters :: GetGuardBotWebAppUrl -> 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
"getGuardBotWebAppUrl"
          , Key
"query_id"   Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
query_id_
          , 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_
          ]

defaultGetGuardBotWebAppUrl :: GetGuardBotWebAppUrl
defaultGetGuardBotWebAppUrl :: GetGuardBotWebAppUrl
defaultGetGuardBotWebAppUrl =
  GetGuardBotWebAppUrl
    { query_id :: Maybe Int
query_id   = Maybe Int
forall a. Maybe a
Nothing
    , parameters :: Maybe WebAppOpenParameters
parameters = Maybe WebAppOpenParameters
forall a. Maybe a
Nothing
    }