{-# 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 Price
module StripeAPI.Types.Price 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.DeletedProduct
import {-# SOURCE #-} StripeAPI.Types.PriceTier
import {-# SOURCE #-} StripeAPI.Types.Product
import {-# SOURCE #-} StripeAPI.Types.Recurring
import {-# SOURCE #-} StripeAPI.Types.TransformQuantity
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.price@ in the specification.
--
-- Prices define the unit cost, currency, and (optional) billing cycle for both recurring and one-time purchases of products.
-- [Products](https:\/\/stripe.com\/docs\/api\#products) help you track inventory or provisioning, and prices help you track payment terms. Different physical goods or levels of service should be represented by products, and pricing options should be represented by prices. This approach lets you change prices without having to change your provisioning scheme.
--
-- For example, you might have a single \"gold\" product that has prices for \$10\/month, \$100\/year, and €9 once.
--
-- Related guides: [Set up a subscription](https:\/\/stripe.com\/docs\/billing\/subscriptions\/set-up-subscription), [create an invoice](https:\/\/stripe.com\/docs\/billing\/invoices\/create), and more about [products and prices](https:\/\/stripe.com\/docs\/billing\/prices-guide).
data Price = Price
  { -- | active: Whether the price can be used for new purchases.
    Price -> Bool
priceActive :: GHC.Types.Bool,
    -- | billing_scheme: Describes how to compute the price per period. Either \`per_unit\` or \`tiered\`. \`per_unit\` indicates that the fixed amount (specified in \`unit_amount\` or \`unit_amount_decimal\`) will be charged per unit in \`quantity\` (for prices with \`usage_type=licensed\`), or per unit of total usage (for prices with \`usage_type=metered\`). \`tiered\` indicates that the unit pricing will be computed using a tiering strategy as defined using the \`tiers\` and \`tiers_mode\` attributes.
    Price -> PriceBillingScheme'
priceBillingScheme :: PriceBillingScheme',
    -- | created: Time at which the object was created. Measured in seconds since the Unix epoch.
    Price -> Int
priceCreated :: GHC.Types.Int,
    -- | currency: Three-letter [ISO currency code](https:\/\/www.iso.org\/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https:\/\/stripe.com\/docs\/currencies).
    Price -> Text
priceCurrency :: Data.Text.Internal.Text,
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Price -> Text
priceId :: Data.Text.Internal.Text,
    -- | livemode: Has the value \`true\` if the object exists in live mode or the value \`false\` if the object exists in test mode.
    Price -> Bool
priceLivemode :: GHC.Types.Bool,
    -- | lookup_key: A lookup key used to retrieve prices dynamically from a static string.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Price -> Maybe Text
priceLookupKey :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | metadata: Set of [key-value pairs](https:\/\/stripe.com\/docs\/api\/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
    Price -> Object
priceMetadata :: Data.Aeson.Types.Internal.Object,
    -- | nickname: A brief description of the price, hidden from customers.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Price -> Maybe Text
priceNickname :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | product: The ID of the product this price is associated with.
    Price -> PriceProduct'Variants
priceProduct :: PriceProduct'Variants,
    -- | recurring: The recurring components of a price such as \`interval\` and \`usage_type\`.
    Price -> Maybe PriceRecurring'
priceRecurring :: (GHC.Maybe.Maybe PriceRecurring'),
    -- | tax_behavior: Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of \`inclusive\`, \`exclusive\`, or \`unspecified\`. Once specified as either \`inclusive\` or \`exclusive\`, it cannot be changed.
    Price -> Maybe PriceTaxBehavior'
priceTaxBehavior :: (GHC.Maybe.Maybe PriceTaxBehavior'),
    -- | tiers: Each element represents a pricing tier. This parameter requires \`billing_scheme\` to be set to \`tiered\`. See also the documentation for \`billing_scheme\`.
    Price -> Maybe [PriceTier]
priceTiers :: (GHC.Maybe.Maybe ([PriceTier])),
    -- | tiers_mode: Defines if the tiering price should be \`graduated\` or \`volume\` based. In \`volume\`-based tiering, the maximum quantity within a period determines the per unit price. In \`graduated\` tiering, pricing can change as the quantity grows.
    Price -> Maybe PriceTiersMode'
priceTiersMode :: (GHC.Maybe.Maybe PriceTiersMode'),
    -- | transform_quantity: Apply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined with \`tiers\`.
    Price -> Maybe PriceTransformQuantity'
priceTransformQuantity :: (GHC.Maybe.Maybe PriceTransformQuantity'),
    -- | type: One of \`one_time\` or \`recurring\` depending on whether the price is for a one-time purchase or a recurring (subscription) purchase.
    Price -> PriceType'
priceType :: PriceType',
    -- | unit_amount: The unit amount in %s to be charged, represented as a whole integer if possible. Only set if \`billing_scheme=per_unit\`.
    Price -> Maybe Int
priceUnitAmount :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | unit_amount_decimal: The unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places. Only set if \`billing_scheme=per_unit\`.
    Price -> Maybe Text
priceUnitAmountDecimal :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> Price -> ShowS
[Price] -> ShowS
Price -> String
(Int -> Price -> ShowS)
-> (Price -> String) -> ([Price] -> ShowS) -> Show Price
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Price] -> ShowS
$cshowList :: [Price] -> ShowS
show :: Price -> String
$cshow :: Price -> String
showsPrec :: Int -> Price -> ShowS
$cshowsPrec :: Int -> Price -> ShowS
GHC.Show.Show,
      Price -> Price -> Bool
(Price -> Price -> Bool) -> (Price -> Price -> Bool) -> Eq Price
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Price -> Price -> Bool
$c/= :: Price -> Price -> Bool
== :: Price -> Price -> Bool
$c== :: Price -> Price -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON Price where
  toJSON :: Price -> Value
toJSON Price
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"active" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Bool
priceActive Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"billing_scheme" Text -> PriceBillingScheme' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> PriceBillingScheme'
priceBillingScheme Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"created" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Int
priceCreated Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"currency" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Text
priceCurrency Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Text
priceId Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"livemode" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Bool
priceLivemode Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"lookup_key" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe Text
priceLookupKey Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Object -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Object
priceMetadata Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"nickname" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe Text
priceNickname Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"product" Text -> PriceProduct'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> PriceProduct'Variants
priceProduct Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"recurring" Text -> Maybe PriceRecurring' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe PriceRecurring'
priceRecurring Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"tax_behavior" Text -> Maybe PriceTaxBehavior' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe PriceTaxBehavior'
priceTaxBehavior Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"tiers" Text -> Maybe [PriceTier] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe [PriceTier]
priceTiers Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"tiers_mode" Text -> Maybe PriceTiersMode' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe PriceTiersMode'
priceTiersMode Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"transform_quantity" Text -> Maybe PriceTransformQuantity' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe PriceTransformQuantity'
priceTransformQuantity Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"type" Text -> PriceType' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> PriceType'
priceType Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"unit_amount" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe Int
priceUnitAmount Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"unit_amount_decimal" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe Text
priceUnitAmountDecimal Price
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"object" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"price" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: Price -> Encoding
toEncoding Price
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"active" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Bool
priceActive Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"billing_scheme" Text -> PriceBillingScheme' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> PriceBillingScheme'
priceBillingScheme Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"created" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Int
priceCreated Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"currency" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Text
priceCurrency Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"id" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Text
priceId Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"livemode" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Bool
priceLivemode Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"lookup_key" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe Text
priceLookupKey Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text -> Object -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Object
priceMetadata Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"nickname" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe Text
priceNickname Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"product" Text -> PriceProduct'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> PriceProduct'Variants
priceProduct Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"recurring" Text -> Maybe PriceRecurring' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe PriceRecurring'
priceRecurring Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"tax_behavior" Text -> Maybe PriceTaxBehavior' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe PriceTaxBehavior'
priceTaxBehavior Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"tiers" Text -> Maybe [PriceTier] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe [PriceTier]
priceTiers Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"tiers_mode" Text -> Maybe PriceTiersMode' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe PriceTiersMode'
priceTiersMode Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"transform_quantity" Text -> Maybe PriceTransformQuantity' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe PriceTransformQuantity'
priceTransformQuantity Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"type" Text -> PriceType' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> PriceType'
priceType Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"unit_amount" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe Int
priceUnitAmount Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"unit_amount_decimal" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Price -> Maybe Text
priceUnitAmountDecimal Price
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"object" Text -> Value -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"price")))))))))))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON Price where
  parseJSON :: Value -> Parser Price
parseJSON = String -> (Object -> Parser Price) -> Value -> Parser Price
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Price" (\Object
obj -> ((((((((((((((((((Bool
 -> PriceBillingScheme'
 -> Int
 -> Text
 -> Text
 -> Bool
 -> Maybe Text
 -> Object
 -> Maybe Text
 -> PriceProduct'Variants
 -> Maybe PriceRecurring'
 -> Maybe PriceTaxBehavior'
 -> Maybe [PriceTier]
 -> Maybe PriceTiersMode'
 -> Maybe PriceTransformQuantity'
 -> PriceType'
 -> Maybe Int
 -> Maybe Text
 -> Price)
-> Parser
     (Bool
      -> PriceBillingScheme'
      -> Int
      -> Text
      -> Text
      -> Bool
      -> Maybe Text
      -> Object
      -> Maybe Text
      -> PriceProduct'Variants
      -> Maybe PriceRecurring'
      -> Maybe PriceTaxBehavior'
      -> Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Bool
-> PriceBillingScheme'
-> Int
-> Text
-> Text
-> Bool
-> Maybe Text
-> Object
-> Maybe Text
-> PriceProduct'Variants
-> Maybe PriceRecurring'
-> Maybe PriceTaxBehavior'
-> Maybe [PriceTier]
-> Maybe PriceTiersMode'
-> Maybe PriceTransformQuantity'
-> PriceType'
-> Maybe Int
-> Maybe Text
-> Price
Price Parser
  (Bool
   -> PriceBillingScheme'
   -> Int
   -> Text
   -> Text
   -> Bool
   -> Maybe Text
   -> Object
   -> Maybe Text
   -> PriceProduct'Variants
   -> Maybe PriceRecurring'
   -> Maybe PriceTaxBehavior'
   -> Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser Bool
-> Parser
     (PriceBillingScheme'
      -> Int
      -> Text
      -> Text
      -> Bool
      -> Maybe Text
      -> Object
      -> Maybe Text
      -> PriceProduct'Variants
      -> Maybe PriceRecurring'
      -> Maybe PriceTaxBehavior'
      -> Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
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
"active")) Parser
  (PriceBillingScheme'
   -> Int
   -> Text
   -> Text
   -> Bool
   -> Maybe Text
   -> Object
   -> Maybe Text
   -> PriceProduct'Variants
   -> Maybe PriceRecurring'
   -> Maybe PriceTaxBehavior'
   -> Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser PriceBillingScheme'
-> Parser
     (Int
      -> Text
      -> Text
      -> Bool
      -> Maybe Text
      -> Object
      -> Maybe Text
      -> PriceProduct'Variants
      -> Maybe PriceRecurring'
      -> Maybe PriceTaxBehavior'
      -> Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PriceBillingScheme'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"billing_scheme")) Parser
  (Int
   -> Text
   -> Text
   -> Bool
   -> Maybe Text
   -> Object
   -> Maybe Text
   -> PriceProduct'Variants
   -> Maybe PriceRecurring'
   -> Maybe PriceTaxBehavior'
   -> Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser Int
-> Parser
     (Text
      -> Text
      -> Bool
      -> Maybe Text
      -> Object
      -> Maybe Text
      -> PriceProduct'Variants
      -> Maybe PriceRecurring'
      -> Maybe PriceTaxBehavior'
      -> Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
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
"created")) Parser
  (Text
   -> Text
   -> Bool
   -> Maybe Text
   -> Object
   -> Maybe Text
   -> PriceProduct'Variants
   -> Maybe PriceRecurring'
   -> Maybe PriceTaxBehavior'
   -> Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser Text
-> Parser
     (Text
      -> Bool
      -> Maybe Text
      -> Object
      -> Maybe Text
      -> PriceProduct'Variants
      -> Maybe PriceRecurring'
      -> Maybe PriceTaxBehavior'
      -> Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"currency")) Parser
  (Text
   -> Bool
   -> Maybe Text
   -> Object
   -> Maybe Text
   -> PriceProduct'Variants
   -> Maybe PriceRecurring'
   -> Maybe PriceTaxBehavior'
   -> Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser Text
-> Parser
     (Bool
      -> Maybe Text
      -> Object
      -> Maybe Text
      -> PriceProduct'Variants
      -> Maybe PriceRecurring'
      -> Maybe PriceTaxBehavior'
      -> Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"id")) Parser
  (Bool
   -> Maybe Text
   -> Object
   -> Maybe Text
   -> PriceProduct'Variants
   -> Maybe PriceRecurring'
   -> Maybe PriceTaxBehavior'
   -> Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser Bool
-> Parser
     (Maybe Text
      -> Object
      -> Maybe Text
      -> PriceProduct'Variants
      -> Maybe PriceRecurring'
      -> Maybe PriceTaxBehavior'
      -> Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
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
"livemode")) Parser
  (Maybe Text
   -> Object
   -> Maybe Text
   -> PriceProduct'Variants
   -> Maybe PriceRecurring'
   -> Maybe PriceTaxBehavior'
   -> Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser (Maybe Text)
-> Parser
     (Object
      -> Maybe Text
      -> PriceProduct'Variants
      -> Maybe PriceRecurring'
      -> Maybe PriceTaxBehavior'
      -> Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
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
"lookup_key")) Parser
  (Object
   -> Maybe Text
   -> PriceProduct'Variants
   -> Maybe PriceRecurring'
   -> Maybe PriceTaxBehavior'
   -> Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser Object
-> Parser
     (Maybe Text
      -> PriceProduct'Variants
      -> Maybe PriceRecurring'
      -> Maybe PriceTaxBehavior'
      -> Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Object
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"metadata")) Parser
  (Maybe Text
   -> PriceProduct'Variants
   -> Maybe PriceRecurring'
   -> Maybe PriceTaxBehavior'
   -> Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser (Maybe Text)
-> Parser
     (PriceProduct'Variants
      -> Maybe PriceRecurring'
      -> Maybe PriceTaxBehavior'
      -> Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
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
"nickname")) Parser
  (PriceProduct'Variants
   -> Maybe PriceRecurring'
   -> Maybe PriceTaxBehavior'
   -> Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser PriceProduct'Variants
-> Parser
     (Maybe PriceRecurring'
      -> Maybe PriceTaxBehavior'
      -> Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PriceProduct'Variants
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"product")) Parser
  (Maybe PriceRecurring'
   -> Maybe PriceTaxBehavior'
   -> Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser (Maybe PriceRecurring')
-> Parser
     (Maybe PriceTaxBehavior'
      -> Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe PriceRecurring')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"recurring")) Parser
  (Maybe PriceTaxBehavior'
   -> Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser (Maybe PriceTaxBehavior')
-> Parser
     (Maybe [PriceTier]
      -> Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe PriceTaxBehavior')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"tax_behavior")) Parser
  (Maybe [PriceTier]
   -> Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser (Maybe [PriceTier])
-> Parser
     (Maybe PriceTiersMode'
      -> Maybe PriceTransformQuantity'
      -> PriceType'
      -> Maybe Int
      -> Maybe Text
      -> Price)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe [PriceTier])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"tiers")) Parser
  (Maybe PriceTiersMode'
   -> Maybe PriceTransformQuantity'
   -> PriceType'
   -> Maybe Int
   -> Maybe Text
   -> Price)
-> Parser (Maybe PriceTiersMode')
-> Parser
     (Maybe PriceTransformQuantity'
      -> PriceType' -> Maybe Int -> Maybe Text -> Price)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe PriceTiersMode')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"tiers_mode")) Parser
  (Maybe PriceTransformQuantity'
   -> PriceType' -> Maybe Int -> Maybe Text -> Price)
-> Parser (Maybe PriceTransformQuantity')
-> Parser (PriceType' -> Maybe Int -> Maybe Text -> Price)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe PriceTransformQuantity')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"transform_quantity")) Parser (PriceType' -> Maybe Int -> Maybe Text -> Price)
-> Parser PriceType' -> Parser (Maybe Int -> Maybe Text -> Price)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PriceType'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"type")) Parser (Maybe Int -> Maybe Text -> Price)
-> Parser (Maybe Int) -> Parser (Maybe Text -> Price)
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
"unit_amount")) Parser (Maybe Text -> Price) -> Parser (Maybe Text) -> Parser Price
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
"unit_amount_decimal"))

-- | Create a new 'Price' with all required fields.
mkPrice ::
  -- | 'priceActive'
  GHC.Types.Bool ->
  -- | 'priceBillingScheme'
  PriceBillingScheme' ->
  -- | 'priceCreated'
  GHC.Types.Int ->
  -- | 'priceCurrency'
  Data.Text.Internal.Text ->
  -- | 'priceId'
  Data.Text.Internal.Text ->
  -- | 'priceLivemode'
  GHC.Types.Bool ->
  -- | 'priceMetadata'
  Data.Aeson.Types.Internal.Object ->
  -- | 'priceProduct'
  PriceProduct'Variants ->
  -- | 'priceType'
  PriceType' ->
  Price
mkPrice :: Bool
-> PriceBillingScheme'
-> Int
-> Text
-> Text
-> Bool
-> Object
-> PriceProduct'Variants
-> PriceType'
-> Price
mkPrice Bool
priceActive PriceBillingScheme'
priceBillingScheme Int
priceCreated Text
priceCurrency Text
priceId Bool
priceLivemode Object
priceMetadata PriceProduct'Variants
priceProduct PriceType'
priceType =
  Price :: Bool
-> PriceBillingScheme'
-> Int
-> Text
-> Text
-> Bool
-> Maybe Text
-> Object
-> Maybe Text
-> PriceProduct'Variants
-> Maybe PriceRecurring'
-> Maybe PriceTaxBehavior'
-> Maybe [PriceTier]
-> Maybe PriceTiersMode'
-> Maybe PriceTransformQuantity'
-> PriceType'
-> Maybe Int
-> Maybe Text
-> Price
Price
    { priceActive :: Bool
priceActive = Bool
priceActive,
      priceBillingScheme :: PriceBillingScheme'
priceBillingScheme = PriceBillingScheme'
priceBillingScheme,
      priceCreated :: Int
priceCreated = Int
priceCreated,
      priceCurrency :: Text
priceCurrency = Text
priceCurrency,
      priceId :: Text
priceId = Text
priceId,
      priceLivemode :: Bool
priceLivemode = Bool
priceLivemode,
      priceLookupKey :: Maybe Text
priceLookupKey = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      priceMetadata :: Object
priceMetadata = Object
priceMetadata,
      priceNickname :: Maybe Text
priceNickname = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      priceProduct :: PriceProduct'Variants
priceProduct = PriceProduct'Variants
priceProduct,
      priceRecurring :: Maybe PriceRecurring'
priceRecurring = Maybe PriceRecurring'
forall a. Maybe a
GHC.Maybe.Nothing,
      priceTaxBehavior :: Maybe PriceTaxBehavior'
priceTaxBehavior = Maybe PriceTaxBehavior'
forall a. Maybe a
GHC.Maybe.Nothing,
      priceTiers :: Maybe [PriceTier]
priceTiers = Maybe [PriceTier]
forall a. Maybe a
GHC.Maybe.Nothing,
      priceTiersMode :: Maybe PriceTiersMode'
priceTiersMode = Maybe PriceTiersMode'
forall a. Maybe a
GHC.Maybe.Nothing,
      priceTransformQuantity :: Maybe PriceTransformQuantity'
priceTransformQuantity = Maybe PriceTransformQuantity'
forall a. Maybe a
GHC.Maybe.Nothing,
      priceType :: PriceType'
priceType = PriceType'
priceType,
      priceUnitAmount :: Maybe Int
priceUnitAmount = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      priceUnitAmountDecimal :: Maybe Text
priceUnitAmountDecimal = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the enum schema located at @components.schemas.price.properties.billing_scheme@ in the specification.
--
-- Describes how to compute the price per period. Either \`per_unit\` or \`tiered\`. \`per_unit\` indicates that the fixed amount (specified in \`unit_amount\` or \`unit_amount_decimal\`) will be charged per unit in \`quantity\` (for prices with \`usage_type=licensed\`), or per unit of total usage (for prices with \`usage_type=metered\`). \`tiered\` indicates that the unit pricing will be computed using a tiering strategy as defined using the \`tiers\` and \`tiers_mode\` attributes.
data PriceBillingScheme'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PriceBillingScheme'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.
    PriceBillingScheme'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"per_unit"@
    PriceBillingScheme'EnumPerUnit
  | -- | Represents the JSON value @"tiered"@
    PriceBillingScheme'EnumTiered
  deriving (Int -> PriceBillingScheme' -> ShowS
[PriceBillingScheme'] -> ShowS
PriceBillingScheme' -> String
(Int -> PriceBillingScheme' -> ShowS)
-> (PriceBillingScheme' -> String)
-> ([PriceBillingScheme'] -> ShowS)
-> Show PriceBillingScheme'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceBillingScheme'] -> ShowS
$cshowList :: [PriceBillingScheme'] -> ShowS
show :: PriceBillingScheme' -> String
$cshow :: PriceBillingScheme' -> String
showsPrec :: Int -> PriceBillingScheme' -> ShowS
$cshowsPrec :: Int -> PriceBillingScheme' -> ShowS
GHC.Show.Show, PriceBillingScheme' -> PriceBillingScheme' -> Bool
(PriceBillingScheme' -> PriceBillingScheme' -> Bool)
-> (PriceBillingScheme' -> PriceBillingScheme' -> Bool)
-> Eq PriceBillingScheme'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceBillingScheme' -> PriceBillingScheme' -> Bool
$c/= :: PriceBillingScheme' -> PriceBillingScheme' -> Bool
== :: PriceBillingScheme' -> PriceBillingScheme' -> Bool
$c== :: PriceBillingScheme' -> PriceBillingScheme' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PriceBillingScheme' where
  toJSON :: PriceBillingScheme' -> Value
toJSON (PriceBillingScheme'Other Value
val) = Value
val
  toJSON (PriceBillingScheme'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PriceBillingScheme'
PriceBillingScheme'EnumPerUnit) = Value
"per_unit"
  toJSON (PriceBillingScheme'
PriceBillingScheme'EnumTiered) = Value
"tiered"

instance Data.Aeson.Types.FromJSON.FromJSON PriceBillingScheme' where
  parseJSON :: Value -> Parser PriceBillingScheme'
parseJSON Value
val =
    PriceBillingScheme' -> Parser PriceBillingScheme'
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
"per_unit" -> PriceBillingScheme'
PriceBillingScheme'EnumPerUnit
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"tiered" -> PriceBillingScheme'
PriceBillingScheme'EnumTiered
            | Bool
GHC.Base.otherwise -> Value -> PriceBillingScheme'
PriceBillingScheme'Other Value
val
      )

-- | Defines the oneOf schema located at @components.schemas.price.properties.product.anyOf@ in the specification.
--
-- The ID of the product this price is associated with.
data PriceProduct'Variants
  = PriceProduct'Text Data.Text.Internal.Text
  | PriceProduct'Product Product
  | PriceProduct'DeletedProduct DeletedProduct
  deriving (Int -> PriceProduct'Variants -> ShowS
[PriceProduct'Variants] -> ShowS
PriceProduct'Variants -> String
(Int -> PriceProduct'Variants -> ShowS)
-> (PriceProduct'Variants -> String)
-> ([PriceProduct'Variants] -> ShowS)
-> Show PriceProduct'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceProduct'Variants] -> ShowS
$cshowList :: [PriceProduct'Variants] -> ShowS
show :: PriceProduct'Variants -> String
$cshow :: PriceProduct'Variants -> String
showsPrec :: Int -> PriceProduct'Variants -> ShowS
$cshowsPrec :: Int -> PriceProduct'Variants -> ShowS
GHC.Show.Show, PriceProduct'Variants -> PriceProduct'Variants -> Bool
(PriceProduct'Variants -> PriceProduct'Variants -> Bool)
-> (PriceProduct'Variants -> PriceProduct'Variants -> Bool)
-> Eq PriceProduct'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceProduct'Variants -> PriceProduct'Variants -> Bool
$c/= :: PriceProduct'Variants -> PriceProduct'Variants -> Bool
== :: PriceProduct'Variants -> PriceProduct'Variants -> Bool
$c== :: PriceProduct'Variants -> PriceProduct'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PriceProduct'Variants where
  toJSON :: PriceProduct'Variants -> Value
toJSON (PriceProduct'Text Text
a) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
a
  toJSON (PriceProduct'Product Product
a) = Product -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Product
a
  toJSON (PriceProduct'DeletedProduct DeletedProduct
a) = DeletedProduct -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON DeletedProduct
a

instance Data.Aeson.Types.FromJSON.FromJSON PriceProduct'Variants where
  parseJSON :: Value -> Parser PriceProduct'Variants
parseJSON Value
val = case (Text -> PriceProduct'Variants
PriceProduct'Text (Text -> PriceProduct'Variants)
-> Result Text -> Result PriceProduct'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Text
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result PriceProduct'Variants
-> Result PriceProduct'Variants -> Result PriceProduct'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((Product -> PriceProduct'Variants
PriceProduct'Product (Product -> PriceProduct'Variants)
-> Result Product -> Result PriceProduct'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Product
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result PriceProduct'Variants
-> Result PriceProduct'Variants -> Result PriceProduct'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((DeletedProduct -> PriceProduct'Variants
PriceProduct'DeletedProduct (DeletedProduct -> PriceProduct'Variants)
-> Result DeletedProduct -> Result PriceProduct'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result DeletedProduct
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result PriceProduct'Variants
-> Result PriceProduct'Variants -> Result PriceProduct'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String -> Result PriceProduct'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched")) of
    Data.Aeson.Types.Internal.Success PriceProduct'Variants
a -> PriceProduct'Variants -> Parser PriceProduct'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PriceProduct'Variants
a
    Data.Aeson.Types.Internal.Error String
a -> String -> Parser PriceProduct'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a

-- | Defines the object schema located at @components.schemas.price.properties.recurring.anyOf@ in the specification.
--
-- The recurring components of a price such as \\\`interval\\\` and \\\`usage_type\\\`.
data PriceRecurring' = PriceRecurring'
  { -- | aggregate_usage: Specifies a usage aggregation strategy for prices of \`usage_type=metered\`. Allowed values are \`sum\` for summing up all usage during a period, \`last_during_period\` for using the last usage record reported within a period, \`last_ever\` for using the last usage record ever (across period bounds) or \`max\` which uses the usage record with the maximum reported usage during a period. Defaults to \`sum\`.
    PriceRecurring' -> Maybe PriceRecurring'AggregateUsage'
priceRecurring'AggregateUsage :: (GHC.Maybe.Maybe PriceRecurring'AggregateUsage'),
    -- | interval: The frequency at which a subscription is billed. One of \`day\`, \`week\`, \`month\` or \`year\`.
    PriceRecurring' -> Maybe PriceRecurring'Interval'
priceRecurring'Interval :: (GHC.Maybe.Maybe PriceRecurring'Interval'),
    -- | interval_count: The number of intervals (specified in the \`interval\` attribute) between subscription billings. For example, \`interval=month\` and \`interval_count=3\` bills every 3 months.
    PriceRecurring' -> Maybe Int
priceRecurring'IntervalCount :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | usage_type: Configures how the quantity per period should be determined. Can be either \`metered\` or \`licensed\`. \`licensed\` automatically bills the \`quantity\` set when adding it to a subscription. \`metered\` aggregates the total usage based on usage records. Defaults to \`licensed\`.
    PriceRecurring' -> Maybe PriceRecurring'UsageType'
priceRecurring'UsageType :: (GHC.Maybe.Maybe PriceRecurring'UsageType')
  }
  deriving
    ( Int -> PriceRecurring' -> ShowS
[PriceRecurring'] -> ShowS
PriceRecurring' -> String
(Int -> PriceRecurring' -> ShowS)
-> (PriceRecurring' -> String)
-> ([PriceRecurring'] -> ShowS)
-> Show PriceRecurring'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceRecurring'] -> ShowS
$cshowList :: [PriceRecurring'] -> ShowS
show :: PriceRecurring' -> String
$cshow :: PriceRecurring' -> String
showsPrec :: Int -> PriceRecurring' -> ShowS
$cshowsPrec :: Int -> PriceRecurring' -> ShowS
GHC.Show.Show,
      PriceRecurring' -> PriceRecurring' -> Bool
(PriceRecurring' -> PriceRecurring' -> Bool)
-> (PriceRecurring' -> PriceRecurring' -> Bool)
-> Eq PriceRecurring'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceRecurring' -> PriceRecurring' -> Bool
$c/= :: PriceRecurring' -> PriceRecurring' -> Bool
== :: PriceRecurring' -> PriceRecurring' -> Bool
$c== :: PriceRecurring' -> PriceRecurring' -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PriceRecurring' where
  toJSON :: PriceRecurring' -> Value
toJSON PriceRecurring'
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"aggregate_usage" Text -> Maybe PriceRecurring'AggregateUsage' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PriceRecurring' -> Maybe PriceRecurring'AggregateUsage'
priceRecurring'AggregateUsage PriceRecurring'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"interval" Text -> Maybe PriceRecurring'Interval' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PriceRecurring' -> Maybe PriceRecurring'Interval'
priceRecurring'Interval PriceRecurring'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"interval_count" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PriceRecurring' -> Maybe Int
priceRecurring'IntervalCount PriceRecurring'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"usage_type" Text -> Maybe PriceRecurring'UsageType' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PriceRecurring' -> Maybe PriceRecurring'UsageType'
priceRecurring'UsageType PriceRecurring'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PriceRecurring' -> Encoding
toEncoding PriceRecurring'
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"aggregate_usage" Text -> Maybe PriceRecurring'AggregateUsage' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PriceRecurring' -> Maybe PriceRecurring'AggregateUsage'
priceRecurring'AggregateUsage PriceRecurring'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"interval" Text -> Maybe PriceRecurring'Interval' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PriceRecurring' -> Maybe PriceRecurring'Interval'
priceRecurring'Interval PriceRecurring'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"interval_count" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PriceRecurring' -> Maybe Int
priceRecurring'IntervalCount PriceRecurring'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"usage_type" Text -> Maybe PriceRecurring'UsageType' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PriceRecurring' -> Maybe PriceRecurring'UsageType'
priceRecurring'UsageType PriceRecurring'
obj))))

instance Data.Aeson.Types.FromJSON.FromJSON PriceRecurring' where
  parseJSON :: Value -> Parser PriceRecurring'
parseJSON = String
-> (Object -> Parser PriceRecurring')
-> Value
-> Parser PriceRecurring'
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PriceRecurring'" (\Object
obj -> ((((Maybe PriceRecurring'AggregateUsage'
 -> Maybe PriceRecurring'Interval'
 -> Maybe Int
 -> Maybe PriceRecurring'UsageType'
 -> PriceRecurring')
-> Parser
     (Maybe PriceRecurring'AggregateUsage'
      -> Maybe PriceRecurring'Interval'
      -> Maybe Int
      -> Maybe PriceRecurring'UsageType'
      -> PriceRecurring')
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe PriceRecurring'AggregateUsage'
-> Maybe PriceRecurring'Interval'
-> Maybe Int
-> Maybe PriceRecurring'UsageType'
-> PriceRecurring'
PriceRecurring' Parser
  (Maybe PriceRecurring'AggregateUsage'
   -> Maybe PriceRecurring'Interval'
   -> Maybe Int
   -> Maybe PriceRecurring'UsageType'
   -> PriceRecurring')
-> Parser (Maybe PriceRecurring'AggregateUsage')
-> Parser
     (Maybe PriceRecurring'Interval'
      -> Maybe Int -> Maybe PriceRecurring'UsageType' -> PriceRecurring')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe PriceRecurring'AggregateUsage')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"aggregate_usage")) Parser
  (Maybe PriceRecurring'Interval'
   -> Maybe Int -> Maybe PriceRecurring'UsageType' -> PriceRecurring')
-> Parser (Maybe PriceRecurring'Interval')
-> Parser
     (Maybe Int -> Maybe PriceRecurring'UsageType' -> PriceRecurring')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe PriceRecurring'Interval')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"interval")) Parser
  (Maybe Int -> Maybe PriceRecurring'UsageType' -> PriceRecurring')
-> Parser (Maybe Int)
-> Parser (Maybe PriceRecurring'UsageType' -> PriceRecurring')
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
"interval_count")) Parser (Maybe PriceRecurring'UsageType' -> PriceRecurring')
-> Parser (Maybe PriceRecurring'UsageType')
-> Parser PriceRecurring'
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe PriceRecurring'UsageType')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"usage_type"))

-- | Create a new 'PriceRecurring'' with all required fields.
mkPriceRecurring' :: PriceRecurring'
mkPriceRecurring' :: PriceRecurring'
mkPriceRecurring' =
  PriceRecurring' :: Maybe PriceRecurring'AggregateUsage'
-> Maybe PriceRecurring'Interval'
-> Maybe Int
-> Maybe PriceRecurring'UsageType'
-> PriceRecurring'
PriceRecurring'
    { priceRecurring'AggregateUsage :: Maybe PriceRecurring'AggregateUsage'
priceRecurring'AggregateUsage = Maybe PriceRecurring'AggregateUsage'
forall a. Maybe a
GHC.Maybe.Nothing,
      priceRecurring'Interval :: Maybe PriceRecurring'Interval'
priceRecurring'Interval = Maybe PriceRecurring'Interval'
forall a. Maybe a
GHC.Maybe.Nothing,
      priceRecurring'IntervalCount :: Maybe Int
priceRecurring'IntervalCount = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      priceRecurring'UsageType :: Maybe PriceRecurring'UsageType'
priceRecurring'UsageType = Maybe PriceRecurring'UsageType'
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the enum schema located at @components.schemas.price.properties.recurring.anyOf.properties.aggregate_usage@ in the specification.
--
-- Specifies a usage aggregation strategy for prices of \`usage_type=metered\`. Allowed values are \`sum\` for summing up all usage during a period, \`last_during_period\` for using the last usage record reported within a period, \`last_ever\` for using the last usage record ever (across period bounds) or \`max\` which uses the usage record with the maximum reported usage during a period. Defaults to \`sum\`.
data PriceRecurring'AggregateUsage'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PriceRecurring'AggregateUsage'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.
    PriceRecurring'AggregateUsage'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"last_during_period"@
    PriceRecurring'AggregateUsage'EnumLastDuringPeriod
  | -- | Represents the JSON value @"last_ever"@
    PriceRecurring'AggregateUsage'EnumLastEver
  | -- | Represents the JSON value @"max"@
    PriceRecurring'AggregateUsage'EnumMax
  | -- | Represents the JSON value @"sum"@
    PriceRecurring'AggregateUsage'EnumSum
  deriving (Int -> PriceRecurring'AggregateUsage' -> ShowS
[PriceRecurring'AggregateUsage'] -> ShowS
PriceRecurring'AggregateUsage' -> String
(Int -> PriceRecurring'AggregateUsage' -> ShowS)
-> (PriceRecurring'AggregateUsage' -> String)
-> ([PriceRecurring'AggregateUsage'] -> ShowS)
-> Show PriceRecurring'AggregateUsage'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceRecurring'AggregateUsage'] -> ShowS
$cshowList :: [PriceRecurring'AggregateUsage'] -> ShowS
show :: PriceRecurring'AggregateUsage' -> String
$cshow :: PriceRecurring'AggregateUsage' -> String
showsPrec :: Int -> PriceRecurring'AggregateUsage' -> ShowS
$cshowsPrec :: Int -> PriceRecurring'AggregateUsage' -> ShowS
GHC.Show.Show, PriceRecurring'AggregateUsage'
-> PriceRecurring'AggregateUsage' -> Bool
(PriceRecurring'AggregateUsage'
 -> PriceRecurring'AggregateUsage' -> Bool)
-> (PriceRecurring'AggregateUsage'
    -> PriceRecurring'AggregateUsage' -> Bool)
-> Eq PriceRecurring'AggregateUsage'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceRecurring'AggregateUsage'
-> PriceRecurring'AggregateUsage' -> Bool
$c/= :: PriceRecurring'AggregateUsage'
-> PriceRecurring'AggregateUsage' -> Bool
== :: PriceRecurring'AggregateUsage'
-> PriceRecurring'AggregateUsage' -> Bool
$c== :: PriceRecurring'AggregateUsage'
-> PriceRecurring'AggregateUsage' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PriceRecurring'AggregateUsage' where
  toJSON :: PriceRecurring'AggregateUsage' -> Value
toJSON (PriceRecurring'AggregateUsage'Other Value
val) = Value
val
  toJSON (PriceRecurring'AggregateUsage'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PriceRecurring'AggregateUsage'
PriceRecurring'AggregateUsage'EnumLastDuringPeriod) = Value
"last_during_period"
  toJSON (PriceRecurring'AggregateUsage'
PriceRecurring'AggregateUsage'EnumLastEver) = Value
"last_ever"
  toJSON (PriceRecurring'AggregateUsage'
PriceRecurring'AggregateUsage'EnumMax) = Value
"max"
  toJSON (PriceRecurring'AggregateUsage'
PriceRecurring'AggregateUsage'EnumSum) = Value
"sum"

instance Data.Aeson.Types.FromJSON.FromJSON PriceRecurring'AggregateUsage' where
  parseJSON :: Value -> Parser PriceRecurring'AggregateUsage'
parseJSON Value
val =
    PriceRecurring'AggregateUsage'
-> Parser PriceRecurring'AggregateUsage'
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
"last_during_period" -> PriceRecurring'AggregateUsage'
PriceRecurring'AggregateUsage'EnumLastDuringPeriod
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"last_ever" -> PriceRecurring'AggregateUsage'
PriceRecurring'AggregateUsage'EnumLastEver
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"max" -> PriceRecurring'AggregateUsage'
PriceRecurring'AggregateUsage'EnumMax
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"sum" -> PriceRecurring'AggregateUsage'
PriceRecurring'AggregateUsage'EnumSum
            | Bool
GHC.Base.otherwise -> Value -> PriceRecurring'AggregateUsage'
PriceRecurring'AggregateUsage'Other Value
val
      )

-- | Defines the enum schema located at @components.schemas.price.properties.recurring.anyOf.properties.interval@ in the specification.
--
-- The frequency at which a subscription is billed. One of \`day\`, \`week\`, \`month\` or \`year\`.
data PriceRecurring'Interval'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PriceRecurring'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.
    PriceRecurring'Interval'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"day"@
    PriceRecurring'Interval'EnumDay
  | -- | Represents the JSON value @"month"@
    PriceRecurring'Interval'EnumMonth
  | -- | Represents the JSON value @"week"@
    PriceRecurring'Interval'EnumWeek
  | -- | Represents the JSON value @"year"@
    PriceRecurring'Interval'EnumYear
  deriving (Int -> PriceRecurring'Interval' -> ShowS
[PriceRecurring'Interval'] -> ShowS
PriceRecurring'Interval' -> String
(Int -> PriceRecurring'Interval' -> ShowS)
-> (PriceRecurring'Interval' -> String)
-> ([PriceRecurring'Interval'] -> ShowS)
-> Show PriceRecurring'Interval'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceRecurring'Interval'] -> ShowS
$cshowList :: [PriceRecurring'Interval'] -> ShowS
show :: PriceRecurring'Interval' -> String
$cshow :: PriceRecurring'Interval' -> String
showsPrec :: Int -> PriceRecurring'Interval' -> ShowS
$cshowsPrec :: Int -> PriceRecurring'Interval' -> ShowS
GHC.Show.Show, PriceRecurring'Interval' -> PriceRecurring'Interval' -> Bool
(PriceRecurring'Interval' -> PriceRecurring'Interval' -> Bool)
-> (PriceRecurring'Interval' -> PriceRecurring'Interval' -> Bool)
-> Eq PriceRecurring'Interval'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceRecurring'Interval' -> PriceRecurring'Interval' -> Bool
$c/= :: PriceRecurring'Interval' -> PriceRecurring'Interval' -> Bool
== :: PriceRecurring'Interval' -> PriceRecurring'Interval' -> Bool
$c== :: PriceRecurring'Interval' -> PriceRecurring'Interval' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PriceRecurring'Interval' where
  toJSON :: PriceRecurring'Interval' -> Value
toJSON (PriceRecurring'Interval'Other Value
val) = Value
val
  toJSON (PriceRecurring'Interval'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PriceRecurring'Interval'
PriceRecurring'Interval'EnumDay) = Value
"day"
  toJSON (PriceRecurring'Interval'
PriceRecurring'Interval'EnumMonth) = Value
"month"
  toJSON (PriceRecurring'Interval'
PriceRecurring'Interval'EnumWeek) = Value
"week"
  toJSON (PriceRecurring'Interval'
PriceRecurring'Interval'EnumYear) = Value
"year"

instance Data.Aeson.Types.FromJSON.FromJSON PriceRecurring'Interval' where
  parseJSON :: Value -> Parser PriceRecurring'Interval'
parseJSON Value
val =
    PriceRecurring'Interval' -> Parser PriceRecurring'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
"day" -> PriceRecurring'Interval'
PriceRecurring'Interval'EnumDay
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"month" -> PriceRecurring'Interval'
PriceRecurring'Interval'EnumMonth
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"week" -> PriceRecurring'Interval'
PriceRecurring'Interval'EnumWeek
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"year" -> PriceRecurring'Interval'
PriceRecurring'Interval'EnumYear
            | Bool
GHC.Base.otherwise -> Value -> PriceRecurring'Interval'
PriceRecurring'Interval'Other Value
val
      )

-- | Defines the enum schema located at @components.schemas.price.properties.recurring.anyOf.properties.usage_type@ in the specification.
--
-- Configures how the quantity per period should be determined. Can be either \`metered\` or \`licensed\`. \`licensed\` automatically bills the \`quantity\` set when adding it to a subscription. \`metered\` aggregates the total usage based on usage records. Defaults to \`licensed\`.
data PriceRecurring'UsageType'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PriceRecurring'UsageType'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.
    PriceRecurring'UsageType'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"licensed"@
    PriceRecurring'UsageType'EnumLicensed
  | -- | Represents the JSON value @"metered"@
    PriceRecurring'UsageType'EnumMetered
  deriving (Int -> PriceRecurring'UsageType' -> ShowS
[PriceRecurring'UsageType'] -> ShowS
PriceRecurring'UsageType' -> String
(Int -> PriceRecurring'UsageType' -> ShowS)
-> (PriceRecurring'UsageType' -> String)
-> ([PriceRecurring'UsageType'] -> ShowS)
-> Show PriceRecurring'UsageType'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceRecurring'UsageType'] -> ShowS
$cshowList :: [PriceRecurring'UsageType'] -> ShowS
show :: PriceRecurring'UsageType' -> String
$cshow :: PriceRecurring'UsageType' -> String
showsPrec :: Int -> PriceRecurring'UsageType' -> ShowS
$cshowsPrec :: Int -> PriceRecurring'UsageType' -> ShowS
GHC.Show.Show, PriceRecurring'UsageType' -> PriceRecurring'UsageType' -> Bool
(PriceRecurring'UsageType' -> PriceRecurring'UsageType' -> Bool)
-> (PriceRecurring'UsageType' -> PriceRecurring'UsageType' -> Bool)
-> Eq PriceRecurring'UsageType'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceRecurring'UsageType' -> PriceRecurring'UsageType' -> Bool
$c/= :: PriceRecurring'UsageType' -> PriceRecurring'UsageType' -> Bool
== :: PriceRecurring'UsageType' -> PriceRecurring'UsageType' -> Bool
$c== :: PriceRecurring'UsageType' -> PriceRecurring'UsageType' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PriceRecurring'UsageType' where
  toJSON :: PriceRecurring'UsageType' -> Value
toJSON (PriceRecurring'UsageType'Other Value
val) = Value
val
  toJSON (PriceRecurring'UsageType'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PriceRecurring'UsageType'
PriceRecurring'UsageType'EnumLicensed) = Value
"licensed"
  toJSON (PriceRecurring'UsageType'
PriceRecurring'UsageType'EnumMetered) = Value
"metered"

instance Data.Aeson.Types.FromJSON.FromJSON PriceRecurring'UsageType' where
  parseJSON :: Value -> Parser PriceRecurring'UsageType'
parseJSON Value
val =
    PriceRecurring'UsageType' -> Parser PriceRecurring'UsageType'
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
"licensed" -> PriceRecurring'UsageType'
PriceRecurring'UsageType'EnumLicensed
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"metered" -> PriceRecurring'UsageType'
PriceRecurring'UsageType'EnumMetered
            | Bool
GHC.Base.otherwise -> Value -> PriceRecurring'UsageType'
PriceRecurring'UsageType'Other Value
val
      )

-- | Defines the enum schema located at @components.schemas.price.properties.tax_behavior@ in the specification.
--
-- Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of \`inclusive\`, \`exclusive\`, or \`unspecified\`. Once specified as either \`inclusive\` or \`exclusive\`, it cannot be changed.
data PriceTaxBehavior'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PriceTaxBehavior'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.
    PriceTaxBehavior'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"exclusive"@
    PriceTaxBehavior'EnumExclusive
  | -- | Represents the JSON value @"inclusive"@
    PriceTaxBehavior'EnumInclusive
  | -- | Represents the JSON value @"unspecified"@
    PriceTaxBehavior'EnumUnspecified
  deriving (Int -> PriceTaxBehavior' -> ShowS
[PriceTaxBehavior'] -> ShowS
PriceTaxBehavior' -> String
(Int -> PriceTaxBehavior' -> ShowS)
-> (PriceTaxBehavior' -> String)
-> ([PriceTaxBehavior'] -> ShowS)
-> Show PriceTaxBehavior'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceTaxBehavior'] -> ShowS
$cshowList :: [PriceTaxBehavior'] -> ShowS
show :: PriceTaxBehavior' -> String
$cshow :: PriceTaxBehavior' -> String
showsPrec :: Int -> PriceTaxBehavior' -> ShowS
$cshowsPrec :: Int -> PriceTaxBehavior' -> ShowS
GHC.Show.Show, PriceTaxBehavior' -> PriceTaxBehavior' -> Bool
(PriceTaxBehavior' -> PriceTaxBehavior' -> Bool)
-> (PriceTaxBehavior' -> PriceTaxBehavior' -> Bool)
-> Eq PriceTaxBehavior'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceTaxBehavior' -> PriceTaxBehavior' -> Bool
$c/= :: PriceTaxBehavior' -> PriceTaxBehavior' -> Bool
== :: PriceTaxBehavior' -> PriceTaxBehavior' -> Bool
$c== :: PriceTaxBehavior' -> PriceTaxBehavior' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PriceTaxBehavior' where
  toJSON :: PriceTaxBehavior' -> Value
toJSON (PriceTaxBehavior'Other Value
val) = Value
val
  toJSON (PriceTaxBehavior'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PriceTaxBehavior'
PriceTaxBehavior'EnumExclusive) = Value
"exclusive"
  toJSON (PriceTaxBehavior'
PriceTaxBehavior'EnumInclusive) = Value
"inclusive"
  toJSON (PriceTaxBehavior'
PriceTaxBehavior'EnumUnspecified) = Value
"unspecified"

instance Data.Aeson.Types.FromJSON.FromJSON PriceTaxBehavior' where
  parseJSON :: Value -> Parser PriceTaxBehavior'
parseJSON Value
val =
    PriceTaxBehavior' -> Parser PriceTaxBehavior'
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
"exclusive" -> PriceTaxBehavior'
PriceTaxBehavior'EnumExclusive
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"inclusive" -> PriceTaxBehavior'
PriceTaxBehavior'EnumInclusive
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"unspecified" -> PriceTaxBehavior'
PriceTaxBehavior'EnumUnspecified
            | Bool
GHC.Base.otherwise -> Value -> PriceTaxBehavior'
PriceTaxBehavior'Other Value
val
      )

-- | Defines the enum schema located at @components.schemas.price.properties.tiers_mode@ in the specification.
--
-- Defines if the tiering price should be \`graduated\` or \`volume\` based. In \`volume\`-based tiering, the maximum quantity within a period determines the per unit price. In \`graduated\` tiering, pricing can change as the quantity grows.
data PriceTiersMode'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PriceTiersMode'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.
    PriceTiersMode'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"graduated"@
    PriceTiersMode'EnumGraduated
  | -- | Represents the JSON value @"volume"@
    PriceTiersMode'EnumVolume
  deriving (Int -> PriceTiersMode' -> ShowS
[PriceTiersMode'] -> ShowS
PriceTiersMode' -> String
(Int -> PriceTiersMode' -> ShowS)
-> (PriceTiersMode' -> String)
-> ([PriceTiersMode'] -> ShowS)
-> Show PriceTiersMode'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceTiersMode'] -> ShowS
$cshowList :: [PriceTiersMode'] -> ShowS
show :: PriceTiersMode' -> String
$cshow :: PriceTiersMode' -> String
showsPrec :: Int -> PriceTiersMode' -> ShowS
$cshowsPrec :: Int -> PriceTiersMode' -> ShowS
GHC.Show.Show, PriceTiersMode' -> PriceTiersMode' -> Bool
(PriceTiersMode' -> PriceTiersMode' -> Bool)
-> (PriceTiersMode' -> PriceTiersMode' -> Bool)
-> Eq PriceTiersMode'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceTiersMode' -> PriceTiersMode' -> Bool
$c/= :: PriceTiersMode' -> PriceTiersMode' -> Bool
== :: PriceTiersMode' -> PriceTiersMode' -> Bool
$c== :: PriceTiersMode' -> PriceTiersMode' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PriceTiersMode' where
  toJSON :: PriceTiersMode' -> Value
toJSON (PriceTiersMode'Other Value
val) = Value
val
  toJSON (PriceTiersMode'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PriceTiersMode'
PriceTiersMode'EnumGraduated) = Value
"graduated"
  toJSON (PriceTiersMode'
PriceTiersMode'EnumVolume) = Value
"volume"

instance Data.Aeson.Types.FromJSON.FromJSON PriceTiersMode' where
  parseJSON :: Value -> Parser PriceTiersMode'
parseJSON Value
val =
    PriceTiersMode' -> Parser PriceTiersMode'
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
"graduated" -> PriceTiersMode'
PriceTiersMode'EnumGraduated
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"volume" -> PriceTiersMode'
PriceTiersMode'EnumVolume
            | Bool
GHC.Base.otherwise -> Value -> PriceTiersMode'
PriceTiersMode'Other Value
val
      )

-- | Defines the object schema located at @components.schemas.price.properties.transform_quantity.anyOf@ in the specification.
--
-- Apply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined with \\\`tiers\\\`.
data PriceTransformQuantity' = PriceTransformQuantity'
  { -- | divide_by: Divide usage by this number.
    PriceTransformQuantity' -> Maybe Int
priceTransformQuantity'DivideBy :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | round: After division, either round the result \`up\` or \`down\`.
    PriceTransformQuantity' -> Maybe PriceTransformQuantity'Round'
priceTransformQuantity'Round :: (GHC.Maybe.Maybe PriceTransformQuantity'Round')
  }
  deriving
    ( Int -> PriceTransformQuantity' -> ShowS
[PriceTransformQuantity'] -> ShowS
PriceTransformQuantity' -> String
(Int -> PriceTransformQuantity' -> ShowS)
-> (PriceTransformQuantity' -> String)
-> ([PriceTransformQuantity'] -> ShowS)
-> Show PriceTransformQuantity'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceTransformQuantity'] -> ShowS
$cshowList :: [PriceTransformQuantity'] -> ShowS
show :: PriceTransformQuantity' -> String
$cshow :: PriceTransformQuantity' -> String
showsPrec :: Int -> PriceTransformQuantity' -> ShowS
$cshowsPrec :: Int -> PriceTransformQuantity' -> ShowS
GHC.Show.Show,
      PriceTransformQuantity' -> PriceTransformQuantity' -> Bool
(PriceTransformQuantity' -> PriceTransformQuantity' -> Bool)
-> (PriceTransformQuantity' -> PriceTransformQuantity' -> Bool)
-> Eq PriceTransformQuantity'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceTransformQuantity' -> PriceTransformQuantity' -> Bool
$c/= :: PriceTransformQuantity' -> PriceTransformQuantity' -> Bool
== :: PriceTransformQuantity' -> PriceTransformQuantity' -> Bool
$c== :: PriceTransformQuantity' -> PriceTransformQuantity' -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PriceTransformQuantity' where
  toJSON :: PriceTransformQuantity' -> Value
toJSON PriceTransformQuantity'
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"divide_by" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PriceTransformQuantity' -> Maybe Int
priceTransformQuantity'DivideBy PriceTransformQuantity'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"round" Text -> Maybe PriceTransformQuantity'Round' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PriceTransformQuantity' -> Maybe PriceTransformQuantity'Round'
priceTransformQuantity'Round PriceTransformQuantity'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PriceTransformQuantity' -> Encoding
toEncoding PriceTransformQuantity'
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"divide_by" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PriceTransformQuantity' -> Maybe Int
priceTransformQuantity'DivideBy PriceTransformQuantity'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"round" Text -> Maybe PriceTransformQuantity'Round' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PriceTransformQuantity' -> Maybe PriceTransformQuantity'Round'
priceTransformQuantity'Round PriceTransformQuantity'
obj))

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

-- | Create a new 'PriceTransformQuantity'' with all required fields.
mkPriceTransformQuantity' :: PriceTransformQuantity'
mkPriceTransformQuantity' :: PriceTransformQuantity'
mkPriceTransformQuantity' =
  PriceTransformQuantity' :: Maybe Int
-> Maybe PriceTransformQuantity'Round' -> PriceTransformQuantity'
PriceTransformQuantity'
    { priceTransformQuantity'DivideBy :: Maybe Int
priceTransformQuantity'DivideBy = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      priceTransformQuantity'Round :: Maybe PriceTransformQuantity'Round'
priceTransformQuantity'Round = Maybe PriceTransformQuantity'Round'
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the enum schema located at @components.schemas.price.properties.transform_quantity.anyOf.properties.round@ in the specification.
--
-- After division, either round the result \`up\` or \`down\`.
data PriceTransformQuantity'Round'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PriceTransformQuantity'Round'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.
    PriceTransformQuantity'Round'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"down"@
    PriceTransformQuantity'Round'EnumDown
  | -- | Represents the JSON value @"up"@
    PriceTransformQuantity'Round'EnumUp
  deriving (Int -> PriceTransformQuantity'Round' -> ShowS
[PriceTransformQuantity'Round'] -> ShowS
PriceTransformQuantity'Round' -> String
(Int -> PriceTransformQuantity'Round' -> ShowS)
-> (PriceTransformQuantity'Round' -> String)
-> ([PriceTransformQuantity'Round'] -> ShowS)
-> Show PriceTransformQuantity'Round'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceTransformQuantity'Round'] -> ShowS
$cshowList :: [PriceTransformQuantity'Round'] -> ShowS
show :: PriceTransformQuantity'Round' -> String
$cshow :: PriceTransformQuantity'Round' -> String
showsPrec :: Int -> PriceTransformQuantity'Round' -> ShowS
$cshowsPrec :: Int -> PriceTransformQuantity'Round' -> ShowS
GHC.Show.Show, PriceTransformQuantity'Round'
-> PriceTransformQuantity'Round' -> Bool
(PriceTransformQuantity'Round'
 -> PriceTransformQuantity'Round' -> Bool)
-> (PriceTransformQuantity'Round'
    -> PriceTransformQuantity'Round' -> Bool)
-> Eq PriceTransformQuantity'Round'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceTransformQuantity'Round'
-> PriceTransformQuantity'Round' -> Bool
$c/= :: PriceTransformQuantity'Round'
-> PriceTransformQuantity'Round' -> Bool
== :: PriceTransformQuantity'Round'
-> PriceTransformQuantity'Round' -> Bool
$c== :: PriceTransformQuantity'Round'
-> PriceTransformQuantity'Round' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PriceTransformQuantity'Round' where
  toJSON :: PriceTransformQuantity'Round' -> Value
toJSON (PriceTransformQuantity'Round'Other Value
val) = Value
val
  toJSON (PriceTransformQuantity'Round'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PriceTransformQuantity'Round'
PriceTransformQuantity'Round'EnumDown) = Value
"down"
  toJSON (PriceTransformQuantity'Round'
PriceTransformQuantity'Round'EnumUp) = Value
"up"

instance Data.Aeson.Types.FromJSON.FromJSON PriceTransformQuantity'Round' where
  parseJSON :: Value -> Parser PriceTransformQuantity'Round'
parseJSON Value
val =
    PriceTransformQuantity'Round'
-> Parser PriceTransformQuantity'Round'
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
"down" -> PriceTransformQuantity'Round'
PriceTransformQuantity'Round'EnumDown
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"up" -> PriceTransformQuantity'Round'
PriceTransformQuantity'Round'EnumUp
            | Bool
GHC.Base.otherwise -> Value -> PriceTransformQuantity'Round'
PriceTransformQuantity'Round'Other Value
val
      )

-- | Defines the enum schema located at @components.schemas.price.properties.type@ in the specification.
--
-- One of \`one_time\` or \`recurring\` depending on whether the price is for a one-time purchase or a recurring (subscription) purchase.
data PriceType'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    PriceType'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.
    PriceType'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"one_time"@
    PriceType'EnumOneTime
  | -- | Represents the JSON value @"recurring"@
    PriceType'EnumRecurring
  deriving (Int -> PriceType' -> ShowS
[PriceType'] -> ShowS
PriceType' -> String
(Int -> PriceType' -> ShowS)
-> (PriceType' -> String)
-> ([PriceType'] -> ShowS)
-> Show PriceType'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PriceType'] -> ShowS
$cshowList :: [PriceType'] -> ShowS
show :: PriceType' -> String
$cshow :: PriceType' -> String
showsPrec :: Int -> PriceType' -> ShowS
$cshowsPrec :: Int -> PriceType' -> ShowS
GHC.Show.Show, PriceType' -> PriceType' -> Bool
(PriceType' -> PriceType' -> Bool)
-> (PriceType' -> PriceType' -> Bool) -> Eq PriceType'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PriceType' -> PriceType' -> Bool
$c/= :: PriceType' -> PriceType' -> Bool
== :: PriceType' -> PriceType' -> Bool
$c== :: PriceType' -> PriceType' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PriceType' where
  toJSON :: PriceType' -> Value
toJSON (PriceType'Other Value
val) = Value
val
  toJSON (PriceType'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PriceType'
PriceType'EnumOneTime) = Value
"one_time"
  toJSON (PriceType'
PriceType'EnumRecurring) = Value
"recurring"

instance Data.Aeson.Types.FromJSON.FromJSON PriceType' where
  parseJSON :: Value -> Parser PriceType'
parseJSON Value
val =
    PriceType' -> Parser PriceType'
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
"one_time" -> PriceType'
PriceType'EnumOneTime
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"recurring" -> PriceType'
PriceType'EnumRecurring
            | Bool
GHC.Base.otherwise -> Value -> PriceType'
PriceType'Other Value
val
      )