module TD.Data.OnRampPaymentQuote
  (OnRampPaymentQuote(..)) 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

data OnRampPaymentQuote
  = OnRampPaymentQuote -- ^ Describes a quote for an on-ramp purchase
    { OnRampPaymentQuote -> Maybe Text
payment_method        :: Maybe T.Text -- ^ The payment method to be used
    , OnRampPaymentQuote -> Maybe Int
expiration_date       :: Maybe Int    -- ^ Point in time (Unix timestamp) when the quote will expire
    , OnRampPaymentQuote -> Maybe Text
base_currency_amount  :: Maybe T.Text -- ^ Paid amount of the base currency
    , OnRampPaymentQuote -> Maybe Text
cryptocurrency_amount :: Maybe T.Text -- ^ Purchased amount of the cryptocurrency
    , OnRampPaymentQuote -> Maybe Text
cryptocurrency_price  :: Maybe T.Text -- ^ The price of the cryptocurrency
    , OnRampPaymentQuote -> Maybe Text
fee_amount            :: Maybe T.Text -- ^ Fee amount
    , OnRampPaymentQuote -> Maybe Text
extra_fee_amount      :: Maybe T.Text -- ^ Extra fee amount
    , OnRampPaymentQuote -> Maybe Text
network_fee_amount    :: Maybe T.Text -- ^ Network fee amount
    , OnRampPaymentQuote -> Maybe Text
total_amount          :: Maybe T.Text -- ^ Total paid amount
    }
  deriving (OnRampPaymentQuote -> OnRampPaymentQuote -> Bool
(OnRampPaymentQuote -> OnRampPaymentQuote -> Bool)
-> (OnRampPaymentQuote -> OnRampPaymentQuote -> Bool)
-> Eq OnRampPaymentQuote
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OnRampPaymentQuote -> OnRampPaymentQuote -> Bool
== :: OnRampPaymentQuote -> OnRampPaymentQuote -> Bool
$c/= :: OnRampPaymentQuote -> OnRampPaymentQuote -> Bool
/= :: OnRampPaymentQuote -> OnRampPaymentQuote -> Bool
Eq, Int -> OnRampPaymentQuote -> ShowS
[OnRampPaymentQuote] -> ShowS
OnRampPaymentQuote -> String
(Int -> OnRampPaymentQuote -> ShowS)
-> (OnRampPaymentQuote -> String)
-> ([OnRampPaymentQuote] -> ShowS)
-> Show OnRampPaymentQuote
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OnRampPaymentQuote -> ShowS
showsPrec :: Int -> OnRampPaymentQuote -> ShowS
$cshow :: OnRampPaymentQuote -> String
show :: OnRampPaymentQuote -> String
$cshowList :: [OnRampPaymentQuote] -> ShowS
showList :: [OnRampPaymentQuote] -> ShowS
Show)

instance I.ShortShow OnRampPaymentQuote where
  shortShow :: OnRampPaymentQuote -> String
shortShow OnRampPaymentQuote
    { payment_method :: OnRampPaymentQuote -> Maybe Text
payment_method        = Maybe Text
payment_method_
    , expiration_date :: OnRampPaymentQuote -> Maybe Int
expiration_date       = Maybe Int
expiration_date_
    , base_currency_amount :: OnRampPaymentQuote -> Maybe Text
base_currency_amount  = Maybe Text
base_currency_amount_
    , cryptocurrency_amount :: OnRampPaymentQuote -> Maybe Text
cryptocurrency_amount = Maybe Text
cryptocurrency_amount_
    , cryptocurrency_price :: OnRampPaymentQuote -> Maybe Text
cryptocurrency_price  = Maybe Text
cryptocurrency_price_
    , fee_amount :: OnRampPaymentQuote -> Maybe Text
fee_amount            = Maybe Text
fee_amount_
    , extra_fee_amount :: OnRampPaymentQuote -> Maybe Text
extra_fee_amount      = Maybe Text
extra_fee_amount_
    , network_fee_amount :: OnRampPaymentQuote -> Maybe Text
network_fee_amount    = Maybe Text
network_fee_amount_
    , total_amount :: OnRampPaymentQuote -> Maybe Text
total_amount          = Maybe Text
total_amount_
    }
      = String
"OnRampPaymentQuote"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"payment_method"        String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
payment_method_
        , String
"expiration_date"       String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
expiration_date_
        , String
"base_currency_amount"  String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
base_currency_amount_
        , String
"cryptocurrency_amount" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
cryptocurrency_amount_
        , String
"cryptocurrency_price"  String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
cryptocurrency_price_
        , String
"fee_amount"            String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
fee_amount_
        , String
"extra_fee_amount"      String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
extra_fee_amount_
        , String
"network_fee_amount"    String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
network_fee_amount_
        , String
"total_amount"          String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
total_amount_
        ]

instance AT.FromJSON OnRampPaymentQuote where
  parseJSON :: Value -> Parser OnRampPaymentQuote
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
"onRampPaymentQuote" -> Value -> Parser OnRampPaymentQuote
parseOnRampPaymentQuote Value
v
      String
_                    -> Parser OnRampPaymentQuote
forall a. Monoid a => a
mempty
    
    where
      parseOnRampPaymentQuote :: A.Value -> AT.Parser OnRampPaymentQuote
      parseOnRampPaymentQuote :: Value -> Parser OnRampPaymentQuote
parseOnRampPaymentQuote = String
-> (Object -> Parser OnRampPaymentQuote)
-> Value
-> Parser OnRampPaymentQuote
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"OnRampPaymentQuote" ((Object -> Parser OnRampPaymentQuote)
 -> Value -> Parser OnRampPaymentQuote)
-> (Object -> Parser OnRampPaymentQuote)
-> Value
-> Parser OnRampPaymentQuote
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Text
payment_method_        <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"payment_method"
        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 Text
base_currency_amount_  <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"base_currency_amount"
        Maybe Text
cryptocurrency_amount_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"cryptocurrency_amount"
        Maybe Text
cryptocurrency_price_  <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"cryptocurrency_price"
        Maybe Text
fee_amount_            <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"fee_amount"
        Maybe Text
extra_fee_amount_      <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"extra_fee_amount"
        Maybe Text
network_fee_amount_    <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"network_fee_amount"
        Maybe Text
total_amount_          <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"total_amount"
        OnRampPaymentQuote -> Parser OnRampPaymentQuote
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (OnRampPaymentQuote -> Parser OnRampPaymentQuote)
-> OnRampPaymentQuote -> Parser OnRampPaymentQuote
forall a b. (a -> b) -> a -> b
$ OnRampPaymentQuote
          { payment_method :: Maybe Text
payment_method        = Maybe Text
payment_method_
          , expiration_date :: Maybe Int
expiration_date       = Maybe Int
expiration_date_
          , base_currency_amount :: Maybe Text
base_currency_amount  = Maybe Text
base_currency_amount_
          , cryptocurrency_amount :: Maybe Text
cryptocurrency_amount = Maybe Text
cryptocurrency_amount_
          , cryptocurrency_price :: Maybe Text
cryptocurrency_price  = Maybe Text
cryptocurrency_price_
          , fee_amount :: Maybe Text
fee_amount            = Maybe Text
fee_amount_
          , extra_fee_amount :: Maybe Text
extra_fee_amount      = Maybe Text
extra_fee_amount_
          , network_fee_amount :: Maybe Text
network_fee_amount    = Maybe Text
network_fee_amount_
          , total_amount :: Maybe Text
total_amount          = Maybe Text
total_amount_
          }
  parseJSON Value
_ = Parser OnRampPaymentQuote
forall a. Monoid a => a
mempty