module TD.Query.CreateOnRampPaymentSession
  (CreateOnRampPaymentSession(..)
  , defaultCreateOnRampPaymentSession
  ) 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

-- | Creates a session for an on-ramp payment. Returns 'TD.Data.OnRampPaymentSession.OnRampPaymentSession'
data CreateOnRampPaymentSession
  = CreateOnRampPaymentSession
    { CreateOnRampPaymentSession -> Maybe Text
provider_id           :: Maybe T.Text -- ^ Unique identifier of the on-ramp provider
    , CreateOnRampPaymentSession -> Maybe Text
cryptocurrency        :: Maybe T.Text -- ^ The cryptocurrency that will be bought
    , CreateOnRampPaymentSession -> Maybe Text
address               :: Maybe T.Text -- ^ Address to which the cryptocurrency will be sent
    , CreateOnRampPaymentSession -> Maybe Text
payment_method_name   :: Maybe T.Text -- ^ Name of the chosen payment method; pass an empty string if none
    , CreateOnRampPaymentSession -> Maybe Text
base_currency         :: Maybe T.Text -- ^ ISO 4217 currency code of the currency that will be used for the purchase; pass an empty string if unknown
    , CreateOnRampPaymentSession -> Maybe Text
cryptocurrency_amount :: Maybe T.Text -- ^ The amount of the cryptocurrency to buy; pass an empty string if the user selected base_currency_amount
    , CreateOnRampPaymentSession -> Maybe Text
base_currency_amount  :: Maybe T.Text -- ^ The amount of the base currency to spend; pass an empty string if the user selected cryptocurrency_amount
    , CreateOnRampPaymentSession -> Maybe Text
memo                  :: Maybe T.Text -- ^ Memo for the query; pass an empty string if none
    , CreateOnRampPaymentSession -> Maybe Text
theme                 :: Maybe T.Text -- ^ Preferred theme for the WebView; pass "light" for a light theme, "dark" for a dark theme, or leave empty for a default theme
    , CreateOnRampPaymentSession -> Maybe Text
success_return_url    :: Maybe T.Text -- ^ The URL opened on successful payment; pass an empty string if none
    , CreateOnRampPaymentSession -> Maybe Text
fail_return_url       :: Maybe T.Text -- ^ The URL opened on failed payment; pass an empty string if none
    }
  deriving (CreateOnRampPaymentSession -> CreateOnRampPaymentSession -> Bool
(CreateOnRampPaymentSession -> CreateOnRampPaymentSession -> Bool)
-> (CreateOnRampPaymentSession
    -> CreateOnRampPaymentSession -> Bool)
-> Eq CreateOnRampPaymentSession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateOnRampPaymentSession -> CreateOnRampPaymentSession -> Bool
== :: CreateOnRampPaymentSession -> CreateOnRampPaymentSession -> Bool
$c/= :: CreateOnRampPaymentSession -> CreateOnRampPaymentSession -> Bool
/= :: CreateOnRampPaymentSession -> CreateOnRampPaymentSession -> Bool
Eq, Int -> CreateOnRampPaymentSession -> ShowS
[CreateOnRampPaymentSession] -> ShowS
CreateOnRampPaymentSession -> String
(Int -> CreateOnRampPaymentSession -> ShowS)
-> (CreateOnRampPaymentSession -> String)
-> ([CreateOnRampPaymentSession] -> ShowS)
-> Show CreateOnRampPaymentSession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateOnRampPaymentSession -> ShowS
showsPrec :: Int -> CreateOnRampPaymentSession -> ShowS
$cshow :: CreateOnRampPaymentSession -> String
show :: CreateOnRampPaymentSession -> String
$cshowList :: [CreateOnRampPaymentSession] -> ShowS
showList :: [CreateOnRampPaymentSession] -> ShowS
Show)

instance I.ShortShow CreateOnRampPaymentSession where
  shortShow :: CreateOnRampPaymentSession -> String
shortShow
    CreateOnRampPaymentSession
      { provider_id :: CreateOnRampPaymentSession -> Maybe Text
provider_id           = Maybe Text
provider_id_
      , cryptocurrency :: CreateOnRampPaymentSession -> Maybe Text
cryptocurrency        = Maybe Text
cryptocurrency_
      , address :: CreateOnRampPaymentSession -> Maybe Text
address               = Maybe Text
address_
      , payment_method_name :: CreateOnRampPaymentSession -> Maybe Text
payment_method_name   = Maybe Text
payment_method_name_
      , base_currency :: CreateOnRampPaymentSession -> Maybe Text
base_currency         = Maybe Text
base_currency_
      , cryptocurrency_amount :: CreateOnRampPaymentSession -> Maybe Text
cryptocurrency_amount = Maybe Text
cryptocurrency_amount_
      , base_currency_amount :: CreateOnRampPaymentSession -> Maybe Text
base_currency_amount  = Maybe Text
base_currency_amount_
      , memo :: CreateOnRampPaymentSession -> Maybe Text
memo                  = Maybe Text
memo_
      , theme :: CreateOnRampPaymentSession -> Maybe Text
theme                 = Maybe Text
theme_
      , success_return_url :: CreateOnRampPaymentSession -> Maybe Text
success_return_url    = Maybe Text
success_return_url_
      , fail_return_url :: CreateOnRampPaymentSession -> Maybe Text
fail_return_url       = Maybe Text
fail_return_url_
      }
        = String
"CreateOnRampPaymentSession"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"provider_id"           String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
provider_id_
          , String
"cryptocurrency"        String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
cryptocurrency_
          , String
"address"               String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
address_
          , String
"payment_method_name"   String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
payment_method_name_
          , String
"base_currency"         String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
base_currency_
          , String
"cryptocurrency_amount" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
cryptocurrency_amount_
          , String
"base_currency_amount"  String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
base_currency_amount_
          , String
"memo"                  String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
memo_
          , String
"theme"                 String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
theme_
          , String
"success_return_url"    String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
success_return_url_
          , String
"fail_return_url"       String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
fail_return_url_
          ]

instance AT.ToJSON CreateOnRampPaymentSession where
  toJSON :: CreateOnRampPaymentSession -> Value
toJSON
    CreateOnRampPaymentSession
      { provider_id :: CreateOnRampPaymentSession -> Maybe Text
provider_id           = Maybe Text
provider_id_
      , cryptocurrency :: CreateOnRampPaymentSession -> Maybe Text
cryptocurrency        = Maybe Text
cryptocurrency_
      , address :: CreateOnRampPaymentSession -> Maybe Text
address               = Maybe Text
address_
      , payment_method_name :: CreateOnRampPaymentSession -> Maybe Text
payment_method_name   = Maybe Text
payment_method_name_
      , base_currency :: CreateOnRampPaymentSession -> Maybe Text
base_currency         = Maybe Text
base_currency_
      , cryptocurrency_amount :: CreateOnRampPaymentSession -> Maybe Text
cryptocurrency_amount = Maybe Text
cryptocurrency_amount_
      , base_currency_amount :: CreateOnRampPaymentSession -> Maybe Text
base_currency_amount  = Maybe Text
base_currency_amount_
      , memo :: CreateOnRampPaymentSession -> Maybe Text
memo                  = Maybe Text
memo_
      , theme :: CreateOnRampPaymentSession -> Maybe Text
theme                 = Maybe Text
theme_
      , success_return_url :: CreateOnRampPaymentSession -> Maybe Text
success_return_url    = Maybe Text
success_return_url_
      , fail_return_url :: CreateOnRampPaymentSession -> Maybe Text
fail_return_url       = Maybe Text
fail_return_url_
      }
        = [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
"createOnRampPaymentSession"
          , Key
"provider_id"           Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
provider_id_
          , Key
"cryptocurrency"        Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
cryptocurrency_
          , Key
"address"               Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
address_
          , Key
"payment_method_name"   Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
payment_method_name_
          , Key
"base_currency"         Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
base_currency_
          , Key
"cryptocurrency_amount" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
cryptocurrency_amount_
          , Key
"base_currency_amount"  Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
base_currency_amount_
          , Key
"memo"                  Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
memo_
          , Key
"theme"                 Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
theme_
          , Key
"success_return_url"    Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
success_return_url_
          , Key
"fail_return_url"       Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
fail_return_url_
          ]

defaultCreateOnRampPaymentSession :: CreateOnRampPaymentSession
defaultCreateOnRampPaymentSession :: CreateOnRampPaymentSession
defaultCreateOnRampPaymentSession =
  CreateOnRampPaymentSession
    { provider_id :: Maybe Text
provider_id           = Maybe Text
forall a. Maybe a
Nothing
    , cryptocurrency :: Maybe Text
cryptocurrency        = Maybe Text
forall a. Maybe a
Nothing
    , address :: Maybe Text
address               = Maybe Text
forall a. Maybe a
Nothing
    , payment_method_name :: Maybe Text
payment_method_name   = Maybe Text
forall a. Maybe a
Nothing
    , base_currency :: Maybe Text
base_currency         = Maybe Text
forall a. Maybe a
Nothing
    , cryptocurrency_amount :: Maybe Text
cryptocurrency_amount = Maybe Text
forall a. Maybe a
Nothing
    , base_currency_amount :: Maybe Text
base_currency_amount  = Maybe Text
forall a. Maybe a
Nothing
    , memo :: Maybe Text
memo                  = Maybe Text
forall a. Maybe a
Nothing
    , theme :: Maybe Text
theme                 = Maybe Text
forall a. Maybe a
Nothing
    , success_return_url :: Maybe Text
success_return_url    = Maybe Text
forall a. Maybe a
Nothing
    , fail_return_url :: Maybe Text
fail_return_url       = Maybe Text
forall a. Maybe a
Nothing
    }