module TD.Query.EditChatFolderInviteLink
  (EditChatFolderInviteLink(..)
  , defaultEditChatFolderInviteLink
  ) 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

-- | Edits an invite link for a chat folder. Returns 'TD.Data.ChatFolderInviteLink.ChatFolderInviteLink'
data EditChatFolderInviteLink
  = EditChatFolderInviteLink
    { EditChatFolderInviteLink -> Maybe Int
chat_folder_id :: Maybe Int    -- ^ Chat folder identifier
    , EditChatFolderInviteLink -> Maybe Text
invite_link    :: Maybe T.Text -- ^ Invite link to be edited
    , EditChatFolderInviteLink -> Maybe Text
name           :: Maybe T.Text -- ^ New name of the link; 0-32 characters
    , EditChatFolderInviteLink -> Maybe [Int]
chat_ids       :: Maybe [Int]  -- ^ New identifiers of chats to be accessible by the invite link. Use getChatsForChatFolderInviteLink to get suitable chats. Basic groups will be automatically converted to supergroups before link editing
    }
  deriving (EditChatFolderInviteLink -> EditChatFolderInviteLink -> Bool
(EditChatFolderInviteLink -> EditChatFolderInviteLink -> Bool)
-> (EditChatFolderInviteLink -> EditChatFolderInviteLink -> Bool)
-> Eq EditChatFolderInviteLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EditChatFolderInviteLink -> EditChatFolderInviteLink -> Bool
== :: EditChatFolderInviteLink -> EditChatFolderInviteLink -> Bool
$c/= :: EditChatFolderInviteLink -> EditChatFolderInviteLink -> Bool
/= :: EditChatFolderInviteLink -> EditChatFolderInviteLink -> Bool
Eq, Int -> EditChatFolderInviteLink -> ShowS
[EditChatFolderInviteLink] -> ShowS
EditChatFolderInviteLink -> String
(Int -> EditChatFolderInviteLink -> ShowS)
-> (EditChatFolderInviteLink -> String)
-> ([EditChatFolderInviteLink] -> ShowS)
-> Show EditChatFolderInviteLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EditChatFolderInviteLink -> ShowS
showsPrec :: Int -> EditChatFolderInviteLink -> ShowS
$cshow :: EditChatFolderInviteLink -> String
show :: EditChatFolderInviteLink -> String
$cshowList :: [EditChatFolderInviteLink] -> ShowS
showList :: [EditChatFolderInviteLink] -> ShowS
Show)

instance I.ShortShow EditChatFolderInviteLink where
  shortShow :: EditChatFolderInviteLink -> String
shortShow
    EditChatFolderInviteLink
      { chat_folder_id :: EditChatFolderInviteLink -> Maybe Int
chat_folder_id = Maybe Int
chat_folder_id_
      , invite_link :: EditChatFolderInviteLink -> Maybe Text
invite_link    = Maybe Text
invite_link_
      , name :: EditChatFolderInviteLink -> Maybe Text
name           = Maybe Text
name_
      , chat_ids :: EditChatFolderInviteLink -> Maybe [Int]
chat_ids       = Maybe [Int]
chat_ids_
      }
        = String
"EditChatFolderInviteLink"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_folder_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_folder_id_
          , String
"invite_link"    String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
invite_link_
          , String
"name"           String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
          , String
"chat_ids"       String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
chat_ids_
          ]

instance AT.ToJSON EditChatFolderInviteLink where
  toJSON :: EditChatFolderInviteLink -> Value
toJSON
    EditChatFolderInviteLink
      { chat_folder_id :: EditChatFolderInviteLink -> Maybe Int
chat_folder_id = Maybe Int
chat_folder_id_
      , invite_link :: EditChatFolderInviteLink -> Maybe Text
invite_link    = Maybe Text
invite_link_
      , name :: EditChatFolderInviteLink -> Maybe Text
name           = Maybe Text
name_
      , chat_ids :: EditChatFolderInviteLink -> Maybe [Int]
chat_ids       = Maybe [Int]
chat_ids_
      }
        = [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
"editChatFolderInviteLink"
          , Key
"chat_folder_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_folder_id_
          , Key
"invite_link"    Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
invite_link_
          , Key
"name"           Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
name_
          , Key
"chat_ids"       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_ids_
          ]

defaultEditChatFolderInviteLink :: EditChatFolderInviteLink
defaultEditChatFolderInviteLink :: EditChatFolderInviteLink
defaultEditChatFolderInviteLink =
  EditChatFolderInviteLink
    { chat_folder_id :: Maybe Int
chat_folder_id = Maybe Int
forall a. Maybe a
Nothing
    , invite_link :: Maybe Text
invite_link    = Maybe Text
forall a. Maybe a
Nothing
    , name :: Maybe Text
name           = Maybe Text
forall a. Maybe a
Nothing
    , chat_ids :: Maybe [Int]
chat_ids       = Maybe [Int]
forall a. Maybe a
Nothing
    }