module TD.Query.ReadChatList
  (ReadChatList(..)
  ) where

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

-- | Traverse all chats in a chat list and marks all messages in the chats as read. Returns 'TD.Data.Ok.Ok'
data ReadChatList
  = ReadChatList
    { ReadChatList -> Maybe ChatList
chat_list :: Maybe ChatList.ChatList -- ^ Chat list in which to mark all chats as read
    }
  deriving (ReadChatList -> ReadChatList -> Bool
(ReadChatList -> ReadChatList -> Bool)
-> (ReadChatList -> ReadChatList -> Bool) -> Eq ReadChatList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReadChatList -> ReadChatList -> Bool
== :: ReadChatList -> ReadChatList -> Bool
$c/= :: ReadChatList -> ReadChatList -> Bool
/= :: ReadChatList -> ReadChatList -> Bool
Eq, Int -> ReadChatList -> ShowS
[ReadChatList] -> ShowS
ReadChatList -> String
(Int -> ReadChatList -> ShowS)
-> (ReadChatList -> String)
-> ([ReadChatList] -> ShowS)
-> Show ReadChatList
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReadChatList -> ShowS
showsPrec :: Int -> ReadChatList -> ShowS
$cshow :: ReadChatList -> String
show :: ReadChatList -> String
$cshowList :: [ReadChatList] -> ShowS
showList :: [ReadChatList] -> ShowS
Show)

instance I.ShortShow ReadChatList where
  shortShow :: ReadChatList -> String
shortShow
    ReadChatList
      { chat_list :: ReadChatList -> Maybe ChatList
chat_list = Maybe ChatList
chat_list_
      }
        = String
"ReadChatList"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_list" String -> Maybe ChatList -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatList
chat_list_
          ]

instance AT.ToJSON ReadChatList where
  toJSON :: ReadChatList -> Value
toJSON
    ReadChatList
      { chat_list :: ReadChatList -> Maybe ChatList
chat_list = Maybe ChatList
chat_list_
      }
        = [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
"readChatList"
          , Key
"chat_list" Key -> Maybe ChatList -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ChatList
chat_list_
          ]