{-# 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 SubscriptionItem
module StripeAPI.Types.SubscriptionItem 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.Price
import {-# SOURCE #-} StripeAPI.Types.SubscriptionItemBillingThresholds
import {-# SOURCE #-} StripeAPI.Types.TaxRate
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.subscription_item@ in the specification.
--
-- Subscription items allow you to create customer subscriptions with more than
-- one plan, making it easy to represent complex billing relationships.
data SubscriptionItem = SubscriptionItem
  { -- | billing_thresholds: Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period
    SubscriptionItem -> Maybe SubscriptionItemBillingThresholds'
subscriptionItemBillingThresholds :: (GHC.Maybe.Maybe SubscriptionItemBillingThresholds'),
    -- | created: Time at which the object was created. Measured in seconds since the Unix epoch.
    SubscriptionItem -> Int
subscriptionItemCreated :: GHC.Types.Int,
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    SubscriptionItem -> Text
subscriptionItemId :: 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.
    SubscriptionItem -> Object
subscriptionItemMetadata :: Data.Aeson.Types.Internal.Object,
    -- | price: 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).
    SubscriptionItem -> Price
subscriptionItemPrice :: Price,
    -- | quantity: The [quantity](https:\/\/stripe.com\/docs\/subscriptions\/quantities) of the plan to which the customer should be subscribed.
    SubscriptionItem -> Maybe Int
subscriptionItemQuantity :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | subscription: The \`subscription\` this \`subscription_item\` belongs to.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    SubscriptionItem -> Text
subscriptionItemSubscription :: Data.Text.Internal.Text,
    -- | tax_rates: The tax rates which apply to this \`subscription_item\`. When set, the \`default_tax_rates\` on the subscription do not apply to this \`subscription_item\`.
    SubscriptionItem -> Maybe [TaxRate]
subscriptionItemTaxRates :: (GHC.Maybe.Maybe ([TaxRate]))
  }
  deriving
    ( Int -> SubscriptionItem -> ShowS
[SubscriptionItem] -> ShowS
SubscriptionItem -> String
(Int -> SubscriptionItem -> ShowS)
-> (SubscriptionItem -> String)
-> ([SubscriptionItem] -> ShowS)
-> Show SubscriptionItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubscriptionItem] -> ShowS
$cshowList :: [SubscriptionItem] -> ShowS
show :: SubscriptionItem -> String
$cshow :: SubscriptionItem -> String
showsPrec :: Int -> SubscriptionItem -> ShowS
$cshowsPrec :: Int -> SubscriptionItem -> ShowS
GHC.Show.Show,
      SubscriptionItem -> SubscriptionItem -> Bool
(SubscriptionItem -> SubscriptionItem -> Bool)
-> (SubscriptionItem -> SubscriptionItem -> Bool)
-> Eq SubscriptionItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubscriptionItem -> SubscriptionItem -> Bool
$c/= :: SubscriptionItem -> SubscriptionItem -> Bool
== :: SubscriptionItem -> SubscriptionItem -> Bool
$c== :: SubscriptionItem -> SubscriptionItem -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON SubscriptionItem where
  toJSON :: SubscriptionItem -> Value
toJSON SubscriptionItem
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"billing_thresholds" Text -> Maybe SubscriptionItemBillingThresholds' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionItem -> Maybe SubscriptionItemBillingThresholds'
subscriptionItemBillingThresholds SubscriptionItem
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..= SubscriptionItem -> Int
subscriptionItemCreated SubscriptionItem
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..= SubscriptionItem -> Text
subscriptionItemId SubscriptionItem
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..= SubscriptionItem -> Object
subscriptionItemMetadata SubscriptionItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"price" Text -> Price -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionItem -> Price
subscriptionItemPrice SubscriptionItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"quantity" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionItem -> Maybe Int
subscriptionItemQuantity SubscriptionItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"subscription" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionItem -> Text
subscriptionItemSubscription SubscriptionItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"tax_rates" Text -> Maybe [TaxRate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionItem -> Maybe [TaxRate]
subscriptionItemTaxRates SubscriptionItem
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
"subscription_item" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: SubscriptionItem -> Encoding
toEncoding SubscriptionItem
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"billing_thresholds" Text -> Maybe SubscriptionItemBillingThresholds' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionItem -> Maybe SubscriptionItemBillingThresholds'
subscriptionItemBillingThresholds SubscriptionItem
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..= SubscriptionItem -> Int
subscriptionItemCreated SubscriptionItem
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..= SubscriptionItem -> Text
subscriptionItemId SubscriptionItem
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..= SubscriptionItem -> Object
subscriptionItemMetadata SubscriptionItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"price" Text -> Price -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionItem -> Price
subscriptionItemPrice SubscriptionItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"quantity" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionItem -> Maybe Int
subscriptionItemQuantity SubscriptionItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"subscription" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionItem -> Text
subscriptionItemSubscription SubscriptionItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"tax_rates" Text -> Maybe [TaxRate] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionItem -> Maybe [TaxRate]
subscriptionItemTaxRates SubscriptionItem
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
"subscription_item")))))))))

instance Data.Aeson.Types.FromJSON.FromJSON SubscriptionItem where
  parseJSON :: Value -> Parser SubscriptionItem
parseJSON = String
-> (Object -> Parser SubscriptionItem)
-> Value
-> Parser SubscriptionItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SubscriptionItem" (\Object
obj -> ((((((((Maybe SubscriptionItemBillingThresholds'
 -> Int
 -> Text
 -> Object
 -> Price
 -> Maybe Int
 -> Text
 -> Maybe [TaxRate]
 -> SubscriptionItem)
-> Parser
     (Maybe SubscriptionItemBillingThresholds'
      -> Int
      -> Text
      -> Object
      -> Price
      -> Maybe Int
      -> Text
      -> Maybe [TaxRate]
      -> SubscriptionItem)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe SubscriptionItemBillingThresholds'
-> Int
-> Text
-> Object
-> Price
-> Maybe Int
-> Text
-> Maybe [TaxRate]
-> SubscriptionItem
SubscriptionItem Parser
  (Maybe SubscriptionItemBillingThresholds'
   -> Int
   -> Text
   -> Object
   -> Price
   -> Maybe Int
   -> Text
   -> Maybe [TaxRate]
   -> SubscriptionItem)
-> Parser (Maybe SubscriptionItemBillingThresholds')
-> Parser
     (Int
      -> Text
      -> Object
      -> Price
      -> Maybe Int
      -> Text
      -> Maybe [TaxRate]
      -> SubscriptionItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe SubscriptionItemBillingThresholds')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"billing_thresholds")) Parser
  (Int
   -> Text
   -> Object
   -> Price
   -> Maybe Int
   -> Text
   -> Maybe [TaxRate]
   -> SubscriptionItem)
-> Parser Int
-> Parser
     (Text
      -> Object
      -> Price
      -> Maybe Int
      -> Text
      -> Maybe [TaxRate]
      -> SubscriptionItem)
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
   -> Object
   -> Price
   -> Maybe Int
   -> Text
   -> Maybe [TaxRate]
   -> SubscriptionItem)
-> Parser Text
-> Parser
     (Object
      -> Price
      -> Maybe Int
      -> Text
      -> Maybe [TaxRate]
      -> SubscriptionItem)
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
  (Object
   -> Price
   -> Maybe Int
   -> Text
   -> Maybe [TaxRate]
   -> SubscriptionItem)
-> Parser Object
-> Parser
     (Price -> Maybe Int -> Text -> Maybe [TaxRate] -> SubscriptionItem)
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
  (Price -> Maybe Int -> Text -> Maybe [TaxRate] -> SubscriptionItem)
-> Parser Price
-> Parser
     (Maybe Int -> Text -> Maybe [TaxRate] -> SubscriptionItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Price
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"price")) Parser (Maybe Int -> Text -> Maybe [TaxRate] -> SubscriptionItem)
-> Parser (Maybe Int)
-> Parser (Text -> Maybe [TaxRate] -> SubscriptionItem)
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
"quantity")) Parser (Text -> Maybe [TaxRate] -> SubscriptionItem)
-> Parser Text -> Parser (Maybe [TaxRate] -> SubscriptionItem)
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
"subscription")) Parser (Maybe [TaxRate] -> SubscriptionItem)
-> Parser (Maybe [TaxRate]) -> Parser SubscriptionItem
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe [TaxRate])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"tax_rates"))

-- | Create a new 'SubscriptionItem' with all required fields.
mkSubscriptionItem ::
  -- | 'subscriptionItemCreated'
  GHC.Types.Int ->
  -- | 'subscriptionItemId'
  Data.Text.Internal.Text ->
  -- | 'subscriptionItemMetadata'
  Data.Aeson.Types.Internal.Object ->
  -- | 'subscriptionItemPrice'
  Price ->
  -- | 'subscriptionItemSubscription'
  Data.Text.Internal.Text ->
  SubscriptionItem
mkSubscriptionItem :: Int -> Text -> Object -> Price -> Text -> SubscriptionItem
mkSubscriptionItem Int
subscriptionItemCreated Text
subscriptionItemId Object
subscriptionItemMetadata Price
subscriptionItemPrice Text
subscriptionItemSubscription =
  SubscriptionItem :: Maybe SubscriptionItemBillingThresholds'
-> Int
-> Text
-> Object
-> Price
-> Maybe Int
-> Text
-> Maybe [TaxRate]
-> SubscriptionItem
SubscriptionItem
    { subscriptionItemBillingThresholds :: Maybe SubscriptionItemBillingThresholds'
subscriptionItemBillingThresholds = Maybe SubscriptionItemBillingThresholds'
forall a. Maybe a
GHC.Maybe.Nothing,
      subscriptionItemCreated :: Int
subscriptionItemCreated = Int
subscriptionItemCreated,
      subscriptionItemId :: Text
subscriptionItemId = Text
subscriptionItemId,
      subscriptionItemMetadata :: Object
subscriptionItemMetadata = Object
subscriptionItemMetadata,
      subscriptionItemPrice :: Price
subscriptionItemPrice = Price
subscriptionItemPrice,
      subscriptionItemQuantity :: Maybe Int
subscriptionItemQuantity = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      subscriptionItemSubscription :: Text
subscriptionItemSubscription = Text
subscriptionItemSubscription,
      subscriptionItemTaxRates :: Maybe [TaxRate]
subscriptionItemTaxRates = Maybe [TaxRate]
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the object schema located at @components.schemas.subscription_item.properties.billing_thresholds.anyOf@ in the specification.
--
-- Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period
data SubscriptionItemBillingThresholds' = SubscriptionItemBillingThresholds'
  { -- | usage_gte: Usage threshold that triggers the subscription to create an invoice
    SubscriptionItemBillingThresholds' -> Maybe Int
subscriptionItemBillingThresholds'UsageGte :: (GHC.Maybe.Maybe GHC.Types.Int)
  }
  deriving
    ( Int -> SubscriptionItemBillingThresholds' -> ShowS
[SubscriptionItemBillingThresholds'] -> ShowS
SubscriptionItemBillingThresholds' -> String
(Int -> SubscriptionItemBillingThresholds' -> ShowS)
-> (SubscriptionItemBillingThresholds' -> String)
-> ([SubscriptionItemBillingThresholds'] -> ShowS)
-> Show SubscriptionItemBillingThresholds'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubscriptionItemBillingThresholds'] -> ShowS
$cshowList :: [SubscriptionItemBillingThresholds'] -> ShowS
show :: SubscriptionItemBillingThresholds' -> String
$cshow :: SubscriptionItemBillingThresholds' -> String
showsPrec :: Int -> SubscriptionItemBillingThresholds' -> ShowS
$cshowsPrec :: Int -> SubscriptionItemBillingThresholds' -> ShowS
GHC.Show.Show,
      SubscriptionItemBillingThresholds'
-> SubscriptionItemBillingThresholds' -> Bool
(SubscriptionItemBillingThresholds'
 -> SubscriptionItemBillingThresholds' -> Bool)
-> (SubscriptionItemBillingThresholds'
    -> SubscriptionItemBillingThresholds' -> Bool)
-> Eq SubscriptionItemBillingThresholds'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubscriptionItemBillingThresholds'
-> SubscriptionItemBillingThresholds' -> Bool
$c/= :: SubscriptionItemBillingThresholds'
-> SubscriptionItemBillingThresholds' -> Bool
== :: SubscriptionItemBillingThresholds'
-> SubscriptionItemBillingThresholds' -> Bool
$c== :: SubscriptionItemBillingThresholds'
-> SubscriptionItemBillingThresholds' -> Bool
GHC.Classes.Eq
    )

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

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

-- | Create a new 'SubscriptionItemBillingThresholds'' with all required fields.
mkSubscriptionItemBillingThresholds' :: SubscriptionItemBillingThresholds'
mkSubscriptionItemBillingThresholds' :: SubscriptionItemBillingThresholds'
mkSubscriptionItemBillingThresholds' = SubscriptionItemBillingThresholds' :: Maybe Int -> SubscriptionItemBillingThresholds'
SubscriptionItemBillingThresholds' {subscriptionItemBillingThresholds'UsageGte :: Maybe Int
subscriptionItemBillingThresholds'UsageGte = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing}