{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Types.Coupon 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.CouponAppliesTo
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
data Coupon = Coupon
{
Coupon -> Maybe Int
couponAmountOff :: (GHC.Maybe.Maybe GHC.Types.Int),
Coupon -> Maybe CouponAppliesTo
couponAppliesTo :: (GHC.Maybe.Maybe CouponAppliesTo),
Coupon -> Int
couponCreated :: GHC.Types.Int,
Coupon -> Maybe Text
couponCurrency :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
Coupon -> CouponDuration'
couponDuration :: CouponDuration',
Coupon -> Maybe Int
couponDurationInMonths :: (GHC.Maybe.Maybe GHC.Types.Int),
Coupon -> Text
couponId :: Data.Text.Internal.Text,
Coupon -> Bool
couponLivemode :: GHC.Types.Bool,
Coupon -> Maybe Int
couponMaxRedemptions :: (GHC.Maybe.Maybe GHC.Types.Int),
Coupon -> Maybe Object
couponMetadata :: (GHC.Maybe.Maybe Data.Aeson.Types.Internal.Object),
Coupon -> Maybe Text
couponName :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
Coupon -> Maybe Double
couponPercentOff :: (GHC.Maybe.Maybe GHC.Types.Double),
Coupon -> Maybe Int
couponRedeemBy :: (GHC.Maybe.Maybe GHC.Types.Int),
Coupon -> Int
couponTimesRedeemed :: GHC.Types.Int,
Coupon -> Bool
couponValid :: GHC.Types.Bool
}
deriving
( Int -> Coupon -> ShowS
[Coupon] -> ShowS
Coupon -> String
(Int -> Coupon -> ShowS)
-> (Coupon -> String) -> ([Coupon] -> ShowS) -> Show Coupon
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Coupon] -> ShowS
$cshowList :: [Coupon] -> ShowS
show :: Coupon -> String
$cshow :: Coupon -> String
showsPrec :: Int -> Coupon -> ShowS
$cshowsPrec :: Int -> Coupon -> ShowS
GHC.Show.Show,
Coupon -> Coupon -> Bool
(Coupon -> Coupon -> Bool)
-> (Coupon -> Coupon -> Bool) -> Eq Coupon
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Coupon -> Coupon -> Bool
$c/= :: Coupon -> Coupon -> Bool
== :: Coupon -> Coupon -> Bool
$c== :: Coupon -> Coupon -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON Coupon where
toJSON :: Coupon -> Value
toJSON Coupon
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"amount_off" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Int
couponAmountOff Coupon
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"applies_to" Text -> Maybe CouponAppliesTo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe CouponAppliesTo
couponAppliesTo Coupon
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..= Coupon -> Int
couponCreated Coupon
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"currency" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Text
couponCurrency Coupon
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"duration" Text -> CouponDuration' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> CouponDuration'
couponDuration Coupon
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"duration_in_months" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Int
couponDurationInMonths Coupon
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..= Coupon -> Text
couponId Coupon
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..= Coupon -> Bool
couponLivemode Coupon
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"max_redemptions" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Int
couponMaxRedemptions Coupon
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Maybe Object -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Object
couponMetadata Coupon
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"name" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Text
couponName Coupon
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"percent_off" Text -> Maybe Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Double
couponPercentOff Coupon
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"redeem_by" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Int
couponRedeemBy Coupon
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"times_redeemed" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Int
couponTimesRedeemed Coupon
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"valid" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Bool
couponValid Coupon
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
"coupon" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: Coupon -> Encoding
toEncoding Coupon
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"amount_off" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Int
couponAmountOff Coupon
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"applies_to" Text -> Maybe CouponAppliesTo -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe CouponAppliesTo
couponAppliesTo Coupon
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..= Coupon -> Int
couponCreated Coupon
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"currency" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Text
couponCurrency Coupon
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"duration" Text -> CouponDuration' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> CouponDuration'
couponDuration Coupon
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"duration_in_months" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Int
couponDurationInMonths Coupon
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..= Coupon -> Text
couponId Coupon
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..= Coupon -> Bool
couponLivemode Coupon
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"max_redemptions" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Int
couponMaxRedemptions Coupon
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text -> Maybe Object -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Object
couponMetadata Coupon
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"name" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Text
couponName Coupon
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"percent_off" Text -> Maybe Double -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Double
couponPercentOff Coupon
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"redeem_by" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Maybe Int
couponRedeemBy Coupon
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"times_redeemed" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Int
couponTimesRedeemed Coupon
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"valid" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Coupon -> Bool
couponValid Coupon
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
"coupon"))))))))))))))))
instance Data.Aeson.Types.FromJSON.FromJSON Coupon where
parseJSON :: Value -> Parser Coupon
parseJSON = String -> (Object -> Parser Coupon) -> Value -> Parser Coupon
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Coupon" (\Object
obj -> (((((((((((((((Maybe Int
-> Maybe CouponAppliesTo
-> Int
-> Maybe Text
-> CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
-> Parser
(Maybe Int
-> Maybe CouponAppliesTo
-> Int
-> Maybe Text
-> CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Int
-> Maybe CouponAppliesTo
-> Int
-> Maybe Text
-> CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon
Coupon Parser
(Maybe Int
-> Maybe CouponAppliesTo
-> Int
-> Maybe Text
-> CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
-> Parser (Maybe Int)
-> Parser
(Maybe CouponAppliesTo
-> Int
-> Maybe Text
-> CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
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_off")) Parser
(Maybe CouponAppliesTo
-> Int
-> Maybe Text
-> CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
-> Parser (Maybe CouponAppliesTo)
-> Parser
(Int
-> Maybe Text
-> CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe CouponAppliesTo)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"applies_to")) Parser
(Int
-> Maybe Text
-> CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
-> Parser Int
-> Parser
(Maybe Text
-> CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
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
(Maybe Text
-> CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
-> Parser (Maybe Text)
-> Parser
(CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
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
"currency")) Parser
(CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
-> Parser CouponDuration'
-> Parser
(Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser CouponDuration'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"duration")) Parser
(Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
-> Parser (Maybe Int)
-> Parser
(Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
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
"duration_in_months")) Parser
(Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
-> Parser Text
-> Parser
(Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
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 Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
-> Parser Bool
-> Parser
(Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
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 Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
-> Parser (Maybe Int)
-> Parser
(Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
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
"max_redemptions")) Parser
(Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon)
-> Parser (Maybe Object)
-> Parser
(Maybe Text -> Maybe Double -> Maybe Int -> Int -> Bool -> Coupon)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Object)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"metadata")) Parser
(Maybe Text -> Maybe Double -> Maybe Int -> Int -> Bool -> Coupon)
-> Parser (Maybe Text)
-> Parser (Maybe Double -> Maybe Int -> Int -> Bool -> Coupon)
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
"name")) Parser (Maybe Double -> Maybe Int -> Int -> Bool -> Coupon)
-> Parser (Maybe Double)
-> Parser (Maybe Int -> Int -> Bool -> Coupon)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"percent_off")) Parser (Maybe Int -> Int -> Bool -> Coupon)
-> Parser (Maybe Int) -> Parser (Int -> Bool -> Coupon)
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
"redeem_by")) Parser (Int -> Bool -> Coupon)
-> Parser Int -> Parser (Bool -> Coupon)
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
"times_redeemed")) Parser (Bool -> Coupon) -> Parser Bool -> Parser Coupon
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
"valid"))
mkCoupon ::
GHC.Types.Int ->
CouponDuration' ->
Data.Text.Internal.Text ->
GHC.Types.Bool ->
GHC.Types.Int ->
GHC.Types.Bool ->
Coupon
mkCoupon :: Int -> CouponDuration' -> Text -> Bool -> Int -> Bool -> Coupon
mkCoupon Int
couponCreated CouponDuration'
couponDuration Text
couponId Bool
couponLivemode Int
couponTimesRedeemed Bool
couponValid =
Coupon :: Maybe Int
-> Maybe CouponAppliesTo
-> Int
-> Maybe Text
-> CouponDuration'
-> Maybe Int
-> Text
-> Bool
-> Maybe Int
-> Maybe Object
-> Maybe Text
-> Maybe Double
-> Maybe Int
-> Int
-> Bool
-> Coupon
Coupon
{ couponAmountOff :: Maybe Int
couponAmountOff = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
couponAppliesTo :: Maybe CouponAppliesTo
couponAppliesTo = Maybe CouponAppliesTo
forall a. Maybe a
GHC.Maybe.Nothing,
couponCreated :: Int
couponCreated = Int
couponCreated,
couponCurrency :: Maybe Text
couponCurrency = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
couponDuration :: CouponDuration'
couponDuration = CouponDuration'
couponDuration,
couponDurationInMonths :: Maybe Int
couponDurationInMonths = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
couponId :: Text
couponId = Text
couponId,
couponLivemode :: Bool
couponLivemode = Bool
couponLivemode,
couponMaxRedemptions :: Maybe Int
couponMaxRedemptions = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
couponMetadata :: Maybe Object
couponMetadata = Maybe Object
forall a. Maybe a
GHC.Maybe.Nothing,
couponName :: Maybe Text
couponName = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
couponPercentOff :: Maybe Double
couponPercentOff = Maybe Double
forall a. Maybe a
GHC.Maybe.Nothing,
couponRedeemBy :: Maybe Int
couponRedeemBy = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
couponTimesRedeemed :: Int
couponTimesRedeemed = Int
couponTimesRedeemed,
couponValid :: Bool
couponValid = Bool
couponValid
}
data CouponDuration'
=
CouponDuration'Other Data.Aeson.Types.Internal.Value
|
CouponDuration'Typed Data.Text.Internal.Text
|
CouponDuration'EnumForever
|
CouponDuration'EnumOnce
|
CouponDuration'EnumRepeating
deriving (Int -> CouponDuration' -> ShowS
[CouponDuration'] -> ShowS
CouponDuration' -> String
(Int -> CouponDuration' -> ShowS)
-> (CouponDuration' -> String)
-> ([CouponDuration'] -> ShowS)
-> Show CouponDuration'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CouponDuration'] -> ShowS
$cshowList :: [CouponDuration'] -> ShowS
show :: CouponDuration' -> String
$cshow :: CouponDuration' -> String
showsPrec :: Int -> CouponDuration' -> ShowS
$cshowsPrec :: Int -> CouponDuration' -> ShowS
GHC.Show.Show, CouponDuration' -> CouponDuration' -> Bool
(CouponDuration' -> CouponDuration' -> Bool)
-> (CouponDuration' -> CouponDuration' -> Bool)
-> Eq CouponDuration'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CouponDuration' -> CouponDuration' -> Bool
$c/= :: CouponDuration' -> CouponDuration' -> Bool
== :: CouponDuration' -> CouponDuration' -> Bool
$c== :: CouponDuration' -> CouponDuration' -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON CouponDuration' where
toJSON :: CouponDuration' -> Value
toJSON (CouponDuration'Other Value
val) = Value
val
toJSON (CouponDuration'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (CouponDuration'
CouponDuration'EnumForever) = Value
"forever"
toJSON (CouponDuration'
CouponDuration'EnumOnce) = Value
"once"
toJSON (CouponDuration'
CouponDuration'EnumRepeating) = Value
"repeating"
instance Data.Aeson.Types.FromJSON.FromJSON CouponDuration' where
parseJSON :: Value -> Parser CouponDuration'
parseJSON Value
val =
CouponDuration' -> Parser CouponDuration'
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
"forever" -> CouponDuration'
CouponDuration'EnumForever
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"once" -> CouponDuration'
CouponDuration'EnumOnce
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"repeating" -> CouponDuration'
CouponDuration'EnumRepeating
| Bool
GHC.Base.otherwise -> Value -> CouponDuration'
CouponDuration'Other Value
val
)