{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Types.PortalSubscriptionCancel 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 PortalSubscriptionCancel = PortalSubscriptionCancel
{
PortalSubscriptionCancel -> Bool
portalSubscriptionCancelEnabled :: GHC.Types.Bool,
PortalSubscriptionCancel -> PortalSubscriptionCancelMode'
portalSubscriptionCancelMode :: PortalSubscriptionCancelMode',
PortalSubscriptionCancel
-> PortalSubscriptionCancelProrationBehavior'
portalSubscriptionCancelProrationBehavior :: PortalSubscriptionCancelProrationBehavior'
}
deriving
( Int -> PortalSubscriptionCancel -> ShowS
[PortalSubscriptionCancel] -> ShowS
PortalSubscriptionCancel -> String
(Int -> PortalSubscriptionCancel -> ShowS)
-> (PortalSubscriptionCancel -> String)
-> ([PortalSubscriptionCancel] -> ShowS)
-> Show PortalSubscriptionCancel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortalSubscriptionCancel] -> ShowS
$cshowList :: [PortalSubscriptionCancel] -> ShowS
show :: PortalSubscriptionCancel -> String
$cshow :: PortalSubscriptionCancel -> String
showsPrec :: Int -> PortalSubscriptionCancel -> ShowS
$cshowsPrec :: Int -> PortalSubscriptionCancel -> ShowS
GHC.Show.Show,
PortalSubscriptionCancel -> PortalSubscriptionCancel -> Bool
(PortalSubscriptionCancel -> PortalSubscriptionCancel -> Bool)
-> (PortalSubscriptionCancel -> PortalSubscriptionCancel -> Bool)
-> Eq PortalSubscriptionCancel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortalSubscriptionCancel -> PortalSubscriptionCancel -> Bool
$c/= :: PortalSubscriptionCancel -> PortalSubscriptionCancel -> Bool
== :: PortalSubscriptionCancel -> PortalSubscriptionCancel -> Bool
$c== :: PortalSubscriptionCancel -> PortalSubscriptionCancel -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON PortalSubscriptionCancel where
toJSON :: PortalSubscriptionCancel -> Value
toJSON PortalSubscriptionCancel
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalSubscriptionCancel -> Bool
portalSubscriptionCancelEnabled PortalSubscriptionCancel
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"mode" Text -> PortalSubscriptionCancelMode' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalSubscriptionCancel -> PortalSubscriptionCancelMode'
portalSubscriptionCancelMode PortalSubscriptionCancel
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"proration_behavior" Text -> PortalSubscriptionCancelProrationBehavior' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalSubscriptionCancel
-> PortalSubscriptionCancelProrationBehavior'
portalSubscriptionCancelProrationBehavior PortalSubscriptionCancel
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: PortalSubscriptionCancel -> Encoding
toEncoding PortalSubscriptionCancel
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"enabled" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalSubscriptionCancel -> Bool
portalSubscriptionCancelEnabled PortalSubscriptionCancel
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"mode" Text -> PortalSubscriptionCancelMode' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalSubscriptionCancel -> PortalSubscriptionCancelMode'
portalSubscriptionCancelMode PortalSubscriptionCancel
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"proration_behavior" Text -> PortalSubscriptionCancelProrationBehavior' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PortalSubscriptionCancel
-> PortalSubscriptionCancelProrationBehavior'
portalSubscriptionCancelProrationBehavior PortalSubscriptionCancel
obj)))
instance Data.Aeson.Types.FromJSON.FromJSON PortalSubscriptionCancel where
parseJSON :: Value -> Parser PortalSubscriptionCancel
parseJSON = String
-> (Object -> Parser PortalSubscriptionCancel)
-> Value
-> Parser PortalSubscriptionCancel
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PortalSubscriptionCancel" (\Object
obj -> (((Bool
-> PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancel)
-> Parser
(Bool
-> PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancel)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Bool
-> PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancel
PortalSubscriptionCancel Parser
(Bool
-> PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancel)
-> Parser Bool
-> Parser
(PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancel)
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
"enabled")) Parser
(PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancel)
-> Parser PortalSubscriptionCancelMode'
-> Parser
(PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancel)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PortalSubscriptionCancelMode'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"mode")) Parser
(PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancel)
-> Parser PortalSubscriptionCancelProrationBehavior'
-> Parser PortalSubscriptionCancel
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser PortalSubscriptionCancelProrationBehavior'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"proration_behavior"))
mkPortalSubscriptionCancel ::
GHC.Types.Bool ->
PortalSubscriptionCancelMode' ->
PortalSubscriptionCancelProrationBehavior' ->
PortalSubscriptionCancel
mkPortalSubscriptionCancel :: Bool
-> PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancel
mkPortalSubscriptionCancel Bool
portalSubscriptionCancelEnabled PortalSubscriptionCancelMode'
portalSubscriptionCancelMode PortalSubscriptionCancelProrationBehavior'
portalSubscriptionCancelProrationBehavior =
PortalSubscriptionCancel :: Bool
-> PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancel
PortalSubscriptionCancel
{ portalSubscriptionCancelEnabled :: Bool
portalSubscriptionCancelEnabled = Bool
portalSubscriptionCancelEnabled,
portalSubscriptionCancelMode :: PortalSubscriptionCancelMode'
portalSubscriptionCancelMode = PortalSubscriptionCancelMode'
portalSubscriptionCancelMode,
portalSubscriptionCancelProrationBehavior :: PortalSubscriptionCancelProrationBehavior'
portalSubscriptionCancelProrationBehavior = PortalSubscriptionCancelProrationBehavior'
portalSubscriptionCancelProrationBehavior
}
data PortalSubscriptionCancelMode'
=
PortalSubscriptionCancelMode'Other Data.Aeson.Types.Internal.Value
|
PortalSubscriptionCancelMode'Typed Data.Text.Internal.Text
|
PortalSubscriptionCancelMode'EnumAtPeriodEnd
|
PortalSubscriptionCancelMode'EnumImmediately
deriving (Int -> PortalSubscriptionCancelMode' -> ShowS
[PortalSubscriptionCancelMode'] -> ShowS
PortalSubscriptionCancelMode' -> String
(Int -> PortalSubscriptionCancelMode' -> ShowS)
-> (PortalSubscriptionCancelMode' -> String)
-> ([PortalSubscriptionCancelMode'] -> ShowS)
-> Show PortalSubscriptionCancelMode'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortalSubscriptionCancelMode'] -> ShowS
$cshowList :: [PortalSubscriptionCancelMode'] -> ShowS
show :: PortalSubscriptionCancelMode' -> String
$cshow :: PortalSubscriptionCancelMode' -> String
showsPrec :: Int -> PortalSubscriptionCancelMode' -> ShowS
$cshowsPrec :: Int -> PortalSubscriptionCancelMode' -> ShowS
GHC.Show.Show, PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelMode' -> Bool
(PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelMode' -> Bool)
-> (PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelMode' -> Bool)
-> Eq PortalSubscriptionCancelMode'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelMode' -> Bool
$c/= :: PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelMode' -> Bool
== :: PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelMode' -> Bool
$c== :: PortalSubscriptionCancelMode'
-> PortalSubscriptionCancelMode' -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON PortalSubscriptionCancelMode' where
toJSON :: PortalSubscriptionCancelMode' -> Value
toJSON (PortalSubscriptionCancelMode'Other Value
val) = Value
val
toJSON (PortalSubscriptionCancelMode'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (PortalSubscriptionCancelMode'
PortalSubscriptionCancelMode'EnumAtPeriodEnd) = Value
"at_period_end"
toJSON (PortalSubscriptionCancelMode'
PortalSubscriptionCancelMode'EnumImmediately) = Value
"immediately"
instance Data.Aeson.Types.FromJSON.FromJSON PortalSubscriptionCancelMode' where
parseJSON :: Value -> Parser PortalSubscriptionCancelMode'
parseJSON Value
val =
PortalSubscriptionCancelMode'
-> Parser PortalSubscriptionCancelMode'
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure
( if
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"at_period_end" -> PortalSubscriptionCancelMode'
PortalSubscriptionCancelMode'EnumAtPeriodEnd
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"immediately" -> PortalSubscriptionCancelMode'
PortalSubscriptionCancelMode'EnumImmediately
| Bool
GHC.Base.otherwise -> Value -> PortalSubscriptionCancelMode'
PortalSubscriptionCancelMode'Other Value
val
)
data PortalSubscriptionCancelProrationBehavior'
=
PortalSubscriptionCancelProrationBehavior'Other Data.Aeson.Types.Internal.Value
|
PortalSubscriptionCancelProrationBehavior'Typed Data.Text.Internal.Text
|
PortalSubscriptionCancelProrationBehavior'EnumAlwaysInvoice
|
PortalSubscriptionCancelProrationBehavior'EnumCreateProrations
|
PortalSubscriptionCancelProrationBehavior'EnumNone
deriving (Int -> PortalSubscriptionCancelProrationBehavior' -> ShowS
[PortalSubscriptionCancelProrationBehavior'] -> ShowS
PortalSubscriptionCancelProrationBehavior' -> String
(Int -> PortalSubscriptionCancelProrationBehavior' -> ShowS)
-> (PortalSubscriptionCancelProrationBehavior' -> String)
-> ([PortalSubscriptionCancelProrationBehavior'] -> ShowS)
-> Show PortalSubscriptionCancelProrationBehavior'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortalSubscriptionCancelProrationBehavior'] -> ShowS
$cshowList :: [PortalSubscriptionCancelProrationBehavior'] -> ShowS
show :: PortalSubscriptionCancelProrationBehavior' -> String
$cshow :: PortalSubscriptionCancelProrationBehavior' -> String
showsPrec :: Int -> PortalSubscriptionCancelProrationBehavior' -> ShowS
$cshowsPrec :: Int -> PortalSubscriptionCancelProrationBehavior' -> ShowS
GHC.Show.Show, PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancelProrationBehavior' -> Bool
(PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancelProrationBehavior' -> Bool)
-> (PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancelProrationBehavior' -> Bool)
-> Eq PortalSubscriptionCancelProrationBehavior'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancelProrationBehavior' -> Bool
$c/= :: PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancelProrationBehavior' -> Bool
== :: PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancelProrationBehavior' -> Bool
$c== :: PortalSubscriptionCancelProrationBehavior'
-> PortalSubscriptionCancelProrationBehavior' -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON PortalSubscriptionCancelProrationBehavior' where
toJSON :: PortalSubscriptionCancelProrationBehavior' -> Value
toJSON (PortalSubscriptionCancelProrationBehavior'Other Value
val) = Value
val
toJSON (PortalSubscriptionCancelProrationBehavior'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (PortalSubscriptionCancelProrationBehavior'
PortalSubscriptionCancelProrationBehavior'EnumAlwaysInvoice) = Value
"always_invoice"
toJSON (PortalSubscriptionCancelProrationBehavior'
PortalSubscriptionCancelProrationBehavior'EnumCreateProrations) = Value
"create_prorations"
toJSON (PortalSubscriptionCancelProrationBehavior'
PortalSubscriptionCancelProrationBehavior'EnumNone) = Value
"none"
instance Data.Aeson.Types.FromJSON.FromJSON PortalSubscriptionCancelProrationBehavior' where
parseJSON :: Value -> Parser PortalSubscriptionCancelProrationBehavior'
parseJSON Value
val =
PortalSubscriptionCancelProrationBehavior'
-> Parser PortalSubscriptionCancelProrationBehavior'
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
"always_invoice" -> PortalSubscriptionCancelProrationBehavior'
PortalSubscriptionCancelProrationBehavior'EnumAlwaysInvoice
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"create_prorations" -> PortalSubscriptionCancelProrationBehavior'
PortalSubscriptionCancelProrationBehavior'EnumCreateProrations
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"none" -> PortalSubscriptionCancelProrationBehavior'
PortalSubscriptionCancelProrationBehavior'EnumNone
| Bool
GHC.Base.otherwise -> Value -> PortalSubscriptionCancelProrationBehavior'
PortalSubscriptionCancelProrationBehavior'Other Value
val
)