module TD.Query.SearchWebApp
  (SearchWebApp(..)
  , defaultSearchWebApp
  ) 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

-- | Returns information about a Web App by its short name. Returns a 404 error if the Web App is not found. Returns 'TD.Data.FoundWebApp.FoundWebApp'
data SearchWebApp
  = SearchWebApp
    { SearchWebApp -> Maybe Int
bot_user_id        :: Maybe Int    -- ^ Identifier of the target bot
    , SearchWebApp -> Maybe Text
web_app_short_name :: Maybe T.Text -- ^ Short name of the Web App
    }
  deriving (SearchWebApp -> SearchWebApp -> Bool
(SearchWebApp -> SearchWebApp -> Bool)
-> (SearchWebApp -> SearchWebApp -> Bool) -> Eq SearchWebApp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SearchWebApp -> SearchWebApp -> Bool
== :: SearchWebApp -> SearchWebApp -> Bool
$c/= :: SearchWebApp -> SearchWebApp -> Bool
/= :: SearchWebApp -> SearchWebApp -> Bool
Eq, Int -> SearchWebApp -> ShowS
[SearchWebApp] -> ShowS
SearchWebApp -> String
(Int -> SearchWebApp -> ShowS)
-> (SearchWebApp -> String)
-> ([SearchWebApp] -> ShowS)
-> Show SearchWebApp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SearchWebApp -> ShowS
showsPrec :: Int -> SearchWebApp -> ShowS
$cshow :: SearchWebApp -> String
show :: SearchWebApp -> String
$cshowList :: [SearchWebApp] -> ShowS
showList :: [SearchWebApp] -> ShowS
Show)

instance I.ShortShow SearchWebApp where
  shortShow :: SearchWebApp -> String
shortShow
    SearchWebApp
      { bot_user_id :: SearchWebApp -> Maybe Int
bot_user_id        = Maybe Int
bot_user_id_
      , web_app_short_name :: SearchWebApp -> Maybe Text
web_app_short_name = Maybe Text
web_app_short_name_
      }
        = String
"SearchWebApp"
          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
"web_app_short_name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
web_app_short_name_
          ]

instance AT.ToJSON SearchWebApp where
  toJSON :: SearchWebApp -> Value
toJSON
    SearchWebApp
      { bot_user_id :: SearchWebApp -> Maybe Int
bot_user_id        = Maybe Int
bot_user_id_
      , web_app_short_name :: SearchWebApp -> Maybe Text
web_app_short_name = Maybe Text
web_app_short_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
"searchWebApp"
          , 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
"web_app_short_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
web_app_short_name_
          ]

defaultSearchWebApp :: SearchWebApp
defaultSearchWebApp :: SearchWebApp
defaultSearchWebApp =
  SearchWebApp
    { bot_user_id :: Maybe Int
bot_user_id        = Maybe Int
forall a. Maybe a
Nothing
    , web_app_short_name :: Maybe Text
web_app_short_name = Maybe Text
forall a. Maybe a
Nothing
    }