module TD.Query.GetSearchSponsoredChats
  (GetSearchSponsoredChats(..)
  ) 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 sponsored chats to be shown in the search results. Returns 'TD.Data.SponsoredChats.SponsoredChats'
data GetSearchSponsoredChats
  = GetSearchSponsoredChats
    { GetSearchSponsoredChats -> Maybe Text
query :: Maybe T.Text -- ^ Query the user searches for
    }
  deriving (GetSearchSponsoredChats -> GetSearchSponsoredChats -> Bool
(GetSearchSponsoredChats -> GetSearchSponsoredChats -> Bool)
-> (GetSearchSponsoredChats -> GetSearchSponsoredChats -> Bool)
-> Eq GetSearchSponsoredChats
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetSearchSponsoredChats -> GetSearchSponsoredChats -> Bool
== :: GetSearchSponsoredChats -> GetSearchSponsoredChats -> Bool
$c/= :: GetSearchSponsoredChats -> GetSearchSponsoredChats -> Bool
/= :: GetSearchSponsoredChats -> GetSearchSponsoredChats -> Bool
Eq, Int -> GetSearchSponsoredChats -> ShowS
[GetSearchSponsoredChats] -> ShowS
GetSearchSponsoredChats -> String
(Int -> GetSearchSponsoredChats -> ShowS)
-> (GetSearchSponsoredChats -> String)
-> ([GetSearchSponsoredChats] -> ShowS)
-> Show GetSearchSponsoredChats
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetSearchSponsoredChats -> ShowS
showsPrec :: Int -> GetSearchSponsoredChats -> ShowS
$cshow :: GetSearchSponsoredChats -> String
show :: GetSearchSponsoredChats -> String
$cshowList :: [GetSearchSponsoredChats] -> ShowS
showList :: [GetSearchSponsoredChats] -> ShowS
Show)

instance I.ShortShow GetSearchSponsoredChats where
  shortShow :: GetSearchSponsoredChats -> String
shortShow
    GetSearchSponsoredChats
      { query :: GetSearchSponsoredChats -> Maybe Text
query = Maybe Text
query_
      }
        = String
"GetSearchSponsoredChats"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"query" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
query_
          ]

instance AT.ToJSON GetSearchSponsoredChats where
  toJSON :: GetSearchSponsoredChats -> Value
toJSON
    GetSearchSponsoredChats
      { query :: GetSearchSponsoredChats -> Maybe Text
query = Maybe Text
query_
      }
        = [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
"getSearchSponsoredChats"
          , Key
"query" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
query_
          ]