{-# 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 SourceMandateNotificationBacsDebitData
module StripeAPI.Types.SourceMandateNotificationBacsDebitData 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.source_mandate_notification_bacs_debit_data@ in the specification.
data SourceMandateNotificationBacsDebitData = SourceMandateNotificationBacsDebitData
  { -- | last4: Last 4 digits of the account number associated with the debit.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    SourceMandateNotificationBacsDebitData -> Maybe Text
sourceMandateNotificationBacsDebitDataLast4 :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> SourceMandateNotificationBacsDebitData -> ShowS
[SourceMandateNotificationBacsDebitData] -> ShowS
SourceMandateNotificationBacsDebitData -> String
(Int -> SourceMandateNotificationBacsDebitData -> ShowS)
-> (SourceMandateNotificationBacsDebitData -> String)
-> ([SourceMandateNotificationBacsDebitData] -> ShowS)
-> Show SourceMandateNotificationBacsDebitData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceMandateNotificationBacsDebitData] -> ShowS
$cshowList :: [SourceMandateNotificationBacsDebitData] -> ShowS
show :: SourceMandateNotificationBacsDebitData -> String
$cshow :: SourceMandateNotificationBacsDebitData -> String
showsPrec :: Int -> SourceMandateNotificationBacsDebitData -> ShowS
$cshowsPrec :: Int -> SourceMandateNotificationBacsDebitData -> ShowS
GHC.Show.Show,
      SourceMandateNotificationBacsDebitData
-> SourceMandateNotificationBacsDebitData -> Bool
(SourceMandateNotificationBacsDebitData
 -> SourceMandateNotificationBacsDebitData -> Bool)
-> (SourceMandateNotificationBacsDebitData
    -> SourceMandateNotificationBacsDebitData -> Bool)
-> Eq SourceMandateNotificationBacsDebitData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceMandateNotificationBacsDebitData
-> SourceMandateNotificationBacsDebitData -> Bool
$c/= :: SourceMandateNotificationBacsDebitData
-> SourceMandateNotificationBacsDebitData -> Bool
== :: SourceMandateNotificationBacsDebitData
-> SourceMandateNotificationBacsDebitData -> Bool
$c== :: SourceMandateNotificationBacsDebitData
-> SourceMandateNotificationBacsDebitData -> Bool
GHC.Classes.Eq
    )

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

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