module TD.Query.CreateChatSubscriptionInviteLink
  (CreateChatSubscriptionInviteLink(..)
  , defaultCreateChatSubscriptionInviteLink
  ) 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
import qualified TD.Data.StarSubscriptionPricing as StarSubscriptionPricing

-- | Creates a new subscription invite link for a channel chat. Requires can_invite_users right in the chat. Returns 'TD.Data.ChatInviteLink.ChatInviteLink'
data CreateChatSubscriptionInviteLink
  = CreateChatSubscriptionInviteLink
    { CreateChatSubscriptionInviteLink -> Maybe Int
chat_id              :: Maybe Int                                             -- ^ Chat identifier
    , CreateChatSubscriptionInviteLink -> Maybe Text
name                 :: Maybe T.Text                                          -- ^ Invite link name; 0-32 characters
    , CreateChatSubscriptionInviteLink -> Maybe StarSubscriptionPricing
subscription_pricing :: Maybe StarSubscriptionPricing.StarSubscriptionPricing -- ^ Information about subscription plan that will be applied to the users joining the chat via the link. Subscription period must be 2592000 in production environment, and 60 or 300 if Telegram test environment is used
    }
  deriving (CreateChatSubscriptionInviteLink
-> CreateChatSubscriptionInviteLink -> Bool
(CreateChatSubscriptionInviteLink
 -> CreateChatSubscriptionInviteLink -> Bool)
-> (CreateChatSubscriptionInviteLink
    -> CreateChatSubscriptionInviteLink -> Bool)
-> Eq CreateChatSubscriptionInviteLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateChatSubscriptionInviteLink
-> CreateChatSubscriptionInviteLink -> Bool
== :: CreateChatSubscriptionInviteLink
-> CreateChatSubscriptionInviteLink -> Bool
$c/= :: CreateChatSubscriptionInviteLink
-> CreateChatSubscriptionInviteLink -> Bool
/= :: CreateChatSubscriptionInviteLink
-> CreateChatSubscriptionInviteLink -> Bool
Eq, Int -> CreateChatSubscriptionInviteLink -> ShowS
[CreateChatSubscriptionInviteLink] -> ShowS
CreateChatSubscriptionInviteLink -> String
(Int -> CreateChatSubscriptionInviteLink -> ShowS)
-> (CreateChatSubscriptionInviteLink -> String)
-> ([CreateChatSubscriptionInviteLink] -> ShowS)
-> Show CreateChatSubscriptionInviteLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateChatSubscriptionInviteLink -> ShowS
showsPrec :: Int -> CreateChatSubscriptionInviteLink -> ShowS
$cshow :: CreateChatSubscriptionInviteLink -> String
show :: CreateChatSubscriptionInviteLink -> String
$cshowList :: [CreateChatSubscriptionInviteLink] -> ShowS
showList :: [CreateChatSubscriptionInviteLink] -> ShowS
Show)

instance I.ShortShow CreateChatSubscriptionInviteLink where
  shortShow :: CreateChatSubscriptionInviteLink -> String
shortShow
    CreateChatSubscriptionInviteLink
      { chat_id :: CreateChatSubscriptionInviteLink -> Maybe Int
chat_id              = Maybe Int
chat_id_
      , name :: CreateChatSubscriptionInviteLink -> Maybe Text
name                 = Maybe Text
name_
      , subscription_pricing :: CreateChatSubscriptionInviteLink -> Maybe StarSubscriptionPricing
subscription_pricing = Maybe StarSubscriptionPricing
subscription_pricing_
      }
        = String
"CreateChatSubscriptionInviteLink"
          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
"name"                 String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
          , String
"subscription_pricing" String -> Maybe StarSubscriptionPricing -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StarSubscriptionPricing
subscription_pricing_
          ]

instance AT.ToJSON CreateChatSubscriptionInviteLink where
  toJSON :: CreateChatSubscriptionInviteLink -> Value
toJSON
    CreateChatSubscriptionInviteLink
      { chat_id :: CreateChatSubscriptionInviteLink -> Maybe Int
chat_id              = Maybe Int
chat_id_
      , name :: CreateChatSubscriptionInviteLink -> Maybe Text
name                 = Maybe Text
name_
      , subscription_pricing :: CreateChatSubscriptionInviteLink -> Maybe StarSubscriptionPricing
subscription_pricing = Maybe StarSubscriptionPricing
subscription_pricing_
      }
        = [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
"createChatSubscriptionInviteLink"
          , 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
"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
"subscription_pricing" Key -> Maybe StarSubscriptionPricing -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe StarSubscriptionPricing
subscription_pricing_
          ]

defaultCreateChatSubscriptionInviteLink :: CreateChatSubscriptionInviteLink
defaultCreateChatSubscriptionInviteLink :: CreateChatSubscriptionInviteLink
defaultCreateChatSubscriptionInviteLink =
  CreateChatSubscriptionInviteLink
    { chat_id :: Maybe Int
chat_id              = Maybe Int
forall a. Maybe a
Nothing
    , name :: Maybe Text
name                 = Maybe Text
forall a. Maybe a
Nothing
    , subscription_pricing :: Maybe StarSubscriptionPricing
subscription_pricing = Maybe StarSubscriptionPricing
forall a. Maybe a
Nothing
    }