module TD.Query.SearchRecentlyFoundChats
  (SearchRecentlyFoundChats(..)
  , defaultSearchRecentlyFoundChats
  ) 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

-- | Searches for the specified query in the title and username of up to 50 recently found chats; this is an offline request. Returns 'TD.Data.Chats.Chats'
data SearchRecentlyFoundChats
  = SearchRecentlyFoundChats
    { SearchRecentlyFoundChats -> Maybe Text
query :: Maybe T.Text -- ^ Query to search for
    , SearchRecentlyFoundChats -> Maybe Int
limit :: Maybe Int    -- ^ The maximum number of chats to be returned
    }
  deriving (SearchRecentlyFoundChats -> SearchRecentlyFoundChats -> Bool
(SearchRecentlyFoundChats -> SearchRecentlyFoundChats -> Bool)
-> (SearchRecentlyFoundChats -> SearchRecentlyFoundChats -> Bool)
-> Eq SearchRecentlyFoundChats
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SearchRecentlyFoundChats -> SearchRecentlyFoundChats -> Bool
== :: SearchRecentlyFoundChats -> SearchRecentlyFoundChats -> Bool
$c/= :: SearchRecentlyFoundChats -> SearchRecentlyFoundChats -> Bool
/= :: SearchRecentlyFoundChats -> SearchRecentlyFoundChats -> Bool
Eq, Int -> SearchRecentlyFoundChats -> ShowS
[SearchRecentlyFoundChats] -> ShowS
SearchRecentlyFoundChats -> String
(Int -> SearchRecentlyFoundChats -> ShowS)
-> (SearchRecentlyFoundChats -> String)
-> ([SearchRecentlyFoundChats] -> ShowS)
-> Show SearchRecentlyFoundChats
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SearchRecentlyFoundChats -> ShowS
showsPrec :: Int -> SearchRecentlyFoundChats -> ShowS
$cshow :: SearchRecentlyFoundChats -> String
show :: SearchRecentlyFoundChats -> String
$cshowList :: [SearchRecentlyFoundChats] -> ShowS
showList :: [SearchRecentlyFoundChats] -> ShowS
Show)

instance I.ShortShow SearchRecentlyFoundChats where
  shortShow :: SearchRecentlyFoundChats -> String
shortShow
    SearchRecentlyFoundChats
      { query :: SearchRecentlyFoundChats -> Maybe Text
query = Maybe Text
query_
      , limit :: SearchRecentlyFoundChats -> Maybe Int
limit = Maybe Int
limit_
      }
        = String
"SearchRecentlyFoundChats"
          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_
          , String
"limit" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

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

defaultSearchRecentlyFoundChats :: SearchRecentlyFoundChats
defaultSearchRecentlyFoundChats :: SearchRecentlyFoundChats
defaultSearchRecentlyFoundChats =
  SearchRecentlyFoundChats
    { query :: Maybe Text
query = Maybe Text
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit = Maybe Int
forall a. Maybe a
Nothing
    }