module TD.Query.SearchChatRecentLocationMessages
  (SearchChatRecentLocationMessages(..)
  , defaultSearchChatRecentLocationMessages
  ) where

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

-- | Returns information about the recent locations of chat members that were sent to the chat. Returns up to 1 location message per user. Returns 'TD.Data.Messages.Messages'
data SearchChatRecentLocationMessages
  = SearchChatRecentLocationMessages
    { SearchChatRecentLocationMessages -> Maybe Int
chat_id :: Maybe Int -- ^ Chat identifier
    , SearchChatRecentLocationMessages -> Maybe Int
limit   :: Maybe Int -- ^ The maximum number of messages to be returned
    }
  deriving (SearchChatRecentLocationMessages
-> SearchChatRecentLocationMessages -> Bool
(SearchChatRecentLocationMessages
 -> SearchChatRecentLocationMessages -> Bool)
-> (SearchChatRecentLocationMessages
    -> SearchChatRecentLocationMessages -> Bool)
-> Eq SearchChatRecentLocationMessages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SearchChatRecentLocationMessages
-> SearchChatRecentLocationMessages -> Bool
== :: SearchChatRecentLocationMessages
-> SearchChatRecentLocationMessages -> Bool
$c/= :: SearchChatRecentLocationMessages
-> SearchChatRecentLocationMessages -> Bool
/= :: SearchChatRecentLocationMessages
-> SearchChatRecentLocationMessages -> Bool
Eq, Int -> SearchChatRecentLocationMessages -> ShowS
[SearchChatRecentLocationMessages] -> ShowS
SearchChatRecentLocationMessages -> String
(Int -> SearchChatRecentLocationMessages -> ShowS)
-> (SearchChatRecentLocationMessages -> String)
-> ([SearchChatRecentLocationMessages] -> ShowS)
-> Show SearchChatRecentLocationMessages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SearchChatRecentLocationMessages -> ShowS
showsPrec :: Int -> SearchChatRecentLocationMessages -> ShowS
$cshow :: SearchChatRecentLocationMessages -> String
show :: SearchChatRecentLocationMessages -> String
$cshowList :: [SearchChatRecentLocationMessages] -> ShowS
showList :: [SearchChatRecentLocationMessages] -> ShowS
Show)

instance I.ShortShow SearchChatRecentLocationMessages where
  shortShow :: SearchChatRecentLocationMessages -> String
shortShow
    SearchChatRecentLocationMessages
      { chat_id :: SearchChatRecentLocationMessages -> Maybe Int
chat_id = Maybe Int
chat_id_
      , limit :: SearchChatRecentLocationMessages -> Maybe Int
limit   = Maybe Int
limit_
      }
        = String
"SearchChatRecentLocationMessages"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
          , String
"limit"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON SearchChatRecentLocationMessages where
  toJSON :: SearchChatRecentLocationMessages -> Value
toJSON
    SearchChatRecentLocationMessages
      { chat_id :: SearchChatRecentLocationMessages -> Maybe Int
chat_id = Maybe Int
chat_id_
      , limit :: SearchChatRecentLocationMessages -> 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
"searchChatRecentLocationMessages"
          , Key
"chat_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
chat_id_
          , 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_
          ]

defaultSearchChatRecentLocationMessages :: SearchChatRecentLocationMessages
defaultSearchChatRecentLocationMessages :: SearchChatRecentLocationMessages
defaultSearchChatRecentLocationMessages =
  SearchChatRecentLocationMessages
    { chat_id :: Maybe Int
chat_id = Maybe Int
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit   = Maybe Int
forall a. Maybe a
Nothing
    }