{-# 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 AccountCardPaymentsSettings
module StripeAPI.Types.AccountCardPaymentsSettings 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 {-# SOURCE #-} StripeAPI.Types.AccountDeclineChargeOn
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.account_card_payments_settings@ in the specification.
data AccountCardPaymentsSettings = AccountCardPaymentsSettings
  { -- | decline_on:
    AccountCardPaymentsSettings -> Maybe AccountDeclineChargeOn
accountCardPaymentsSettingsDeclineOn :: (GHC.Maybe.Maybe AccountDeclineChargeOn),
    -- | statement_descriptor_prefix: The default text that appears on credit card statements when a charge is made. This field prefixes any dynamic \`statement_descriptor\` specified on the charge. \`statement_descriptor_prefix\` is useful for maximizing descriptor space for the dynamic portion.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    AccountCardPaymentsSettings -> Maybe Text
accountCardPaymentsSettingsStatementDescriptorPrefix :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> AccountCardPaymentsSettings -> ShowS
[AccountCardPaymentsSettings] -> ShowS
AccountCardPaymentsSettings -> String
(Int -> AccountCardPaymentsSettings -> ShowS)
-> (AccountCardPaymentsSettings -> String)
-> ([AccountCardPaymentsSettings] -> ShowS)
-> Show AccountCardPaymentsSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountCardPaymentsSettings] -> ShowS
$cshowList :: [AccountCardPaymentsSettings] -> ShowS
show :: AccountCardPaymentsSettings -> String
$cshow :: AccountCardPaymentsSettings -> String
showsPrec :: Int -> AccountCardPaymentsSettings -> ShowS
$cshowsPrec :: Int -> AccountCardPaymentsSettings -> ShowS
GHC.Show.Show,
      AccountCardPaymentsSettings -> AccountCardPaymentsSettings -> Bool
(AccountCardPaymentsSettings
 -> AccountCardPaymentsSettings -> Bool)
-> (AccountCardPaymentsSettings
    -> AccountCardPaymentsSettings -> Bool)
-> Eq AccountCardPaymentsSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountCardPaymentsSettings -> AccountCardPaymentsSettings -> Bool
$c/= :: AccountCardPaymentsSettings -> AccountCardPaymentsSettings -> Bool
== :: AccountCardPaymentsSettings -> AccountCardPaymentsSettings -> Bool
$c== :: AccountCardPaymentsSettings -> AccountCardPaymentsSettings -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON AccountCardPaymentsSettings where
  toJSON :: AccountCardPaymentsSettings -> Value
toJSON AccountCardPaymentsSettings
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"decline_on" Text -> Maybe AccountDeclineChargeOn -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountCardPaymentsSettings -> Maybe AccountDeclineChargeOn
accountCardPaymentsSettingsDeclineOn AccountCardPaymentsSettings
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"statement_descriptor_prefix" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountCardPaymentsSettings -> Maybe Text
accountCardPaymentsSettingsStatementDescriptorPrefix AccountCardPaymentsSettings
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: AccountCardPaymentsSettings -> Encoding
toEncoding AccountCardPaymentsSettings
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"decline_on" Text -> Maybe AccountDeclineChargeOn -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountCardPaymentsSettings -> Maybe AccountDeclineChargeOn
accountCardPaymentsSettingsDeclineOn AccountCardPaymentsSettings
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"statement_descriptor_prefix" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountCardPaymentsSettings -> Maybe Text
accountCardPaymentsSettingsStatementDescriptorPrefix AccountCardPaymentsSettings
obj))

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

-- | Create a new 'AccountCardPaymentsSettings' with all required fields.
mkAccountCardPaymentsSettings :: AccountCardPaymentsSettings
mkAccountCardPaymentsSettings :: AccountCardPaymentsSettings
mkAccountCardPaymentsSettings =
  AccountCardPaymentsSettings :: Maybe AccountDeclineChargeOn
-> Maybe Text -> AccountCardPaymentsSettings
AccountCardPaymentsSettings
    { accountCardPaymentsSettingsDeclineOn :: Maybe AccountDeclineChargeOn
accountCardPaymentsSettingsDeclineOn = Maybe AccountDeclineChargeOn
forall a. Maybe a
GHC.Maybe.Nothing,
      accountCardPaymentsSettingsStatementDescriptorPrefix :: Maybe Text
accountCardPaymentsSettingsStatementDescriptorPrefix = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }