{-# 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 PaymentMethodOptionsBoleto
module StripeAPI.Types.PaymentMethodOptionsBoleto 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.payment_method_options_boleto@ in the specification.
data PaymentMethodOptionsBoleto = PaymentMethodOptionsBoleto
  { -- | expires_after_days: The number of calendar days before a Boleto voucher expires. For example, if you create a Boleto voucher on Monday and you set expires_after_days to 2, the Boleto voucher will expire on Wednesday at 23:59 America\/Sao_Paulo time.
    PaymentMethodOptionsBoleto -> Int
paymentMethodOptionsBoletoExpiresAfterDays :: GHC.Types.Int
  }
  deriving
    ( Int -> PaymentMethodOptionsBoleto -> ShowS
[PaymentMethodOptionsBoleto] -> ShowS
PaymentMethodOptionsBoleto -> String
(Int -> PaymentMethodOptionsBoleto -> ShowS)
-> (PaymentMethodOptionsBoleto -> String)
-> ([PaymentMethodOptionsBoleto] -> ShowS)
-> Show PaymentMethodOptionsBoleto
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodOptionsBoleto] -> ShowS
$cshowList :: [PaymentMethodOptionsBoleto] -> ShowS
show :: PaymentMethodOptionsBoleto -> String
$cshow :: PaymentMethodOptionsBoleto -> String
showsPrec :: Int -> PaymentMethodOptionsBoleto -> ShowS
$cshowsPrec :: Int -> PaymentMethodOptionsBoleto -> ShowS
GHC.Show.Show,
      PaymentMethodOptionsBoleto -> PaymentMethodOptionsBoleto -> Bool
(PaymentMethodOptionsBoleto -> PaymentMethodOptionsBoleto -> Bool)
-> (PaymentMethodOptionsBoleto
    -> PaymentMethodOptionsBoleto -> Bool)
-> Eq PaymentMethodOptionsBoleto
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodOptionsBoleto -> PaymentMethodOptionsBoleto -> Bool
$c/= :: PaymentMethodOptionsBoleto -> PaymentMethodOptionsBoleto -> Bool
== :: PaymentMethodOptionsBoleto -> PaymentMethodOptionsBoleto -> Bool
$c== :: PaymentMethodOptionsBoleto -> PaymentMethodOptionsBoleto -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodOptionsBoleto where
  toJSON :: PaymentMethodOptionsBoleto -> Value
toJSON PaymentMethodOptionsBoleto
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"expires_after_days" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsBoleto -> Int
paymentMethodOptionsBoletoExpiresAfterDays PaymentMethodOptionsBoleto
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PaymentMethodOptionsBoleto -> Encoding
toEncoding PaymentMethodOptionsBoleto
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs (Text
"expires_after_days" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsBoleto -> Int
paymentMethodOptionsBoletoExpiresAfterDays PaymentMethodOptionsBoleto
obj)

instance Data.Aeson.Types.FromJSON.FromJSON PaymentMethodOptionsBoleto where
  parseJSON :: Value -> Parser PaymentMethodOptionsBoleto
parseJSON = String
-> (Object -> Parser PaymentMethodOptionsBoleto)
-> Value
-> Parser PaymentMethodOptionsBoleto
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PaymentMethodOptionsBoleto" (\Object
obj -> (Int -> PaymentMethodOptionsBoleto)
-> Parser (Int -> PaymentMethodOptionsBoleto)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Int -> PaymentMethodOptionsBoleto
PaymentMethodOptionsBoleto Parser (Int -> PaymentMethodOptionsBoleto)
-> Parser Int -> Parser PaymentMethodOptionsBoleto
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"expires_after_days"))

-- | Create a new 'PaymentMethodOptionsBoleto' with all required fields.
mkPaymentMethodOptionsBoleto ::
  -- | 'paymentMethodOptionsBoletoExpiresAfterDays'
  GHC.Types.Int ->
  PaymentMethodOptionsBoleto
mkPaymentMethodOptionsBoleto :: Int -> PaymentMethodOptionsBoleto
mkPaymentMethodOptionsBoleto Int
paymentMethodOptionsBoletoExpiresAfterDays = PaymentMethodOptionsBoleto :: Int -> PaymentMethodOptionsBoleto
PaymentMethodOptionsBoleto {paymentMethodOptionsBoletoExpiresAfterDays :: Int
paymentMethodOptionsBoletoExpiresAfterDays = Int
paymentMethodOptionsBoletoExpiresAfterDays}