{-# 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 SourceTypeAchCreditTransfer
module StripeAPI.Types.SourceTypeAchCreditTransfer 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_ach_credit_transfer@ in the specification.
data SourceTypeAchCreditTransfer = SourceTypeAchCreditTransfer
  { -- | account_number
    SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferAccountNumber :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | bank_name
    SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferBankName :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | fingerprint
    SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferFingerprint :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | refund_account_holder_name
    SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferRefundAccountHolderName :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | refund_account_holder_type
    SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferRefundAccountHolderType :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | refund_routing_number
    SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferRefundRoutingNumber :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | routing_number
    SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferRoutingNumber :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | swift_code
    SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferSwiftCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> SourceTypeAchCreditTransfer -> ShowS
[SourceTypeAchCreditTransfer] -> ShowS
SourceTypeAchCreditTransfer -> String
(Int -> SourceTypeAchCreditTransfer -> ShowS)
-> (SourceTypeAchCreditTransfer -> String)
-> ([SourceTypeAchCreditTransfer] -> ShowS)
-> Show SourceTypeAchCreditTransfer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceTypeAchCreditTransfer] -> ShowS
$cshowList :: [SourceTypeAchCreditTransfer] -> ShowS
show :: SourceTypeAchCreditTransfer -> String
$cshow :: SourceTypeAchCreditTransfer -> String
showsPrec :: Int -> SourceTypeAchCreditTransfer -> ShowS
$cshowsPrec :: Int -> SourceTypeAchCreditTransfer -> ShowS
GHC.Show.Show,
      SourceTypeAchCreditTransfer -> SourceTypeAchCreditTransfer -> Bool
(SourceTypeAchCreditTransfer
 -> SourceTypeAchCreditTransfer -> Bool)
-> (SourceTypeAchCreditTransfer
    -> SourceTypeAchCreditTransfer -> Bool)
-> Eq SourceTypeAchCreditTransfer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceTypeAchCreditTransfer -> SourceTypeAchCreditTransfer -> Bool
$c/= :: SourceTypeAchCreditTransfer -> SourceTypeAchCreditTransfer -> Bool
== :: SourceTypeAchCreditTransfer -> SourceTypeAchCreditTransfer -> Bool
$c== :: SourceTypeAchCreditTransfer -> SourceTypeAchCreditTransfer -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON SourceTypeAchCreditTransfer where
  toJSON :: SourceTypeAchCreditTransfer -> Value
toJSON SourceTypeAchCreditTransfer
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"account_number" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferAccountNumber SourceTypeAchCreditTransfer
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..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferBankName SourceTypeAchCreditTransfer
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..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferFingerprint SourceTypeAchCreditTransfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"refund_account_holder_name" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferRefundAccountHolderName SourceTypeAchCreditTransfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"refund_account_holder_type" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferRefundAccountHolderType SourceTypeAchCreditTransfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"refund_routing_number" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferRefundRoutingNumber SourceTypeAchCreditTransfer
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..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferRoutingNumber SourceTypeAchCreditTransfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"swift_code" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferSwiftCode SourceTypeAchCreditTransfer
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: SourceTypeAchCreditTransfer -> Encoding
toEncoding SourceTypeAchCreditTransfer
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"account_number" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferAccountNumber SourceTypeAchCreditTransfer
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..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferBankName SourceTypeAchCreditTransfer
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..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferFingerprint SourceTypeAchCreditTransfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"refund_account_holder_name" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferRefundAccountHolderName SourceTypeAchCreditTransfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"refund_account_holder_type" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferRefundAccountHolderType SourceTypeAchCreditTransfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"refund_routing_number" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferRefundRoutingNumber SourceTypeAchCreditTransfer
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..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferRoutingNumber SourceTypeAchCreditTransfer
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"swift_code" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SourceTypeAchCreditTransfer -> Maybe Text
sourceTypeAchCreditTransferSwiftCode SourceTypeAchCreditTransfer
obj))))))))

instance Data.Aeson.Types.FromJSON.FromJSON SourceTypeAchCreditTransfer where
  parseJSON :: Value -> Parser SourceTypeAchCreditTransfer
parseJSON = String
-> (Object -> Parser SourceTypeAchCreditTransfer)
-> Value
-> Parser SourceTypeAchCreditTransfer
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SourceTypeAchCreditTransfer" (\Object
obj -> ((((((((Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> SourceTypeAchCreditTransfer)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> SourceTypeAchCreditTransfer)
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
-> Maybe Text
-> SourceTypeAchCreditTransfer
SourceTypeAchCreditTransfer Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> SourceTypeAchCreditTransfer)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> SourceTypeAchCreditTransfer)
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
"account_number")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> SourceTypeAchCreditTransfer)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> SourceTypeAchCreditTransfer)
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
   -> Maybe Text
   -> Maybe Text
   -> SourceTypeAchCreditTransfer)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> SourceTypeAchCreditTransfer)
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
   -> Maybe Text
   -> Maybe Text
   -> SourceTypeAchCreditTransfer)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> SourceTypeAchCreditTransfer)
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
"refund_account_holder_name")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> SourceTypeAchCreditTransfer)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> SourceTypeAchCreditTransfer)
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
"refund_account_holder_type")) Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> SourceTypeAchCreditTransfer)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> SourceTypeAchCreditTransfer)
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
"refund_routing_number")) Parser (Maybe Text -> Maybe Text -> SourceTypeAchCreditTransfer)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> SourceTypeAchCreditTransfer)
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")) Parser (Maybe Text -> SourceTypeAchCreditTransfer)
-> Parser (Maybe Text) -> Parser SourceTypeAchCreditTransfer
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
"swift_code"))

-- | Create a new 'SourceTypeAchCreditTransfer' with all required fields.
mkSourceTypeAchCreditTransfer :: SourceTypeAchCreditTransfer
mkSourceTypeAchCreditTransfer :: SourceTypeAchCreditTransfer
mkSourceTypeAchCreditTransfer =
  SourceTypeAchCreditTransfer :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> SourceTypeAchCreditTransfer
SourceTypeAchCreditTransfer
    { sourceTypeAchCreditTransferAccountNumber :: Maybe Text
sourceTypeAchCreditTransferAccountNumber = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeAchCreditTransferBankName :: Maybe Text
sourceTypeAchCreditTransferBankName = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeAchCreditTransferFingerprint :: Maybe Text
sourceTypeAchCreditTransferFingerprint = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeAchCreditTransferRefundAccountHolderName :: Maybe Text
sourceTypeAchCreditTransferRefundAccountHolderName = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeAchCreditTransferRefundAccountHolderType :: Maybe Text
sourceTypeAchCreditTransferRefundAccountHolderType = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeAchCreditTransferRefundRoutingNumber :: Maybe Text
sourceTypeAchCreditTransferRefundRoutingNumber = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeAchCreditTransferRoutingNumber :: Maybe Text
sourceTypeAchCreditTransferRoutingNumber = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      sourceTypeAchCreditTransferSwiftCode :: Maybe Text
sourceTypeAchCreditTransferSwiftCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }