module TD.Query.SetChatDiscussionGroup
  (SetChatDiscussionGroup(..)
  , defaultSetChatDiscussionGroup
  ) where

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

-- | Changes the discussion group of a channel chat; requires can_change_info administrator right in the channel if it is specified. Returns 'TD.Data.Ok.Ok'
data SetChatDiscussionGroup
  = SetChatDiscussionGroup
    { SetChatDiscussionGroup -> Maybe Int
chat_id            :: Maybe Int -- ^ Identifier of the channel chat. Pass 0 to remove a link from the supergroup passed in the second argument to a linked channel chat (requires can_pin_messages member right in the supergroup)
    , SetChatDiscussionGroup -> Maybe Int
discussion_chat_id :: Maybe Int -- ^ Identifier of a new channel's discussion group. Use 0 to remove the discussion group. Use the method getSuitableDiscussionChats to find all suitable groups. Basic group chats must be first upgraded to supergroup chats. If new chat members don't have access to old messages in the supergroup, then toggleSupergroupIsAllHistoryAvailable must be used first to change that
    }
  deriving (SetChatDiscussionGroup -> SetChatDiscussionGroup -> Bool
(SetChatDiscussionGroup -> SetChatDiscussionGroup -> Bool)
-> (SetChatDiscussionGroup -> SetChatDiscussionGroup -> Bool)
-> Eq SetChatDiscussionGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetChatDiscussionGroup -> SetChatDiscussionGroup -> Bool
== :: SetChatDiscussionGroup -> SetChatDiscussionGroup -> Bool
$c/= :: SetChatDiscussionGroup -> SetChatDiscussionGroup -> Bool
/= :: SetChatDiscussionGroup -> SetChatDiscussionGroup -> Bool
Eq, Int -> SetChatDiscussionGroup -> ShowS
[SetChatDiscussionGroup] -> ShowS
SetChatDiscussionGroup -> String
(Int -> SetChatDiscussionGroup -> ShowS)
-> (SetChatDiscussionGroup -> String)
-> ([SetChatDiscussionGroup] -> ShowS)
-> Show SetChatDiscussionGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetChatDiscussionGroup -> ShowS
showsPrec :: Int -> SetChatDiscussionGroup -> ShowS
$cshow :: SetChatDiscussionGroup -> String
show :: SetChatDiscussionGroup -> String
$cshowList :: [SetChatDiscussionGroup] -> ShowS
showList :: [SetChatDiscussionGroup] -> ShowS
Show)

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

instance AT.ToJSON SetChatDiscussionGroup where
  toJSON :: SetChatDiscussionGroup -> Value
toJSON
    SetChatDiscussionGroup
      { chat_id :: SetChatDiscussionGroup -> Maybe Int
chat_id            = Maybe Int
chat_id_
      , discussion_chat_id :: SetChatDiscussionGroup -> Maybe Int
discussion_chat_id = Maybe Int
discussion_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
"setChatDiscussionGroup"
          , 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
"discussion_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
discussion_chat_id_
          ]

defaultSetChatDiscussionGroup :: SetChatDiscussionGroup
defaultSetChatDiscussionGroup :: SetChatDiscussionGroup
defaultSetChatDiscussionGroup =
  SetChatDiscussionGroup
    { chat_id :: Maybe Int
chat_id            = Maybe Int
forall a. Maybe a
Nothing
    , discussion_chat_id :: Maybe Int
discussion_chat_id = Maybe Int
forall a. Maybe a
Nothing
    }