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

-- | Defines the object schema located at @components.schemas.payment_method_sepa_debit@ in the specification.
data PaymentMethodSepaDebit = PaymentMethodSepaDebit
  { -- | bank_code: Bank code of bank associated with the bank account.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitBankCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | branch_code: Branch code of bank associated with the bank account.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitBranchCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | country: Two-letter ISO code representing the country the bank account is located in.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitCountry :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | fingerprint: Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitFingerprint :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | generated_from: Information about the object that generated this PaymentMethod.
    PaymentMethodSepaDebit
-> Maybe PaymentMethodSepaDebitGeneratedFrom'
paymentMethodSepaDebitGeneratedFrom :: (GHC.Maybe.Maybe PaymentMethodSepaDebitGeneratedFrom'),
    -- | last4: Last four characters of the IBAN.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitLast4 :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> PaymentMethodSepaDebit -> ShowS
[PaymentMethodSepaDebit] -> ShowS
PaymentMethodSepaDebit -> String
(Int -> PaymentMethodSepaDebit -> ShowS)
-> (PaymentMethodSepaDebit -> String)
-> ([PaymentMethodSepaDebit] -> ShowS)
-> Show PaymentMethodSepaDebit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodSepaDebit] -> ShowS
$cshowList :: [PaymentMethodSepaDebit] -> ShowS
show :: PaymentMethodSepaDebit -> String
$cshow :: PaymentMethodSepaDebit -> String
showsPrec :: Int -> PaymentMethodSepaDebit -> ShowS
$cshowsPrec :: Int -> PaymentMethodSepaDebit -> ShowS
GHC.Show.Show,
      PaymentMethodSepaDebit -> PaymentMethodSepaDebit -> Bool
(PaymentMethodSepaDebit -> PaymentMethodSepaDebit -> Bool)
-> (PaymentMethodSepaDebit -> PaymentMethodSepaDebit -> Bool)
-> Eq PaymentMethodSepaDebit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodSepaDebit -> PaymentMethodSepaDebit -> Bool
$c/= :: PaymentMethodSepaDebit -> PaymentMethodSepaDebit -> Bool
== :: PaymentMethodSepaDebit -> PaymentMethodSepaDebit -> Bool
$c== :: PaymentMethodSepaDebit -> PaymentMethodSepaDebit -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodSepaDebit where
  toJSON :: PaymentMethodSepaDebit -> Value
toJSON PaymentMethodSepaDebit
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"bank_code" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitBankCode PaymentMethodSepaDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"branch_code" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitBranchCode PaymentMethodSepaDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"country" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitCountry PaymentMethodSepaDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"fingerprint" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitFingerprint PaymentMethodSepaDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"generated_from" Text -> Maybe PaymentMethodSepaDebitGeneratedFrom' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebit
-> Maybe PaymentMethodSepaDebitGeneratedFrom'
paymentMethodSepaDebitGeneratedFrom PaymentMethodSepaDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"last4" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitLast4 PaymentMethodSepaDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PaymentMethodSepaDebit -> Encoding
toEncoding PaymentMethodSepaDebit
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"bank_code" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitBankCode PaymentMethodSepaDebit
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"branch_code" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitBranchCode PaymentMethodSepaDebit
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"country" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitCountry PaymentMethodSepaDebit
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"fingerprint" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitFingerprint PaymentMethodSepaDebit
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"generated_from" Text -> Maybe PaymentMethodSepaDebitGeneratedFrom' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebit
-> Maybe PaymentMethodSepaDebitGeneratedFrom'
paymentMethodSepaDebitGeneratedFrom PaymentMethodSepaDebit
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"last4" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebit -> Maybe Text
paymentMethodSepaDebitLast4 PaymentMethodSepaDebit
obj))))))

instance Data.Aeson.Types.FromJSON.FromJSON PaymentMethodSepaDebit where
  parseJSON :: Value -> Parser PaymentMethodSepaDebit
parseJSON = String
-> (Object -> Parser PaymentMethodSepaDebit)
-> Value
-> Parser PaymentMethodSepaDebit
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PaymentMethodSepaDebit" (\Object
obj -> ((((((Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe PaymentMethodSepaDebitGeneratedFrom'
 -> Maybe Text
 -> PaymentMethodSepaDebit)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe PaymentMethodSepaDebitGeneratedFrom'
      -> Maybe Text
      -> PaymentMethodSepaDebit)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe PaymentMethodSepaDebitGeneratedFrom'
-> Maybe Text
-> PaymentMethodSepaDebit
PaymentMethodSepaDebit Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe PaymentMethodSepaDebitGeneratedFrom'
   -> Maybe Text
   -> PaymentMethodSepaDebit)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe PaymentMethodSepaDebitGeneratedFrom'
      -> Maybe Text
      -> PaymentMethodSepaDebit)
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
"bank_code")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe PaymentMethodSepaDebitGeneratedFrom'
   -> Maybe Text
   -> PaymentMethodSepaDebit)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe PaymentMethodSepaDebitGeneratedFrom'
      -> Maybe Text
      -> PaymentMethodSepaDebit)
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
"branch_code")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe PaymentMethodSepaDebitGeneratedFrom'
   -> Maybe Text
   -> PaymentMethodSepaDebit)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe PaymentMethodSepaDebitGeneratedFrom'
      -> Maybe Text
      -> PaymentMethodSepaDebit)
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
"country")) Parser
  (Maybe Text
   -> Maybe PaymentMethodSepaDebitGeneratedFrom'
   -> Maybe Text
   -> PaymentMethodSepaDebit)
-> Parser (Maybe Text)
-> Parser
     (Maybe PaymentMethodSepaDebitGeneratedFrom'
      -> Maybe Text -> PaymentMethodSepaDebit)
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
"fingerprint")) Parser
  (Maybe PaymentMethodSepaDebitGeneratedFrom'
   -> Maybe Text -> PaymentMethodSepaDebit)
-> Parser (Maybe PaymentMethodSepaDebitGeneratedFrom')
-> Parser (Maybe Text -> PaymentMethodSepaDebit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text -> Parser (Maybe PaymentMethodSepaDebitGeneratedFrom')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"generated_from")) Parser (Maybe Text -> PaymentMethodSepaDebit)
-> Parser (Maybe Text) -> Parser PaymentMethodSepaDebit
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
"last4"))

-- | Create a new 'PaymentMethodSepaDebit' with all required fields.
mkPaymentMethodSepaDebit :: PaymentMethodSepaDebit
mkPaymentMethodSepaDebit :: PaymentMethodSepaDebit
mkPaymentMethodSepaDebit =
  PaymentMethodSepaDebit :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe PaymentMethodSepaDebitGeneratedFrom'
-> Maybe Text
-> PaymentMethodSepaDebit
PaymentMethodSepaDebit
    { paymentMethodSepaDebitBankCode :: Maybe Text
paymentMethodSepaDebitBankCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodSepaDebitBranchCode :: Maybe Text
paymentMethodSepaDebitBranchCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodSepaDebitCountry :: Maybe Text
paymentMethodSepaDebitCountry = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodSepaDebitFingerprint :: Maybe Text
paymentMethodSepaDebitFingerprint = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodSepaDebitGeneratedFrom :: Maybe PaymentMethodSepaDebitGeneratedFrom'
paymentMethodSepaDebitGeneratedFrom = Maybe PaymentMethodSepaDebitGeneratedFrom'
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodSepaDebitLast4 :: Maybe Text
paymentMethodSepaDebitLast4 = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the object schema located at @components.schemas.payment_method_sepa_debit.properties.generated_from.anyOf@ in the specification.
--
-- Information about the object that generated this PaymentMethod.
data PaymentMethodSepaDebitGeneratedFrom' = PaymentMethodSepaDebitGeneratedFrom'
  { -- | charge: The ID of the Charge that generated this PaymentMethod, if any.
    PaymentMethodSepaDebitGeneratedFrom'
-> Maybe PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
paymentMethodSepaDebitGeneratedFrom'Charge :: (GHC.Maybe.Maybe PaymentMethodSepaDebitGeneratedFrom'Charge'Variants),
    -- | setup_attempt: The ID of the SetupAttempt that generated this PaymentMethod, if any.
    PaymentMethodSepaDebitGeneratedFrom'
-> Maybe PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
paymentMethodSepaDebitGeneratedFrom'SetupAttempt :: (GHC.Maybe.Maybe PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants)
  }
  deriving
    ( Int -> PaymentMethodSepaDebitGeneratedFrom' -> ShowS
[PaymentMethodSepaDebitGeneratedFrom'] -> ShowS
PaymentMethodSepaDebitGeneratedFrom' -> String
(Int -> PaymentMethodSepaDebitGeneratedFrom' -> ShowS)
-> (PaymentMethodSepaDebitGeneratedFrom' -> String)
-> ([PaymentMethodSepaDebitGeneratedFrom'] -> ShowS)
-> Show PaymentMethodSepaDebitGeneratedFrom'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodSepaDebitGeneratedFrom'] -> ShowS
$cshowList :: [PaymentMethodSepaDebitGeneratedFrom'] -> ShowS
show :: PaymentMethodSepaDebitGeneratedFrom' -> String
$cshow :: PaymentMethodSepaDebitGeneratedFrom' -> String
showsPrec :: Int -> PaymentMethodSepaDebitGeneratedFrom' -> ShowS
$cshowsPrec :: Int -> PaymentMethodSepaDebitGeneratedFrom' -> ShowS
GHC.Show.Show,
      PaymentMethodSepaDebitGeneratedFrom'
-> PaymentMethodSepaDebitGeneratedFrom' -> Bool
(PaymentMethodSepaDebitGeneratedFrom'
 -> PaymentMethodSepaDebitGeneratedFrom' -> Bool)
-> (PaymentMethodSepaDebitGeneratedFrom'
    -> PaymentMethodSepaDebitGeneratedFrom' -> Bool)
-> Eq PaymentMethodSepaDebitGeneratedFrom'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodSepaDebitGeneratedFrom'
-> PaymentMethodSepaDebitGeneratedFrom' -> Bool
$c/= :: PaymentMethodSepaDebitGeneratedFrom'
-> PaymentMethodSepaDebitGeneratedFrom' -> Bool
== :: PaymentMethodSepaDebitGeneratedFrom'
-> PaymentMethodSepaDebitGeneratedFrom' -> Bool
$c== :: PaymentMethodSepaDebitGeneratedFrom'
-> PaymentMethodSepaDebitGeneratedFrom' -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodSepaDebitGeneratedFrom' where
  toJSON :: PaymentMethodSepaDebitGeneratedFrom' -> Value
toJSON PaymentMethodSepaDebitGeneratedFrom'
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"charge" Text
-> Maybe PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebitGeneratedFrom'
-> Maybe PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
paymentMethodSepaDebitGeneratedFrom'Charge PaymentMethodSepaDebitGeneratedFrom'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"setup_attempt" Text
-> Maybe PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebitGeneratedFrom'
-> Maybe PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
paymentMethodSepaDebitGeneratedFrom'SetupAttempt PaymentMethodSepaDebitGeneratedFrom'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PaymentMethodSepaDebitGeneratedFrom' -> Encoding
toEncoding PaymentMethodSepaDebitGeneratedFrom'
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"charge" Text
-> Maybe PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebitGeneratedFrom'
-> Maybe PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
paymentMethodSepaDebitGeneratedFrom'Charge PaymentMethodSepaDebitGeneratedFrom'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"setup_attempt" Text
-> Maybe PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodSepaDebitGeneratedFrom'
-> Maybe PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
paymentMethodSepaDebitGeneratedFrom'SetupAttempt PaymentMethodSepaDebitGeneratedFrom'
obj))

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

-- | Create a new 'PaymentMethodSepaDebitGeneratedFrom'' with all required fields.
mkPaymentMethodSepaDebitGeneratedFrom' :: PaymentMethodSepaDebitGeneratedFrom'
mkPaymentMethodSepaDebitGeneratedFrom' :: PaymentMethodSepaDebitGeneratedFrom'
mkPaymentMethodSepaDebitGeneratedFrom' =
  PaymentMethodSepaDebitGeneratedFrom' :: Maybe PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> Maybe PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> PaymentMethodSepaDebitGeneratedFrom'
PaymentMethodSepaDebitGeneratedFrom'
    { paymentMethodSepaDebitGeneratedFrom'Charge :: Maybe PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
paymentMethodSepaDebitGeneratedFrom'Charge = Maybe PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodSepaDebitGeneratedFrom'SetupAttempt :: Maybe PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
paymentMethodSepaDebitGeneratedFrom'SetupAttempt = Maybe PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the oneOf schema located at @components.schemas.payment_method_sepa_debit.properties.generated_from.anyOf.properties.charge.anyOf@ in the specification.
--
-- The ID of the Charge that generated this PaymentMethod, if any.
data PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
  = PaymentMethodSepaDebitGeneratedFrom'Charge'Text Data.Text.Internal.Text
  | PaymentMethodSepaDebitGeneratedFrom'Charge'Charge Charge
  deriving (Int -> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> ShowS
[PaymentMethodSepaDebitGeneratedFrom'Charge'Variants] -> ShowS
PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> String
(Int
 -> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> ShowS)
-> (PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> String)
-> ([PaymentMethodSepaDebitGeneratedFrom'Charge'Variants] -> ShowS)
-> Show PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodSepaDebitGeneratedFrom'Charge'Variants] -> ShowS
$cshowList :: [PaymentMethodSepaDebitGeneratedFrom'Charge'Variants] -> ShowS
show :: PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> String
$cshow :: PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> String
showsPrec :: Int -> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> ShowS
$cshowsPrec :: Int -> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> ShowS
GHC.Show.Show, PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> Bool
(PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
 -> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> Bool)
-> (PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
    -> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> Bool)
-> Eq PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> Bool
$c/= :: PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> Bool
== :: PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> Bool
$c== :: PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodSepaDebitGeneratedFrom'Charge'Variants where
  toJSON :: PaymentMethodSepaDebitGeneratedFrom'Charge'Variants -> Value
toJSON (PaymentMethodSepaDebitGeneratedFrom'Charge'Text Text
a) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
a
  toJSON (PaymentMethodSepaDebitGeneratedFrom'Charge'Charge Charge
a) = Charge -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Charge
a

instance Data.Aeson.Types.FromJSON.FromJSON PaymentMethodSepaDebitGeneratedFrom'Charge'Variants where
  parseJSON :: Value -> Parser PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
parseJSON Value
val = case (Text -> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
PaymentMethodSepaDebitGeneratedFrom'Charge'Text (Text -> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants)
-> Result Text
-> Result PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Text
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> Result PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> Result PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((Charge -> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
PaymentMethodSepaDebitGeneratedFrom'Charge'Charge (Charge -> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants)
-> Result Charge
-> Result PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Charge
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> Result PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> Result PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String
-> Result PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched") of
    Data.Aeson.Types.Internal.Success PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
a -> PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
-> Parser PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
a
    Data.Aeson.Types.Internal.Error String
a -> String
-> Parser PaymentMethodSepaDebitGeneratedFrom'Charge'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a

-- | Defines the oneOf schema located at @components.schemas.payment_method_sepa_debit.properties.generated_from.anyOf.properties.setup_attempt.anyOf@ in the specification.
--
-- The ID of the SetupAttempt that generated this PaymentMethod, if any.
data PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
  = PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Text Data.Text.Internal.Text
  | PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'SetupAttempt SetupAttempt
  deriving (Int
-> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> ShowS
[PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants]
-> ShowS
PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants -> String
(Int
 -> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
 -> ShowS)
-> (PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
    -> String)
-> ([PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants]
    -> ShowS)
-> Show PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants]
-> ShowS
$cshowList :: [PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants]
-> ShowS
show :: PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants -> String
$cshow :: PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants -> String
showsPrec :: Int
-> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> ShowS
$cshowsPrec :: Int
-> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> ShowS
GHC.Show.Show, PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> Bool
(PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
 -> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
 -> Bool)
-> (PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
    -> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
    -> Bool)
-> Eq PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> Bool
$c/= :: PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> Bool
== :: PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> Bool
$c== :: PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants where
  toJSON :: PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants -> Value
toJSON (PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Text Text
a) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
a
  toJSON (PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'SetupAttempt SetupAttempt
a) = SetupAttempt -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON SetupAttempt
a

instance Data.Aeson.Types.FromJSON.FromJSON PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants where
  parseJSON :: Value
-> Parser PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
parseJSON Value
val = case (Text -> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Text (Text -> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants)
-> Result Text
-> Result PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Text
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> Result PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> Result PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((SetupAttempt
-> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'SetupAttempt (SetupAttempt
 -> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants)
-> Result SetupAttempt
-> Result PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result SetupAttempt
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> Result PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> Result PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String
-> Result PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched") of
    Data.Aeson.Types.Internal.Success PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
a -> PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
-> Parser PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
a
    Data.Aeson.Types.Internal.Error String
a -> String
-> Parser PaymentMethodSepaDebitGeneratedFrom'SetupAttempt'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a