module TD.Data.TonWalletTransactionType
(TonWalletTransactionType(..)) 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.TonNft as TonNft
data TonWalletTransactionType
= TonWalletTransactionTypeOnRampDeposit
{ TonWalletTransactionType -> Maybe Int
amount :: Maybe Int
, TonWalletTransactionType -> Maybe Text
provider_name :: Maybe T.Text
}
| TonWalletTransactionTypeTransfer
{ amount :: Maybe Int
, TonWalletTransactionType -> Maybe Bool
is_gasless :: Maybe Bool
, :: Maybe T.Text
, :: Maybe Bool
}
| TonWalletTransactionTypeNftTransfer
{ TonWalletTransactionType -> Maybe TonNft
nft :: Maybe TonNft.TonNft
, TonWalletTransactionType -> Maybe Bool
is_outgoing :: Maybe Bool
, :: Maybe T.Text
, :: Maybe Bool
}
| TonWalletTransactionTypeTelegramGiftTransfer
{ nft :: Maybe TonNft.TonNft
, is_outgoing :: Maybe Bool
, TonWalletTransactionType -> Maybe Bool
is_saved :: Maybe Bool
}
| TonWalletTransactionTypeKeyChange
deriving (TonWalletTransactionType -> TonWalletTransactionType -> Bool
(TonWalletTransactionType -> TonWalletTransactionType -> Bool)
-> (TonWalletTransactionType -> TonWalletTransactionType -> Bool)
-> Eq TonWalletTransactionType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TonWalletTransactionType -> TonWalletTransactionType -> Bool
== :: TonWalletTransactionType -> TonWalletTransactionType -> Bool
$c/= :: TonWalletTransactionType -> TonWalletTransactionType -> Bool
/= :: TonWalletTransactionType -> TonWalletTransactionType -> Bool
Eq, Int -> TonWalletTransactionType -> ShowS
[TonWalletTransactionType] -> ShowS
TonWalletTransactionType -> String
(Int -> TonWalletTransactionType -> ShowS)
-> (TonWalletTransactionType -> String)
-> ([TonWalletTransactionType] -> ShowS)
-> Show TonWalletTransactionType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TonWalletTransactionType -> ShowS
showsPrec :: Int -> TonWalletTransactionType -> ShowS
$cshow :: TonWalletTransactionType -> String
show :: TonWalletTransactionType -> String
$cshowList :: [TonWalletTransactionType] -> ShowS
showList :: [TonWalletTransactionType] -> ShowS
Show)
instance I.ShortShow TonWalletTransactionType where
shortShow :: TonWalletTransactionType -> String
shortShow TonWalletTransactionTypeOnRampDeposit
{ amount :: TonWalletTransactionType -> Maybe Int
amount = Maybe Int
amount_
, provider_name :: TonWalletTransactionType -> Maybe Text
provider_name = Maybe Text
provider_name_
}
= String
"TonWalletTransactionTypeOnRampDeposit"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
amount_
, String
"provider_name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
provider_name_
]
shortShow TonWalletTransactionTypeTransfer
{ amount :: TonWalletTransactionType -> Maybe Int
amount = Maybe Int
amount_
, is_gasless :: TonWalletTransactionType -> Maybe Bool
is_gasless = Maybe Bool
is_gasless_
, comment :: TonWalletTransactionType -> Maybe Text
comment = Maybe Text
comment_
, is_comment_encrypted :: TonWalletTransactionType -> Maybe Bool
is_comment_encrypted = Maybe Bool
is_comment_encrypted_
}
= String
"TonWalletTransactionTypeTransfer"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
amount_
, String
"is_gasless" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_gasless_
, String
"comment" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
comment_
, String
"is_comment_encrypted" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_comment_encrypted_
]
shortShow TonWalletTransactionTypeNftTransfer
{ nft :: TonWalletTransactionType -> Maybe TonNft
nft = Maybe TonNft
nft_
, is_outgoing :: TonWalletTransactionType -> Maybe Bool
is_outgoing = Maybe Bool
is_outgoing_
, comment :: TonWalletTransactionType -> Maybe Text
comment = Maybe Text
comment_
, is_comment_encrypted :: TonWalletTransactionType -> Maybe Bool
is_comment_encrypted = Maybe Bool
is_comment_encrypted_
}
= String
"TonWalletTransactionTypeNftTransfer"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"nft" String -> Maybe TonNft -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe TonNft
nft_
, String
"is_outgoing" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_outgoing_
, String
"comment" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
comment_
, String
"is_comment_encrypted" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_comment_encrypted_
]
shortShow TonWalletTransactionTypeTelegramGiftTransfer
{ nft :: TonWalletTransactionType -> Maybe TonNft
nft = Maybe TonNft
nft_
, is_outgoing :: TonWalletTransactionType -> Maybe Bool
is_outgoing = Maybe Bool
is_outgoing_
, is_saved :: TonWalletTransactionType -> Maybe Bool
is_saved = Maybe Bool
is_saved_
}
= String
"TonWalletTransactionTypeTelegramGiftTransfer"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"nft" String -> Maybe TonNft -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe TonNft
nft_
, String
"is_outgoing" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_outgoing_
, String
"is_saved" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_saved_
]
shortShow TonWalletTransactionType
TonWalletTransactionTypeKeyChange
= String
"TonWalletTransactionTypeKeyChange"
instance AT.FromJSON TonWalletTransactionType where
parseJSON :: Value -> Parser TonWalletTransactionType
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
"tonWalletTransactionTypeOnRampDeposit" -> Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeOnRampDeposit Value
v
String
"tonWalletTransactionTypeTransfer" -> Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeTransfer Value
v
String
"tonWalletTransactionTypeNftTransfer" -> Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeNftTransfer Value
v
String
"tonWalletTransactionTypeTelegramGiftTransfer" -> Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeTelegramGiftTransfer Value
v
String
"tonWalletTransactionTypeKeyChange" -> TonWalletTransactionType -> Parser TonWalletTransactionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TonWalletTransactionType
TonWalletTransactionTypeKeyChange
String
_ -> Parser TonWalletTransactionType
forall a. Monoid a => a
mempty
where
parseTonWalletTransactionTypeOnRampDeposit :: A.Value -> AT.Parser TonWalletTransactionType
parseTonWalletTransactionTypeOnRampDeposit :: Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeOnRampDeposit = String
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TonWalletTransactionTypeOnRampDeposit" ((Object -> Parser TonWalletTransactionType)
-> Value -> Parser TonWalletTransactionType)
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
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
"amount"
Maybe Text
provider_name_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"provider_name"
TonWalletTransactionType -> Parser TonWalletTransactionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TonWalletTransactionType -> Parser TonWalletTransactionType)
-> TonWalletTransactionType -> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ TonWalletTransactionTypeOnRampDeposit
{ amount :: Maybe Int
amount = Maybe Int
amount_
, provider_name :: Maybe Text
provider_name = Maybe Text
provider_name_
}
parseTonWalletTransactionTypeTransfer :: A.Value -> AT.Parser TonWalletTransactionType
parseTonWalletTransactionTypeTransfer :: Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeTransfer = String
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TonWalletTransactionTypeTransfer" ((Object -> Parser TonWalletTransactionType)
-> Value -> Parser TonWalletTransactionType)
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
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
"amount"
Maybe Bool
is_gasless_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_gasless"
Maybe Text
comment_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"comment"
Maybe Bool
is_comment_encrypted_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_comment_encrypted"
TonWalletTransactionType -> Parser TonWalletTransactionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TonWalletTransactionType -> Parser TonWalletTransactionType)
-> TonWalletTransactionType -> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ TonWalletTransactionTypeTransfer
{ amount :: Maybe Int
amount = Maybe Int
amount_
, is_gasless :: Maybe Bool
is_gasless = Maybe Bool
is_gasless_
, comment :: Maybe Text
comment = Maybe Text
comment_
, is_comment_encrypted :: Maybe Bool
is_comment_encrypted = Maybe Bool
is_comment_encrypted_
}
parseTonWalletTransactionTypeNftTransfer :: A.Value -> AT.Parser TonWalletTransactionType
parseTonWalletTransactionTypeNftTransfer :: Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeNftTransfer = String
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TonWalletTransactionTypeNftTransfer" ((Object -> Parser TonWalletTransactionType)
-> Value -> Parser TonWalletTransactionType)
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe TonNft
nft_ <- Object
o Object -> Key -> Parser (Maybe TonNft)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"nft"
Maybe Bool
is_outgoing_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_outgoing"
Maybe Text
comment_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"comment"
Maybe Bool
is_comment_encrypted_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_comment_encrypted"
TonWalletTransactionType -> Parser TonWalletTransactionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TonWalletTransactionType -> Parser TonWalletTransactionType)
-> TonWalletTransactionType -> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ TonWalletTransactionTypeNftTransfer
{ nft :: Maybe TonNft
nft = Maybe TonNft
nft_
, is_outgoing :: Maybe Bool
is_outgoing = Maybe Bool
is_outgoing_
, comment :: Maybe Text
comment = Maybe Text
comment_
, is_comment_encrypted :: Maybe Bool
is_comment_encrypted = Maybe Bool
is_comment_encrypted_
}
parseTonWalletTransactionTypeTelegramGiftTransfer :: A.Value -> AT.Parser TonWalletTransactionType
parseTonWalletTransactionTypeTelegramGiftTransfer :: Value -> Parser TonWalletTransactionType
parseTonWalletTransactionTypeTelegramGiftTransfer = String
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"TonWalletTransactionTypeTelegramGiftTransfer" ((Object -> Parser TonWalletTransactionType)
-> Value -> Parser TonWalletTransactionType)
-> (Object -> Parser TonWalletTransactionType)
-> Value
-> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe TonNft
nft_ <- Object
o Object -> Key -> Parser (Maybe TonNft)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"nft"
Maybe Bool
is_outgoing_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_outgoing"
Maybe Bool
is_saved_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_saved"
TonWalletTransactionType -> Parser TonWalletTransactionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TonWalletTransactionType -> Parser TonWalletTransactionType)
-> TonWalletTransactionType -> Parser TonWalletTransactionType
forall a b. (a -> b) -> a -> b
$ TonWalletTransactionTypeTelegramGiftTransfer
{ nft :: Maybe TonNft
nft = Maybe TonNft
nft_
, is_outgoing :: Maybe Bool
is_outgoing = Maybe Bool
is_outgoing_
, is_saved :: Maybe Bool
is_saved = Maybe Bool
is_saved_
}
parseJSON Value
_ = Parser TonWalletTransactionType
forall a. Monoid a => a
mempty