module TD.Data.StarTransactionDirection
(StarTransactionDirection(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data StarTransactionDirection
= StarTransactionDirectionIncoming
| StarTransactionDirectionOutgoing
deriving (StarTransactionDirection -> StarTransactionDirection -> Bool
(StarTransactionDirection -> StarTransactionDirection -> Bool)
-> (StarTransactionDirection -> StarTransactionDirection -> Bool)
-> Eq StarTransactionDirection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StarTransactionDirection -> StarTransactionDirection -> Bool
== :: StarTransactionDirection -> StarTransactionDirection -> Bool
$c/= :: StarTransactionDirection -> StarTransactionDirection -> Bool
/= :: StarTransactionDirection -> StarTransactionDirection -> Bool
Eq, Int -> StarTransactionDirection -> ShowS
[StarTransactionDirection] -> ShowS
StarTransactionDirection -> String
(Int -> StarTransactionDirection -> ShowS)
-> (StarTransactionDirection -> String)
-> ([StarTransactionDirection] -> ShowS)
-> Show StarTransactionDirection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StarTransactionDirection -> ShowS
showsPrec :: Int -> StarTransactionDirection -> ShowS
$cshow :: StarTransactionDirection -> String
show :: StarTransactionDirection -> String
$cshowList :: [StarTransactionDirection] -> ShowS
showList :: [StarTransactionDirection] -> ShowS
Show)
instance I.ShortShow StarTransactionDirection where
shortShow :: StarTransactionDirection -> String
shortShow StarTransactionDirection
StarTransactionDirectionIncoming
= String
"StarTransactionDirectionIncoming"
shortShow StarTransactionDirection
StarTransactionDirectionOutgoing
= String
"StarTransactionDirectionOutgoing"
instance AT.FromJSON StarTransactionDirection where
parseJSON :: Value -> Parser StarTransactionDirection
parseJSON (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
"starTransactionDirectionIncoming" -> StarTransactionDirection -> Parser StarTransactionDirection
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure StarTransactionDirection
StarTransactionDirectionIncoming
String
"starTransactionDirectionOutgoing" -> StarTransactionDirection -> Parser StarTransactionDirection
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure StarTransactionDirection
StarTransactionDirectionOutgoing
String
_ -> Parser StarTransactionDirection
forall a. Monoid a => a
mempty
parseJSON Value
_ = Parser StarTransactionDirection
forall a. Monoid a => a
mempty
instance AT.ToJSON StarTransactionDirection where
toJSON :: StarTransactionDirection -> Value
toJSON StarTransactionDirection
StarTransactionDirectionIncoming
= [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
"starTransactionDirectionIncoming"
]
toJSON StarTransactionDirection
StarTransactionDirectionOutgoing
= [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
"starTransactionDirectionOutgoing"
]