module TD.Query.CancelGiftOnChainPurchaseOffer
  (CancelGiftOnChainPurchaseOffer(..)
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Cancels an on-chain gift purchase offer sent by the current user; can be used only if getOption("can_use_ton_wallet"). A fine may be charged if the offer is canceled before it expires. Returns the transaction that must be sent from the TON wallet of the current user to cancel the offer. The offer is canceled only after the transaction is executed on the TON blockchain. Returns 'TD.Data.GiftOnChainPurchaseOfferTransaction.GiftOnChainPurchaseOfferTransaction'
data CancelGiftOnChainPurchaseOffer
  = CancelGiftOnChainPurchaseOffer
    { CancelGiftOnChainPurchaseOffer -> Maybe Int
message_id :: Maybe Int -- ^ Identifier of the message messageUpgradedGiftOnChainPurchaseOffer with the offer in the chat 777000
    }
  deriving (CancelGiftOnChainPurchaseOffer
-> CancelGiftOnChainPurchaseOffer -> Bool
(CancelGiftOnChainPurchaseOffer
 -> CancelGiftOnChainPurchaseOffer -> Bool)
-> (CancelGiftOnChainPurchaseOffer
    -> CancelGiftOnChainPurchaseOffer -> Bool)
-> Eq CancelGiftOnChainPurchaseOffer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CancelGiftOnChainPurchaseOffer
-> CancelGiftOnChainPurchaseOffer -> Bool
== :: CancelGiftOnChainPurchaseOffer
-> CancelGiftOnChainPurchaseOffer -> Bool
$c/= :: CancelGiftOnChainPurchaseOffer
-> CancelGiftOnChainPurchaseOffer -> Bool
/= :: CancelGiftOnChainPurchaseOffer
-> CancelGiftOnChainPurchaseOffer -> Bool
Eq, Int -> CancelGiftOnChainPurchaseOffer -> ShowS
[CancelGiftOnChainPurchaseOffer] -> ShowS
CancelGiftOnChainPurchaseOffer -> String
(Int -> CancelGiftOnChainPurchaseOffer -> ShowS)
-> (CancelGiftOnChainPurchaseOffer -> String)
-> ([CancelGiftOnChainPurchaseOffer] -> ShowS)
-> Show CancelGiftOnChainPurchaseOffer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CancelGiftOnChainPurchaseOffer -> ShowS
showsPrec :: Int -> CancelGiftOnChainPurchaseOffer -> ShowS
$cshow :: CancelGiftOnChainPurchaseOffer -> String
show :: CancelGiftOnChainPurchaseOffer -> String
$cshowList :: [CancelGiftOnChainPurchaseOffer] -> ShowS
showList :: [CancelGiftOnChainPurchaseOffer] -> ShowS
Show)

instance I.ShortShow CancelGiftOnChainPurchaseOffer where
  shortShow :: CancelGiftOnChainPurchaseOffer -> String
shortShow
    CancelGiftOnChainPurchaseOffer
      { message_id :: CancelGiftOnChainPurchaseOffer -> Maybe Int
message_id = Maybe Int
message_id_
      }
        = String
"CancelGiftOnChainPurchaseOffer"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"message_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_id_
          ]

instance AT.ToJSON CancelGiftOnChainPurchaseOffer where
  toJSON :: CancelGiftOnChainPurchaseOffer -> Value
toJSON
    CancelGiftOnChainPurchaseOffer
      { message_id :: CancelGiftOnChainPurchaseOffer -> Maybe Int
message_id = Maybe Int
message_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
"cancelGiftOnChainPurchaseOffer"
          , Key
"message_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
message_id_
          ]