{-# 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 SubscriptionAddOnCreate
module RecurlyClient.Types.SubscriptionAddOnCreate 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
import qualified Data.ByteString as Data.ByteString.Internal
import qualified Data.Foldable
import qualified Data.Functor
import qualified Data.Maybe
import qualified Data.Scientific
import qualified Data.Text
import qualified Data.Text as 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 RecurlyClient.Common
import RecurlyClient.TypeAlias
import {-# SOURCE #-} RecurlyClient.Types.SubscriptionAddOnPercentageTier
import {-# SOURCE #-} RecurlyClient.Types.SubscriptionAddOnTier
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.SubscriptionAddOnCreate@ in the specification.
data SubscriptionAddOnCreate = SubscriptionAddOnCreate
    { SubscriptionAddOnCreate
-> Maybe SubscriptionAddOnCreateAdd_on_source
subscriptionAddOnCreateAdd_on_source :: (GHC.Maybe.Maybe SubscriptionAddOnCreateAdd_on_source)
    -- ^ add_on_source: Used to determine where the associated add-on data is pulled from. If this value is set to
    -- \`plan_add_on\` or left blank, then add-on data will be pulled from the plan\'s add-ons. If the associated
    -- \`plan\` has \`allow_any_item_on_subscriptions\` set to \`true\` and this field is set to \`item\`, then
    -- the associated add-on data will be pulled from the site\'s item catalog.
    , SubscriptionAddOnCreate -> Text
subscriptionAddOnCreateCode :: Data.Text.Internal.Text
    -- ^ code: If \`add_on_source\` is set to \`plan_add_on\` or left blank, then plan\'s add-on \`code\` should be used.
    -- If \`add_on_source\` is set to \`item\`, then the \`code\` from the associated item should be used.
    --
    --
    -- Constraints:
    --
    -- * Maximum length of 50
    , SubscriptionAddOnCreate
-> Maybe (NonEmpty SubscriptionAddOnPercentageTier)
subscriptionAddOnCreatePercentage_tiers :: (GHC.Maybe.Maybe (GHC.Base.NonEmpty SubscriptionAddOnPercentageTier))
    -- ^ percentage_tiers: If percentage tiers are provided in the request, all existing percentage tiers on the Subscription Add-on will be
    -- removed and replaced by the percentage tiers in the request. There must be one tier without ending_amount value
    -- which represents the final tier. Use only if add_on.tier_type is tiered or volume and add_on.usage_type is
    -- percentage. This feature is currently in development and requires approval and enablement, please contact support.
    --
    --
    -- Constraints:
    --
    -- * Must have a minimum of 1 items
    , SubscriptionAddOnCreate -> Maybe Int
subscriptionAddOnCreateQuantity :: (GHC.Maybe.Maybe GHC.Types.Int)
    -- ^ quantity
    --
    -- Constraints:
    --
    -- * Minimum  of 0.0
    , SubscriptionAddOnCreate
-> Maybe SubscriptionAddOnCreateRevenue_schedule_type
subscriptionAddOnCreateRevenue_schedule_type :: (GHC.Maybe.Maybe SubscriptionAddOnCreateRevenue_schedule_type)
    -- ^ revenue_schedule_type
    , SubscriptionAddOnCreate -> Maybe (NonEmpty SubscriptionAddOnTier)
subscriptionAddOnCreateTiers :: (GHC.Maybe.Maybe (GHC.Base.NonEmpty SubscriptionAddOnTier))
    -- ^ tiers: If the plan add-on\'s \`tier_type\` is \`flat\`, then \`tiers\` must be absent. The \`tiers\` object
    -- must include one to many tiers with \`ending_quantity\` and \`unit_amount\`.
    -- There must be one tier without an \`ending_quantity\` value which represents the final tier.
    -- See our [Guide](https:\/\/recurly.com\/developers\/guides\/item-addon-guide.html)
    -- for an overview of how to configure quantity-based pricing models.
    --
    --
    -- Constraints:
    --
    -- * Must have a minimum of 1 items
    , SubscriptionAddOnCreate -> Maybe Float
subscriptionAddOnCreateUnit_amount :: (GHC.Maybe.Maybe GHC.Types.Float)
    -- ^ unit_amount: Allows up to 2 decimal places. Optionally, override the add-on\'s default unit amount.
    -- If the plan add-on\'s \`tier_type\` is \`tiered\`, \`volume\`, or \`stairstep\`, then \`unit_amount\` cannot be provided.
    --
    --
    -- Constraints:
    --
    -- * Maxium  of 1000000.0
    -- * Minimum  of 0.0
    , SubscriptionAddOnCreate -> Maybe Text
subscriptionAddOnCreateUnit_amount_decimal :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ unit_amount_decimal: Allows up to 9 decimal places.  Optionally, override the add-on\'s default unit amount.
    -- If the plan add-on\'s \`tier_type\` is \`tiered\`, \`volume\`, or \`stairstep\`, then \`unit_amount_decimal\` cannot be provided.
    -- Only supported when the plan add-on\'s \`add_on_type\` = \`usage\`.
    -- If \`unit_amount_decimal\` is provided, \`unit_amount\` cannot be provided.
    --
    --
    -- Constraints:
    --
    -- * Maxium  of 1000000.0
    -- * Minimum  of 0.0
    , SubscriptionAddOnCreate -> Maybe Float
subscriptionAddOnCreateUsage_percentage :: (GHC.Maybe.Maybe GHC.Types.Float)
    -- ^ usage_percentage: The percentage taken of the monetary amount of usage tracked. This can be up to 4 decimal places. A value between 0.0 and 100.0. Required if \`add_on_type\` is usage and \`usage_type\` is percentage. Must be omitted otherwise. \`usage_percentage\` does not support tiers. See our [Guide](https:\/\/recurly.com\/developers\/guides\/usage-based-billing-guide.html) for an overview of how to configure usage add-ons.
    --
    -- Constraints:
    --
    -- * Maxium  of 100.0
    -- * Minimum  of 0.0
    }
    deriving
        ( Int -> SubscriptionAddOnCreate -> ShowS
[SubscriptionAddOnCreate] -> ShowS
SubscriptionAddOnCreate -> String
(Int -> SubscriptionAddOnCreate -> ShowS)
-> (SubscriptionAddOnCreate -> String)
-> ([SubscriptionAddOnCreate] -> ShowS)
-> Show SubscriptionAddOnCreate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SubscriptionAddOnCreate -> ShowS
showsPrec :: Int -> SubscriptionAddOnCreate -> ShowS
$cshow :: SubscriptionAddOnCreate -> String
show :: SubscriptionAddOnCreate -> String
$cshowList :: [SubscriptionAddOnCreate] -> ShowS
showList :: [SubscriptionAddOnCreate] -> ShowS
GHC.Show.Show
        , SubscriptionAddOnCreate -> SubscriptionAddOnCreate -> Bool
(SubscriptionAddOnCreate -> SubscriptionAddOnCreate -> Bool)
-> (SubscriptionAddOnCreate -> SubscriptionAddOnCreate -> Bool)
-> Eq SubscriptionAddOnCreate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SubscriptionAddOnCreate -> SubscriptionAddOnCreate -> Bool
== :: SubscriptionAddOnCreate -> SubscriptionAddOnCreate -> Bool
$c/= :: SubscriptionAddOnCreate -> SubscriptionAddOnCreate -> Bool
/= :: SubscriptionAddOnCreate -> SubscriptionAddOnCreate -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON SubscriptionAddOnCreate where
    toJSON :: SubscriptionAddOnCreate -> Value
toJSON SubscriptionAddOnCreate
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Pair]
-> (SubscriptionAddOnCreateAdd_on_source -> [Pair])
-> Maybe SubscriptionAddOnCreateAdd_on_source
-> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (SubscriptionAddOnCreateAdd_on_source -> Pair)
-> SubscriptionAddOnCreateAdd_on_source
-> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"add_on_source" Key -> SubscriptionAddOnCreateAdd_on_source -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate
-> Maybe SubscriptionAddOnCreateAdd_on_source
subscriptionAddOnCreateAdd_on_source SubscriptionAddOnCreate
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Key
"code" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..= SubscriptionAddOnCreate -> Text
subscriptionAddOnCreateCode SubscriptionAddOnCreate
obj] [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (NonEmpty SubscriptionAddOnPercentageTier -> [Pair])
-> Maybe (NonEmpty SubscriptionAddOnPercentageTier)
-> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (NonEmpty SubscriptionAddOnPercentageTier -> Pair)
-> NonEmpty SubscriptionAddOnPercentageTier
-> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"percentage_tiers" Key -> NonEmpty SubscriptionAddOnPercentageTier -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate
-> Maybe (NonEmpty SubscriptionAddOnPercentageTier)
subscriptionAddOnCreatePercentage_tiers SubscriptionAddOnCreate
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Int -> [Pair]) -> Maybe Int -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Int -> Pair) -> Int -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"quantity" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate -> Maybe Int
subscriptionAddOnCreateQuantity SubscriptionAddOnCreate
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (SubscriptionAddOnCreateRevenue_schedule_type -> [Pair])
-> Maybe SubscriptionAddOnCreateRevenue_schedule_type
-> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (SubscriptionAddOnCreateRevenue_schedule_type -> Pair)
-> SubscriptionAddOnCreateRevenue_schedule_type
-> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"revenue_schedule_type" Key -> SubscriptionAddOnCreateRevenue_schedule_type -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate
-> Maybe SubscriptionAddOnCreateRevenue_schedule_type
subscriptionAddOnCreateRevenue_schedule_type SubscriptionAddOnCreate
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (NonEmpty SubscriptionAddOnTier -> [Pair])
-> Maybe (NonEmpty SubscriptionAddOnTier)
-> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (NonEmpty SubscriptionAddOnTier -> Pair)
-> NonEmpty SubscriptionAddOnTier
-> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"tiers" Key -> NonEmpty SubscriptionAddOnTier -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate -> Maybe (NonEmpty SubscriptionAddOnTier)
subscriptionAddOnCreateTiers SubscriptionAddOnCreate
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Float -> [Pair]) -> Maybe Float -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Float -> Pair) -> Float -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"unit_amount" Key -> Float -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate -> Maybe Float
subscriptionAddOnCreateUnit_amount SubscriptionAddOnCreate
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"unit_amount_decimal" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate -> Maybe Text
subscriptionAddOnCreateUnit_amount_decimal SubscriptionAddOnCreate
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Float -> [Pair]) -> Maybe Float -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Float -> Pair) -> Float -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"usage_percentage" Key -> Float -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate -> Maybe Float
subscriptionAddOnCreateUsage_percentage SubscriptionAddOnCreate
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: SubscriptionAddOnCreate -> Encoding
toEncoding SubscriptionAddOnCreate
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ([Series] -> Series
forall a. Monoid a => [a] -> a
GHC.Base.mconcat ([[Series]] -> [Series]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Series]
-> (SubscriptionAddOnCreateAdd_on_source -> [Series])
-> Maybe SubscriptionAddOnCreateAdd_on_source
-> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (SubscriptionAddOnCreateAdd_on_source -> Series)
-> SubscriptionAddOnCreateAdd_on_source
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"add_on_source" Key -> SubscriptionAddOnCreateAdd_on_source -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate
-> Maybe SubscriptionAddOnCreateAdd_on_source
subscriptionAddOnCreateAdd_on_source SubscriptionAddOnCreate
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Key
"code" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..= SubscriptionAddOnCreate -> Text
subscriptionAddOnCreateCode SubscriptionAddOnCreate
obj] [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (NonEmpty SubscriptionAddOnPercentageTier -> [Series])
-> Maybe (NonEmpty SubscriptionAddOnPercentageTier)
-> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (NonEmpty SubscriptionAddOnPercentageTier -> Series)
-> NonEmpty SubscriptionAddOnPercentageTier
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"percentage_tiers" Key -> NonEmpty SubscriptionAddOnPercentageTier -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate
-> Maybe (NonEmpty SubscriptionAddOnPercentageTier)
subscriptionAddOnCreatePercentage_tiers SubscriptionAddOnCreate
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Int -> [Series]) -> Maybe Int -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Int -> Series) -> Int -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"quantity" Key -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate -> Maybe Int
subscriptionAddOnCreateQuantity SubscriptionAddOnCreate
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (SubscriptionAddOnCreateRevenue_schedule_type -> [Series])
-> Maybe SubscriptionAddOnCreateRevenue_schedule_type
-> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (SubscriptionAddOnCreateRevenue_schedule_type -> Series)
-> SubscriptionAddOnCreateRevenue_schedule_type
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"revenue_schedule_type" Key -> SubscriptionAddOnCreateRevenue_schedule_type -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate
-> Maybe SubscriptionAddOnCreateRevenue_schedule_type
subscriptionAddOnCreateRevenue_schedule_type SubscriptionAddOnCreate
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (NonEmpty SubscriptionAddOnTier -> [Series])
-> Maybe (NonEmpty SubscriptionAddOnTier)
-> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (NonEmpty SubscriptionAddOnTier -> Series)
-> NonEmpty SubscriptionAddOnTier
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"tiers" Key -> NonEmpty SubscriptionAddOnTier -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate -> Maybe (NonEmpty SubscriptionAddOnTier)
subscriptionAddOnCreateTiers SubscriptionAddOnCreate
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Float -> [Series]) -> Maybe Float -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Float -> Series) -> Float -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"unit_amount" Key -> Float -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate -> Maybe Float
subscriptionAddOnCreateUnit_amount SubscriptionAddOnCreate
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"unit_amount_decimal" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate -> Maybe Text
subscriptionAddOnCreateUnit_amount_decimal SubscriptionAddOnCreate
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Float -> [Series]) -> Maybe Float -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Float -> Series) -> Float -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"usage_percentage" Key -> Float -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (SubscriptionAddOnCreate -> Maybe Float
subscriptionAddOnCreateUsage_percentage SubscriptionAddOnCreate
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON SubscriptionAddOnCreate where
    parseJSON :: Value -> Parser SubscriptionAddOnCreate
parseJSON = String
-> (Object -> Parser SubscriptionAddOnCreate)
-> Value
-> Parser SubscriptionAddOnCreate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SubscriptionAddOnCreate" (\Object
obj -> (((((((((Maybe SubscriptionAddOnCreateAdd_on_source
 -> Text
 -> Maybe (NonEmpty SubscriptionAddOnPercentageTier)
 -> Maybe Int
 -> Maybe SubscriptionAddOnCreateRevenue_schedule_type
 -> Maybe (NonEmpty SubscriptionAddOnTier)
 -> Maybe Float
 -> Maybe Text
 -> Maybe Float
 -> SubscriptionAddOnCreate)
-> Parser
     (Maybe SubscriptionAddOnCreateAdd_on_source
      -> Text
      -> Maybe (NonEmpty SubscriptionAddOnPercentageTier)
      -> Maybe Int
      -> Maybe SubscriptionAddOnCreateRevenue_schedule_type
      -> Maybe (NonEmpty SubscriptionAddOnTier)
      -> Maybe Float
      -> Maybe Text
      -> Maybe Float
      -> SubscriptionAddOnCreate)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe SubscriptionAddOnCreateAdd_on_source
-> Text
-> Maybe (NonEmpty SubscriptionAddOnPercentageTier)
-> Maybe Int
-> Maybe SubscriptionAddOnCreateRevenue_schedule_type
-> Maybe (NonEmpty SubscriptionAddOnTier)
-> Maybe Float
-> Maybe Text
-> Maybe Float
-> SubscriptionAddOnCreate
SubscriptionAddOnCreate Parser
  (Maybe SubscriptionAddOnCreateAdd_on_source
   -> Text
   -> Maybe (NonEmpty SubscriptionAddOnPercentageTier)
   -> Maybe Int
   -> Maybe SubscriptionAddOnCreateRevenue_schedule_type
   -> Maybe (NonEmpty SubscriptionAddOnTier)
   -> Maybe Float
   -> Maybe Text
   -> Maybe Float
   -> SubscriptionAddOnCreate)
-> Parser (Maybe SubscriptionAddOnCreateAdd_on_source)
-> Parser
     (Text
      -> Maybe (NonEmpty SubscriptionAddOnPercentageTier)
      -> Maybe Int
      -> Maybe SubscriptionAddOnCreateRevenue_schedule_type
      -> Maybe (NonEmpty SubscriptionAddOnTier)
      -> Maybe Float
      -> Maybe Text
      -> Maybe Float
      -> SubscriptionAddOnCreate)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Key -> Parser (Maybe SubscriptionAddOnCreateAdd_on_source)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"add_on_source")) Parser
  (Text
   -> Maybe (NonEmpty SubscriptionAddOnPercentageTier)
   -> Maybe Int
   -> Maybe SubscriptionAddOnCreateRevenue_schedule_type
   -> Maybe (NonEmpty SubscriptionAddOnTier)
   -> Maybe Float
   -> Maybe Text
   -> Maybe Float
   -> SubscriptionAddOnCreate)
-> Parser Text
-> Parser
     (Maybe (NonEmpty SubscriptionAddOnPercentageTier)
      -> Maybe Int
      -> Maybe SubscriptionAddOnCreateRevenue_schedule_type
      -> Maybe (NonEmpty SubscriptionAddOnTier)
      -> Maybe Float
      -> Maybe Text
      -> Maybe Float
      -> SubscriptionAddOnCreate)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
Data.Aeson.Types.FromJSON..: Key
"code")) Parser
  (Maybe (NonEmpty SubscriptionAddOnPercentageTier)
   -> Maybe Int
   -> Maybe SubscriptionAddOnCreateRevenue_schedule_type
   -> Maybe (NonEmpty SubscriptionAddOnTier)
   -> Maybe Float
   -> Maybe Text
   -> Maybe Float
   -> SubscriptionAddOnCreate)
-> Parser (Maybe (NonEmpty SubscriptionAddOnPercentageTier))
-> Parser
     (Maybe Int
      -> Maybe SubscriptionAddOnCreateRevenue_schedule_type
      -> Maybe (NonEmpty SubscriptionAddOnTier)
      -> Maybe Float
      -> Maybe Text
      -> Maybe Float
      -> SubscriptionAddOnCreate)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Key -> Parser (Maybe (NonEmpty SubscriptionAddOnPercentageTier))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"percentage_tiers")) Parser
  (Maybe Int
   -> Maybe SubscriptionAddOnCreateRevenue_schedule_type
   -> Maybe (NonEmpty SubscriptionAddOnTier)
   -> Maybe Float
   -> Maybe Text
   -> Maybe Float
   -> SubscriptionAddOnCreate)
-> Parser (Maybe Int)
-> Parser
     (Maybe SubscriptionAddOnCreateRevenue_schedule_type
      -> Maybe (NonEmpty SubscriptionAddOnTier)
      -> Maybe Float
      -> Maybe Text
      -> Maybe Float
      -> SubscriptionAddOnCreate)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"quantity")) Parser
  (Maybe SubscriptionAddOnCreateRevenue_schedule_type
   -> Maybe (NonEmpty SubscriptionAddOnTier)
   -> Maybe Float
   -> Maybe Text
   -> Maybe Float
   -> SubscriptionAddOnCreate)
-> Parser (Maybe SubscriptionAddOnCreateRevenue_schedule_type)
-> Parser
     (Maybe (NonEmpty SubscriptionAddOnTier)
      -> Maybe Float
      -> Maybe Text
      -> Maybe Float
      -> SubscriptionAddOnCreate)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Key
-> Parser (Maybe SubscriptionAddOnCreateRevenue_schedule_type)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"revenue_schedule_type")) Parser
  (Maybe (NonEmpty SubscriptionAddOnTier)
   -> Maybe Float
   -> Maybe Text
   -> Maybe Float
   -> SubscriptionAddOnCreate)
-> Parser (Maybe (NonEmpty SubscriptionAddOnTier))
-> Parser
     (Maybe Float
      -> Maybe Text -> Maybe Float -> SubscriptionAddOnCreate)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe (NonEmpty SubscriptionAddOnTier))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"tiers")) Parser
  (Maybe Float
   -> Maybe Text -> Maybe Float -> SubscriptionAddOnCreate)
-> Parser (Maybe Float)
-> Parser (Maybe Text -> Maybe Float -> SubscriptionAddOnCreate)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Float)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"unit_amount")) Parser (Maybe Text -> Maybe Float -> SubscriptionAddOnCreate)
-> Parser (Maybe Text)
-> Parser (Maybe Float -> SubscriptionAddOnCreate)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"unit_amount_decimal")) Parser (Maybe Float -> SubscriptionAddOnCreate)
-> Parser (Maybe Float) -> Parser SubscriptionAddOnCreate
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Float)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"usage_percentage"))

-- | Create a new 'SubscriptionAddOnCreate' with all required fields.
mkSubscriptionAddOnCreate ::
    -- | 'subscriptionAddOnCreateCode'
    Data.Text.Internal.Text ->
    SubscriptionAddOnCreate
mkSubscriptionAddOnCreate :: Text -> SubscriptionAddOnCreate
mkSubscriptionAddOnCreate Text
subscriptionAddOnCreateCode =
    SubscriptionAddOnCreate
        { subscriptionAddOnCreateAdd_on_source :: Maybe SubscriptionAddOnCreateAdd_on_source
subscriptionAddOnCreateAdd_on_source = Maybe SubscriptionAddOnCreateAdd_on_source
forall a. Maybe a
GHC.Maybe.Nothing
        , subscriptionAddOnCreateCode :: Text
subscriptionAddOnCreateCode = Text
subscriptionAddOnCreateCode
        , subscriptionAddOnCreatePercentage_tiers :: Maybe (NonEmpty SubscriptionAddOnPercentageTier)
subscriptionAddOnCreatePercentage_tiers = Maybe (NonEmpty SubscriptionAddOnPercentageTier)
forall a. Maybe a
GHC.Maybe.Nothing
        , subscriptionAddOnCreateQuantity :: Maybe Int
subscriptionAddOnCreateQuantity = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing
        , subscriptionAddOnCreateRevenue_schedule_type :: Maybe SubscriptionAddOnCreateRevenue_schedule_type
subscriptionAddOnCreateRevenue_schedule_type = Maybe SubscriptionAddOnCreateRevenue_schedule_type
forall a. Maybe a
GHC.Maybe.Nothing
        , subscriptionAddOnCreateTiers :: Maybe (NonEmpty SubscriptionAddOnTier)
subscriptionAddOnCreateTiers = Maybe (NonEmpty SubscriptionAddOnTier)
forall a. Maybe a
GHC.Maybe.Nothing
        , subscriptionAddOnCreateUnit_amount :: Maybe Float
subscriptionAddOnCreateUnit_amount = Maybe Float
forall a. Maybe a
GHC.Maybe.Nothing
        , subscriptionAddOnCreateUnit_amount_decimal :: Maybe Text
subscriptionAddOnCreateUnit_amount_decimal = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , subscriptionAddOnCreateUsage_percentage :: Maybe Float
subscriptionAddOnCreateUsage_percentage = Maybe Float
forall a. Maybe a
GHC.Maybe.Nothing
        }

{- | Defines the enum schema located at @components.schemas.SubscriptionAddOnCreate.properties.add_on_source@ in the specification.

Used to determine where the associated add-on data is pulled from. If this value is set to
\`plan_add_on\` or left blank, then add-on data will be pulled from the plan\'s add-ons. If the associated
\`plan\` has \`allow_any_item_on_subscriptions\` set to \`true\` and this field is set to \`item\`, then
the associated add-on data will be pulled from the site\'s item catalog.
-}
data SubscriptionAddOnCreateAdd_on_source
    = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
      SubscriptionAddOnCreateAdd_on_sourceOther Data.Aeson.Types.Internal.Value
    | -- | This constructor can be used to send values to the server which are not present in the specification yet.
      SubscriptionAddOnCreateAdd_on_sourceTyped Data.Text.Internal.Text
    | -- | Represents the JSON value @"plan_add_on"@
      SubscriptionAddOnCreateAdd_on_sourceEnumPlan_add_on
    | -- | Represents the JSON value @"item"@
      SubscriptionAddOnCreateAdd_on_sourceEnumItem
    deriving (Int -> SubscriptionAddOnCreateAdd_on_source -> ShowS
[SubscriptionAddOnCreateAdd_on_source] -> ShowS
SubscriptionAddOnCreateAdd_on_source -> String
(Int -> SubscriptionAddOnCreateAdd_on_source -> ShowS)
-> (SubscriptionAddOnCreateAdd_on_source -> String)
-> ([SubscriptionAddOnCreateAdd_on_source] -> ShowS)
-> Show SubscriptionAddOnCreateAdd_on_source
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SubscriptionAddOnCreateAdd_on_source -> ShowS
showsPrec :: Int -> SubscriptionAddOnCreateAdd_on_source -> ShowS
$cshow :: SubscriptionAddOnCreateAdd_on_source -> String
show :: SubscriptionAddOnCreateAdd_on_source -> String
$cshowList :: [SubscriptionAddOnCreateAdd_on_source] -> ShowS
showList :: [SubscriptionAddOnCreateAdd_on_source] -> ShowS
GHC.Show.Show, SubscriptionAddOnCreateAdd_on_source
-> SubscriptionAddOnCreateAdd_on_source -> Bool
(SubscriptionAddOnCreateAdd_on_source
 -> SubscriptionAddOnCreateAdd_on_source -> Bool)
-> (SubscriptionAddOnCreateAdd_on_source
    -> SubscriptionAddOnCreateAdd_on_source -> Bool)
-> Eq SubscriptionAddOnCreateAdd_on_source
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SubscriptionAddOnCreateAdd_on_source
-> SubscriptionAddOnCreateAdd_on_source -> Bool
== :: SubscriptionAddOnCreateAdd_on_source
-> SubscriptionAddOnCreateAdd_on_source -> Bool
$c/= :: SubscriptionAddOnCreateAdd_on_source
-> SubscriptionAddOnCreateAdd_on_source -> Bool
/= :: SubscriptionAddOnCreateAdd_on_source
-> SubscriptionAddOnCreateAdd_on_source -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON SubscriptionAddOnCreateAdd_on_source where
    toJSON :: SubscriptionAddOnCreateAdd_on_source -> Value
toJSON (SubscriptionAddOnCreateAdd_on_sourceOther Value
val) = Value
val
    toJSON (SubscriptionAddOnCreateAdd_on_sourceTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
    toJSON (SubscriptionAddOnCreateAdd_on_source
SubscriptionAddOnCreateAdd_on_sourceEnumPlan_add_on) = Value
"plan_add_on"
    toJSON (SubscriptionAddOnCreateAdd_on_source
SubscriptionAddOnCreateAdd_on_sourceEnumItem) = Value
"item"
instance Data.Aeson.Types.FromJSON.FromJSON SubscriptionAddOnCreateAdd_on_source where
    parseJSON :: Value -> Parser SubscriptionAddOnCreateAdd_on_source
parseJSON Value
val =
        SubscriptionAddOnCreateAdd_on_source
-> Parser SubscriptionAddOnCreateAdd_on_source
forall a. a -> Parser a
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
"plan_add_on" -> SubscriptionAddOnCreateAdd_on_source
SubscriptionAddOnCreateAdd_on_sourceEnumPlan_add_on
                | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"item" -> SubscriptionAddOnCreateAdd_on_source
SubscriptionAddOnCreateAdd_on_sourceEnumItem
                | Bool
GHC.Base.otherwise -> Value -> SubscriptionAddOnCreateAdd_on_source
SubscriptionAddOnCreateAdd_on_sourceOther Value
val
            )

-- | Defines the enum schema located at @components.schemas.SubscriptionAddOnCreate.properties.revenue_schedule_type@ in the specification.
data SubscriptionAddOnCreateRevenue_schedule_type
    = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
      SubscriptionAddOnCreateRevenue_schedule_typeOther Data.Aeson.Types.Internal.Value
    | -- | This constructor can be used to send values to the server which are not present in the specification yet.
      SubscriptionAddOnCreateRevenue_schedule_typeTyped Data.Text.Internal.Text
    | -- | Represents the JSON value @"at_range_end"@
      SubscriptionAddOnCreateRevenue_schedule_typeEnumAt_range_end
    | -- | Represents the JSON value @"at_range_start"@
      SubscriptionAddOnCreateRevenue_schedule_typeEnumAt_range_start
    | -- | Represents the JSON value @"evenly"@
      SubscriptionAddOnCreateRevenue_schedule_typeEnumEvenly
    | -- | Represents the JSON value @"never"@
      SubscriptionAddOnCreateRevenue_schedule_typeEnumNever
    deriving (Int -> SubscriptionAddOnCreateRevenue_schedule_type -> ShowS
[SubscriptionAddOnCreateRevenue_schedule_type] -> ShowS
SubscriptionAddOnCreateRevenue_schedule_type -> String
(Int -> SubscriptionAddOnCreateRevenue_schedule_type -> ShowS)
-> (SubscriptionAddOnCreateRevenue_schedule_type -> String)
-> ([SubscriptionAddOnCreateRevenue_schedule_type] -> ShowS)
-> Show SubscriptionAddOnCreateRevenue_schedule_type
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SubscriptionAddOnCreateRevenue_schedule_type -> ShowS
showsPrec :: Int -> SubscriptionAddOnCreateRevenue_schedule_type -> ShowS
$cshow :: SubscriptionAddOnCreateRevenue_schedule_type -> String
show :: SubscriptionAddOnCreateRevenue_schedule_type -> String
$cshowList :: [SubscriptionAddOnCreateRevenue_schedule_type] -> ShowS
showList :: [SubscriptionAddOnCreateRevenue_schedule_type] -> ShowS
GHC.Show.Show, SubscriptionAddOnCreateRevenue_schedule_type
-> SubscriptionAddOnCreateRevenue_schedule_type -> Bool
(SubscriptionAddOnCreateRevenue_schedule_type
 -> SubscriptionAddOnCreateRevenue_schedule_type -> Bool)
-> (SubscriptionAddOnCreateRevenue_schedule_type
    -> SubscriptionAddOnCreateRevenue_schedule_type -> Bool)
-> Eq SubscriptionAddOnCreateRevenue_schedule_type
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SubscriptionAddOnCreateRevenue_schedule_type
-> SubscriptionAddOnCreateRevenue_schedule_type -> Bool
== :: SubscriptionAddOnCreateRevenue_schedule_type
-> SubscriptionAddOnCreateRevenue_schedule_type -> Bool
$c/= :: SubscriptionAddOnCreateRevenue_schedule_type
-> SubscriptionAddOnCreateRevenue_schedule_type -> Bool
/= :: SubscriptionAddOnCreateRevenue_schedule_type
-> SubscriptionAddOnCreateRevenue_schedule_type -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON SubscriptionAddOnCreateRevenue_schedule_type where
    toJSON :: SubscriptionAddOnCreateRevenue_schedule_type -> Value
toJSON (SubscriptionAddOnCreateRevenue_schedule_typeOther Value
val) = Value
val
    toJSON (SubscriptionAddOnCreateRevenue_schedule_typeTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
    toJSON (SubscriptionAddOnCreateRevenue_schedule_type
SubscriptionAddOnCreateRevenue_schedule_typeEnumAt_range_end) = Value
"at_range_end"
    toJSON (SubscriptionAddOnCreateRevenue_schedule_type
SubscriptionAddOnCreateRevenue_schedule_typeEnumAt_range_start) = Value
"at_range_start"
    toJSON (SubscriptionAddOnCreateRevenue_schedule_type
SubscriptionAddOnCreateRevenue_schedule_typeEnumEvenly) = Value
"evenly"
    toJSON (SubscriptionAddOnCreateRevenue_schedule_type
SubscriptionAddOnCreateRevenue_schedule_typeEnumNever) = Value
"never"
instance Data.Aeson.Types.FromJSON.FromJSON SubscriptionAddOnCreateRevenue_schedule_type where
    parseJSON :: Value -> Parser SubscriptionAddOnCreateRevenue_schedule_type
parseJSON Value
val =
        SubscriptionAddOnCreateRevenue_schedule_type
-> Parser SubscriptionAddOnCreateRevenue_schedule_type
forall a. a -> Parser a
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
"at_range_end" -> SubscriptionAddOnCreateRevenue_schedule_type
SubscriptionAddOnCreateRevenue_schedule_typeEnumAt_range_end
                | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"at_range_start" -> SubscriptionAddOnCreateRevenue_schedule_type
SubscriptionAddOnCreateRevenue_schedule_typeEnumAt_range_start
                | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"evenly" -> SubscriptionAddOnCreateRevenue_schedule_type
SubscriptionAddOnCreateRevenue_schedule_typeEnumEvenly
                | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"never" -> SubscriptionAddOnCreateRevenue_schedule_type
SubscriptionAddOnCreateRevenue_schedule_typeEnumNever
                | Bool
GHC.Base.otherwise -> Value -> SubscriptionAddOnCreateRevenue_schedule_type
SubscriptionAddOnCreateRevenue_schedule_typeOther Value
val
            )