{-# 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 DeletedBankAccount
module StripeAPI.Types.DeletedBankAccount 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.deleted_bank_account@ in the specification.
data DeletedBankAccount = DeletedBankAccount
  { -- | currency: Three-letter [ISO code for the currency](https:\/\/stripe.com\/docs\/payouts) paid out to the bank account.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    DeletedBankAccount -> Maybe Text
deletedBankAccountCurrency :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    DeletedBankAccount -> Text
deletedBankAccountId :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> DeletedBankAccount -> ShowS
[DeletedBankAccount] -> ShowS
DeletedBankAccount -> String
(Int -> DeletedBankAccount -> ShowS)
-> (DeletedBankAccount -> String)
-> ([DeletedBankAccount] -> ShowS)
-> Show DeletedBankAccount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletedBankAccount] -> ShowS
$cshowList :: [DeletedBankAccount] -> ShowS
show :: DeletedBankAccount -> String
$cshow :: DeletedBankAccount -> String
showsPrec :: Int -> DeletedBankAccount -> ShowS
$cshowsPrec :: Int -> DeletedBankAccount -> ShowS
GHC.Show.Show,
      DeletedBankAccount -> DeletedBankAccount -> Bool
(DeletedBankAccount -> DeletedBankAccount -> Bool)
-> (DeletedBankAccount -> DeletedBankAccount -> Bool)
-> Eq DeletedBankAccount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletedBankAccount -> DeletedBankAccount -> Bool
$c/= :: DeletedBankAccount -> DeletedBankAccount -> Bool
== :: DeletedBankAccount -> DeletedBankAccount -> Bool
$c== :: DeletedBankAccount -> DeletedBankAccount -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON DeletedBankAccount where
  toJSON :: DeletedBankAccount -> Value
toJSON DeletedBankAccount
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"currency" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= DeletedBankAccount -> Maybe Text
deletedBankAccountCurrency DeletedBankAccount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= DeletedBankAccount -> Text
deletedBankAccountId DeletedBankAccount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"deleted" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Bool -> Value
Data.Aeson.Types.Internal.Bool Bool
GHC.Types.True Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"object" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"bank_account" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: DeletedBankAccount -> Encoding
toEncoding DeletedBankAccount
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"currency" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= DeletedBankAccount -> Maybe Text
deletedBankAccountCurrency DeletedBankAccount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"id" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= DeletedBankAccount -> Text
deletedBankAccountId DeletedBankAccount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"deleted" Text -> Value -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Bool -> Value
Data.Aeson.Types.Internal.Bool Bool
GHC.Types.True) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"object" Text -> Value -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"bank_account"))))

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

-- | Create a new 'DeletedBankAccount' with all required fields.
mkDeletedBankAccount ::
  -- | 'deletedBankAccountId'
  Data.Text.Internal.Text ->
  DeletedBankAccount
mkDeletedBankAccount :: Text -> DeletedBankAccount
mkDeletedBankAccount Text
deletedBankAccountId =
  DeletedBankAccount :: Maybe Text -> Text -> DeletedBankAccount
DeletedBankAccount
    { deletedBankAccountCurrency :: Maybe Text
deletedBankAccountCurrency = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      deletedBankAccountId :: Text
deletedBankAccountId = Text
deletedBankAccountId
    }