module TD.Data.OnRampProviders
(OnRampProviders(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.OnRampProvider as OnRampProvider
data OnRampProviders
= OnRampProviders
{ OnRampProviders -> Maybe [OnRampProvider]
providers :: Maybe [OnRampProvider.OnRampProvider]
}
deriving (OnRampProviders -> OnRampProviders -> Bool
(OnRampProviders -> OnRampProviders -> Bool)
-> (OnRampProviders -> OnRampProviders -> Bool)
-> Eq OnRampProviders
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OnRampProviders -> OnRampProviders -> Bool
== :: OnRampProviders -> OnRampProviders -> Bool
$c/= :: OnRampProviders -> OnRampProviders -> Bool
/= :: OnRampProviders -> OnRampProviders -> Bool
Eq, Int -> OnRampProviders -> ShowS
[OnRampProviders] -> ShowS
OnRampProviders -> String
(Int -> OnRampProviders -> ShowS)
-> (OnRampProviders -> String)
-> ([OnRampProviders] -> ShowS)
-> Show OnRampProviders
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OnRampProviders -> ShowS
showsPrec :: Int -> OnRampProviders -> ShowS
$cshow :: OnRampProviders -> String
show :: OnRampProviders -> String
$cshowList :: [OnRampProviders] -> ShowS
showList :: [OnRampProviders] -> ShowS
Show)
instance I.ShortShow OnRampProviders where
shortShow :: OnRampProviders -> String
shortShow OnRampProviders
{ providers :: OnRampProviders -> Maybe [OnRampProvider]
providers = Maybe [OnRampProvider]
providers_
}
= String
"OnRampProviders"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"providers" String -> Maybe [OnRampProvider] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [OnRampProvider]
providers_
]
instance AT.FromJSON OnRampProviders where
parseJSON :: Value -> Parser OnRampProviders
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
"onRampProviders" -> Value -> Parser OnRampProviders
parseOnRampProviders Value
v
String
_ -> Parser OnRampProviders
forall a. Monoid a => a
mempty
where
parseOnRampProviders :: A.Value -> AT.Parser OnRampProviders
parseOnRampProviders :: Value -> Parser OnRampProviders
parseOnRampProviders = String
-> (Object -> Parser OnRampProviders)
-> Value
-> Parser OnRampProviders
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"OnRampProviders" ((Object -> Parser OnRampProviders)
-> Value -> Parser OnRampProviders)
-> (Object -> Parser OnRampProviders)
-> Value
-> Parser OnRampProviders
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [OnRampProvider]
providers_ <- Object
o Object -> Key -> Parser (Maybe [OnRampProvider])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"providers"
OnRampProviders -> Parser OnRampProviders
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (OnRampProviders -> Parser OnRampProviders)
-> OnRampProviders -> Parser OnRampProviders
forall a b. (a -> b) -> a -> b
$ OnRampProviders
{ providers :: Maybe [OnRampProvider]
providers = Maybe [OnRampProvider]
providers_
}
parseJSON Value
_ = Parser OnRampProviders
forall a. Monoid a => a
mempty