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