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

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodOptionsOxxo where
  toJSON :: PaymentMethodOptionsOxxo -> Value
toJSON PaymentMethodOptionsOxxo
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..= PaymentMethodOptionsOxxo -> Int
paymentMethodOptionsOxxoExpiresAfterDays PaymentMethodOptionsOxxo
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PaymentMethodOptionsOxxo -> Encoding
toEncoding PaymentMethodOptionsOxxo
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..= PaymentMethodOptionsOxxo -> Int
paymentMethodOptionsOxxoExpiresAfterDays PaymentMethodOptionsOxxo
obj)

instance Data.Aeson.Types.FromJSON.FromJSON PaymentMethodOptionsOxxo where
  parseJSON :: Value -> Parser PaymentMethodOptionsOxxo
parseJSON = String
-> (Object -> Parser PaymentMethodOptionsOxxo)
-> Value
-> Parser PaymentMethodOptionsOxxo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PaymentMethodOptionsOxxo" (\Object
obj -> (Int -> PaymentMethodOptionsOxxo)
-> Parser (Int -> PaymentMethodOptionsOxxo)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Int -> PaymentMethodOptionsOxxo
PaymentMethodOptionsOxxo Parser (Int -> PaymentMethodOptionsOxxo)
-> Parser Int -> Parser PaymentMethodOptionsOxxo
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 'PaymentMethodOptionsOxxo' with all required fields.
mkPaymentMethodOptionsOxxo ::
  -- | 'paymentMethodOptionsOxxoExpiresAfterDays'
  GHC.Types.Int ->
  PaymentMethodOptionsOxxo
mkPaymentMethodOptionsOxxo :: Int -> PaymentMethodOptionsOxxo
mkPaymentMethodOptionsOxxo Int
paymentMethodOptionsOxxoExpiresAfterDays = PaymentMethodOptionsOxxo :: Int -> PaymentMethodOptionsOxxo
PaymentMethodOptionsOxxo {paymentMethodOptionsOxxoExpiresAfterDays :: Int
paymentMethodOptionsOxxoExpiresAfterDays = Int
paymentMethodOptionsOxxoExpiresAfterDays}