module TD.Query.CloseWebApp
  (CloseWebApp(..)
  ) where

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

-- | Informs TDLib that a previously opened Web App was closed. Returns 'TD.Data.Ok.Ok'
data CloseWebApp
  = CloseWebApp
    { CloseWebApp -> Maybe Int
web_app_launch_id :: Maybe Int -- ^ Identifier of Web App launch, received from openWebApp
    }
  deriving (CloseWebApp -> CloseWebApp -> Bool
(CloseWebApp -> CloseWebApp -> Bool)
-> (CloseWebApp -> CloseWebApp -> Bool) -> Eq CloseWebApp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CloseWebApp -> CloseWebApp -> Bool
== :: CloseWebApp -> CloseWebApp -> Bool
$c/= :: CloseWebApp -> CloseWebApp -> Bool
/= :: CloseWebApp -> CloseWebApp -> Bool
Eq, Int -> CloseWebApp -> ShowS
[CloseWebApp] -> ShowS
CloseWebApp -> String
(Int -> CloseWebApp -> ShowS)
-> (CloseWebApp -> String)
-> ([CloseWebApp] -> ShowS)
-> Show CloseWebApp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CloseWebApp -> ShowS
showsPrec :: Int -> CloseWebApp -> ShowS
$cshow :: CloseWebApp -> String
show :: CloseWebApp -> String
$cshowList :: [CloseWebApp] -> ShowS
showList :: [CloseWebApp] -> ShowS
Show)

instance I.ShortShow CloseWebApp where
  shortShow :: CloseWebApp -> String
shortShow
    CloseWebApp
      { web_app_launch_id :: CloseWebApp -> Maybe Int
web_app_launch_id = Maybe Int
web_app_launch_id_
      }
        = String
"CloseWebApp"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"web_app_launch_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
web_app_launch_id_
          ]

instance AT.ToJSON CloseWebApp where
  toJSON :: CloseWebApp -> Value
toJSON
    CloseWebApp
      { web_app_launch_id :: CloseWebApp -> Maybe Int
web_app_launch_id = Maybe Int
web_app_launch_id_
      }
        = [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
"closeWebApp"
          , Key
"web_app_launch_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
web_app_launch_id_
          ]