{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Types.SubscriptionBillingThresholds where
import qualified Control.Monad.Fail
import qualified Data.Aeson
import qualified Data.Aeson as Data.Aeson.Encoding.Internal
import qualified Data.Aeson as Data.Aeson.Types
import qualified Data.Aeson as Data.Aeson.Types.FromJSON
import qualified Data.Aeson as Data.Aeson.Types.Internal
import qualified Data.Aeson as Data.Aeson.Types.ToJSON
import qualified Data.ByteString.Char8
import qualified Data.ByteString.Char8 as Data.ByteString.Internal
import qualified Data.Functor
import qualified Data.Scientific
import qualified Data.Text
import qualified Data.Text.Internal
import qualified Data.Time.Calendar as Data.Time.Calendar.Days
import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime
import qualified GHC.Base
import qualified GHC.Classes
import qualified GHC.Int
import qualified GHC.Show
import qualified GHC.Types
import qualified StripeAPI.Common
import StripeAPI.TypeAlias
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
data SubscriptionBillingThresholds = SubscriptionBillingThresholds
{
SubscriptionBillingThresholds -> Maybe Int
subscriptionBillingThresholdsAmountGte :: (GHC.Maybe.Maybe GHC.Types.Int),
SubscriptionBillingThresholds -> Maybe Bool
subscriptionBillingThresholdsResetBillingCycleAnchor :: (GHC.Maybe.Maybe GHC.Types.Bool)
}
deriving
( Int -> SubscriptionBillingThresholds -> ShowS
[SubscriptionBillingThresholds] -> ShowS
SubscriptionBillingThresholds -> String
(Int -> SubscriptionBillingThresholds -> ShowS)
-> (SubscriptionBillingThresholds -> String)
-> ([SubscriptionBillingThresholds] -> ShowS)
-> Show SubscriptionBillingThresholds
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubscriptionBillingThresholds] -> ShowS
$cshowList :: [SubscriptionBillingThresholds] -> ShowS
show :: SubscriptionBillingThresholds -> String
$cshow :: SubscriptionBillingThresholds -> String
showsPrec :: Int -> SubscriptionBillingThresholds -> ShowS
$cshowsPrec :: Int -> SubscriptionBillingThresholds -> ShowS
GHC.Show.Show,
SubscriptionBillingThresholds
-> SubscriptionBillingThresholds -> Bool
(SubscriptionBillingThresholds
-> SubscriptionBillingThresholds -> Bool)
-> (SubscriptionBillingThresholds
-> SubscriptionBillingThresholds -> Bool)
-> Eq SubscriptionBillingThresholds
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubscriptionBillingThresholds
-> SubscriptionBillingThresholds -> Bool
$c/= :: SubscriptionBillingThresholds
-> SubscriptionBillingThresholds -> Bool
== :: SubscriptionBillingThresholds
-> SubscriptionBillingThresholds -> Bool
$c== :: SubscriptionBillingThresholds
-> SubscriptionBillingThresholds -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON SubscriptionBillingThresholds where
toJSON :: SubscriptionBillingThresholds -> Value
toJSON SubscriptionBillingThresholds
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"amount_gte" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionBillingThresholds -> Maybe Int
subscriptionBillingThresholdsAmountGte SubscriptionBillingThresholds
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"reset_billing_cycle_anchor" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionBillingThresholds -> Maybe Bool
subscriptionBillingThresholdsResetBillingCycleAnchor SubscriptionBillingThresholds
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: SubscriptionBillingThresholds -> Encoding
toEncoding SubscriptionBillingThresholds
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"amount_gte" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionBillingThresholds -> Maybe Int
subscriptionBillingThresholdsAmountGte SubscriptionBillingThresholds
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"reset_billing_cycle_anchor" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SubscriptionBillingThresholds -> Maybe Bool
subscriptionBillingThresholdsResetBillingCycleAnchor SubscriptionBillingThresholds
obj))
instance Data.Aeson.Types.FromJSON.FromJSON SubscriptionBillingThresholds where
parseJSON :: Value -> Parser SubscriptionBillingThresholds
parseJSON = String
-> (Object -> Parser SubscriptionBillingThresholds)
-> Value
-> Parser SubscriptionBillingThresholds
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SubscriptionBillingThresholds" (\Object
obj -> ((Maybe Int -> Maybe Bool -> SubscriptionBillingThresholds)
-> Parser
(Maybe Int -> Maybe Bool -> SubscriptionBillingThresholds)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Int -> Maybe Bool -> SubscriptionBillingThresholds
SubscriptionBillingThresholds Parser (Maybe Int -> Maybe Bool -> SubscriptionBillingThresholds)
-> Parser (Maybe Int)
-> Parser (Maybe Bool -> SubscriptionBillingThresholds)
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
"amount_gte")) Parser (Maybe Bool -> SubscriptionBillingThresholds)
-> Parser (Maybe Bool) -> Parser SubscriptionBillingThresholds
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"reset_billing_cycle_anchor"))
mkSubscriptionBillingThresholds :: SubscriptionBillingThresholds
mkSubscriptionBillingThresholds :: SubscriptionBillingThresholds
mkSubscriptionBillingThresholds =
SubscriptionBillingThresholds :: Maybe Int -> Maybe Bool -> SubscriptionBillingThresholds
SubscriptionBillingThresholds
{ subscriptionBillingThresholdsAmountGte :: Maybe Int
subscriptionBillingThresholdsAmountGte = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
subscriptionBillingThresholdsResetBillingCycleAnchor :: Maybe Bool
subscriptionBillingThresholdsResetBillingCycleAnchor = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing
}