module TD.Query.GetPersonalChatHistory
  (GetPersonalChatHistory(..)
  , defaultGetPersonalChatHistory
  ) where

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

-- | Returns messages in the personal chat of a given user; for bots only. Returns 'TD.Data.Messages.Messages'
data GetPersonalChatHistory
  = GetPersonalChatHistory
    { GetPersonalChatHistory -> Maybe Int
user_id :: Maybe Int -- ^ User identifier
    , GetPersonalChatHistory -> Maybe Int
limit   :: Maybe Int -- ^ The maximum number of messages to be returned; 1-20
    }
  deriving (GetPersonalChatHistory -> GetPersonalChatHistory -> Bool
(GetPersonalChatHistory -> GetPersonalChatHistory -> Bool)
-> (GetPersonalChatHistory -> GetPersonalChatHistory -> Bool)
-> Eq GetPersonalChatHistory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetPersonalChatHistory -> GetPersonalChatHistory -> Bool
== :: GetPersonalChatHistory -> GetPersonalChatHistory -> Bool
$c/= :: GetPersonalChatHistory -> GetPersonalChatHistory -> Bool
/= :: GetPersonalChatHistory -> GetPersonalChatHistory -> Bool
Eq, Int -> GetPersonalChatHistory -> ShowS
[GetPersonalChatHistory] -> ShowS
GetPersonalChatHistory -> String
(Int -> GetPersonalChatHistory -> ShowS)
-> (GetPersonalChatHistory -> String)
-> ([GetPersonalChatHistory] -> ShowS)
-> Show GetPersonalChatHistory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetPersonalChatHistory -> ShowS
showsPrec :: Int -> GetPersonalChatHistory -> ShowS
$cshow :: GetPersonalChatHistory -> String
show :: GetPersonalChatHistory -> String
$cshowList :: [GetPersonalChatHistory] -> ShowS
showList :: [GetPersonalChatHistory] -> ShowS
Show)

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

instance AT.ToJSON GetPersonalChatHistory where
  toJSON :: GetPersonalChatHistory -> Value
toJSON
    GetPersonalChatHistory
      { user_id :: GetPersonalChatHistory -> Maybe Int
user_id = Maybe Int
user_id_
      , limit :: GetPersonalChatHistory -> 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
"getPersonalChatHistory"
          , Key
"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
user_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_
          ]

defaultGetPersonalChatHistory :: GetPersonalChatHistory
defaultGetPersonalChatHistory :: GetPersonalChatHistory
defaultGetPersonalChatHistory =
  GetPersonalChatHistory
    { user_id :: Maybe Int
user_id = Maybe Int
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit   = Maybe Int
forall a. Maybe a
Nothing
    }