module TD.Query.ReplacePrimaryChatInviteLink
  (ReplacePrimaryChatInviteLink(..)
  ) where

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

-- | Replaces current primary invite link for a chat with a new primary invite link. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right. Returns 'TD.Data.ChatInviteLink.ChatInviteLink'
data ReplacePrimaryChatInviteLink
  = ReplacePrimaryChatInviteLink
    { ReplacePrimaryChatInviteLink -> Maybe Int
chat_id :: Maybe Int -- ^ Chat identifier
    }
  deriving (ReplacePrimaryChatInviteLink
-> ReplacePrimaryChatInviteLink -> Bool
(ReplacePrimaryChatInviteLink
 -> ReplacePrimaryChatInviteLink -> Bool)
-> (ReplacePrimaryChatInviteLink
    -> ReplacePrimaryChatInviteLink -> Bool)
-> Eq ReplacePrimaryChatInviteLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReplacePrimaryChatInviteLink
-> ReplacePrimaryChatInviteLink -> Bool
== :: ReplacePrimaryChatInviteLink
-> ReplacePrimaryChatInviteLink -> Bool
$c/= :: ReplacePrimaryChatInviteLink
-> ReplacePrimaryChatInviteLink -> Bool
/= :: ReplacePrimaryChatInviteLink
-> ReplacePrimaryChatInviteLink -> Bool
Eq, Int -> ReplacePrimaryChatInviteLink -> ShowS
[ReplacePrimaryChatInviteLink] -> ShowS
ReplacePrimaryChatInviteLink -> String
(Int -> ReplacePrimaryChatInviteLink -> ShowS)
-> (ReplacePrimaryChatInviteLink -> String)
-> ([ReplacePrimaryChatInviteLink] -> ShowS)
-> Show ReplacePrimaryChatInviteLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReplacePrimaryChatInviteLink -> ShowS
showsPrec :: Int -> ReplacePrimaryChatInviteLink -> ShowS
$cshow :: ReplacePrimaryChatInviteLink -> String
show :: ReplacePrimaryChatInviteLink -> String
$cshowList :: [ReplacePrimaryChatInviteLink] -> ShowS
showList :: [ReplacePrimaryChatInviteLink] -> ShowS
Show)

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