module TD.Query.AcceptGiftOnChainPurchaseOffer
  (AcceptGiftOnChainPurchaseOffer(..)
  ) where

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

-- | Accepts an on-chain gift purchase offer received by the current user; can be used only if getOption("can_use_ton_wallet"). The gift must not be listed for sale. Other offers for the gift will be canceled after the gift is sold. Returns the transaction that must be sent from the TON wallet of the current user to accept the offer. The offer is accepted only after the transaction is executed on the TON blockchain and the gift is transferred to the buyer. Returns 'TD.Data.GiftOnChainPurchaseOfferTransaction.GiftOnChainPurchaseOfferTransaction'
data AcceptGiftOnChainPurchaseOffer
  = AcceptGiftOnChainPurchaseOffer
    { AcceptGiftOnChainPurchaseOffer -> Maybe Int
message_id :: Maybe Int -- ^ Identifier of the message messageUpgradedGiftOnChainPurchaseOffer with the offer in the chat 777000
    }
  deriving (AcceptGiftOnChainPurchaseOffer
-> AcceptGiftOnChainPurchaseOffer -> Bool
(AcceptGiftOnChainPurchaseOffer
 -> AcceptGiftOnChainPurchaseOffer -> Bool)
-> (AcceptGiftOnChainPurchaseOffer
    -> AcceptGiftOnChainPurchaseOffer -> Bool)
-> Eq AcceptGiftOnChainPurchaseOffer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AcceptGiftOnChainPurchaseOffer
-> AcceptGiftOnChainPurchaseOffer -> Bool
== :: AcceptGiftOnChainPurchaseOffer
-> AcceptGiftOnChainPurchaseOffer -> Bool
$c/= :: AcceptGiftOnChainPurchaseOffer
-> AcceptGiftOnChainPurchaseOffer -> Bool
/= :: AcceptGiftOnChainPurchaseOffer
-> AcceptGiftOnChainPurchaseOffer -> Bool
Eq, Int -> AcceptGiftOnChainPurchaseOffer -> ShowS
[AcceptGiftOnChainPurchaseOffer] -> ShowS
AcceptGiftOnChainPurchaseOffer -> String
(Int -> AcceptGiftOnChainPurchaseOffer -> ShowS)
-> (AcceptGiftOnChainPurchaseOffer -> String)
-> ([AcceptGiftOnChainPurchaseOffer] -> ShowS)
-> Show AcceptGiftOnChainPurchaseOffer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AcceptGiftOnChainPurchaseOffer -> ShowS
showsPrec :: Int -> AcceptGiftOnChainPurchaseOffer -> ShowS
$cshow :: AcceptGiftOnChainPurchaseOffer -> String
show :: AcceptGiftOnChainPurchaseOffer -> String
$cshowList :: [AcceptGiftOnChainPurchaseOffer] -> ShowS
showList :: [AcceptGiftOnChainPurchaseOffer] -> ShowS
Show)

instance I.ShortShow AcceptGiftOnChainPurchaseOffer where
  shortShow :: AcceptGiftOnChainPurchaseOffer -> String
shortShow
    AcceptGiftOnChainPurchaseOffer
      { message_id :: AcceptGiftOnChainPurchaseOffer -> Maybe Int
message_id = Maybe Int
message_id_
      }
        = String
"AcceptGiftOnChainPurchaseOffer"
          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 AcceptGiftOnChainPurchaseOffer where
  toJSON :: AcceptGiftOnChainPurchaseOffer -> Value
toJSON
    AcceptGiftOnChainPurchaseOffer
      { message_id :: AcceptGiftOnChainPurchaseOffer -> 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
"acceptGiftOnChainPurchaseOffer"
          , 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_
          ]