{-# 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 PaymentMethodAuBecsDebit
module StripeAPI.Types.PaymentMethodAuBecsDebit 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_au_becs_debit@ in the specification.
data PaymentMethodAuBecsDebit = PaymentMethodAuBecsDebit
  { -- | bsb_number: Six-digit number identifying bank and branch associated with this bank account.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodAuBecsDebit -> Maybe Text
paymentMethodAuBecsDebitBsbNumber :: (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
    PaymentMethodAuBecsDebit -> Maybe Text
paymentMethodAuBecsDebitFingerprint :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | last4: Last four digits of the bank account number.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PaymentMethodAuBecsDebit -> Maybe Text
paymentMethodAuBecsDebitLast4 :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> PaymentMethodAuBecsDebit -> ShowS
[PaymentMethodAuBecsDebit] -> ShowS
PaymentMethodAuBecsDebit -> String
(Int -> PaymentMethodAuBecsDebit -> ShowS)
-> (PaymentMethodAuBecsDebit -> String)
-> ([PaymentMethodAuBecsDebit] -> ShowS)
-> Show PaymentMethodAuBecsDebit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodAuBecsDebit] -> ShowS
$cshowList :: [PaymentMethodAuBecsDebit] -> ShowS
show :: PaymentMethodAuBecsDebit -> String
$cshow :: PaymentMethodAuBecsDebit -> String
showsPrec :: Int -> PaymentMethodAuBecsDebit -> ShowS
$cshowsPrec :: Int -> PaymentMethodAuBecsDebit -> ShowS
GHC.Show.Show,
      PaymentMethodAuBecsDebit -> PaymentMethodAuBecsDebit -> Bool
(PaymentMethodAuBecsDebit -> PaymentMethodAuBecsDebit -> Bool)
-> (PaymentMethodAuBecsDebit -> PaymentMethodAuBecsDebit -> Bool)
-> Eq PaymentMethodAuBecsDebit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodAuBecsDebit -> PaymentMethodAuBecsDebit -> Bool
$c/= :: PaymentMethodAuBecsDebit -> PaymentMethodAuBecsDebit -> Bool
== :: PaymentMethodAuBecsDebit -> PaymentMethodAuBecsDebit -> Bool
$c== :: PaymentMethodAuBecsDebit -> PaymentMethodAuBecsDebit -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodAuBecsDebit where
  toJSON :: PaymentMethodAuBecsDebit -> Value
toJSON PaymentMethodAuBecsDebit
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"bsb_number" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodAuBecsDebit -> Maybe Text
paymentMethodAuBecsDebitBsbNumber PaymentMethodAuBecsDebit
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..= PaymentMethodAuBecsDebit -> Maybe Text
paymentMethodAuBecsDebitFingerprint PaymentMethodAuBecsDebit
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..= PaymentMethodAuBecsDebit -> Maybe Text
paymentMethodAuBecsDebitLast4 PaymentMethodAuBecsDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PaymentMethodAuBecsDebit -> Encoding
toEncoding PaymentMethodAuBecsDebit
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"bsb_number" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodAuBecsDebit -> Maybe Text
paymentMethodAuBecsDebitBsbNumber PaymentMethodAuBecsDebit
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..= PaymentMethodAuBecsDebit -> Maybe Text
paymentMethodAuBecsDebitFingerprint PaymentMethodAuBecsDebit
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..= PaymentMethodAuBecsDebit -> Maybe Text
paymentMethodAuBecsDebitLast4 PaymentMethodAuBecsDebit
obj)))

instance Data.Aeson.Types.FromJSON.FromJSON PaymentMethodAuBecsDebit where
  parseJSON :: Value -> Parser PaymentMethodAuBecsDebit
parseJSON = String
-> (Object -> Parser PaymentMethodAuBecsDebit)
-> Value
-> Parser PaymentMethodAuBecsDebit
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PaymentMethodAuBecsDebit" (\Object
obj -> (((Maybe Text
 -> Maybe Text -> Maybe Text -> PaymentMethodAuBecsDebit)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> PaymentMethodAuBecsDebit)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text -> Maybe Text -> Maybe Text -> PaymentMethodAuBecsDebit
PaymentMethodAuBecsDebit Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> PaymentMethodAuBecsDebit)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> PaymentMethodAuBecsDebit)
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
"bsb_number")) Parser (Maybe Text -> Maybe Text -> PaymentMethodAuBecsDebit)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> PaymentMethodAuBecsDebit)
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 -> PaymentMethodAuBecsDebit)
-> Parser (Maybe Text) -> Parser PaymentMethodAuBecsDebit
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 'PaymentMethodAuBecsDebit' with all required fields.
mkPaymentMethodAuBecsDebit :: PaymentMethodAuBecsDebit
mkPaymentMethodAuBecsDebit :: PaymentMethodAuBecsDebit
mkPaymentMethodAuBecsDebit =
  PaymentMethodAuBecsDebit :: Maybe Text -> Maybe Text -> Maybe Text -> PaymentMethodAuBecsDebit
PaymentMethodAuBecsDebit
    { paymentMethodAuBecsDebitBsbNumber :: Maybe Text
paymentMethodAuBecsDebitBsbNumber = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodAuBecsDebitFingerprint :: Maybe Text
paymentMethodAuBecsDebitFingerprint = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodAuBecsDebitLast4 :: Maybe Text
paymentMethodAuBecsDebitLast4 = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }