{-# 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 InvoicePaymentMethodOptionsCard
module StripeAPI.Types.InvoicePaymentMethodOptionsCard 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.invoice_payment_method_options_card@ in the specification.
data InvoicePaymentMethodOptionsCard = InvoicePaymentMethodOptionsCard
  { -- | 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. 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.
    InvoicePaymentMethodOptionsCard
-> Maybe InvoicePaymentMethodOptionsCardRequestThreeDSecure'
invoicePaymentMethodOptionsCardRequestThreeDSecure :: (GHC.Maybe.Maybe InvoicePaymentMethodOptionsCardRequestThreeDSecure')
  }
  deriving
    ( Int -> InvoicePaymentMethodOptionsCard -> ShowS
[InvoicePaymentMethodOptionsCard] -> ShowS
InvoicePaymentMethodOptionsCard -> String
(Int -> InvoicePaymentMethodOptionsCard -> ShowS)
-> (InvoicePaymentMethodOptionsCard -> String)
-> ([InvoicePaymentMethodOptionsCard] -> ShowS)
-> Show InvoicePaymentMethodOptionsCard
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InvoicePaymentMethodOptionsCard] -> ShowS
$cshowList :: [InvoicePaymentMethodOptionsCard] -> ShowS
show :: InvoicePaymentMethodOptionsCard -> String
$cshow :: InvoicePaymentMethodOptionsCard -> String
showsPrec :: Int -> InvoicePaymentMethodOptionsCard -> ShowS
$cshowsPrec :: Int -> InvoicePaymentMethodOptionsCard -> ShowS
GHC.Show.Show,
      InvoicePaymentMethodOptionsCard
-> InvoicePaymentMethodOptionsCard -> Bool
(InvoicePaymentMethodOptionsCard
 -> InvoicePaymentMethodOptionsCard -> Bool)
-> (InvoicePaymentMethodOptionsCard
    -> InvoicePaymentMethodOptionsCard -> Bool)
-> Eq InvoicePaymentMethodOptionsCard
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InvoicePaymentMethodOptionsCard
-> InvoicePaymentMethodOptionsCard -> Bool
$c/= :: InvoicePaymentMethodOptionsCard
-> InvoicePaymentMethodOptionsCard -> Bool
== :: InvoicePaymentMethodOptionsCard
-> InvoicePaymentMethodOptionsCard -> Bool
$c== :: InvoicePaymentMethodOptionsCard
-> InvoicePaymentMethodOptionsCard -> Bool
GHC.Classes.Eq
    )

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

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

-- | Create a new 'InvoicePaymentMethodOptionsCard' with all required fields.
mkInvoicePaymentMethodOptionsCard :: InvoicePaymentMethodOptionsCard
mkInvoicePaymentMethodOptionsCard :: InvoicePaymentMethodOptionsCard
mkInvoicePaymentMethodOptionsCard = InvoicePaymentMethodOptionsCard :: Maybe InvoicePaymentMethodOptionsCardRequestThreeDSecure'
-> InvoicePaymentMethodOptionsCard
InvoicePaymentMethodOptionsCard {invoicePaymentMethodOptionsCardRequestThreeDSecure :: Maybe InvoicePaymentMethodOptionsCardRequestThreeDSecure'
invoicePaymentMethodOptionsCardRequestThreeDSecure = Maybe InvoicePaymentMethodOptionsCardRequestThreeDSecure'
forall a. Maybe a
GHC.Maybe.Nothing}

-- | Defines the enum schema located at @components.schemas.invoice_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. 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 InvoicePaymentMethodOptionsCardRequestThreeDSecure'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    InvoicePaymentMethodOptionsCardRequestThreeDSecure'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.
    InvoicePaymentMethodOptionsCardRequestThreeDSecure'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"any"@
    InvoicePaymentMethodOptionsCardRequestThreeDSecure'EnumAny
  | -- | Represents the JSON value @"automatic"@
    InvoicePaymentMethodOptionsCardRequestThreeDSecure'EnumAutomatic
  deriving (Int -> InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> ShowS
[InvoicePaymentMethodOptionsCardRequestThreeDSecure'] -> ShowS
InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> String
(Int
 -> InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> ShowS)
-> (InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> String)
-> ([InvoicePaymentMethodOptionsCardRequestThreeDSecure'] -> ShowS)
-> Show InvoicePaymentMethodOptionsCardRequestThreeDSecure'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InvoicePaymentMethodOptionsCardRequestThreeDSecure'] -> ShowS
$cshowList :: [InvoicePaymentMethodOptionsCardRequestThreeDSecure'] -> ShowS
show :: InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> String
$cshow :: InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> String
showsPrec :: Int -> InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> ShowS
$cshowsPrec :: Int -> InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> ShowS
GHC.Show.Show, InvoicePaymentMethodOptionsCardRequestThreeDSecure'
-> InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> Bool
(InvoicePaymentMethodOptionsCardRequestThreeDSecure'
 -> InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> Bool)
-> (InvoicePaymentMethodOptionsCardRequestThreeDSecure'
    -> InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> Bool)
-> Eq InvoicePaymentMethodOptionsCardRequestThreeDSecure'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InvoicePaymentMethodOptionsCardRequestThreeDSecure'
-> InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> Bool
$c/= :: InvoicePaymentMethodOptionsCardRequestThreeDSecure'
-> InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> Bool
== :: InvoicePaymentMethodOptionsCardRequestThreeDSecure'
-> InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> Bool
$c== :: InvoicePaymentMethodOptionsCardRequestThreeDSecure'
-> InvoicePaymentMethodOptionsCardRequestThreeDSecure' -> Bool
GHC.Classes.Eq)

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

instance Data.Aeson.Types.FromJSON.FromJSON InvoicePaymentMethodOptionsCardRequestThreeDSecure' where
  parseJSON :: Value -> Parser InvoicePaymentMethodOptionsCardRequestThreeDSecure'
parseJSON Value
val =
    InvoicePaymentMethodOptionsCardRequestThreeDSecure'
-> Parser InvoicePaymentMethodOptionsCardRequestThreeDSecure'
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" -> InvoicePaymentMethodOptionsCardRequestThreeDSecure'
InvoicePaymentMethodOptionsCardRequestThreeDSecure'EnumAny
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"automatic" -> InvoicePaymentMethodOptionsCardRequestThreeDSecure'
InvoicePaymentMethodOptionsCardRequestThreeDSecure'EnumAutomatic
            | Bool
GHC.Base.otherwise -> Value -> InvoicePaymentMethodOptionsCardRequestThreeDSecure'
InvoicePaymentMethodOptionsCardRequestThreeDSecure'Other Value
val
      )