module TD.Query.TransferChatOwnership
  (TransferChatOwnership(..)
  , defaultTransferChatOwnership
  ) where

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

-- | Changes the owner of a chat; for basic groups, supergroups and channel chats only; requires owner privileges in the chat. Use the method canTransferOwnership to check whether the ownership can be transferred from the current session. Returns 'TD.Data.Ok.Ok'
data TransferChatOwnership
  = TransferChatOwnership
    { TransferChatOwnership -> Maybe Int
chat_id  :: Maybe Int    -- ^ Chat identifier
    , TransferChatOwnership -> Maybe Int
user_id  :: Maybe Int    -- ^ Identifier of the user to which transfer the ownership. The ownership can't be transferred to a bot or to a deleted user
    , TransferChatOwnership -> Maybe Text
password :: Maybe T.Text -- ^ The 2-step verification password of the current user
    }
  deriving (TransferChatOwnership -> TransferChatOwnership -> Bool
(TransferChatOwnership -> TransferChatOwnership -> Bool)
-> (TransferChatOwnership -> TransferChatOwnership -> Bool)
-> Eq TransferChatOwnership
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TransferChatOwnership -> TransferChatOwnership -> Bool
== :: TransferChatOwnership -> TransferChatOwnership -> Bool
$c/= :: TransferChatOwnership -> TransferChatOwnership -> Bool
/= :: TransferChatOwnership -> TransferChatOwnership -> Bool
Eq, Int -> TransferChatOwnership -> ShowS
[TransferChatOwnership] -> ShowS
TransferChatOwnership -> String
(Int -> TransferChatOwnership -> ShowS)
-> (TransferChatOwnership -> String)
-> ([TransferChatOwnership] -> ShowS)
-> Show TransferChatOwnership
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TransferChatOwnership -> ShowS
showsPrec :: Int -> TransferChatOwnership -> ShowS
$cshow :: TransferChatOwnership -> String
show :: TransferChatOwnership -> String
$cshowList :: [TransferChatOwnership] -> ShowS
showList :: [TransferChatOwnership] -> ShowS
Show)

instance I.ShortShow TransferChatOwnership where
  shortShow :: TransferChatOwnership -> String
shortShow
    TransferChatOwnership
      { chat_id :: TransferChatOwnership -> Maybe Int
chat_id  = Maybe Int
chat_id_
      , user_id :: TransferChatOwnership -> Maybe Int
user_id  = Maybe Int
user_id_
      , password :: TransferChatOwnership -> Maybe Text
password = Maybe Text
password_
      }
        = String
"TransferChatOwnership"
          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
"user_id"  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
          , String
"password" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
password_
          ]

instance AT.ToJSON TransferChatOwnership where
  toJSON :: TransferChatOwnership -> Value
toJSON
    TransferChatOwnership
      { chat_id :: TransferChatOwnership -> Maybe Int
chat_id  = Maybe Int
chat_id_
      , user_id :: TransferChatOwnership -> Maybe Int
user_id  = Maybe Int
user_id_
      , password :: TransferChatOwnership -> Maybe Text
password = Maybe Text
password_
      }
        = [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
"transferChatOwnership"
          , 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
"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
"password" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
password_
          ]

defaultTransferChatOwnership :: TransferChatOwnership
defaultTransferChatOwnership :: TransferChatOwnership
defaultTransferChatOwnership =
  TransferChatOwnership
    { chat_id :: Maybe Int
chat_id  = Maybe Int
forall a. Maybe a
Nothing
    , user_id :: Maybe Int
user_id  = Maybe Int
forall a. Maybe a
Nothing
    , password :: Maybe Text
password = Maybe Text
forall a. Maybe a
Nothing
    }