{-# 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 ThreeDSecure
module StripeAPI.Types.ThreeDSecure 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 {-# SOURCE #-} StripeAPI.Types.Card
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.three_d_secure@ in the specification.
--
-- Cardholder authentication via 3D Secure is initiated by creating a \`3D Secure\`
-- object. Once the object has been created, you can use it to authenticate the
-- cardholder and create a charge.
data ThreeDSecure = ThreeDSecure
  { -- | amount: Amount of the charge that you will create when authentication completes.
    ThreeDSecure -> Int
threeDSecureAmount :: GHC.Types.Int,
    -- | authenticated: True if the cardholder went through the authentication flow and their bank indicated that authentication succeeded.
    ThreeDSecure -> Bool
threeDSecureAuthenticated :: GHC.Types.Bool,
    -- | card: You can store multiple cards on a customer in order to charge the customer
    -- later. You can also store multiple debit cards on a recipient in order to
    -- transfer to those cards later.
    --
    -- Related guide: [Card Payments with Sources](https:\/\/stripe.com\/docs\/sources\/cards).
    ThreeDSecure -> Card
threeDSecureCard :: Card,
    -- | created: Time at which the object was created. Measured in seconds since the Unix epoch.
    ThreeDSecure -> Int
threeDSecureCreated :: GHC.Types.Int,
    -- | currency: Three-letter [ISO currency code](https:\/\/www.iso.org\/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https:\/\/stripe.com\/docs\/currencies).
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    ThreeDSecure -> Text
threeDSecureCurrency :: Data.Text.Internal.Text,
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    ThreeDSecure -> Text
threeDSecureId :: Data.Text.Internal.Text,
    -- | livemode: Has the value \`true\` if the object exists in live mode or the value \`false\` if the object exists in test mode.
    ThreeDSecure -> Bool
threeDSecureLivemode :: GHC.Types.Bool,
    -- | redirect_url: If present, this is the URL that you should send the cardholder to for authentication. If you are going to use Stripe.js to display the authentication page in an iframe, you should use the value \"_callback\".
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    ThreeDSecure -> Maybe Text
threeDSecureRedirectUrl :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | status: Possible values are \`redirect_pending\`, \`succeeded\`, or \`failed\`. When the cardholder can be authenticated, the object starts with status \`redirect_pending\`. When liability will be shifted to the cardholder\'s bank (either because the cardholder was successfully authenticated, or because the bank has not implemented 3D Secure, the object wlil be in status \`succeeded\`. \`failed\` indicates that authentication was attempted unsuccessfully.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    ThreeDSecure -> Text
threeDSecureStatus :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> ThreeDSecure -> ShowS
[ThreeDSecure] -> ShowS
ThreeDSecure -> String
(Int -> ThreeDSecure -> ShowS)
-> (ThreeDSecure -> String)
-> ([ThreeDSecure] -> ShowS)
-> Show ThreeDSecure
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThreeDSecure] -> ShowS
$cshowList :: [ThreeDSecure] -> ShowS
show :: ThreeDSecure -> String
$cshow :: ThreeDSecure -> String
showsPrec :: Int -> ThreeDSecure -> ShowS
$cshowsPrec :: Int -> ThreeDSecure -> ShowS
GHC.Show.Show,
      ThreeDSecure -> ThreeDSecure -> Bool
(ThreeDSecure -> ThreeDSecure -> Bool)
-> (ThreeDSecure -> ThreeDSecure -> Bool) -> Eq ThreeDSecure
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThreeDSecure -> ThreeDSecure -> Bool
$c/= :: ThreeDSecure -> ThreeDSecure -> Bool
== :: ThreeDSecure -> ThreeDSecure -> Bool
$c== :: ThreeDSecure -> ThreeDSecure -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON ThreeDSecure where
  toJSON :: ThreeDSecure -> Value
toJSON ThreeDSecure
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"amount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Int
threeDSecureAmount ThreeDSecure
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"authenticated" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Bool
threeDSecureAuthenticated ThreeDSecure
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"card" Text -> Card -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Card
threeDSecureCard ThreeDSecure
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"created" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Int
threeDSecureCreated ThreeDSecure
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"currency" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Text
threeDSecureCurrency ThreeDSecure
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Text
threeDSecureId ThreeDSecure
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"livemode" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Bool
threeDSecureLivemode ThreeDSecure
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"redirect_url" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Maybe Text
threeDSecureRedirectUrl ThreeDSecure
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"status" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Text
threeDSecureStatus ThreeDSecure
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"object" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"three_d_secure" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: ThreeDSecure -> Encoding
toEncoding ThreeDSecure
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"amount" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Int
threeDSecureAmount ThreeDSecure
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"authenticated" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Bool
threeDSecureAuthenticated ThreeDSecure
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"card" Text -> Card -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Card
threeDSecureCard ThreeDSecure
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"created" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Int
threeDSecureCreated ThreeDSecure
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"currency" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Text
threeDSecureCurrency ThreeDSecure
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"id" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Text
threeDSecureId ThreeDSecure
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"livemode" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Bool
threeDSecureLivemode ThreeDSecure
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"redirect_url" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Maybe Text
threeDSecureRedirectUrl ThreeDSecure
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"status" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= ThreeDSecure -> Text
threeDSecureStatus ThreeDSecure
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"object" Text -> Value -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"three_d_secure"))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON ThreeDSecure where
  parseJSON :: Value -> Parser ThreeDSecure
parseJSON = String
-> (Object -> Parser ThreeDSecure) -> Value -> Parser ThreeDSecure
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"ThreeDSecure" (\Object
obj -> (((((((((Int
 -> Bool
 -> Card
 -> Int
 -> Text
 -> Text
 -> Bool
 -> Maybe Text
 -> Text
 -> ThreeDSecure)
-> Parser
     (Int
      -> Bool
      -> Card
      -> Int
      -> Text
      -> Text
      -> Bool
      -> Maybe Text
      -> Text
      -> ThreeDSecure)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Int
-> Bool
-> Card
-> Int
-> Text
-> Text
-> Bool
-> Maybe Text
-> Text
-> ThreeDSecure
ThreeDSecure Parser
  (Int
   -> Bool
   -> Card
   -> Int
   -> Text
   -> Text
   -> Bool
   -> Maybe Text
   -> Text
   -> ThreeDSecure)
-> Parser Int
-> Parser
     (Bool
      -> Card
      -> Int
      -> Text
      -> Text
      -> Bool
      -> Maybe Text
      -> Text
      -> ThreeDSecure)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"amount")) Parser
  (Bool
   -> Card
   -> Int
   -> Text
   -> Text
   -> Bool
   -> Maybe Text
   -> Text
   -> ThreeDSecure)
-> Parser Bool
-> Parser
     (Card
      -> Int
      -> Text
      -> Text
      -> Bool
      -> Maybe Text
      -> Text
      -> ThreeDSecure)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"authenticated")) Parser
  (Card
   -> Int
   -> Text
   -> Text
   -> Bool
   -> Maybe Text
   -> Text
   -> ThreeDSecure)
-> Parser Card
-> Parser
     (Int -> Text -> Text -> Bool -> Maybe Text -> Text -> ThreeDSecure)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Card
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"card")) Parser
  (Int -> Text -> Text -> Bool -> Maybe Text -> Text -> ThreeDSecure)
-> Parser Int
-> Parser
     (Text -> Text -> Bool -> Maybe Text -> Text -> ThreeDSecure)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"created")) Parser (Text -> Text -> Bool -> Maybe Text -> Text -> ThreeDSecure)
-> Parser Text
-> Parser (Text -> Bool -> Maybe Text -> Text -> ThreeDSecure)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"currency")) Parser (Text -> Bool -> Maybe Text -> Text -> ThreeDSecure)
-> Parser Text
-> Parser (Bool -> Maybe Text -> Text -> ThreeDSecure)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"id")) Parser (Bool -> Maybe Text -> Text -> ThreeDSecure)
-> Parser Bool -> Parser (Maybe Text -> Text -> ThreeDSecure)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"livemode")) Parser (Maybe Text -> Text -> ThreeDSecure)
-> Parser (Maybe Text) -> Parser (Text -> ThreeDSecure)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"redirect_url")) Parser (Text -> ThreeDSecure) -> Parser Text -> Parser ThreeDSecure
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"status"))

-- | Create a new 'ThreeDSecure' with all required fields.
mkThreeDSecure ::
  -- | 'threeDSecureAmount'
  GHC.Types.Int ->
  -- | 'threeDSecureAuthenticated'
  GHC.Types.Bool ->
  -- | 'threeDSecureCard'
  Card ->
  -- | 'threeDSecureCreated'
  GHC.Types.Int ->
  -- | 'threeDSecureCurrency'
  Data.Text.Internal.Text ->
  -- | 'threeDSecureId'
  Data.Text.Internal.Text ->
  -- | 'threeDSecureLivemode'
  GHC.Types.Bool ->
  -- | 'threeDSecureStatus'
  Data.Text.Internal.Text ->
  ThreeDSecure
mkThreeDSecure :: Int
-> Bool
-> Card
-> Int
-> Text
-> Text
-> Bool
-> Text
-> ThreeDSecure
mkThreeDSecure Int
threeDSecureAmount Bool
threeDSecureAuthenticated Card
threeDSecureCard Int
threeDSecureCreated Text
threeDSecureCurrency Text
threeDSecureId Bool
threeDSecureLivemode Text
threeDSecureStatus =
  ThreeDSecure :: Int
-> Bool
-> Card
-> Int
-> Text
-> Text
-> Bool
-> Maybe Text
-> Text
-> ThreeDSecure
ThreeDSecure
    { threeDSecureAmount :: Int
threeDSecureAmount = Int
threeDSecureAmount,
      threeDSecureAuthenticated :: Bool
threeDSecureAuthenticated = Bool
threeDSecureAuthenticated,
      threeDSecureCard :: Card
threeDSecureCard = Card
threeDSecureCard,
      threeDSecureCreated :: Int
threeDSecureCreated = Int
threeDSecureCreated,
      threeDSecureCurrency :: Text
threeDSecureCurrency = Text
threeDSecureCurrency,
      threeDSecureId :: Text
threeDSecureId = Text
threeDSecureId,
      threeDSecureLivemode :: Bool
threeDSecureLivemode = Bool
threeDSecureLivemode,
      threeDSecureRedirectUrl :: Maybe Text
threeDSecureRedirectUrl = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      threeDSecureStatus :: Text
threeDSecureStatus = Text
threeDSecureStatus
    }