module TD.Query.RefundStarPayment
  (RefundStarPayment(..)
  , defaultRefundStarPayment
  ) 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

-- | Refunds a previously done payment in Telegram Stars; for bots only. Returns 'TD.Data.Ok.Ok'
data RefundStarPayment
  = RefundStarPayment
    { RefundStarPayment -> Maybe Int
user_id                    :: Maybe Int    -- ^ Identifier of the user that did the payment
    , RefundStarPayment -> Maybe Text
telegram_payment_charge_id :: Maybe T.Text -- ^ Telegram payment identifier
    }
  deriving (RefundStarPayment -> RefundStarPayment -> Bool
(RefundStarPayment -> RefundStarPayment -> Bool)
-> (RefundStarPayment -> RefundStarPayment -> Bool)
-> Eq RefundStarPayment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RefundStarPayment -> RefundStarPayment -> Bool
== :: RefundStarPayment -> RefundStarPayment -> Bool
$c/= :: RefundStarPayment -> RefundStarPayment -> Bool
/= :: RefundStarPayment -> RefundStarPayment -> Bool
Eq, Int -> RefundStarPayment -> ShowS
[RefundStarPayment] -> ShowS
RefundStarPayment -> String
(Int -> RefundStarPayment -> ShowS)
-> (RefundStarPayment -> String)
-> ([RefundStarPayment] -> ShowS)
-> Show RefundStarPayment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RefundStarPayment -> ShowS
showsPrec :: Int -> RefundStarPayment -> ShowS
$cshow :: RefundStarPayment -> String
show :: RefundStarPayment -> String
$cshowList :: [RefundStarPayment] -> ShowS
showList :: [RefundStarPayment] -> ShowS
Show)

instance I.ShortShow RefundStarPayment where
  shortShow :: RefundStarPayment -> String
shortShow
    RefundStarPayment
      { user_id :: RefundStarPayment -> Maybe Int
user_id                    = Maybe Int
user_id_
      , telegram_payment_charge_id :: RefundStarPayment -> Maybe Text
telegram_payment_charge_id = Maybe Text
telegram_payment_charge_id_
      }
        = String
"RefundStarPayment"
          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_
          ]

instance AT.ToJSON RefundStarPayment where
  toJSON :: RefundStarPayment -> Value
toJSON
    RefundStarPayment
      { user_id :: RefundStarPayment -> Maybe Int
user_id                    = Maybe Int
user_id_
      , telegram_payment_charge_id :: RefundStarPayment -> Maybe Text
telegram_payment_charge_id = Maybe Text
telegram_payment_charge_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
"refundStarPayment"
          , 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_
          ]

defaultRefundStarPayment :: RefundStarPayment
defaultRefundStarPayment :: RefundStarPayment
defaultRefundStarPayment =
  RefundStarPayment
    { 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
    }