module TD.Query.AddRecentlyFoundChat
  (AddRecentlyFoundChat(..)
  ) where

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

-- | Adds a chat to the list of recently found chats. The chat is added to the beginning of the list. If the chat is already in the list, it will be removed from the list first. Returns 'TD.Data.Ok.Ok'
data AddRecentlyFoundChat
  = AddRecentlyFoundChat
    { AddRecentlyFoundChat -> Maybe Int
chat_id :: Maybe Int -- ^ Identifier of the chat to add
    }
  deriving (AddRecentlyFoundChat -> AddRecentlyFoundChat -> Bool
(AddRecentlyFoundChat -> AddRecentlyFoundChat -> Bool)
-> (AddRecentlyFoundChat -> AddRecentlyFoundChat -> Bool)
-> Eq AddRecentlyFoundChat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddRecentlyFoundChat -> AddRecentlyFoundChat -> Bool
== :: AddRecentlyFoundChat -> AddRecentlyFoundChat -> Bool
$c/= :: AddRecentlyFoundChat -> AddRecentlyFoundChat -> Bool
/= :: AddRecentlyFoundChat -> AddRecentlyFoundChat -> Bool
Eq, Int -> AddRecentlyFoundChat -> ShowS
[AddRecentlyFoundChat] -> ShowS
AddRecentlyFoundChat -> String
(Int -> AddRecentlyFoundChat -> ShowS)
-> (AddRecentlyFoundChat -> String)
-> ([AddRecentlyFoundChat] -> ShowS)
-> Show AddRecentlyFoundChat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddRecentlyFoundChat -> ShowS
showsPrec :: Int -> AddRecentlyFoundChat -> ShowS
$cshow :: AddRecentlyFoundChat -> String
show :: AddRecentlyFoundChat -> String
$cshowList :: [AddRecentlyFoundChat] -> ShowS
showList :: [AddRecentlyFoundChat] -> ShowS
Show)

instance I.ShortShow AddRecentlyFoundChat where
  shortShow :: AddRecentlyFoundChat -> String
shortShow
    AddRecentlyFoundChat
      { chat_id :: AddRecentlyFoundChat -> Maybe Int
chat_id = Maybe Int
chat_id_
      }
        = String
"AddRecentlyFoundChat"
          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_
          ]

instance AT.ToJSON AddRecentlyFoundChat where
  toJSON :: AddRecentlyFoundChat -> Value
toJSON
    AddRecentlyFoundChat
      { chat_id :: AddRecentlyFoundChat -> Maybe Int
chat_id = Maybe Int
chat_id_
      }
        = [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
"addRecentlyFoundChat"
          , 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_
          ]