{-# 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 PaymentMethodDetailsAchDebit
module StripeAPI.Types.PaymentMethodDetailsAchDebit 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.payment_method_details_ach_debit@ in the specification.
data PaymentMethodDetailsAchDebit = PaymentMethodDetailsAchDebit
  { -- | account_holder_type: Type of entity that holds the account. This can be either \`individual\` or \`company\`.
    PaymentMethodDetailsAchDebit
-> Maybe PaymentMethodDetailsAchDebitAccountHolderType'
paymentMethodDetailsAchDebitAccountHolderType :: (GHC.Maybe.Maybe PaymentMethodDetailsAchDebitAccountHolderType'),
    -- | bank_name: Name of the bank associated with the bank account.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitBankName :: (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
    PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitCountry :: (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
    PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitFingerprint :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | last4: Last four digits of the bank account number.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitLast4 :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | routing_number: Routing transit number of the bank account.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitRoutingNumber :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> PaymentMethodDetailsAchDebit -> ShowS
[PaymentMethodDetailsAchDebit] -> ShowS
PaymentMethodDetailsAchDebit -> String
(Int -> PaymentMethodDetailsAchDebit -> ShowS)
-> (PaymentMethodDetailsAchDebit -> String)
-> ([PaymentMethodDetailsAchDebit] -> ShowS)
-> Show PaymentMethodDetailsAchDebit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodDetailsAchDebit] -> ShowS
$cshowList :: [PaymentMethodDetailsAchDebit] -> ShowS
show :: PaymentMethodDetailsAchDebit -> String
$cshow :: PaymentMethodDetailsAchDebit -> String
showsPrec :: Int -> PaymentMethodDetailsAchDebit -> ShowS
$cshowsPrec :: Int -> PaymentMethodDetailsAchDebit -> ShowS
GHC.Show.Show,
      PaymentMethodDetailsAchDebit
-> PaymentMethodDetailsAchDebit -> Bool
(PaymentMethodDetailsAchDebit
 -> PaymentMethodDetailsAchDebit -> Bool)
-> (PaymentMethodDetailsAchDebit
    -> PaymentMethodDetailsAchDebit -> Bool)
-> Eq PaymentMethodDetailsAchDebit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodDetailsAchDebit
-> PaymentMethodDetailsAchDebit -> Bool
$c/= :: PaymentMethodDetailsAchDebit
-> PaymentMethodDetailsAchDebit -> Bool
== :: PaymentMethodDetailsAchDebit
-> PaymentMethodDetailsAchDebit -> Bool
$c== :: PaymentMethodDetailsAchDebit
-> PaymentMethodDetailsAchDebit -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodDetailsAchDebit where
  toJSON :: PaymentMethodDetailsAchDebit -> Value
toJSON PaymentMethodDetailsAchDebit
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"account_holder_type" Text
-> Maybe PaymentMethodDetailsAchDebitAccountHolderType' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodDetailsAchDebit
-> Maybe PaymentMethodDetailsAchDebitAccountHolderType'
paymentMethodDetailsAchDebitAccountHolderType PaymentMethodDetailsAchDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"bank_name" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitBankName PaymentMethodDetailsAchDebit
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..= PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitCountry PaymentMethodDetailsAchDebit
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..= PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitFingerprint PaymentMethodDetailsAchDebit
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..= PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitLast4 PaymentMethodDetailsAchDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"routing_number" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitRoutingNumber PaymentMethodDetailsAchDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PaymentMethodDetailsAchDebit -> Encoding
toEncoding PaymentMethodDetailsAchDebit
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"account_holder_type" Text
-> Maybe PaymentMethodDetailsAchDebitAccountHolderType' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodDetailsAchDebit
-> Maybe PaymentMethodDetailsAchDebitAccountHolderType'
paymentMethodDetailsAchDebitAccountHolderType PaymentMethodDetailsAchDebit
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"bank_name" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitBankName PaymentMethodDetailsAchDebit
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..= PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitCountry PaymentMethodDetailsAchDebit
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..= PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitFingerprint PaymentMethodDetailsAchDebit
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..= PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitLast4 PaymentMethodDetailsAchDebit
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"routing_number" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodDetailsAchDebit -> Maybe Text
paymentMethodDetailsAchDebitRoutingNumber PaymentMethodDetailsAchDebit
obj))))))

instance Data.Aeson.Types.FromJSON.FromJSON PaymentMethodDetailsAchDebit where
  parseJSON :: Value -> Parser PaymentMethodDetailsAchDebit
parseJSON = String
-> (Object -> Parser PaymentMethodDetailsAchDebit)
-> Value
-> Parser PaymentMethodDetailsAchDebit
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PaymentMethodDetailsAchDebit" (\Object
obj -> ((((((Maybe PaymentMethodDetailsAchDebitAccountHolderType'
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> PaymentMethodDetailsAchDebit)
-> Parser
     (Maybe PaymentMethodDetailsAchDebitAccountHolderType'
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PaymentMethodDetailsAchDebit)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe PaymentMethodDetailsAchDebitAccountHolderType'
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PaymentMethodDetailsAchDebit
PaymentMethodDetailsAchDebit Parser
  (Maybe PaymentMethodDetailsAchDebitAccountHolderType'
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PaymentMethodDetailsAchDebit)
-> Parser (Maybe PaymentMethodDetailsAchDebitAccountHolderType')
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PaymentMethodDetailsAchDebit)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe PaymentMethodDetailsAchDebitAccountHolderType')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"account_holder_type")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PaymentMethodDetailsAchDebit)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PaymentMethodDetailsAchDebit)
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_name")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PaymentMethodDetailsAchDebit)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> PaymentMethodDetailsAchDebit)
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 Text -> Maybe Text -> PaymentMethodDetailsAchDebit)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> PaymentMethodDetailsAchDebit)
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 Text -> Maybe Text -> PaymentMethodDetailsAchDebit)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> PaymentMethodDetailsAchDebit)
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")) Parser (Maybe Text -> PaymentMethodDetailsAchDebit)
-> Parser (Maybe Text) -> Parser PaymentMethodDetailsAchDebit
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
"routing_number"))

-- | Create a new 'PaymentMethodDetailsAchDebit' with all required fields.
mkPaymentMethodDetailsAchDebit :: PaymentMethodDetailsAchDebit
mkPaymentMethodDetailsAchDebit :: PaymentMethodDetailsAchDebit
mkPaymentMethodDetailsAchDebit =
  PaymentMethodDetailsAchDebit :: Maybe PaymentMethodDetailsAchDebitAccountHolderType'
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PaymentMethodDetailsAchDebit
PaymentMethodDetailsAchDebit
    { paymentMethodDetailsAchDebitAccountHolderType :: Maybe PaymentMethodDetailsAchDebitAccountHolderType'
paymentMethodDetailsAchDebitAccountHolderType = Maybe PaymentMethodDetailsAchDebitAccountHolderType'
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodDetailsAchDebitBankName :: Maybe Text
paymentMethodDetailsAchDebitBankName = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodDetailsAchDebitCountry :: Maybe Text
paymentMethodDetailsAchDebitCountry = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodDetailsAchDebitFingerprint :: Maybe Text
paymentMethodDetailsAchDebitFingerprint = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodDetailsAchDebitLast4 :: Maybe Text
paymentMethodDetailsAchDebitLast4 = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodDetailsAchDebitRoutingNumber :: Maybe Text
paymentMethodDetailsAchDebitRoutingNumber = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the enum schema located at @components.schemas.payment_method_details_ach_debit.properties.account_holder_type@ in the specification.
--
-- Type of entity that holds the account. This can be either \`individual\` or \`company\`.
data PaymentMethodDetailsAchDebitAccountHolderType'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PaymentMethodDetailsAchDebitAccountHolderType'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.
    PaymentMethodDetailsAchDebitAccountHolderType'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"company"@
    PaymentMethodDetailsAchDebitAccountHolderType'EnumCompany
  | -- | Represents the JSON value @"individual"@
    PaymentMethodDetailsAchDebitAccountHolderType'EnumIndividual
  deriving (Int -> PaymentMethodDetailsAchDebitAccountHolderType' -> ShowS
[PaymentMethodDetailsAchDebitAccountHolderType'] -> ShowS
PaymentMethodDetailsAchDebitAccountHolderType' -> String
(Int -> PaymentMethodDetailsAchDebitAccountHolderType' -> ShowS)
-> (PaymentMethodDetailsAchDebitAccountHolderType' -> String)
-> ([PaymentMethodDetailsAchDebitAccountHolderType'] -> ShowS)
-> Show PaymentMethodDetailsAchDebitAccountHolderType'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodDetailsAchDebitAccountHolderType'] -> ShowS
$cshowList :: [PaymentMethodDetailsAchDebitAccountHolderType'] -> ShowS
show :: PaymentMethodDetailsAchDebitAccountHolderType' -> String
$cshow :: PaymentMethodDetailsAchDebitAccountHolderType' -> String
showsPrec :: Int -> PaymentMethodDetailsAchDebitAccountHolderType' -> ShowS
$cshowsPrec :: Int -> PaymentMethodDetailsAchDebitAccountHolderType' -> ShowS
GHC.Show.Show, PaymentMethodDetailsAchDebitAccountHolderType'
-> PaymentMethodDetailsAchDebitAccountHolderType' -> Bool
(PaymentMethodDetailsAchDebitAccountHolderType'
 -> PaymentMethodDetailsAchDebitAccountHolderType' -> Bool)
-> (PaymentMethodDetailsAchDebitAccountHolderType'
    -> PaymentMethodDetailsAchDebitAccountHolderType' -> Bool)
-> Eq PaymentMethodDetailsAchDebitAccountHolderType'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodDetailsAchDebitAccountHolderType'
-> PaymentMethodDetailsAchDebitAccountHolderType' -> Bool
$c/= :: PaymentMethodDetailsAchDebitAccountHolderType'
-> PaymentMethodDetailsAchDebitAccountHolderType' -> Bool
== :: PaymentMethodDetailsAchDebitAccountHolderType'
-> PaymentMethodDetailsAchDebitAccountHolderType' -> Bool
$c== :: PaymentMethodDetailsAchDebitAccountHolderType'
-> PaymentMethodDetailsAchDebitAccountHolderType' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodDetailsAchDebitAccountHolderType' where
  toJSON :: PaymentMethodDetailsAchDebitAccountHolderType' -> Value
toJSON (PaymentMethodDetailsAchDebitAccountHolderType'Other Value
val) = Value
val
  toJSON (PaymentMethodDetailsAchDebitAccountHolderType'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PaymentMethodDetailsAchDebitAccountHolderType'
PaymentMethodDetailsAchDebitAccountHolderType'EnumCompany) = Value
"company"
  toJSON (PaymentMethodDetailsAchDebitAccountHolderType'
PaymentMethodDetailsAchDebitAccountHolderType'EnumIndividual) = Value
"individual"

instance Data.Aeson.Types.FromJSON.FromJSON PaymentMethodDetailsAchDebitAccountHolderType' where
  parseJSON :: Value -> Parser PaymentMethodDetailsAchDebitAccountHolderType'
parseJSON Value
val =
    PaymentMethodDetailsAchDebitAccountHolderType'
-> Parser PaymentMethodDetailsAchDebitAccountHolderType'
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
"company" -> PaymentMethodDetailsAchDebitAccountHolderType'
PaymentMethodDetailsAchDebitAccountHolderType'EnumCompany
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"individual" -> PaymentMethodDetailsAchDebitAccountHolderType'
PaymentMethodDetailsAchDebitAccountHolderType'EnumIndividual
            | Bool
GHC.Base.otherwise -> Value -> PaymentMethodDetailsAchDebitAccountHolderType'
PaymentMethodDetailsAchDebitAccountHolderType'Other Value
val
      )