module TD.Query.EditUserStarSubscription
  (EditUserStarSubscription(..)
  , defaultEditUserStarSubscription
  ) 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

-- | Cancels or re-enables Telegram Star subscription for a user; for bots only. Returns 'TD.Data.Ok.Ok'
data EditUserStarSubscription
  = EditUserStarSubscription
    { EditUserStarSubscription -> Maybe Int
user_id                    :: Maybe Int    -- ^ User identifier
    , EditUserStarSubscription -> Maybe Text
telegram_payment_charge_id :: Maybe T.Text -- ^ Telegram payment identifier of the subscription
    , EditUserStarSubscription -> Maybe Bool
is_canceled                :: Maybe Bool   -- ^ Pass true to cancel the subscription; pass false to allow the user to enable it
    }
  deriving (EditUserStarSubscription -> EditUserStarSubscription -> Bool
(EditUserStarSubscription -> EditUserStarSubscription -> Bool)
-> (EditUserStarSubscription -> EditUserStarSubscription -> Bool)
-> Eq EditUserStarSubscription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EditUserStarSubscription -> EditUserStarSubscription -> Bool
== :: EditUserStarSubscription -> EditUserStarSubscription -> Bool
$c/= :: EditUserStarSubscription -> EditUserStarSubscription -> Bool
/= :: EditUserStarSubscription -> EditUserStarSubscription -> Bool
Eq, Int -> EditUserStarSubscription -> ShowS
[EditUserStarSubscription] -> ShowS
EditUserStarSubscription -> String
(Int -> EditUserStarSubscription -> ShowS)
-> (EditUserStarSubscription -> String)
-> ([EditUserStarSubscription] -> ShowS)
-> Show EditUserStarSubscription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EditUserStarSubscription -> ShowS
showsPrec :: Int -> EditUserStarSubscription -> ShowS
$cshow :: EditUserStarSubscription -> String
show :: EditUserStarSubscription -> String
$cshowList :: [EditUserStarSubscription] -> ShowS
showList :: [EditUserStarSubscription] -> ShowS
Show)

instance I.ShortShow EditUserStarSubscription where
  shortShow :: EditUserStarSubscription -> String
shortShow
    EditUserStarSubscription
      { user_id :: EditUserStarSubscription -> Maybe Int
user_id                    = Maybe Int
user_id_
      , telegram_payment_charge_id :: EditUserStarSubscription -> Maybe Text
telegram_payment_charge_id = Maybe Text
telegram_payment_charge_id_
      , is_canceled :: EditUserStarSubscription -> Maybe Bool
is_canceled                = Maybe Bool
is_canceled_
      }
        = String
"EditUserStarSubscription"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"user_id"                    String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
          , String
"telegram_payment_charge_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
telegram_payment_charge_id_
          , String
"is_canceled"                String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_canceled_
          ]

instance AT.ToJSON EditUserStarSubscription where
  toJSON :: EditUserStarSubscription -> Value
toJSON
    EditUserStarSubscription
      { user_id :: EditUserStarSubscription -> Maybe Int
user_id                    = Maybe Int
user_id_
      , telegram_payment_charge_id :: EditUserStarSubscription -> Maybe Text
telegram_payment_charge_id = Maybe Text
telegram_payment_charge_id_
      , is_canceled :: EditUserStarSubscription -> Maybe Bool
is_canceled                = Maybe Bool
is_canceled_
      }
        = [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
"editUserStarSubscription"
          , Key
"user_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
user_id_
          , Key
"telegram_payment_charge_id" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
telegram_payment_charge_id_
          , Key
"is_canceled"                Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_canceled_
          ]

defaultEditUserStarSubscription :: EditUserStarSubscription
defaultEditUserStarSubscription :: EditUserStarSubscription
defaultEditUserStarSubscription =
  EditUserStarSubscription
    { user_id :: Maybe Int
user_id                    = Maybe Int
forall a. Maybe a
Nothing
    , telegram_payment_charge_id :: Maybe Text
telegram_payment_charge_id = Maybe Text
forall a. Maybe a
Nothing
    , is_canceled :: Maybe Bool
is_canceled                = Maybe Bool
forall a. Maybe a
Nothing
    }