{-# 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 PaymentMethodOptionsCardInstallments
module StripeAPI.Types.PaymentMethodOptionsCardInstallments 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.PaymentMethodDetailsCardInstallmentsPlan
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.payment_method_options_card_installments@ in the specification.
data PaymentMethodOptionsCardInstallments = PaymentMethodOptionsCardInstallments
  { -- | available_plans: Installment plans that may be selected for this PaymentIntent.
    PaymentMethodOptionsCardInstallments
-> Maybe [PaymentMethodDetailsCardInstallmentsPlan]
paymentMethodOptionsCardInstallmentsAvailablePlans :: (GHC.Maybe.Maybe ([PaymentMethodDetailsCardInstallmentsPlan])),
    -- | enabled: Whether Installments are enabled for this PaymentIntent.
    PaymentMethodOptionsCardInstallments -> Bool
paymentMethodOptionsCardInstallmentsEnabled :: GHC.Types.Bool,
    -- | plan: Installment plan selected for this PaymentIntent.
    PaymentMethodOptionsCardInstallments
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'
paymentMethodOptionsCardInstallmentsPlan :: (GHC.Maybe.Maybe PaymentMethodOptionsCardInstallmentsPlan')
  }
  deriving
    ( Int -> PaymentMethodOptionsCardInstallments -> ShowS
[PaymentMethodOptionsCardInstallments] -> ShowS
PaymentMethodOptionsCardInstallments -> String
(Int -> PaymentMethodOptionsCardInstallments -> ShowS)
-> (PaymentMethodOptionsCardInstallments -> String)
-> ([PaymentMethodOptionsCardInstallments] -> ShowS)
-> Show PaymentMethodOptionsCardInstallments
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodOptionsCardInstallments] -> ShowS
$cshowList :: [PaymentMethodOptionsCardInstallments] -> ShowS
show :: PaymentMethodOptionsCardInstallments -> String
$cshow :: PaymentMethodOptionsCardInstallments -> String
showsPrec :: Int -> PaymentMethodOptionsCardInstallments -> ShowS
$cshowsPrec :: Int -> PaymentMethodOptionsCardInstallments -> ShowS
GHC.Show.Show,
      PaymentMethodOptionsCardInstallments
-> PaymentMethodOptionsCardInstallments -> Bool
(PaymentMethodOptionsCardInstallments
 -> PaymentMethodOptionsCardInstallments -> Bool)
-> (PaymentMethodOptionsCardInstallments
    -> PaymentMethodOptionsCardInstallments -> Bool)
-> Eq PaymentMethodOptionsCardInstallments
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodOptionsCardInstallments
-> PaymentMethodOptionsCardInstallments -> Bool
$c/= :: PaymentMethodOptionsCardInstallments
-> PaymentMethodOptionsCardInstallments -> Bool
== :: PaymentMethodOptionsCardInstallments
-> PaymentMethodOptionsCardInstallments -> Bool
$c== :: PaymentMethodOptionsCardInstallments
-> PaymentMethodOptionsCardInstallments -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodOptionsCardInstallments where
  toJSON :: PaymentMethodOptionsCardInstallments -> Value
toJSON PaymentMethodOptionsCardInstallments
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"available_plans" Text -> Maybe [PaymentMethodDetailsCardInstallmentsPlan] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsCardInstallments
-> Maybe [PaymentMethodDetailsCardInstallmentsPlan]
paymentMethodOptionsCardInstallmentsAvailablePlans PaymentMethodOptionsCardInstallments
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsCardInstallments -> Bool
paymentMethodOptionsCardInstallmentsEnabled PaymentMethodOptionsCardInstallments
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"plan" Text -> Maybe PaymentMethodOptionsCardInstallmentsPlan' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsCardInstallments
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'
paymentMethodOptionsCardInstallmentsPlan PaymentMethodOptionsCardInstallments
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PaymentMethodOptionsCardInstallments -> Encoding
toEncoding PaymentMethodOptionsCardInstallments
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"available_plans" Text -> Maybe [PaymentMethodDetailsCardInstallmentsPlan] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsCardInstallments
-> Maybe [PaymentMethodDetailsCardInstallmentsPlan]
paymentMethodOptionsCardInstallmentsAvailablePlans PaymentMethodOptionsCardInstallments
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"enabled" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsCardInstallments -> Bool
paymentMethodOptionsCardInstallmentsEnabled PaymentMethodOptionsCardInstallments
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"plan" Text -> Maybe PaymentMethodOptionsCardInstallmentsPlan' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsCardInstallments
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'
paymentMethodOptionsCardInstallmentsPlan PaymentMethodOptionsCardInstallments
obj)))

instance Data.Aeson.Types.FromJSON.FromJSON PaymentMethodOptionsCardInstallments where
  parseJSON :: Value -> Parser PaymentMethodOptionsCardInstallments
parseJSON = String
-> (Object -> Parser PaymentMethodOptionsCardInstallments)
-> Value
-> Parser PaymentMethodOptionsCardInstallments
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PaymentMethodOptionsCardInstallments" (\Object
obj -> (((Maybe [PaymentMethodDetailsCardInstallmentsPlan]
 -> Bool
 -> Maybe PaymentMethodOptionsCardInstallmentsPlan'
 -> PaymentMethodOptionsCardInstallments)
-> Parser
     (Maybe [PaymentMethodDetailsCardInstallmentsPlan]
      -> Bool
      -> Maybe PaymentMethodOptionsCardInstallmentsPlan'
      -> PaymentMethodOptionsCardInstallments)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe [PaymentMethodDetailsCardInstallmentsPlan]
-> Bool
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'
-> PaymentMethodOptionsCardInstallments
PaymentMethodOptionsCardInstallments Parser
  (Maybe [PaymentMethodDetailsCardInstallmentsPlan]
   -> Bool
   -> Maybe PaymentMethodOptionsCardInstallmentsPlan'
   -> PaymentMethodOptionsCardInstallments)
-> Parser (Maybe [PaymentMethodDetailsCardInstallmentsPlan])
-> Parser
     (Bool
      -> Maybe PaymentMethodOptionsCardInstallmentsPlan'
      -> PaymentMethodOptionsCardInstallments)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe [PaymentMethodDetailsCardInstallmentsPlan])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"available_plans")) Parser
  (Bool
   -> Maybe PaymentMethodOptionsCardInstallmentsPlan'
   -> PaymentMethodOptionsCardInstallments)
-> Parser Bool
-> Parser
     (Maybe PaymentMethodOptionsCardInstallmentsPlan'
      -> PaymentMethodOptionsCardInstallments)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"enabled")) Parser
  (Maybe PaymentMethodOptionsCardInstallmentsPlan'
   -> PaymentMethodOptionsCardInstallments)
-> Parser (Maybe PaymentMethodOptionsCardInstallmentsPlan')
-> Parser PaymentMethodOptionsCardInstallments
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text -> Parser (Maybe PaymentMethodOptionsCardInstallmentsPlan')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"plan"))

-- | Create a new 'PaymentMethodOptionsCardInstallments' with all required fields.
mkPaymentMethodOptionsCardInstallments ::
  -- | 'paymentMethodOptionsCardInstallmentsEnabled'
  GHC.Types.Bool ->
  PaymentMethodOptionsCardInstallments
mkPaymentMethodOptionsCardInstallments :: Bool -> PaymentMethodOptionsCardInstallments
mkPaymentMethodOptionsCardInstallments Bool
paymentMethodOptionsCardInstallmentsEnabled =
  PaymentMethodOptionsCardInstallments :: Maybe [PaymentMethodDetailsCardInstallmentsPlan]
-> Bool
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'
-> PaymentMethodOptionsCardInstallments
PaymentMethodOptionsCardInstallments
    { paymentMethodOptionsCardInstallmentsAvailablePlans :: Maybe [PaymentMethodDetailsCardInstallmentsPlan]
paymentMethodOptionsCardInstallmentsAvailablePlans = Maybe [PaymentMethodDetailsCardInstallmentsPlan]
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodOptionsCardInstallmentsEnabled :: Bool
paymentMethodOptionsCardInstallmentsEnabled = Bool
paymentMethodOptionsCardInstallmentsEnabled,
      paymentMethodOptionsCardInstallmentsPlan :: Maybe PaymentMethodOptionsCardInstallmentsPlan'
paymentMethodOptionsCardInstallmentsPlan = Maybe PaymentMethodOptionsCardInstallmentsPlan'
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the object schema located at @components.schemas.payment_method_options_card_installments.properties.plan.anyOf@ in the specification.
--
-- Installment plan selected for this PaymentIntent.
data PaymentMethodOptionsCardInstallmentsPlan' = PaymentMethodOptionsCardInstallmentsPlan'
  { -- | count: For \`fixed_count\` installment plans, this is the number of installment payments your customer will make to their credit card.
    PaymentMethodOptionsCardInstallmentsPlan' -> Maybe Int
paymentMethodOptionsCardInstallmentsPlan'Count :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | interval: For \`fixed_count\` installment plans, this is the interval between installment payments your customer will make to their credit card.
    -- One of \`month\`.
    PaymentMethodOptionsCardInstallmentsPlan'
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
paymentMethodOptionsCardInstallmentsPlan'Interval :: (GHC.Maybe.Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'),
    -- | type: Type of installment plan, one of \`fixed_count\`.
    PaymentMethodOptionsCardInstallmentsPlan'
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
paymentMethodOptionsCardInstallmentsPlan'Type :: (GHC.Maybe.Maybe PaymentMethodOptionsCardInstallmentsPlan'Type')
  }
  deriving
    ( Int -> PaymentMethodOptionsCardInstallmentsPlan' -> ShowS
[PaymentMethodOptionsCardInstallmentsPlan'] -> ShowS
PaymentMethodOptionsCardInstallmentsPlan' -> String
(Int -> PaymentMethodOptionsCardInstallmentsPlan' -> ShowS)
-> (PaymentMethodOptionsCardInstallmentsPlan' -> String)
-> ([PaymentMethodOptionsCardInstallmentsPlan'] -> ShowS)
-> Show PaymentMethodOptionsCardInstallmentsPlan'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodOptionsCardInstallmentsPlan'] -> ShowS
$cshowList :: [PaymentMethodOptionsCardInstallmentsPlan'] -> ShowS
show :: PaymentMethodOptionsCardInstallmentsPlan' -> String
$cshow :: PaymentMethodOptionsCardInstallmentsPlan' -> String
showsPrec :: Int -> PaymentMethodOptionsCardInstallmentsPlan' -> ShowS
$cshowsPrec :: Int -> PaymentMethodOptionsCardInstallmentsPlan' -> ShowS
GHC.Show.Show,
      PaymentMethodOptionsCardInstallmentsPlan'
-> PaymentMethodOptionsCardInstallmentsPlan' -> Bool
(PaymentMethodOptionsCardInstallmentsPlan'
 -> PaymentMethodOptionsCardInstallmentsPlan' -> Bool)
-> (PaymentMethodOptionsCardInstallmentsPlan'
    -> PaymentMethodOptionsCardInstallmentsPlan' -> Bool)
-> Eq PaymentMethodOptionsCardInstallmentsPlan'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodOptionsCardInstallmentsPlan'
-> PaymentMethodOptionsCardInstallmentsPlan' -> Bool
$c/= :: PaymentMethodOptionsCardInstallmentsPlan'
-> PaymentMethodOptionsCardInstallmentsPlan' -> Bool
== :: PaymentMethodOptionsCardInstallmentsPlan'
-> PaymentMethodOptionsCardInstallmentsPlan' -> Bool
$c== :: PaymentMethodOptionsCardInstallmentsPlan'
-> PaymentMethodOptionsCardInstallmentsPlan' -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodOptionsCardInstallmentsPlan' where
  toJSON :: PaymentMethodOptionsCardInstallmentsPlan' -> Value
toJSON PaymentMethodOptionsCardInstallmentsPlan'
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"count" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsCardInstallmentsPlan' -> Maybe Int
paymentMethodOptionsCardInstallmentsPlan'Count PaymentMethodOptionsCardInstallmentsPlan'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"interval" Text
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsCardInstallmentsPlan'
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
paymentMethodOptionsCardInstallmentsPlan'Interval PaymentMethodOptionsCardInstallmentsPlan'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"type" Text
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Type' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsCardInstallmentsPlan'
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
paymentMethodOptionsCardInstallmentsPlan'Type PaymentMethodOptionsCardInstallmentsPlan'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PaymentMethodOptionsCardInstallmentsPlan' -> Encoding
toEncoding PaymentMethodOptionsCardInstallmentsPlan'
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"count" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsCardInstallmentsPlan' -> Maybe Int
paymentMethodOptionsCardInstallmentsPlan'Count PaymentMethodOptionsCardInstallmentsPlan'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"interval" Text
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
-> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsCardInstallmentsPlan'
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
paymentMethodOptionsCardInstallmentsPlan'Interval PaymentMethodOptionsCardInstallmentsPlan'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"type" Text
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Type' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentMethodOptionsCardInstallmentsPlan'
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
paymentMethodOptionsCardInstallmentsPlan'Type PaymentMethodOptionsCardInstallmentsPlan'
obj)))

instance Data.Aeson.Types.FromJSON.FromJSON PaymentMethodOptionsCardInstallmentsPlan' where
  parseJSON :: Value -> Parser PaymentMethodOptionsCardInstallmentsPlan'
parseJSON = String
-> (Object -> Parser PaymentMethodOptionsCardInstallmentsPlan')
-> Value
-> Parser PaymentMethodOptionsCardInstallmentsPlan'
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PaymentMethodOptionsCardInstallmentsPlan'" (\Object
obj -> (((Maybe Int
 -> Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
 -> Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
 -> PaymentMethodOptionsCardInstallmentsPlan')
-> Parser
     (Maybe Int
      -> Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
      -> Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
      -> PaymentMethodOptionsCardInstallmentsPlan')
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Int
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
-> PaymentMethodOptionsCardInstallmentsPlan'
PaymentMethodOptionsCardInstallmentsPlan' Parser
  (Maybe Int
   -> Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
   -> Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
   -> PaymentMethodOptionsCardInstallmentsPlan')
-> Parser (Maybe Int)
-> Parser
     (Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
      -> Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
      -> PaymentMethodOptionsCardInstallmentsPlan')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"count")) Parser
  (Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
   -> Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
   -> PaymentMethodOptionsCardInstallmentsPlan')
-> Parser
     (Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval')
-> Parser
     (Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
      -> PaymentMethodOptionsCardInstallmentsPlan')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser
     (Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"interval")) Parser
  (Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
   -> PaymentMethodOptionsCardInstallmentsPlan')
-> Parser (Maybe PaymentMethodOptionsCardInstallmentsPlan'Type')
-> Parser PaymentMethodOptionsCardInstallmentsPlan'
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe PaymentMethodOptionsCardInstallmentsPlan'Type')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"type"))

-- | Create a new 'PaymentMethodOptionsCardInstallmentsPlan'' with all required fields.
mkPaymentMethodOptionsCardInstallmentsPlan' :: PaymentMethodOptionsCardInstallmentsPlan'
mkPaymentMethodOptionsCardInstallmentsPlan' :: PaymentMethodOptionsCardInstallmentsPlan'
mkPaymentMethodOptionsCardInstallmentsPlan' =
  PaymentMethodOptionsCardInstallmentsPlan' :: Maybe Int
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
-> Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
-> PaymentMethodOptionsCardInstallmentsPlan'
PaymentMethodOptionsCardInstallmentsPlan'
    { paymentMethodOptionsCardInstallmentsPlan'Count :: Maybe Int
paymentMethodOptionsCardInstallmentsPlan'Count = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodOptionsCardInstallmentsPlan'Interval :: Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
paymentMethodOptionsCardInstallmentsPlan'Interval = Maybe PaymentMethodOptionsCardInstallmentsPlan'Interval'
forall a. Maybe a
GHC.Maybe.Nothing,
      paymentMethodOptionsCardInstallmentsPlan'Type :: Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
paymentMethodOptionsCardInstallmentsPlan'Type = Maybe PaymentMethodOptionsCardInstallmentsPlan'Type'
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the enum schema located at @components.schemas.payment_method_options_card_installments.properties.plan.anyOf.properties.interval@ in the specification.
--
-- For \`fixed_count\` installment plans, this is the interval between installment payments your customer will make to their credit card.
-- One of \`month\`.
data PaymentMethodOptionsCardInstallmentsPlan'Interval'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PaymentMethodOptionsCardInstallmentsPlan'Interval'Other Data.Aeson.Types.Internal.Value
  | -- | This constructor can be used to send values to the server which are not present in the specification yet.
    PaymentMethodOptionsCardInstallmentsPlan'Interval'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"month"@
    PaymentMethodOptionsCardInstallmentsPlan'Interval'EnumMonth
  deriving (Int -> PaymentMethodOptionsCardInstallmentsPlan'Interval' -> ShowS
[PaymentMethodOptionsCardInstallmentsPlan'Interval'] -> ShowS
PaymentMethodOptionsCardInstallmentsPlan'Interval' -> String
(Int
 -> PaymentMethodOptionsCardInstallmentsPlan'Interval' -> ShowS)
-> (PaymentMethodOptionsCardInstallmentsPlan'Interval' -> String)
-> ([PaymentMethodOptionsCardInstallmentsPlan'Interval'] -> ShowS)
-> Show PaymentMethodOptionsCardInstallmentsPlan'Interval'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodOptionsCardInstallmentsPlan'Interval'] -> ShowS
$cshowList :: [PaymentMethodOptionsCardInstallmentsPlan'Interval'] -> ShowS
show :: PaymentMethodOptionsCardInstallmentsPlan'Interval' -> String
$cshow :: PaymentMethodOptionsCardInstallmentsPlan'Interval' -> String
showsPrec :: Int -> PaymentMethodOptionsCardInstallmentsPlan'Interval' -> ShowS
$cshowsPrec :: Int -> PaymentMethodOptionsCardInstallmentsPlan'Interval' -> ShowS
GHC.Show.Show, PaymentMethodOptionsCardInstallmentsPlan'Interval'
-> PaymentMethodOptionsCardInstallmentsPlan'Interval' -> Bool
(PaymentMethodOptionsCardInstallmentsPlan'Interval'
 -> PaymentMethodOptionsCardInstallmentsPlan'Interval' -> Bool)
-> (PaymentMethodOptionsCardInstallmentsPlan'Interval'
    -> PaymentMethodOptionsCardInstallmentsPlan'Interval' -> Bool)
-> Eq PaymentMethodOptionsCardInstallmentsPlan'Interval'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodOptionsCardInstallmentsPlan'Interval'
-> PaymentMethodOptionsCardInstallmentsPlan'Interval' -> Bool
$c/= :: PaymentMethodOptionsCardInstallmentsPlan'Interval'
-> PaymentMethodOptionsCardInstallmentsPlan'Interval' -> Bool
== :: PaymentMethodOptionsCardInstallmentsPlan'Interval'
-> PaymentMethodOptionsCardInstallmentsPlan'Interval' -> Bool
$c== :: PaymentMethodOptionsCardInstallmentsPlan'Interval'
-> PaymentMethodOptionsCardInstallmentsPlan'Interval' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodOptionsCardInstallmentsPlan'Interval' where
  toJSON :: PaymentMethodOptionsCardInstallmentsPlan'Interval' -> Value
toJSON (PaymentMethodOptionsCardInstallmentsPlan'Interval'Other Value
val) = Value
val
  toJSON (PaymentMethodOptionsCardInstallmentsPlan'Interval'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PaymentMethodOptionsCardInstallmentsPlan'Interval'
PaymentMethodOptionsCardInstallmentsPlan'Interval'EnumMonth) = Value
"month"

instance Data.Aeson.Types.FromJSON.FromJSON PaymentMethodOptionsCardInstallmentsPlan'Interval' where
  parseJSON :: Value -> Parser PaymentMethodOptionsCardInstallmentsPlan'Interval'
parseJSON Value
val =
    PaymentMethodOptionsCardInstallmentsPlan'Interval'
-> Parser PaymentMethodOptionsCardInstallmentsPlan'Interval'
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure
      ( if
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"month" -> PaymentMethodOptionsCardInstallmentsPlan'Interval'
PaymentMethodOptionsCardInstallmentsPlan'Interval'EnumMonth
            | Bool
GHC.Base.otherwise -> Value -> PaymentMethodOptionsCardInstallmentsPlan'Interval'
PaymentMethodOptionsCardInstallmentsPlan'Interval'Other Value
val
      )

-- | Defines the enum schema located at @components.schemas.payment_method_options_card_installments.properties.plan.anyOf.properties.type@ in the specification.
--
-- Type of installment plan, one of \`fixed_count\`.
data PaymentMethodOptionsCardInstallmentsPlan'Type'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PaymentMethodOptionsCardInstallmentsPlan'Type'Other Data.Aeson.Types.Internal.Value
  | -- | This constructor can be used to send values to the server which are not present in the specification yet.
    PaymentMethodOptionsCardInstallmentsPlan'Type'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"fixed_count"@
    PaymentMethodOptionsCardInstallmentsPlan'Type'EnumFixedCount
  deriving (Int -> PaymentMethodOptionsCardInstallmentsPlan'Type' -> ShowS
[PaymentMethodOptionsCardInstallmentsPlan'Type'] -> ShowS
PaymentMethodOptionsCardInstallmentsPlan'Type' -> String
(Int -> PaymentMethodOptionsCardInstallmentsPlan'Type' -> ShowS)
-> (PaymentMethodOptionsCardInstallmentsPlan'Type' -> String)
-> ([PaymentMethodOptionsCardInstallmentsPlan'Type'] -> ShowS)
-> Show PaymentMethodOptionsCardInstallmentsPlan'Type'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentMethodOptionsCardInstallmentsPlan'Type'] -> ShowS
$cshowList :: [PaymentMethodOptionsCardInstallmentsPlan'Type'] -> ShowS
show :: PaymentMethodOptionsCardInstallmentsPlan'Type' -> String
$cshow :: PaymentMethodOptionsCardInstallmentsPlan'Type' -> String
showsPrec :: Int -> PaymentMethodOptionsCardInstallmentsPlan'Type' -> ShowS
$cshowsPrec :: Int -> PaymentMethodOptionsCardInstallmentsPlan'Type' -> ShowS
GHC.Show.Show, PaymentMethodOptionsCardInstallmentsPlan'Type'
-> PaymentMethodOptionsCardInstallmentsPlan'Type' -> Bool
(PaymentMethodOptionsCardInstallmentsPlan'Type'
 -> PaymentMethodOptionsCardInstallmentsPlan'Type' -> Bool)
-> (PaymentMethodOptionsCardInstallmentsPlan'Type'
    -> PaymentMethodOptionsCardInstallmentsPlan'Type' -> Bool)
-> Eq PaymentMethodOptionsCardInstallmentsPlan'Type'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentMethodOptionsCardInstallmentsPlan'Type'
-> PaymentMethodOptionsCardInstallmentsPlan'Type' -> Bool
$c/= :: PaymentMethodOptionsCardInstallmentsPlan'Type'
-> PaymentMethodOptionsCardInstallmentsPlan'Type' -> Bool
== :: PaymentMethodOptionsCardInstallmentsPlan'Type'
-> PaymentMethodOptionsCardInstallmentsPlan'Type' -> Bool
$c== :: PaymentMethodOptionsCardInstallmentsPlan'Type'
-> PaymentMethodOptionsCardInstallmentsPlan'Type' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PaymentMethodOptionsCardInstallmentsPlan'Type' where
  toJSON :: PaymentMethodOptionsCardInstallmentsPlan'Type' -> Value
toJSON (PaymentMethodOptionsCardInstallmentsPlan'Type'Other Value
val) = Value
val
  toJSON (PaymentMethodOptionsCardInstallmentsPlan'Type'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PaymentMethodOptionsCardInstallmentsPlan'Type'
PaymentMethodOptionsCardInstallmentsPlan'Type'EnumFixedCount) = Value
"fixed_count"

instance Data.Aeson.Types.FromJSON.FromJSON PaymentMethodOptionsCardInstallmentsPlan'Type' where
  parseJSON :: Value -> Parser PaymentMethodOptionsCardInstallmentsPlan'Type'
parseJSON Value
val =
    PaymentMethodOptionsCardInstallmentsPlan'Type'
-> Parser PaymentMethodOptionsCardInstallmentsPlan'Type'
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure
      ( if
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"fixed_count" -> PaymentMethodOptionsCardInstallmentsPlan'Type'
PaymentMethodOptionsCardInstallmentsPlan'Type'EnumFixedCount
            | Bool
GHC.Base.otherwise -> Value -> PaymentMethodOptionsCardInstallmentsPlan'Type'
PaymentMethodOptionsCardInstallmentsPlan'Type'Other Value
val
      )