{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Types.Recurring 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 Recurring = Recurring
{
Recurring -> Maybe RecurringAggregateUsage'
recurringAggregateUsage :: (GHC.Maybe.Maybe RecurringAggregateUsage'),
Recurring -> RecurringInterval'
recurringInterval :: RecurringInterval',
Recurring -> Int
recurringIntervalCount :: GHC.Types.Int,
Recurring -> RecurringUsageType'
recurringUsageType :: RecurringUsageType'
}
deriving
( Int -> Recurring -> ShowS
[Recurring] -> ShowS
Recurring -> String
(Int -> Recurring -> ShowS)
-> (Recurring -> String)
-> ([Recurring] -> ShowS)
-> Show Recurring
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Recurring] -> ShowS
$cshowList :: [Recurring] -> ShowS
show :: Recurring -> String
$cshow :: Recurring -> String
showsPrec :: Int -> Recurring -> ShowS
$cshowsPrec :: Int -> Recurring -> ShowS
GHC.Show.Show,
Recurring -> Recurring -> Bool
(Recurring -> Recurring -> Bool)
-> (Recurring -> Recurring -> Bool) -> Eq Recurring
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Recurring -> Recurring -> Bool
$c/= :: Recurring -> Recurring -> Bool
== :: Recurring -> Recurring -> Bool
$c== :: Recurring -> Recurring -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON Recurring where
toJSON :: Recurring -> Value
toJSON Recurring
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"aggregate_usage" Text -> Maybe RecurringAggregateUsage' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Recurring -> Maybe RecurringAggregateUsage'
recurringAggregateUsage Recurring
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"interval" Text -> RecurringInterval' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Recurring -> RecurringInterval'
recurringInterval Recurring
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"interval_count" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Recurring -> Int
recurringIntervalCount Recurring
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"usage_type" Text -> RecurringUsageType' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Recurring -> RecurringUsageType'
recurringUsageType Recurring
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: Recurring -> Encoding
toEncoding Recurring
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"aggregate_usage" Text -> Maybe RecurringAggregateUsage' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Recurring -> Maybe RecurringAggregateUsage'
recurringAggregateUsage Recurring
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"interval" Text -> RecurringInterval' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Recurring -> RecurringInterval'
recurringInterval Recurring
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"interval_count" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Recurring -> Int
recurringIntervalCount Recurring
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"usage_type" Text -> RecurringUsageType' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Recurring -> RecurringUsageType'
recurringUsageType Recurring
obj))))
instance Data.Aeson.Types.FromJSON.FromJSON Recurring where
parseJSON :: Value -> Parser Recurring
parseJSON = String -> (Object -> Parser Recurring) -> Value -> Parser Recurring
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Recurring" (\Object
obj -> ((((Maybe RecurringAggregateUsage'
-> RecurringInterval' -> Int -> RecurringUsageType' -> Recurring)
-> Parser
(Maybe RecurringAggregateUsage'
-> RecurringInterval' -> Int -> RecurringUsageType' -> Recurring)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe RecurringAggregateUsage'
-> RecurringInterval' -> Int -> RecurringUsageType' -> Recurring
Recurring Parser
(Maybe RecurringAggregateUsage'
-> RecurringInterval' -> Int -> RecurringUsageType' -> Recurring)
-> Parser (Maybe RecurringAggregateUsage')
-> Parser
(RecurringInterval' -> Int -> RecurringUsageType' -> Recurring)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe RecurringAggregateUsage')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"aggregate_usage")) Parser
(RecurringInterval' -> Int -> RecurringUsageType' -> Recurring)
-> Parser RecurringInterval'
-> Parser (Int -> RecurringUsageType' -> Recurring)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser RecurringInterval'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"interval")) Parser (Int -> RecurringUsageType' -> Recurring)
-> Parser Int -> Parser (RecurringUsageType' -> Recurring)
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
"interval_count")) Parser (RecurringUsageType' -> Recurring)
-> Parser RecurringUsageType' -> Parser Recurring
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser RecurringUsageType'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"usage_type"))
mkRecurring ::
RecurringInterval' ->
GHC.Types.Int ->
RecurringUsageType' ->
Recurring
mkRecurring :: RecurringInterval' -> Int -> RecurringUsageType' -> Recurring
mkRecurring RecurringInterval'
recurringInterval Int
recurringIntervalCount RecurringUsageType'
recurringUsageType =
Recurring :: Maybe RecurringAggregateUsage'
-> RecurringInterval' -> Int -> RecurringUsageType' -> Recurring
Recurring
{ recurringAggregateUsage :: Maybe RecurringAggregateUsage'
recurringAggregateUsage = Maybe RecurringAggregateUsage'
forall a. Maybe a
GHC.Maybe.Nothing,
recurringInterval :: RecurringInterval'
recurringInterval = RecurringInterval'
recurringInterval,
recurringIntervalCount :: Int
recurringIntervalCount = Int
recurringIntervalCount,
recurringUsageType :: RecurringUsageType'
recurringUsageType = RecurringUsageType'
recurringUsageType
}
data RecurringAggregateUsage'
=
RecurringAggregateUsage'Other Data.Aeson.Types.Internal.Value
|
RecurringAggregateUsage'Typed Data.Text.Internal.Text
|
RecurringAggregateUsage'EnumLastDuringPeriod
|
RecurringAggregateUsage'EnumLastEver
|
RecurringAggregateUsage'EnumMax
|
RecurringAggregateUsage'EnumSum
deriving (Int -> RecurringAggregateUsage' -> ShowS
[RecurringAggregateUsage'] -> ShowS
RecurringAggregateUsage' -> String
(Int -> RecurringAggregateUsage' -> ShowS)
-> (RecurringAggregateUsage' -> String)
-> ([RecurringAggregateUsage'] -> ShowS)
-> Show RecurringAggregateUsage'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecurringAggregateUsage'] -> ShowS
$cshowList :: [RecurringAggregateUsage'] -> ShowS
show :: RecurringAggregateUsage' -> String
$cshow :: RecurringAggregateUsage' -> String
showsPrec :: Int -> RecurringAggregateUsage' -> ShowS
$cshowsPrec :: Int -> RecurringAggregateUsage' -> ShowS
GHC.Show.Show, RecurringAggregateUsage' -> RecurringAggregateUsage' -> Bool
(RecurringAggregateUsage' -> RecurringAggregateUsage' -> Bool)
-> (RecurringAggregateUsage' -> RecurringAggregateUsage' -> Bool)
-> Eq RecurringAggregateUsage'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecurringAggregateUsage' -> RecurringAggregateUsage' -> Bool
$c/= :: RecurringAggregateUsage' -> RecurringAggregateUsage' -> Bool
== :: RecurringAggregateUsage' -> RecurringAggregateUsage' -> Bool
$c== :: RecurringAggregateUsage' -> RecurringAggregateUsage' -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON RecurringAggregateUsage' where
toJSON :: RecurringAggregateUsage' -> Value
toJSON (RecurringAggregateUsage'Other Value
val) = Value
val
toJSON (RecurringAggregateUsage'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (RecurringAggregateUsage'
RecurringAggregateUsage'EnumLastDuringPeriod) = Value
"last_during_period"
toJSON (RecurringAggregateUsage'
RecurringAggregateUsage'EnumLastEver) = Value
"last_ever"
toJSON (RecurringAggregateUsage'
RecurringAggregateUsage'EnumMax) = Value
"max"
toJSON (RecurringAggregateUsage'
RecurringAggregateUsage'EnumSum) = Value
"sum"
instance Data.Aeson.Types.FromJSON.FromJSON RecurringAggregateUsage' where
parseJSON :: Value -> Parser RecurringAggregateUsage'
parseJSON Value
val =
RecurringAggregateUsage' -> Parser RecurringAggregateUsage'
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" -> RecurringAggregateUsage'
RecurringAggregateUsage'EnumLastDuringPeriod
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"last_ever" -> RecurringAggregateUsage'
RecurringAggregateUsage'EnumLastEver
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"max" -> RecurringAggregateUsage'
RecurringAggregateUsage'EnumMax
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"sum" -> RecurringAggregateUsage'
RecurringAggregateUsage'EnumSum
| Bool
GHC.Base.otherwise -> Value -> RecurringAggregateUsage'
RecurringAggregateUsage'Other Value
val
)
data RecurringInterval'
=
RecurringInterval'Other Data.Aeson.Types.Internal.Value
|
RecurringInterval'Typed Data.Text.Internal.Text
|
RecurringInterval'EnumDay
|
RecurringInterval'EnumMonth
|
RecurringInterval'EnumWeek
|
RecurringInterval'EnumYear
deriving (Int -> RecurringInterval' -> ShowS
[RecurringInterval'] -> ShowS
RecurringInterval' -> String
(Int -> RecurringInterval' -> ShowS)
-> (RecurringInterval' -> String)
-> ([RecurringInterval'] -> ShowS)
-> Show RecurringInterval'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecurringInterval'] -> ShowS
$cshowList :: [RecurringInterval'] -> ShowS
show :: RecurringInterval' -> String
$cshow :: RecurringInterval' -> String
showsPrec :: Int -> RecurringInterval' -> ShowS
$cshowsPrec :: Int -> RecurringInterval' -> ShowS
GHC.Show.Show, RecurringInterval' -> RecurringInterval' -> Bool
(RecurringInterval' -> RecurringInterval' -> Bool)
-> (RecurringInterval' -> RecurringInterval' -> Bool)
-> Eq RecurringInterval'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecurringInterval' -> RecurringInterval' -> Bool
$c/= :: RecurringInterval' -> RecurringInterval' -> Bool
== :: RecurringInterval' -> RecurringInterval' -> Bool
$c== :: RecurringInterval' -> RecurringInterval' -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON RecurringInterval' where
toJSON :: RecurringInterval' -> Value
toJSON (RecurringInterval'Other Value
val) = Value
val
toJSON (RecurringInterval'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (RecurringInterval'
RecurringInterval'EnumDay) = Value
"day"
toJSON (RecurringInterval'
RecurringInterval'EnumMonth) = Value
"month"
toJSON (RecurringInterval'
RecurringInterval'EnumWeek) = Value
"week"
toJSON (RecurringInterval'
RecurringInterval'EnumYear) = Value
"year"
instance Data.Aeson.Types.FromJSON.FromJSON RecurringInterval' where
parseJSON :: Value -> Parser RecurringInterval'
parseJSON Value
val =
RecurringInterval' -> Parser RecurringInterval'
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" -> RecurringInterval'
RecurringInterval'EnumDay
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"month" -> RecurringInterval'
RecurringInterval'EnumMonth
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"week" -> RecurringInterval'
RecurringInterval'EnumWeek
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"year" -> RecurringInterval'
RecurringInterval'EnumYear
| Bool
GHC.Base.otherwise -> Value -> RecurringInterval'
RecurringInterval'Other Value
val
)
data RecurringUsageType'
=
RecurringUsageType'Other Data.Aeson.Types.Internal.Value
|
RecurringUsageType'Typed Data.Text.Internal.Text
|
RecurringUsageType'EnumLicensed
|
RecurringUsageType'EnumMetered
deriving (Int -> RecurringUsageType' -> ShowS
[RecurringUsageType'] -> ShowS
RecurringUsageType' -> String
(Int -> RecurringUsageType' -> ShowS)
-> (RecurringUsageType' -> String)
-> ([RecurringUsageType'] -> ShowS)
-> Show RecurringUsageType'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecurringUsageType'] -> ShowS
$cshowList :: [RecurringUsageType'] -> ShowS
show :: RecurringUsageType' -> String
$cshow :: RecurringUsageType' -> String
showsPrec :: Int -> RecurringUsageType' -> ShowS
$cshowsPrec :: Int -> RecurringUsageType' -> ShowS
GHC.Show.Show, RecurringUsageType' -> RecurringUsageType' -> Bool
(RecurringUsageType' -> RecurringUsageType' -> Bool)
-> (RecurringUsageType' -> RecurringUsageType' -> Bool)
-> Eq RecurringUsageType'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecurringUsageType' -> RecurringUsageType' -> Bool
$c/= :: RecurringUsageType' -> RecurringUsageType' -> Bool
== :: RecurringUsageType' -> RecurringUsageType' -> Bool
$c== :: RecurringUsageType' -> RecurringUsageType' -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON RecurringUsageType' where
toJSON :: RecurringUsageType' -> Value
toJSON (RecurringUsageType'Other Value
val) = Value
val
toJSON (RecurringUsageType'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (RecurringUsageType'
RecurringUsageType'EnumLicensed) = Value
"licensed"
toJSON (RecurringUsageType'
RecurringUsageType'EnumMetered) = Value
"metered"
instance Data.Aeson.Types.FromJSON.FromJSON RecurringUsageType' where
parseJSON :: Value -> Parser RecurringUsageType'
parseJSON Value
val =
RecurringUsageType' -> Parser RecurringUsageType'
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" -> RecurringUsageType'
RecurringUsageType'EnumLicensed
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"metered" -> RecurringUsageType'
RecurringUsageType'EnumMetered
| Bool
GHC.Base.otherwise -> Value -> RecurringUsageType'
RecurringUsageType'Other Value
val
)