{-# 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 SourceTypeBancontact
module StripeAPI.Types.SourceTypeBancontact 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_bancontact@ in the specification.
data SourceTypeBancontact = SourceTypeBancontact
  { -- | bank_code
    SourceTypeBancontact -> Maybe Text
sourceTypeBancontactBankCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | bank_name
    SourceTypeBancontact -> Maybe Text
sourceTypeBancontactBankName :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | bic
    SourceTypeBancontact -> Maybe Text
sourceTypeBancontactBic :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | iban_last4
    SourceTypeBancontact -> Maybe Text
sourceTypeBancontactIbanLast4 :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | preferred_language
    SourceTypeBancontact -> Maybe Text
sourceTypeBancontactPreferredLanguage :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | statement_descriptor
    SourceTypeBancontact -> Maybe Text
sourceTypeBancontactStatementDescriptor :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> SourceTypeBancontact -> ShowS
[SourceTypeBancontact] -> ShowS
SourceTypeBancontact -> String
(Int -> SourceTypeBancontact -> ShowS)
-> (SourceTypeBancontact -> String)
-> ([SourceTypeBancontact] -> ShowS)
-> Show SourceTypeBancontact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceTypeBancontact] -> ShowS
$cshowList :: [SourceTypeBancontact] -> ShowS
show :: SourceTypeBancontact -> String
$cshow :: SourceTypeBancontact -> String
showsPrec :: Int -> SourceTypeBancontact -> ShowS
$cshowsPrec :: Int -> SourceTypeBancontact -> ShowS
GHC.Show.Show,
      SourceTypeBancontact -> SourceTypeBancontact -> Bool
(SourceTypeBancontact -> SourceTypeBancontact -> Bool)
-> (SourceTypeBancontact -> SourceTypeBancontact -> Bool)
-> Eq SourceTypeBancontact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceTypeBancontact -> SourceTypeBancontact -> Bool
$c/= :: SourceTypeBancontact -> SourceTypeBancontact -> Bool
== :: SourceTypeBancontact -> SourceTypeBancontact -> Bool
$c== :: SourceTypeBancontact -> SourceTypeBancontact -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON SourceTypeBancontact where
  toJSON :: SourceTypeBancontact -> Value
toJSON SourceTypeBancontact
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..= SourceTypeBancontact -> Maybe Text
sourceTypeBancontactBankCode SourceTypeBancontact
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..= SourceTypeBancontact -> Maybe Text
sourceTypeBancontactBankName SourceTypeBancontact
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"bic" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeBancontact -> Maybe Text
sourceTypeBancontactBic SourceTypeBancontact
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"iban_last4" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeBancontact -> Maybe Text
sourceTypeBancontactIbanLast4 SourceTypeBancontact
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"preferred_language" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeBancontact -> Maybe Text
sourceTypeBancontactPreferredLanguage SourceTypeBancontact
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"statement_descriptor" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeBancontact -> Maybe Text
sourceTypeBancontactStatementDescriptor SourceTypeBancontact
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: SourceTypeBancontact -> Encoding
toEncoding SourceTypeBancontact
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..= SourceTypeBancontact -> Maybe Text
sourceTypeBancontactBankCode SourceTypeBancontact
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..= SourceTypeBancontact -> Maybe Text
sourceTypeBancontactBankName SourceTypeBancontact
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"bic" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeBancontact -> Maybe Text
sourceTypeBancontactBic SourceTypeBancontact
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"iban_last4" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeBancontact -> Maybe Text
sourceTypeBancontactIbanLast4 SourceTypeBancontact
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"preferred_language" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeBancontact -> Maybe Text
sourceTypeBancontactPreferredLanguage SourceTypeBancontact
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"statement_descriptor" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeBancontact -> Maybe Text
sourceTypeBancontactStatementDescriptor SourceTypeBancontact
obj))))))

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

-- | Create a new 'SourceTypeBancontact' with all required fields.
mkSourceTypeBancontact :: SourceTypeBancontact
mkSourceTypeBancontact :: SourceTypeBancontact
mkSourceTypeBancontact =
  SourceTypeBancontact :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SourceTypeBancontact
SourceTypeBancontact
    { sourceTypeBancontactBankCode :: Maybe Text
sourceTypeBancontactBankCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeBancontactBankName :: Maybe Text
sourceTypeBancontactBankName = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeBancontactBic :: Maybe Text
sourceTypeBancontactBic = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeBancontactIbanLast4 :: Maybe Text
sourceTypeBancontactIbanLast4 = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeBancontactPreferredLanguage :: Maybe Text
sourceTypeBancontactPreferredLanguage = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeBancontactStatementDescriptor :: Maybe Text
sourceTypeBancontactStatementDescriptor = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }