module TD.Query.AddChatToList
  (AddChatToList(..)
  , defaultAddChatToList
  ) 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

-- | Adds a chat to a chat list. A chat can't be simultaneously in Main and Archive chat lists, so it is automatically removed from another one if needed. Returns 'TD.Data.Ok.Ok'
data AddChatToList
  = AddChatToList
    { AddChatToList -> Maybe Int
chat_id   :: Maybe Int               -- ^ Chat identifier
    , AddChatToList -> Maybe ChatList
chat_list :: Maybe ChatList.ChatList -- ^ The chat list. Use getChatListsToAddChat to get suitable chat lists
    }
  deriving (AddChatToList -> AddChatToList -> Bool
(AddChatToList -> AddChatToList -> Bool)
-> (AddChatToList -> AddChatToList -> Bool) -> Eq AddChatToList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddChatToList -> AddChatToList -> Bool
== :: AddChatToList -> AddChatToList -> Bool
$c/= :: AddChatToList -> AddChatToList -> Bool
/= :: AddChatToList -> AddChatToList -> Bool
Eq, Int -> AddChatToList -> ShowS
[AddChatToList] -> ShowS
AddChatToList -> String
(Int -> AddChatToList -> ShowS)
-> (AddChatToList -> String)
-> ([AddChatToList] -> ShowS)
-> Show AddChatToList
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddChatToList -> ShowS
showsPrec :: Int -> AddChatToList -> ShowS
$cshow :: AddChatToList -> String
show :: AddChatToList -> String
$cshowList :: [AddChatToList] -> ShowS
showList :: [AddChatToList] -> ShowS
Show)

instance I.ShortShow AddChatToList where
  shortShow :: AddChatToList -> String
shortShow
    AddChatToList
      { chat_id :: AddChatToList -> Maybe Int
chat_id   = Maybe Int
chat_id_
      , chat_list :: AddChatToList -> Maybe ChatList
chat_list = Maybe ChatList
chat_list_
      }
        = String
"AddChatToList"
          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
"chat_list" String -> Maybe ChatList -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatList
chat_list_
          ]

instance AT.ToJSON AddChatToList where
  toJSON :: AddChatToList -> Value
toJSON
    AddChatToList
      { chat_id :: AddChatToList -> Maybe Int
chat_id   = Maybe Int
chat_id_
      , chat_list :: AddChatToList -> 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
"addChatToList"
          , 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
"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_
          ]

defaultAddChatToList :: AddChatToList
defaultAddChatToList :: AddChatToList
defaultAddChatToList =
  AddChatToList
    { chat_id :: Maybe Int
chat_id   = Maybe Int
forall a. Maybe a
Nothing
    , chat_list :: Maybe ChatList
chat_list = Maybe ChatList
forall a. Maybe a
Nothing
    }