module TD.Query.CheckWebAppFileDownload
  (CheckWebAppFileDownload(..)
  , defaultCheckWebAppFileDownload
  ) 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

-- | Checks whether a file can be downloaded and saved locally by Web App request. Returns 'TD.Data.Ok.Ok'
data CheckWebAppFileDownload
  = CheckWebAppFileDownload
    { CheckWebAppFileDownload -> Maybe Int
bot_user_id :: Maybe Int    -- ^ Identifier of the bot, providing the Web App
    , CheckWebAppFileDownload -> Maybe Text
file_name   :: Maybe T.Text -- ^ Name of the file
    , CheckWebAppFileDownload -> Maybe Text
url         :: Maybe T.Text -- ^ URL of the file
    }
  deriving (CheckWebAppFileDownload -> CheckWebAppFileDownload -> Bool
(CheckWebAppFileDownload -> CheckWebAppFileDownload -> Bool)
-> (CheckWebAppFileDownload -> CheckWebAppFileDownload -> Bool)
-> Eq CheckWebAppFileDownload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CheckWebAppFileDownload -> CheckWebAppFileDownload -> Bool
== :: CheckWebAppFileDownload -> CheckWebAppFileDownload -> Bool
$c/= :: CheckWebAppFileDownload -> CheckWebAppFileDownload -> Bool
/= :: CheckWebAppFileDownload -> CheckWebAppFileDownload -> Bool
Eq, Int -> CheckWebAppFileDownload -> ShowS
[CheckWebAppFileDownload] -> ShowS
CheckWebAppFileDownload -> String
(Int -> CheckWebAppFileDownload -> ShowS)
-> (CheckWebAppFileDownload -> String)
-> ([CheckWebAppFileDownload] -> ShowS)
-> Show CheckWebAppFileDownload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CheckWebAppFileDownload -> ShowS
showsPrec :: Int -> CheckWebAppFileDownload -> ShowS
$cshow :: CheckWebAppFileDownload -> String
show :: CheckWebAppFileDownload -> String
$cshowList :: [CheckWebAppFileDownload] -> ShowS
showList :: [CheckWebAppFileDownload] -> ShowS
Show)

instance I.ShortShow CheckWebAppFileDownload where
  shortShow :: CheckWebAppFileDownload -> String
shortShow
    CheckWebAppFileDownload
      { bot_user_id :: CheckWebAppFileDownload -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
      , file_name :: CheckWebAppFileDownload -> Maybe Text
file_name   = Maybe Text
file_name_
      , url :: CheckWebAppFileDownload -> Maybe Text
url         = Maybe Text
url_
      }
        = String
"CheckWebAppFileDownload"
          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
"file_name"   String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
file_name_
          , String
"url"         String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
url_
          ]

instance AT.ToJSON CheckWebAppFileDownload where
  toJSON :: CheckWebAppFileDownload -> Value
toJSON
    CheckWebAppFileDownload
      { bot_user_id :: CheckWebAppFileDownload -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
      , file_name :: CheckWebAppFileDownload -> Maybe Text
file_name   = Maybe Text
file_name_
      , url :: CheckWebAppFileDownload -> Maybe Text
url         = Maybe Text
url_
      }
        = [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
"checkWebAppFileDownload"
          , 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
"file_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
file_name_
          , 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_
          ]

defaultCheckWebAppFileDownload :: CheckWebAppFileDownload
defaultCheckWebAppFileDownload :: CheckWebAppFileDownload
defaultCheckWebAppFileDownload =
  CheckWebAppFileDownload
    { bot_user_id :: Maybe Int
bot_user_id = Maybe Int
forall a. Maybe a
Nothing
    , file_name :: Maybe Text
file_name   = Maybe Text
forall a. Maybe a
Nothing
    , url :: Maybe Text
url         = Maybe Text
forall a. Maybe a
Nothing
    }