{-# 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 PaymentIntentNextAction
module StripeAPI.Types.PaymentIntentNextAction 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.PaymentIntentNextActionAlipayHandleRedirect
import {-# SOURCE #-} StripeAPI.Types.PaymentIntentNextActionBoleto
import {-# SOURCE #-} StripeAPI.Types.PaymentIntentNextActionDisplayOxxoDetails
import {-# SOURCE #-} StripeAPI.Types.PaymentIntentNextActionRedirectToUrl
import {-# SOURCE #-} StripeAPI.Types.PaymentIntentNextActionVerifyWithMicrodeposits
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.payment_intent_next_action@ in the specification.
data PaymentIntentNextAction = PaymentIntentNextAction
  { -- | alipay_handle_redirect:
    PaymentIntentNextAction
-> Maybe PaymentIntentNextActionAlipayHandleRedirect
paymentIntentNextActionAlipayHandleRedirect :: (GHC.Maybe.Maybe PaymentIntentNextActionAlipayHandleRedirect),
    -- | boleto_display_details:
    PaymentIntentNextAction -> Maybe PaymentIntentNextActionBoleto
paymentIntentNextActionBoletoDisplayDetails :: (GHC.Maybe.Maybe PaymentIntentNextActionBoleto),
    -- | oxxo_display_details:
    PaymentIntentNextAction
-> Maybe PaymentIntentNextActionDisplayOxxoDetails
paymentIntentNextActionOxxoDisplayDetails :: (GHC.Maybe.Maybe PaymentIntentNextActionDisplayOxxoDetails),
    -- | redirect_to_url:
    PaymentIntentNextAction
-> Maybe PaymentIntentNextActionRedirectToUrl
paymentIntentNextActionRedirectToUrl :: (GHC.Maybe.Maybe PaymentIntentNextActionRedirectToUrl),
    -- | type: Type of the next action to perform, one of \`redirect_to_url\`, \`use_stripe_sdk\`, \`alipay_handle_redirect\`, or \`oxxo_display_details\`.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentIntentNextAction -> Text
paymentIntentNextActionType :: Data.Text.Internal.Text,
    -- | use_stripe_sdk: When confirming a PaymentIntent with Stripe.js, Stripe.js depends on the contents of this dictionary to invoke authentication flows. The shape of the contents is subject to change and is only intended to be used by Stripe.js.
    PaymentIntentNextAction -> Maybe Object
paymentIntentNextActionUseStripeSdk :: (GHC.Maybe.Maybe Data.Aeson.Types.Internal.Object),
    -- | verify_with_microdeposits:
    PaymentIntentNextAction
-> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
paymentIntentNextActionVerifyWithMicrodeposits :: (GHC.Maybe.Maybe PaymentIntentNextActionVerifyWithMicrodeposits)
  }
  deriving
    ( Int -> PaymentIntentNextAction -> ShowS
[PaymentIntentNextAction] -> ShowS
PaymentIntentNextAction -> String
(Int -> PaymentIntentNextAction -> ShowS)
-> (PaymentIntentNextAction -> String)
-> ([PaymentIntentNextAction] -> ShowS)
-> Show PaymentIntentNextAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentIntentNextAction] -> ShowS
$cshowList :: [PaymentIntentNextAction] -> ShowS
show :: PaymentIntentNextAction -> String
$cshow :: PaymentIntentNextAction -> String
showsPrec :: Int -> PaymentIntentNextAction -> ShowS
$cshowsPrec :: Int -> PaymentIntentNextAction -> ShowS
GHC.Show.Show,
      PaymentIntentNextAction -> PaymentIntentNextAction -> Bool
(PaymentIntentNextAction -> PaymentIntentNextAction -> Bool)
-> (PaymentIntentNextAction -> PaymentIntentNextAction -> Bool)
-> Eq PaymentIntentNextAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentIntentNextAction -> PaymentIntentNextAction -> Bool
$c/= :: PaymentIntentNextAction -> PaymentIntentNextAction -> Bool
== :: PaymentIntentNextAction -> PaymentIntentNextAction -> Bool
$c== :: PaymentIntentNextAction -> PaymentIntentNextAction -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PaymentIntentNextAction where
  toJSON :: PaymentIntentNextAction -> Value
toJSON PaymentIntentNextAction
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"alipay_handle_redirect" Text -> Maybe PaymentIntentNextActionAlipayHandleRedirect -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction
-> Maybe PaymentIntentNextActionAlipayHandleRedirect
paymentIntentNextActionAlipayHandleRedirect PaymentIntentNextAction
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"boleto_display_details" Text -> Maybe PaymentIntentNextActionBoleto -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction -> Maybe PaymentIntentNextActionBoleto
paymentIntentNextActionBoletoDisplayDetails PaymentIntentNextAction
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"oxxo_display_details" Text -> Maybe PaymentIntentNextActionDisplayOxxoDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction
-> Maybe PaymentIntentNextActionDisplayOxxoDetails
paymentIntentNextActionOxxoDisplayDetails PaymentIntentNextAction
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"redirect_to_url" Text -> Maybe PaymentIntentNextActionRedirectToUrl -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction
-> Maybe PaymentIntentNextActionRedirectToUrl
paymentIntentNextActionRedirectToUrl PaymentIntentNextAction
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction -> Text
paymentIntentNextActionType PaymentIntentNextAction
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"use_stripe_sdk" Text -> Maybe Object -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction -> Maybe Object
paymentIntentNextActionUseStripeSdk PaymentIntentNextAction
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"verify_with_microdeposits" Text
-> Maybe PaymentIntentNextActionVerifyWithMicrodeposits -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction
-> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
paymentIntentNextActionVerifyWithMicrodeposits PaymentIntentNextAction
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PaymentIntentNextAction -> Encoding
toEncoding PaymentIntentNextAction
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"alipay_handle_redirect" Text -> Maybe PaymentIntentNextActionAlipayHandleRedirect -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction
-> Maybe PaymentIntentNextActionAlipayHandleRedirect
paymentIntentNextActionAlipayHandleRedirect PaymentIntentNextAction
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"boleto_display_details" Text -> Maybe PaymentIntentNextActionBoleto -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction -> Maybe PaymentIntentNextActionBoleto
paymentIntentNextActionBoletoDisplayDetails PaymentIntentNextAction
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"oxxo_display_details" Text -> Maybe PaymentIntentNextActionDisplayOxxoDetails -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction
-> Maybe PaymentIntentNextActionDisplayOxxoDetails
paymentIntentNextActionOxxoDisplayDetails PaymentIntentNextAction
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"redirect_to_url" Text -> Maybe PaymentIntentNextActionRedirectToUrl -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction
-> Maybe PaymentIntentNextActionRedirectToUrl
paymentIntentNextActionRedirectToUrl PaymentIntentNextAction
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"type" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction -> Text
paymentIntentNextActionType PaymentIntentNextAction
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"use_stripe_sdk" Text -> Maybe Object -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction -> Maybe Object
paymentIntentNextActionUseStripeSdk PaymentIntentNextAction
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"verify_with_microdeposits" Text
-> Maybe PaymentIntentNextActionVerifyWithMicrodeposits -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentIntentNextAction
-> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
paymentIntentNextActionVerifyWithMicrodeposits PaymentIntentNextAction
obj)))))))

instance Data.Aeson.Types.FromJSON.FromJSON PaymentIntentNextAction where
  parseJSON :: Value -> Parser PaymentIntentNextAction
parseJSON = String
-> (Object -> Parser PaymentIntentNextAction)
-> Value
-> Parser PaymentIntentNextAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PaymentIntentNextAction" (\Object
obj -> (((((((Maybe PaymentIntentNextActionAlipayHandleRedirect
 -> Maybe PaymentIntentNextActionBoleto
 -> Maybe PaymentIntentNextActionDisplayOxxoDetails
 -> Maybe PaymentIntentNextActionRedirectToUrl
 -> Text
 -> Maybe Object
 -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
 -> PaymentIntentNextAction)
-> Parser
     (Maybe PaymentIntentNextActionAlipayHandleRedirect
      -> Maybe PaymentIntentNextActionBoleto
      -> Maybe PaymentIntentNextActionDisplayOxxoDetails
      -> Maybe PaymentIntentNextActionRedirectToUrl
      -> Text
      -> Maybe Object
      -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
      -> PaymentIntentNextAction)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe PaymentIntentNextActionAlipayHandleRedirect
-> Maybe PaymentIntentNextActionBoleto
-> Maybe PaymentIntentNextActionDisplayOxxoDetails
-> Maybe PaymentIntentNextActionRedirectToUrl
-> Text
-> Maybe Object
-> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
-> PaymentIntentNextAction
PaymentIntentNextAction Parser
  (Maybe PaymentIntentNextActionAlipayHandleRedirect
   -> Maybe PaymentIntentNextActionBoleto
   -> Maybe PaymentIntentNextActionDisplayOxxoDetails
   -> Maybe PaymentIntentNextActionRedirectToUrl
   -> Text
   -> Maybe Object
   -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
   -> PaymentIntentNextAction)
-> Parser (Maybe PaymentIntentNextActionAlipayHandleRedirect)
-> Parser
     (Maybe PaymentIntentNextActionBoleto
      -> Maybe PaymentIntentNextActionDisplayOxxoDetails
      -> Maybe PaymentIntentNextActionRedirectToUrl
      -> Text
      -> Maybe Object
      -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
      -> PaymentIntentNextAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe PaymentIntentNextActionAlipayHandleRedirect)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"alipay_handle_redirect")) Parser
  (Maybe PaymentIntentNextActionBoleto
   -> Maybe PaymentIntentNextActionDisplayOxxoDetails
   -> Maybe PaymentIntentNextActionRedirectToUrl
   -> Text
   -> Maybe Object
   -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
   -> PaymentIntentNextAction)
-> Parser (Maybe PaymentIntentNextActionBoleto)
-> Parser
     (Maybe PaymentIntentNextActionDisplayOxxoDetails
      -> Maybe PaymentIntentNextActionRedirectToUrl
      -> Text
      -> Maybe Object
      -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
      -> PaymentIntentNextAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe PaymentIntentNextActionBoleto)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"boleto_display_details")) Parser
  (Maybe PaymentIntentNextActionDisplayOxxoDetails
   -> Maybe PaymentIntentNextActionRedirectToUrl
   -> Text
   -> Maybe Object
   -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
   -> PaymentIntentNextAction)
-> Parser (Maybe PaymentIntentNextActionDisplayOxxoDetails)
-> Parser
     (Maybe PaymentIntentNextActionRedirectToUrl
      -> Text
      -> Maybe Object
      -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
      -> PaymentIntentNextAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text -> Parser (Maybe PaymentIntentNextActionDisplayOxxoDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"oxxo_display_details")) Parser
  (Maybe PaymentIntentNextActionRedirectToUrl
   -> Text
   -> Maybe Object
   -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
   -> PaymentIntentNextAction)
-> Parser (Maybe PaymentIntentNextActionRedirectToUrl)
-> Parser
     (Text
      -> Maybe Object
      -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
      -> PaymentIntentNextAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text -> Parser (Maybe PaymentIntentNextActionRedirectToUrl)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"redirect_to_url")) Parser
  (Text
   -> Maybe Object
   -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
   -> PaymentIntentNextAction)
-> Parser Text
-> Parser
     (Maybe Object
      -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
      -> PaymentIntentNextAction)
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
"type")) Parser
  (Maybe Object
   -> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
   -> PaymentIntentNextAction)
-> Parser (Maybe Object)
-> Parser
     (Maybe PaymentIntentNextActionVerifyWithMicrodeposits
      -> PaymentIntentNextAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Object)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"use_stripe_sdk")) Parser
  (Maybe PaymentIntentNextActionVerifyWithMicrodeposits
   -> PaymentIntentNextAction)
-> Parser (Maybe PaymentIntentNextActionVerifyWithMicrodeposits)
-> Parser PaymentIntentNextAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe PaymentIntentNextActionVerifyWithMicrodeposits)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"verify_with_microdeposits"))

-- | Create a new 'PaymentIntentNextAction' with all required fields.
mkPaymentIntentNextAction ::
  -- | 'paymentIntentNextActionType'
  Data.Text.Internal.Text ->
  PaymentIntentNextAction
mkPaymentIntentNextAction :: Text -> PaymentIntentNextAction
mkPaymentIntentNextAction Text
paymentIntentNextActionType =
  PaymentIntentNextAction :: Maybe PaymentIntentNextActionAlipayHandleRedirect
-> Maybe PaymentIntentNextActionBoleto
-> Maybe PaymentIntentNextActionDisplayOxxoDetails
-> Maybe PaymentIntentNextActionRedirectToUrl
-> Text
-> Maybe Object
-> Maybe PaymentIntentNextActionVerifyWithMicrodeposits
-> PaymentIntentNextAction
PaymentIntentNextAction
    { paymentIntentNextActionAlipayHandleRedirect :: Maybe PaymentIntentNextActionAlipayHandleRedirect
paymentIntentNextActionAlipayHandleRedirect = Maybe PaymentIntentNextActionAlipayHandleRedirect
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentIntentNextActionBoletoDisplayDetails :: Maybe PaymentIntentNextActionBoleto
paymentIntentNextActionBoletoDisplayDetails = Maybe PaymentIntentNextActionBoleto
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentIntentNextActionOxxoDisplayDetails :: Maybe PaymentIntentNextActionDisplayOxxoDetails
paymentIntentNextActionOxxoDisplayDetails = Maybe PaymentIntentNextActionDisplayOxxoDetails
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentIntentNextActionRedirectToUrl :: Maybe PaymentIntentNextActionRedirectToUrl
paymentIntentNextActionRedirectToUrl = Maybe PaymentIntentNextActionRedirectToUrl
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentIntentNextActionType :: Text
paymentIntentNextActionType = Text
paymentIntentNextActionType,
      paymentIntentNextActionUseStripeSdk :: Maybe Object
paymentIntentNextActionUseStripeSdk = Maybe Object
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentIntentNextActionVerifyWithMicrodeposits :: Maybe PaymentIntentNextActionVerifyWithMicrodeposits
paymentIntentNextActionVerifyWithMicrodeposits = Maybe PaymentIntentNextActionVerifyWithMicrodeposits
forall a. Maybe a
GHC.Maybe.Nothing
    }