module TD.Query.CreateChatFolderInviteLink
  (CreateChatFolderInviteLink(..)
  , defaultCreateChatFolderInviteLink
  ) 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

-- | Creates a new invite link for a chat folder. A link can be created for a chat folder if it has only pinned and included chats. Returns 'TD.Data.ChatFolderInviteLink.ChatFolderInviteLink'
data CreateChatFolderInviteLink
  = CreateChatFolderInviteLink
    { CreateChatFolderInviteLink -> Maybe Int
chat_folder_id :: Maybe Int    -- ^ Chat folder identifier
    , CreateChatFolderInviteLink -> Maybe Text
name           :: Maybe T.Text -- ^ Name of the link; 0-32 characters
    , CreateChatFolderInviteLink -> Maybe [Int]
chat_ids       :: Maybe [Int]  -- ^ 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 creation
    }
  deriving (CreateChatFolderInviteLink -> CreateChatFolderInviteLink -> Bool
(CreateChatFolderInviteLink -> CreateChatFolderInviteLink -> Bool)
-> (CreateChatFolderInviteLink
    -> CreateChatFolderInviteLink -> Bool)
-> Eq CreateChatFolderInviteLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateChatFolderInviteLink -> CreateChatFolderInviteLink -> Bool
== :: CreateChatFolderInviteLink -> CreateChatFolderInviteLink -> Bool
$c/= :: CreateChatFolderInviteLink -> CreateChatFolderInviteLink -> Bool
/= :: CreateChatFolderInviteLink -> CreateChatFolderInviteLink -> Bool
Eq, Int -> CreateChatFolderInviteLink -> ShowS
[CreateChatFolderInviteLink] -> ShowS
CreateChatFolderInviteLink -> String
(Int -> CreateChatFolderInviteLink -> ShowS)
-> (CreateChatFolderInviteLink -> String)
-> ([CreateChatFolderInviteLink] -> ShowS)
-> Show CreateChatFolderInviteLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateChatFolderInviteLink -> ShowS
showsPrec :: Int -> CreateChatFolderInviteLink -> ShowS
$cshow :: CreateChatFolderInviteLink -> String
show :: CreateChatFolderInviteLink -> String
$cshowList :: [CreateChatFolderInviteLink] -> ShowS
showList :: [CreateChatFolderInviteLink] -> ShowS
Show)

instance I.ShortShow CreateChatFolderInviteLink where
  shortShow :: CreateChatFolderInviteLink -> String
shortShow
    CreateChatFolderInviteLink
      { chat_folder_id :: CreateChatFolderInviteLink -> Maybe Int
chat_folder_id = Maybe Int
chat_folder_id_
      , name :: CreateChatFolderInviteLink -> Maybe Text
name           = Maybe Text
name_
      , chat_ids :: CreateChatFolderInviteLink -> Maybe [Int]
chat_ids       = Maybe [Int]
chat_ids_
      }
        = String
"CreateChatFolderInviteLink"
          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
"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 CreateChatFolderInviteLink where
  toJSON :: CreateChatFolderInviteLink -> Value
toJSON
    CreateChatFolderInviteLink
      { chat_folder_id :: CreateChatFolderInviteLink -> Maybe Int
chat_folder_id = Maybe Int
chat_folder_id_
      , name :: CreateChatFolderInviteLink -> Maybe Text
name           = Maybe Text
name_
      , chat_ids :: CreateChatFolderInviteLink -> 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
"createChatFolderInviteLink"
          , 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
"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_
          ]

defaultCreateChatFolderInviteLink :: CreateChatFolderInviteLink
defaultCreateChatFolderInviteLink :: CreateChatFolderInviteLink
defaultCreateChatFolderInviteLink =
  CreateChatFolderInviteLink
    { chat_folder_id :: Maybe Int
chat_folder_id = Maybe Int
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
    }