{-# 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 Discount
module StripeAPI.Types.Discount 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.Coupon
import {-# SOURCE #-} StripeAPI.Types.Customer
import {-# SOURCE #-} StripeAPI.Types.DeletedCustomer
import {-# SOURCE #-} StripeAPI.Types.PromotionCode
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.discount@ in the specification.
--
-- A discount represents the actual application of a coupon to a particular
-- customer. It contains information about when the discount began and when it
-- will end.
--
-- Related guide: [Applying Discounts to Subscriptions](https:\/\/stripe.com\/docs\/billing\/subscriptions\/discounts).
data Discount = Discount
  { -- | checkout_session: The Checkout session that this coupon is applied to, if it is applied to a particular session in payment mode. Will not be present for subscription mode.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Discount -> Maybe Text
discountCheckoutSession :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | coupon: A coupon contains information about a percent-off or amount-off discount you
    -- might want to apply to a customer. Coupons may be applied to [invoices](https:\/\/stripe.com\/docs\/api\#invoices) or
    -- [orders](https:\/\/stripe.com\/docs\/api\#create_order-coupon). Coupons do not work with conventional one-off [charges](https:\/\/stripe.com\/docs\/api\#create_charge).
    Discount -> Coupon
discountCoupon :: Coupon,
    -- | customer: The ID of the customer associated with this discount.
    Discount -> Maybe DiscountCustomer'Variants
discountCustomer :: (GHC.Maybe.Maybe DiscountCustomer'Variants),
    -- | end: If the coupon has a duration of \`repeating\`, the date that this discount will end. If the coupon has a duration of \`once\` or \`forever\`, this attribute will be null.
    Discount -> Maybe Int
discountEnd :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | id: The ID of the discount object. Discounts cannot be fetched by ID. Use \`expand[]=discounts\` in API calls to expand discount IDs in an array.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Discount -> Text
discountId :: Data.Text.Internal.Text,
    -- | invoice: The invoice that the discount\'s coupon was applied to, if it was applied directly to a particular invoice.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Discount -> Maybe Text
discountInvoice :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | invoice_item: The invoice item \`id\` (or invoice line item \`id\` for invoice line items of type=\'subscription\') that the discount\'s coupon was applied to, if it was applied directly to a particular invoice item or invoice line item.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Discount -> Maybe Text
discountInvoiceItem :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | promotion_code: The promotion code applied to create this discount.
    Discount -> Maybe DiscountPromotionCode'Variants
discountPromotionCode :: (GHC.Maybe.Maybe DiscountPromotionCode'Variants),
    -- | start: Date that the coupon was applied.
    Discount -> Int
discountStart :: GHC.Types.Int,
    -- | subscription: The subscription that this coupon is applied to, if it is applied to a particular subscription.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Discount -> Maybe Text
discountSubscription :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> Discount -> ShowS
[Discount] -> ShowS
Discount -> String
(Int -> Discount -> ShowS)
-> (Discount -> String) -> ([Discount] -> ShowS) -> Show Discount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Discount] -> ShowS
$cshowList :: [Discount] -> ShowS
show :: Discount -> String
$cshow :: Discount -> String
showsPrec :: Int -> Discount -> ShowS
$cshowsPrec :: Int -> Discount -> ShowS
GHC.Show.Show,
      Discount -> Discount -> Bool
(Discount -> Discount -> Bool)
-> (Discount -> Discount -> Bool) -> Eq Discount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Discount -> Discount -> Bool
$c/= :: Discount -> Discount -> Bool
== :: Discount -> Discount -> Bool
$c== :: Discount -> Discount -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON Discount where
  toJSON :: Discount -> Value
toJSON Discount
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"checkout_session" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe Text
discountCheckoutSession Discount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"coupon" Text -> Coupon -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Coupon
discountCoupon Discount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"customer" Text -> Maybe DiscountCustomer'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe DiscountCustomer'Variants
discountCustomer Discount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"end" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe Int
discountEnd Discount
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..= Discount -> Text
discountId Discount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"invoice" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe Text
discountInvoice Discount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"invoice_item" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe Text
discountInvoiceItem Discount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"promotion_code" Text -> Maybe DiscountPromotionCode'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe DiscountPromotionCode'Variants
discountPromotionCode Discount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"start" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Int
discountStart Discount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"subscription" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe Text
discountSubscription Discount
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
"discount" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: Discount -> Encoding
toEncoding Discount
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"checkout_session" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe Text
discountCheckoutSession Discount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"coupon" Text -> Coupon -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Coupon
discountCoupon Discount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"customer" Text -> Maybe DiscountCustomer'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe DiscountCustomer'Variants
discountCustomer Discount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"end" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe Int
discountEnd Discount
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..= Discount -> Text
discountId Discount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"invoice" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe Text
discountInvoice Discount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"invoice_item" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe Text
discountInvoiceItem Discount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"promotion_code" Text -> Maybe DiscountPromotionCode'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe DiscountPromotionCode'Variants
discountPromotionCode Discount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"start" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Int
discountStart Discount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"subscription" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Discount -> Maybe Text
discountSubscription Discount
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
"discount")))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON Discount where
  parseJSON :: Value -> Parser Discount
parseJSON = String -> (Object -> Parser Discount) -> Value -> Parser Discount
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Discount" (\Object
obj -> ((((((((((Maybe Text
 -> Coupon
 -> Maybe DiscountCustomer'Variants
 -> Maybe Int
 -> Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe DiscountPromotionCode'Variants
 -> Int
 -> Maybe Text
 -> Discount)
-> Parser
     (Maybe Text
      -> Coupon
      -> Maybe DiscountCustomer'Variants
      -> Maybe Int
      -> Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe DiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> Discount)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Coupon
-> Maybe DiscountCustomer'Variants
-> Maybe Int
-> Text
-> Maybe Text
-> Maybe Text
-> Maybe DiscountPromotionCode'Variants
-> Int
-> Maybe Text
-> Discount
Discount Parser
  (Maybe Text
   -> Coupon
   -> Maybe DiscountCustomer'Variants
   -> Maybe Int
   -> Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe DiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> Discount)
-> Parser (Maybe Text)
-> Parser
     (Coupon
      -> Maybe DiscountCustomer'Variants
      -> Maybe Int
      -> Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe DiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> Discount)
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
"checkout_session")) Parser
  (Coupon
   -> Maybe DiscountCustomer'Variants
   -> Maybe Int
   -> Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe DiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> Discount)
-> Parser Coupon
-> Parser
     (Maybe DiscountCustomer'Variants
      -> Maybe Int
      -> Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe DiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> Discount)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Coupon
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"coupon")) Parser
  (Maybe DiscountCustomer'Variants
   -> Maybe Int
   -> Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe DiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> Discount)
-> Parser (Maybe DiscountCustomer'Variants)
-> Parser
     (Maybe Int
      -> Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe DiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> Discount)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe DiscountCustomer'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"customer")) Parser
  (Maybe Int
   -> Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe DiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> Discount)
-> Parser (Maybe Int)
-> Parser
     (Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe DiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> Discount)
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
"end")) Parser
  (Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe DiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> Discount)
-> Parser Text
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe DiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> Discount)
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
  (Maybe Text
   -> Maybe Text
   -> Maybe DiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> Discount)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe DiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> Discount)
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
"invoice")) Parser
  (Maybe Text
   -> Maybe DiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> Discount)
-> Parser (Maybe Text)
-> Parser
     (Maybe DiscountPromotionCode'Variants
      -> Int -> Maybe Text -> Discount)
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
"invoice_item")) Parser
  (Maybe DiscountPromotionCode'Variants
   -> Int -> Maybe Text -> Discount)
-> Parser (Maybe DiscountPromotionCode'Variants)
-> Parser (Int -> Maybe Text -> Discount)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe DiscountPromotionCode'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"promotion_code")) Parser (Int -> Maybe Text -> Discount)
-> Parser Int -> Parser (Maybe Text -> Discount)
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
"start")) Parser (Maybe Text -> Discount)
-> Parser (Maybe Text) -> Parser Discount
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
"subscription"))

-- | Create a new 'Discount' with all required fields.
mkDiscount ::
  -- | 'discountCoupon'
  Coupon ->
  -- | 'discountId'
  Data.Text.Internal.Text ->
  -- | 'discountStart'
  GHC.Types.Int ->
  Discount
mkDiscount :: Coupon -> Text -> Int -> Discount
mkDiscount Coupon
discountCoupon Text
discountId Int
discountStart =
  Discount :: Maybe Text
-> Coupon
-> Maybe DiscountCustomer'Variants
-> Maybe Int
-> Text
-> Maybe Text
-> Maybe Text
-> Maybe DiscountPromotionCode'Variants
-> Int
-> Maybe Text
-> Discount
Discount
    { discountCheckoutSession :: Maybe Text
discountCheckoutSession = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      discountCoupon :: Coupon
discountCoupon = Coupon
discountCoupon,
      discountCustomer :: Maybe DiscountCustomer'Variants
discountCustomer = Maybe DiscountCustomer'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      discountEnd :: Maybe Int
discountEnd = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      discountId :: Text
discountId = Text
discountId,
      discountInvoice :: Maybe Text
discountInvoice = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      discountInvoiceItem :: Maybe Text
discountInvoiceItem = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      discountPromotionCode :: Maybe DiscountPromotionCode'Variants
discountPromotionCode = Maybe DiscountPromotionCode'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      discountStart :: Int
discountStart = Int
discountStart,
      discountSubscription :: Maybe Text
discountSubscription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the oneOf schema located at @components.schemas.discount.properties.customer.anyOf@ in the specification.
--
-- The ID of the customer associated with this discount.
data DiscountCustomer'Variants
  = DiscountCustomer'Text Data.Text.Internal.Text
  | DiscountCustomer'Customer Customer
  | DiscountCustomer'DeletedCustomer DeletedCustomer
  deriving (Int -> DiscountCustomer'Variants -> ShowS
[DiscountCustomer'Variants] -> ShowS
DiscountCustomer'Variants -> String
(Int -> DiscountCustomer'Variants -> ShowS)
-> (DiscountCustomer'Variants -> String)
-> ([DiscountCustomer'Variants] -> ShowS)
-> Show DiscountCustomer'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DiscountCustomer'Variants] -> ShowS
$cshowList :: [DiscountCustomer'Variants] -> ShowS
show :: DiscountCustomer'Variants -> String
$cshow :: DiscountCustomer'Variants -> String
showsPrec :: Int -> DiscountCustomer'Variants -> ShowS
$cshowsPrec :: Int -> DiscountCustomer'Variants -> ShowS
GHC.Show.Show, DiscountCustomer'Variants -> DiscountCustomer'Variants -> Bool
(DiscountCustomer'Variants -> DiscountCustomer'Variants -> Bool)
-> (DiscountCustomer'Variants -> DiscountCustomer'Variants -> Bool)
-> Eq DiscountCustomer'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DiscountCustomer'Variants -> DiscountCustomer'Variants -> Bool
$c/= :: DiscountCustomer'Variants -> DiscountCustomer'Variants -> Bool
== :: DiscountCustomer'Variants -> DiscountCustomer'Variants -> Bool
$c== :: DiscountCustomer'Variants -> DiscountCustomer'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON DiscountCustomer'Variants where
  toJSON :: DiscountCustomer'Variants -> Value
toJSON (DiscountCustomer'Text Text
a) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
a
  toJSON (DiscountCustomer'Customer Customer
a) = Customer -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Customer
a
  toJSON (DiscountCustomer'DeletedCustomer DeletedCustomer
a) = DeletedCustomer -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON DeletedCustomer
a

instance Data.Aeson.Types.FromJSON.FromJSON DiscountCustomer'Variants where
  parseJSON :: Value -> Parser DiscountCustomer'Variants
parseJSON Value
val = case (Text -> DiscountCustomer'Variants
DiscountCustomer'Text (Text -> DiscountCustomer'Variants)
-> Result Text -> Result DiscountCustomer'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Text
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result DiscountCustomer'Variants
-> Result DiscountCustomer'Variants
-> Result DiscountCustomer'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((Customer -> DiscountCustomer'Variants
DiscountCustomer'Customer (Customer -> DiscountCustomer'Variants)
-> Result Customer -> Result DiscountCustomer'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Customer
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result DiscountCustomer'Variants
-> Result DiscountCustomer'Variants
-> Result DiscountCustomer'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((DeletedCustomer -> DiscountCustomer'Variants
DiscountCustomer'DeletedCustomer (DeletedCustomer -> DiscountCustomer'Variants)
-> Result DeletedCustomer -> Result DiscountCustomer'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result DeletedCustomer
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result DiscountCustomer'Variants
-> Result DiscountCustomer'Variants
-> Result DiscountCustomer'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String -> Result DiscountCustomer'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched")) of
    Data.Aeson.Types.Internal.Success DiscountCustomer'Variants
a -> DiscountCustomer'Variants -> Parser DiscountCustomer'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure DiscountCustomer'Variants
a
    Data.Aeson.Types.Internal.Error String
a -> String -> Parser DiscountCustomer'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a

-- | Defines the oneOf schema located at @components.schemas.discount.properties.promotion_code.anyOf@ in the specification.
--
-- The promotion code applied to create this discount.
data DiscountPromotionCode'Variants
  = DiscountPromotionCode'Text Data.Text.Internal.Text
  | DiscountPromotionCode'PromotionCode PromotionCode
  deriving (Int -> DiscountPromotionCode'Variants -> ShowS
[DiscountPromotionCode'Variants] -> ShowS
DiscountPromotionCode'Variants -> String
(Int -> DiscountPromotionCode'Variants -> ShowS)
-> (DiscountPromotionCode'Variants -> String)
-> ([DiscountPromotionCode'Variants] -> ShowS)
-> Show DiscountPromotionCode'Variants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DiscountPromotionCode'Variants] -> ShowS
$cshowList :: [DiscountPromotionCode'Variants] -> ShowS
show :: DiscountPromotionCode'Variants -> String
$cshow :: DiscountPromotionCode'Variants -> String
showsPrec :: Int -> DiscountPromotionCode'Variants -> ShowS
$cshowsPrec :: Int -> DiscountPromotionCode'Variants -> ShowS
GHC.Show.Show, DiscountPromotionCode'Variants
-> DiscountPromotionCode'Variants -> Bool
(DiscountPromotionCode'Variants
 -> DiscountPromotionCode'Variants -> Bool)
-> (DiscountPromotionCode'Variants
    -> DiscountPromotionCode'Variants -> Bool)
-> Eq DiscountPromotionCode'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DiscountPromotionCode'Variants
-> DiscountPromotionCode'Variants -> Bool
$c/= :: DiscountPromotionCode'Variants
-> DiscountPromotionCode'Variants -> Bool
== :: DiscountPromotionCode'Variants
-> DiscountPromotionCode'Variants -> Bool
$c== :: DiscountPromotionCode'Variants
-> DiscountPromotionCode'Variants -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON DiscountPromotionCode'Variants where
  toJSON :: DiscountPromotionCode'Variants -> Value
toJSON (DiscountPromotionCode'Text Text
a) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
a
  toJSON (DiscountPromotionCode'PromotionCode PromotionCode
a) = PromotionCode -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON PromotionCode
a

instance Data.Aeson.Types.FromJSON.FromJSON DiscountPromotionCode'Variants where
  parseJSON :: Value -> Parser DiscountPromotionCode'Variants
parseJSON Value
val = case (Text -> DiscountPromotionCode'Variants
DiscountPromotionCode'Text (Text -> DiscountPromotionCode'Variants)
-> Result Text -> Result DiscountPromotionCode'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Text
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result DiscountPromotionCode'Variants
-> Result DiscountPromotionCode'Variants
-> Result DiscountPromotionCode'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> ((PromotionCode -> DiscountPromotionCode'Variants
DiscountPromotionCode'PromotionCode (PromotionCode -> DiscountPromotionCode'Variants)
-> Result PromotionCode -> Result DiscountPromotionCode'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result PromotionCode
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result DiscountPromotionCode'Variants
-> Result DiscountPromotionCode'Variants
-> Result DiscountPromotionCode'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String -> Result DiscountPromotionCode'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched") of
    Data.Aeson.Types.Internal.Success DiscountPromotionCode'Variants
a -> DiscountPromotionCode'Variants
-> Parser DiscountPromotionCode'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure DiscountPromotionCode'Variants
a
    Data.Aeson.Types.Internal.Error String
a -> String -> Parser DiscountPromotionCode'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a