module TD.Query.SetPersonalChat
  (SetPersonalChat(..)
  ) where

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

-- | Changes the personal chat of the current user. Returns 'TD.Data.Ok.Ok'
data SetPersonalChat
  = SetPersonalChat
    { SetPersonalChat -> Maybe Int
chat_id :: Maybe Int -- ^ Identifier of the new personal chat; pass 0 to remove the chat. Use getSuitablePersonalChats to get suitable chats
    }
  deriving (SetPersonalChat -> SetPersonalChat -> Bool
(SetPersonalChat -> SetPersonalChat -> Bool)
-> (SetPersonalChat -> SetPersonalChat -> Bool)
-> Eq SetPersonalChat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetPersonalChat -> SetPersonalChat -> Bool
== :: SetPersonalChat -> SetPersonalChat -> Bool
$c/= :: SetPersonalChat -> SetPersonalChat -> Bool
/= :: SetPersonalChat -> SetPersonalChat -> Bool
Eq, Int -> SetPersonalChat -> ShowS
[SetPersonalChat] -> ShowS
SetPersonalChat -> String
(Int -> SetPersonalChat -> ShowS)
-> (SetPersonalChat -> String)
-> ([SetPersonalChat] -> ShowS)
-> Show SetPersonalChat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetPersonalChat -> ShowS
showsPrec :: Int -> SetPersonalChat -> ShowS
$cshow :: SetPersonalChat -> String
show :: SetPersonalChat -> String
$cshowList :: [SetPersonalChat] -> ShowS
showList :: [SetPersonalChat] -> ShowS
Show)

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