{-# 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 SourceTypeSepaDebit
module StripeAPI.Types.SourceTypeSepaDebit 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_type_sepa_debit@ in the specification.
data SourceTypeSepaDebit = SourceTypeSepaDebit
  { -- | bank_code
    SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitBankCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | branch_code
    SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitBranchCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | country
    SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitCountry :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | fingerprint
    SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitFingerprint :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | last4
    SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitLast4 :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | mandate_reference
    SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitMandateReference :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | mandate_url
    SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitMandateUrl :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> SourceTypeSepaDebit -> ShowS
[SourceTypeSepaDebit] -> ShowS
SourceTypeSepaDebit -> String
(Int -> SourceTypeSepaDebit -> ShowS)
-> (SourceTypeSepaDebit -> String)
-> ([SourceTypeSepaDebit] -> ShowS)
-> Show SourceTypeSepaDebit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceTypeSepaDebit] -> ShowS
$cshowList :: [SourceTypeSepaDebit] -> ShowS
show :: SourceTypeSepaDebit -> String
$cshow :: SourceTypeSepaDebit -> String
showsPrec :: Int -> SourceTypeSepaDebit -> ShowS
$cshowsPrec :: Int -> SourceTypeSepaDebit -> ShowS
GHC.Show.Show,
      SourceTypeSepaDebit -> SourceTypeSepaDebit -> Bool
(SourceTypeSepaDebit -> SourceTypeSepaDebit -> Bool)
-> (SourceTypeSepaDebit -> SourceTypeSepaDebit -> Bool)
-> Eq SourceTypeSepaDebit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceTypeSepaDebit -> SourceTypeSepaDebit -> Bool
$c/= :: SourceTypeSepaDebit -> SourceTypeSepaDebit -> Bool
== :: SourceTypeSepaDebit -> SourceTypeSepaDebit -> Bool
$c== :: SourceTypeSepaDebit -> SourceTypeSepaDebit -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON SourceTypeSepaDebit where
  toJSON :: SourceTypeSepaDebit -> Value
toJSON SourceTypeSepaDebit
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..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitBankCode SourceTypeSepaDebit
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..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitBranchCode SourceTypeSepaDebit
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..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitCountry SourceTypeSepaDebit
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..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitFingerprint SourceTypeSepaDebit
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..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitLast4 SourceTypeSepaDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"mandate_reference" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitMandateReference SourceTypeSepaDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"mandate_url" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitMandateUrl SourceTypeSepaDebit
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: SourceTypeSepaDebit -> Encoding
toEncoding SourceTypeSepaDebit
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..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitBankCode SourceTypeSepaDebit
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..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitBranchCode SourceTypeSepaDebit
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..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitCountry SourceTypeSepaDebit
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..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitFingerprint SourceTypeSepaDebit
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..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitLast4 SourceTypeSepaDebit
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"mandate_reference" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitMandateReference SourceTypeSepaDebit
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"mandate_url" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeSepaDebit -> Maybe Text
sourceTypeSepaDebitMandateUrl SourceTypeSepaDebit
obj)))))))

instance Data.Aeson.Types.FromJSON.FromJSON SourceTypeSepaDebit where
  parseJSON :: Value -> Parser SourceTypeSepaDebit
parseJSON = String
-> (Object -> Parser SourceTypeSepaDebit)
-> Value
-> Parser SourceTypeSepaDebit
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SourceTypeSepaDebit" (\Object
obj -> (((((((Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> SourceTypeSepaDebit)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> SourceTypeSepaDebit)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SourceTypeSepaDebit
SourceTypeSepaDebit Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> SourceTypeSepaDebit)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> SourceTypeSepaDebit)
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 Text
   -> Maybe Text
   -> Maybe Text
   -> SourceTypeSepaDebit)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> SourceTypeSepaDebit)
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 Text
   -> Maybe Text
   -> Maybe Text
   -> SourceTypeSepaDebit)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> SourceTypeSepaDebit)
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 -> Maybe Text -> SourceTypeSepaDebit)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> SourceTypeSepaDebit)
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 -> Maybe Text -> SourceTypeSepaDebit)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> SourceTypeSepaDebit)
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 -> Maybe Text -> SourceTypeSepaDebit)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> SourceTypeSepaDebit)
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
"mandate_reference")) Parser (Maybe Text -> SourceTypeSepaDebit)
-> Parser (Maybe Text) -> Parser SourceTypeSepaDebit
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
"mandate_url"))

-- | Create a new 'SourceTypeSepaDebit' with all required fields.
mkSourceTypeSepaDebit :: SourceTypeSepaDebit
mkSourceTypeSepaDebit :: SourceTypeSepaDebit
mkSourceTypeSepaDebit =
  SourceTypeSepaDebit :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SourceTypeSepaDebit
SourceTypeSepaDebit
    { sourceTypeSepaDebitBankCode :: Maybe Text
sourceTypeSepaDebitBankCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeSepaDebitBranchCode :: Maybe Text
sourceTypeSepaDebitBranchCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeSepaDebitCountry :: Maybe Text
sourceTypeSepaDebitCountry = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeSepaDebitFingerprint :: Maybe Text
sourceTypeSepaDebitFingerprint = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeSepaDebitLast4 :: Maybe Text
sourceTypeSepaDebitLast4 = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeSepaDebitMandateReference :: Maybe Text
sourceTypeSepaDebitMandateReference = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeSepaDebitMandateUrl :: Maybe Text
sourceTypeSepaDebitMandateUrl = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }