module TD.Data.GiftOnChainPurchaseOfferTransaction
(GiftOnChainPurchaseOfferTransaction(..)) 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.TonWalletMessage as TonWalletMessage
data GiftOnChainPurchaseOfferTransaction
= GiftOnChainPurchaseOfferTransaction
{ GiftOnChainPurchaseOfferTransaction -> Maybe Text
offer_address :: Maybe T.Text
, GiftOnChainPurchaseOfferTransaction -> Maybe Int
expiration_date :: Maybe Int
, GiftOnChainPurchaseOfferTransaction -> Maybe TonWalletMessage
message :: Maybe TonWalletMessage.TonWalletMessage
, GiftOnChainPurchaseOfferTransaction -> Maybe TonWalletMessage
gasless_message :: Maybe TonWalletMessage.TonWalletMessage
, GiftOnChainPurchaseOfferTransaction -> Maybe Int
rent_budget_amount :: Maybe Int
, GiftOnChainPurchaseOfferTransaction -> Maybe Int
execution_allowance_amount :: Maybe Int
, GiftOnChainPurchaseOfferTransaction -> Maybe Int
forward_amount :: Maybe Int
, GiftOnChainPurchaseOfferTransaction -> Maybe Int
fine_amount :: Maybe Int
}
deriving (GiftOnChainPurchaseOfferTransaction
-> GiftOnChainPurchaseOfferTransaction -> Bool
(GiftOnChainPurchaseOfferTransaction
-> GiftOnChainPurchaseOfferTransaction -> Bool)
-> (GiftOnChainPurchaseOfferTransaction
-> GiftOnChainPurchaseOfferTransaction -> Bool)
-> Eq GiftOnChainPurchaseOfferTransaction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GiftOnChainPurchaseOfferTransaction
-> GiftOnChainPurchaseOfferTransaction -> Bool
== :: GiftOnChainPurchaseOfferTransaction
-> GiftOnChainPurchaseOfferTransaction -> Bool
$c/= :: GiftOnChainPurchaseOfferTransaction
-> GiftOnChainPurchaseOfferTransaction -> Bool
/= :: GiftOnChainPurchaseOfferTransaction
-> GiftOnChainPurchaseOfferTransaction -> Bool
Eq, Int -> GiftOnChainPurchaseOfferTransaction -> ShowS
[GiftOnChainPurchaseOfferTransaction] -> ShowS
GiftOnChainPurchaseOfferTransaction -> String
(Int -> GiftOnChainPurchaseOfferTransaction -> ShowS)
-> (GiftOnChainPurchaseOfferTransaction -> String)
-> ([GiftOnChainPurchaseOfferTransaction] -> ShowS)
-> Show GiftOnChainPurchaseOfferTransaction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GiftOnChainPurchaseOfferTransaction -> ShowS
showsPrec :: Int -> GiftOnChainPurchaseOfferTransaction -> ShowS
$cshow :: GiftOnChainPurchaseOfferTransaction -> String
show :: GiftOnChainPurchaseOfferTransaction -> String
$cshowList :: [GiftOnChainPurchaseOfferTransaction] -> ShowS
showList :: [GiftOnChainPurchaseOfferTransaction] -> ShowS
Show)
instance I.ShortShow GiftOnChainPurchaseOfferTransaction where
shortShow :: GiftOnChainPurchaseOfferTransaction -> String
shortShow GiftOnChainPurchaseOfferTransaction
{ offer_address :: GiftOnChainPurchaseOfferTransaction -> Maybe Text
offer_address = Maybe Text
offer_address_
, expiration_date :: GiftOnChainPurchaseOfferTransaction -> Maybe Int
expiration_date = Maybe Int
expiration_date_
, message :: GiftOnChainPurchaseOfferTransaction -> Maybe TonWalletMessage
message = Maybe TonWalletMessage
message_
, gasless_message :: GiftOnChainPurchaseOfferTransaction -> Maybe TonWalletMessage
gasless_message = Maybe TonWalletMessage
gasless_message_
, rent_budget_amount :: GiftOnChainPurchaseOfferTransaction -> Maybe Int
rent_budget_amount = Maybe Int
rent_budget_amount_
, execution_allowance_amount :: GiftOnChainPurchaseOfferTransaction -> Maybe Int
execution_allowance_amount = Maybe Int
execution_allowance_amount_
, forward_amount :: GiftOnChainPurchaseOfferTransaction -> Maybe Int
forward_amount = Maybe Int
forward_amount_
, fine_amount :: GiftOnChainPurchaseOfferTransaction -> Maybe Int
fine_amount = Maybe Int
fine_amount_
}
= String
"GiftOnChainPurchaseOfferTransaction"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"offer_address" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
offer_address_
, String
"expiration_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
expiration_date_
, String
"message" String -> Maybe TonWalletMessage -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe TonWalletMessage
message_
, String
"gasless_message" String -> Maybe TonWalletMessage -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe TonWalletMessage
gasless_message_
, String
"rent_budget_amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
rent_budget_amount_
, String
"execution_allowance_amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
execution_allowance_amount_
, String
"forward_amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
forward_amount_
, String
"fine_amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
fine_amount_
]
instance AT.FromJSON GiftOnChainPurchaseOfferTransaction where
parseJSON :: Value -> Parser GiftOnChainPurchaseOfferTransaction
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"giftOnChainPurchaseOfferTransaction" -> Value -> Parser GiftOnChainPurchaseOfferTransaction
parseGiftOnChainPurchaseOfferTransaction Value
v
String
_ -> Parser GiftOnChainPurchaseOfferTransaction
forall a. Monoid a => a
mempty
where
parseGiftOnChainPurchaseOfferTransaction :: A.Value -> AT.Parser GiftOnChainPurchaseOfferTransaction
parseGiftOnChainPurchaseOfferTransaction :: Value -> Parser GiftOnChainPurchaseOfferTransaction
parseGiftOnChainPurchaseOfferTransaction = String
-> (Object -> Parser GiftOnChainPurchaseOfferTransaction)
-> Value
-> Parser GiftOnChainPurchaseOfferTransaction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"GiftOnChainPurchaseOfferTransaction" ((Object -> Parser GiftOnChainPurchaseOfferTransaction)
-> Value -> Parser GiftOnChainPurchaseOfferTransaction)
-> (Object -> Parser GiftOnChainPurchaseOfferTransaction)
-> Value
-> Parser GiftOnChainPurchaseOfferTransaction
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
offer_address_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"offer_address"
Maybe Int
expiration_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"expiration_date"
Maybe TonWalletMessage
message_ <- Object
o Object -> Key -> Parser (Maybe TonWalletMessage)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"message"
Maybe TonWalletMessage
gasless_message_ <- Object
o Object -> Key -> Parser (Maybe TonWalletMessage)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"gasless_message"
Maybe Int
rent_budget_amount_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"rent_budget_amount"
Maybe Int
execution_allowance_amount_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"execution_allowance_amount"
Maybe Int
forward_amount_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"forward_amount"
Maybe Int
fine_amount_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"fine_amount"
GiftOnChainPurchaseOfferTransaction
-> Parser GiftOnChainPurchaseOfferTransaction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GiftOnChainPurchaseOfferTransaction
-> Parser GiftOnChainPurchaseOfferTransaction)
-> GiftOnChainPurchaseOfferTransaction
-> Parser GiftOnChainPurchaseOfferTransaction
forall a b. (a -> b) -> a -> b
$ GiftOnChainPurchaseOfferTransaction
{ offer_address :: Maybe Text
offer_address = Maybe Text
offer_address_
, expiration_date :: Maybe Int
expiration_date = Maybe Int
expiration_date_
, message :: Maybe TonWalletMessage
message = Maybe TonWalletMessage
message_
, gasless_message :: Maybe TonWalletMessage
gasless_message = Maybe TonWalletMessage
gasless_message_
, rent_budget_amount :: Maybe Int
rent_budget_amount = Maybe Int
rent_budget_amount_
, execution_allowance_amount :: Maybe Int
execution_allowance_amount = Maybe Int
execution_allowance_amount_
, forward_amount :: Maybe Int
forward_amount = Maybe Int
forward_amount_
, fine_amount :: Maybe Int
fine_amount = Maybe Int
fine_amount_
}
parseJSON Value
_ = Parser GiftOnChainPurchaseOfferTransaction
forall a. Monoid a => a
mempty