{-# 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 CheckoutSessionPaymentMethodOptions
module StripeAPI.Types.CheckoutSessionPaymentMethodOptions 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.CheckoutAcssDebitPaymentMethodOptions
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.checkout_session_payment_method_options@ in the specification.
data CheckoutSessionPaymentMethodOptions = CheckoutSessionPaymentMethodOptions
  { -- | acss_debit:
    CheckoutSessionPaymentMethodOptions
-> Maybe CheckoutAcssDebitPaymentMethodOptions
checkoutSessionPaymentMethodOptionsAcssDebit :: (GHC.Maybe.Maybe CheckoutAcssDebitPaymentMethodOptions)
  }
  deriving
    ( Int -> CheckoutSessionPaymentMethodOptions -> ShowS
[CheckoutSessionPaymentMethodOptions] -> ShowS
CheckoutSessionPaymentMethodOptions -> String
(Int -> CheckoutSessionPaymentMethodOptions -> ShowS)
-> (CheckoutSessionPaymentMethodOptions -> String)
-> ([CheckoutSessionPaymentMethodOptions] -> ShowS)
-> Show CheckoutSessionPaymentMethodOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CheckoutSessionPaymentMethodOptions] -> ShowS
$cshowList :: [CheckoutSessionPaymentMethodOptions] -> ShowS
show :: CheckoutSessionPaymentMethodOptions -> String
$cshow :: CheckoutSessionPaymentMethodOptions -> String
showsPrec :: Int -> CheckoutSessionPaymentMethodOptions -> ShowS
$cshowsPrec :: Int -> CheckoutSessionPaymentMethodOptions -> ShowS
GHC.Show.Show,
      CheckoutSessionPaymentMethodOptions
-> CheckoutSessionPaymentMethodOptions -> Bool
(CheckoutSessionPaymentMethodOptions
 -> CheckoutSessionPaymentMethodOptions -> Bool)
-> (CheckoutSessionPaymentMethodOptions
    -> CheckoutSessionPaymentMethodOptions -> Bool)
-> Eq CheckoutSessionPaymentMethodOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CheckoutSessionPaymentMethodOptions
-> CheckoutSessionPaymentMethodOptions -> Bool
$c/= :: CheckoutSessionPaymentMethodOptions
-> CheckoutSessionPaymentMethodOptions -> Bool
== :: CheckoutSessionPaymentMethodOptions
-> CheckoutSessionPaymentMethodOptions -> Bool
$c== :: CheckoutSessionPaymentMethodOptions
-> CheckoutSessionPaymentMethodOptions -> Bool
GHC.Classes.Eq
    )

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

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

-- | Create a new 'CheckoutSessionPaymentMethodOptions' with all required fields.
mkCheckoutSessionPaymentMethodOptions :: CheckoutSessionPaymentMethodOptions
mkCheckoutSessionPaymentMethodOptions :: CheckoutSessionPaymentMethodOptions
mkCheckoutSessionPaymentMethodOptions = CheckoutSessionPaymentMethodOptions :: Maybe CheckoutAcssDebitPaymentMethodOptions
-> CheckoutSessionPaymentMethodOptions
CheckoutSessionPaymentMethodOptions {checkoutSessionPaymentMethodOptionsAcssDebit :: Maybe CheckoutAcssDebitPaymentMethodOptions
checkoutSessionPaymentMethodOptionsAcssDebit = Maybe CheckoutAcssDebitPaymentMethodOptions
forall a. Maybe a
GHC.Maybe.Nothing}