{-# LANGUAGE MultiWayIf #-}
-- CHANGE WITH CAUTION: This is a generated code file generated by https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator.
{-# LANGUAGE OverloadedStrings #-}

-- | Contains the types generated from the schema SetupIntentPaymentMethodOptionsCard
module StripeAPI.Types.SetupIntentPaymentMethodOptionsCard where

import qualified Control.Monad.Fail
import qualified Data.Aeson
import qualified Data.Aeson as Data.Aeson.Encoding.Internal
import qualified Data.Aeson as Data.Aeson.Types
import qualified Data.Aeson as Data.Aeson.Types.FromJSON
import qualified Data.Aeson as Data.Aeson.Types.Internal
import qualified Data.Aeson as Data.Aeson.Types.ToJSON
import qualified Data.ByteString.Char8
import qualified Data.ByteString.Char8 as Data.ByteString.Internal
import qualified Data.Functor
import qualified Data.Scientific
import qualified Data.Text
import qualified Data.Text.Internal
import qualified Data.Time.Calendar as Data.Time.Calendar.Days
import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime
import qualified GHC.Base
import qualified GHC.Classes
import qualified GHC.Int
import qualified GHC.Show
import qualified GHC.Types
import qualified StripeAPI.Common
import StripeAPI.TypeAlias
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.setup_intent_payment_method_options_card@ in the specification.
data SetupIntentPaymentMethodOptionsCard = SetupIntentPaymentMethodOptionsCard
  { -- | request_three_d_secure: We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https:\/\/stripe.com\/docs\/strong-customer-authentication). However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. Permitted values include: \`automatic\` or \`any\`. If not provided, defaults to \`automatic\`. Read our guide on [manually requesting 3D Secure](https:\/\/stripe.com\/docs\/payments\/3d-secure\#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine.
    SetupIntentPaymentMethodOptionsCard
-> Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
setupIntentPaymentMethodOptionsCardRequestThreeDSecure :: (GHC.Maybe.Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure')
  }
  deriving
    ( Int -> SetupIntentPaymentMethodOptionsCard -> ShowS
[SetupIntentPaymentMethodOptionsCard] -> ShowS
SetupIntentPaymentMethodOptionsCard -> String
(Int -> SetupIntentPaymentMethodOptionsCard -> ShowS)
-> (SetupIntentPaymentMethodOptionsCard -> String)
-> ([SetupIntentPaymentMethodOptionsCard] -> ShowS)
-> Show SetupIntentPaymentMethodOptionsCard
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetupIntentPaymentMethodOptionsCard] -> ShowS
$cshowList :: [SetupIntentPaymentMethodOptionsCard] -> ShowS
show :: SetupIntentPaymentMethodOptionsCard -> String
$cshow :: SetupIntentPaymentMethodOptionsCard -> String
showsPrec :: Int -> SetupIntentPaymentMethodOptionsCard -> ShowS
$cshowsPrec :: Int -> SetupIntentPaymentMethodOptionsCard -> ShowS
GHC.Show.Show,
      SetupIntentPaymentMethodOptionsCard
-> SetupIntentPaymentMethodOptionsCard -> Bool
(SetupIntentPaymentMethodOptionsCard
 -> SetupIntentPaymentMethodOptionsCard -> Bool)
-> (SetupIntentPaymentMethodOptionsCard
    -> SetupIntentPaymentMethodOptionsCard -> Bool)
-> Eq SetupIntentPaymentMethodOptionsCard
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetupIntentPaymentMethodOptionsCard
-> SetupIntentPaymentMethodOptionsCard -> Bool
$c/= :: SetupIntentPaymentMethodOptionsCard
-> SetupIntentPaymentMethodOptionsCard -> Bool
== :: SetupIntentPaymentMethodOptionsCard
-> SetupIntentPaymentMethodOptionsCard -> Bool
$c== :: SetupIntentPaymentMethodOptionsCard
-> SetupIntentPaymentMethodOptionsCard -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON SetupIntentPaymentMethodOptionsCard where
  toJSON :: SetupIntentPaymentMethodOptionsCard -> Value
toJSON SetupIntentPaymentMethodOptionsCard
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"request_three_d_secure" Text
-> Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
-> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SetupIntentPaymentMethodOptionsCard
-> Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
setupIntentPaymentMethodOptionsCardRequestThreeDSecure SetupIntentPaymentMethodOptionsCard
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: SetupIntentPaymentMethodOptionsCard -> Encoding
toEncoding SetupIntentPaymentMethodOptionsCard
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs (Text
"request_three_d_secure" Text
-> Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
-> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SetupIntentPaymentMethodOptionsCard
-> Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
setupIntentPaymentMethodOptionsCardRequestThreeDSecure SetupIntentPaymentMethodOptionsCard
obj)

instance Data.Aeson.Types.FromJSON.FromJSON SetupIntentPaymentMethodOptionsCard where
  parseJSON :: Value -> Parser SetupIntentPaymentMethodOptionsCard
parseJSON = String
-> (Object -> Parser SetupIntentPaymentMethodOptionsCard)
-> Value
-> Parser SetupIntentPaymentMethodOptionsCard
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SetupIntentPaymentMethodOptionsCard" (\Object
obj -> (Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
 -> SetupIntentPaymentMethodOptionsCard)
-> Parser
     (Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
      -> SetupIntentPaymentMethodOptionsCard)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
-> SetupIntentPaymentMethodOptionsCard
SetupIntentPaymentMethodOptionsCard Parser
  (Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
   -> SetupIntentPaymentMethodOptionsCard)
-> Parser
     (Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure')
-> Parser SetupIntentPaymentMethodOptionsCard
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser
     (Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"request_three_d_secure"))

-- | Create a new 'SetupIntentPaymentMethodOptionsCard' with all required fields.
mkSetupIntentPaymentMethodOptionsCard :: SetupIntentPaymentMethodOptionsCard
mkSetupIntentPaymentMethodOptionsCard :: SetupIntentPaymentMethodOptionsCard
mkSetupIntentPaymentMethodOptionsCard = SetupIntentPaymentMethodOptionsCard :: Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
-> SetupIntentPaymentMethodOptionsCard
SetupIntentPaymentMethodOptionsCard {setupIntentPaymentMethodOptionsCardRequestThreeDSecure :: Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
setupIntentPaymentMethodOptionsCardRequestThreeDSecure = Maybe SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
forall a. Maybe a
GHC.Maybe.Nothing}

-- | Defines the enum schema located at @components.schemas.setup_intent_payment_method_options_card.properties.request_three_d_secure@ in the specification.
--
-- We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https:\/\/stripe.com\/docs\/strong-customer-authentication). However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. Permitted values include: \`automatic\` or \`any\`. If not provided, defaults to \`automatic\`. Read our guide on [manually requesting 3D Secure](https:\/\/stripe.com\/docs\/payments\/3d-secure\#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine.
data SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'Other Data.Aeson.Types.Internal.Value
  | -- | This constructor can be used to send values to the server which are not present in the specification yet.
    SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"any"@
    SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'EnumAny
  | -- | Represents the JSON value @"automatic"@
    SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'EnumAutomatic
  | -- | Represents the JSON value @"challenge_only"@
    SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'EnumChallengeOnly
  deriving (Int
-> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> ShowS
[SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'] -> ShowS
SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> String
(Int
 -> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
 -> ShowS)
-> (SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
    -> String)
-> ([SetupIntentPaymentMethodOptionsCardRequestThreeDSecure']
    -> ShowS)
-> Show SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'] -> ShowS
$cshowList :: [SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'] -> ShowS
show :: SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> String
$cshow :: SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> String
showsPrec :: Int
-> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> ShowS
$cshowsPrec :: Int
-> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> ShowS
GHC.Show.Show, SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
-> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> Bool
(SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
 -> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> Bool)
-> (SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
    -> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> Bool)
-> Eq SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
-> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> Bool
$c/= :: SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
-> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> Bool
== :: SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
-> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> Bool
$c== :: SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
-> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' where
  toJSON :: SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' -> Value
toJSON (SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'Other Value
val) = Value
val
  toJSON (SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'EnumAny) = Value
"any"
  toJSON (SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'EnumAutomatic) = Value
"automatic"
  toJSON (SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'EnumChallengeOnly) = Value
"challenge_only"

instance Data.Aeson.Types.FromJSON.FromJSON SetupIntentPaymentMethodOptionsCardRequestThreeDSecure' where
  parseJSON :: Value
-> Parser SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
parseJSON Value
val =
    SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
-> Parser SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure
      ( if
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"any" -> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'EnumAny
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"automatic" -> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'EnumAutomatic
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"challenge_only" -> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'EnumChallengeOnly
            | Bool
GHC.Base.otherwise -> Value -> SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'
SetupIntentPaymentMethodOptionsCardRequestThreeDSecure'Other Value
val
      )