{-# 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 DeletedDiscount
module StripeAPI.Types.DeletedDiscount 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.deleted_discount@ in the specification.
data DeletedDiscount = DeletedDiscount
  { -- | 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
    DeletedDiscount -> Maybe Text
deletedDiscountCheckoutSession :: (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).
    DeletedDiscount -> Coupon
deletedDiscountCoupon :: Coupon,
    -- | customer: The ID of the customer associated with this discount.
    DeletedDiscount -> Maybe DeletedDiscountCustomer'Variants
deletedDiscountCustomer :: (GHC.Maybe.Maybe DeletedDiscountCustomer'Variants),
    -- | 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
    DeletedDiscount -> Text
deletedDiscountId :: 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
    DeletedDiscount -> Maybe Text
deletedDiscountInvoice :: (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
    DeletedDiscount -> Maybe Text
deletedDiscountInvoiceItem :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | promotion_code: The promotion code applied to create this discount.
    DeletedDiscount -> Maybe DeletedDiscountPromotionCode'Variants
deletedDiscountPromotionCode :: (GHC.Maybe.Maybe DeletedDiscountPromotionCode'Variants),
    -- | start: Date that the coupon was applied.
    DeletedDiscount -> Int
deletedDiscountStart :: 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
    DeletedDiscount -> Maybe Text
deletedDiscountSubscription :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> DeletedDiscount -> ShowS
[DeletedDiscount] -> ShowS
DeletedDiscount -> String
(Int -> DeletedDiscount -> ShowS)
-> (DeletedDiscount -> String)
-> ([DeletedDiscount] -> ShowS)
-> Show DeletedDiscount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletedDiscount] -> ShowS
$cshowList :: [DeletedDiscount] -> ShowS
show :: DeletedDiscount -> String
$cshow :: DeletedDiscount -> String
showsPrec :: Int -> DeletedDiscount -> ShowS
$cshowsPrec :: Int -> DeletedDiscount -> ShowS
GHC.Show.Show,
      DeletedDiscount -> DeletedDiscount -> Bool
(DeletedDiscount -> DeletedDiscount -> Bool)
-> (DeletedDiscount -> DeletedDiscount -> Bool)
-> Eq DeletedDiscount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletedDiscount -> DeletedDiscount -> Bool
$c/= :: DeletedDiscount -> DeletedDiscount -> Bool
== :: DeletedDiscount -> DeletedDiscount -> Bool
$c== :: DeletedDiscount -> DeletedDiscount -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON DeletedDiscount where
  toJSON :: DeletedDiscount -> Value
toJSON DeletedDiscount
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..= DeletedDiscount -> Maybe Text
deletedDiscountCheckoutSession DeletedDiscount
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..= DeletedDiscount -> Coupon
deletedDiscountCoupon DeletedDiscount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"customer" Text -> Maybe DeletedDiscountCustomer'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= DeletedDiscount -> Maybe DeletedDiscountCustomer'Variants
deletedDiscountCustomer DeletedDiscount
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..= DeletedDiscount -> Text
deletedDiscountId DeletedDiscount
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..= DeletedDiscount -> Maybe Text
deletedDiscountInvoice DeletedDiscount
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..= DeletedDiscount -> Maybe Text
deletedDiscountInvoiceItem DeletedDiscount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"promotion_code" Text -> Maybe DeletedDiscountPromotionCode'Variants -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= DeletedDiscount -> Maybe DeletedDiscountPromotionCode'Variants
deletedDiscountPromotionCode DeletedDiscount
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..= DeletedDiscount -> Int
deletedDiscountStart DeletedDiscount
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..= DeletedDiscount -> Maybe Text
deletedDiscountSubscription DeletedDiscount
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"deleted" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Bool -> Value
Data.Aeson.Types.Internal.Bool Bool
GHC.Types.True 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 :: DeletedDiscount -> Encoding
toEncoding DeletedDiscount
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..= DeletedDiscount -> Maybe Text
deletedDiscountCheckoutSession DeletedDiscount
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..= DeletedDiscount -> Coupon
deletedDiscountCoupon DeletedDiscount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"customer" Text -> Maybe DeletedDiscountCustomer'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= DeletedDiscount -> Maybe DeletedDiscountCustomer'Variants
deletedDiscountCustomer DeletedDiscount
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..= DeletedDiscount -> Text
deletedDiscountId DeletedDiscount
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..= DeletedDiscount -> Maybe Text
deletedDiscountInvoice DeletedDiscount
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..= DeletedDiscount -> Maybe Text
deletedDiscountInvoiceItem DeletedDiscount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"promotion_code" Text -> Maybe DeletedDiscountPromotionCode'Variants -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= DeletedDiscount -> Maybe DeletedDiscountPromotionCode'Variants
deletedDiscountPromotionCode DeletedDiscount
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..= DeletedDiscount -> Int
deletedDiscountStart DeletedDiscount
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..= DeletedDiscount -> Maybe Text
deletedDiscountSubscription DeletedDiscount
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"deleted" Text -> Value -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Bool -> Value
Data.Aeson.Types.Internal.Bool Bool
GHC.Types.True) 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 DeletedDiscount where
  parseJSON :: Value -> Parser DeletedDiscount
parseJSON = String
-> (Object -> Parser DeletedDiscount)
-> Value
-> Parser DeletedDiscount
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"DeletedDiscount" (\Object
obj -> (((((((((Maybe Text
 -> Coupon
 -> Maybe DeletedDiscountCustomer'Variants
 -> Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe DeletedDiscountPromotionCode'Variants
 -> Int
 -> Maybe Text
 -> DeletedDiscount)
-> Parser
     (Maybe Text
      -> Coupon
      -> Maybe DeletedDiscountCustomer'Variants
      -> Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe DeletedDiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> DeletedDiscount)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Coupon
-> Maybe DeletedDiscountCustomer'Variants
-> Text
-> Maybe Text
-> Maybe Text
-> Maybe DeletedDiscountPromotionCode'Variants
-> Int
-> Maybe Text
-> DeletedDiscount
DeletedDiscount Parser
  (Maybe Text
   -> Coupon
   -> Maybe DeletedDiscountCustomer'Variants
   -> Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe DeletedDiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> DeletedDiscount)
-> Parser (Maybe Text)
-> Parser
     (Coupon
      -> Maybe DeletedDiscountCustomer'Variants
      -> Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe DeletedDiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> DeletedDiscount)
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 DeletedDiscountCustomer'Variants
   -> Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe DeletedDiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> DeletedDiscount)
-> Parser Coupon
-> Parser
     (Maybe DeletedDiscountCustomer'Variants
      -> Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe DeletedDiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> DeletedDiscount)
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 DeletedDiscountCustomer'Variants
   -> Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe DeletedDiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> DeletedDiscount)
-> Parser (Maybe DeletedDiscountCustomer'Variants)
-> Parser
     (Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe DeletedDiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> DeletedDiscount)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe DeletedDiscountCustomer'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"customer")) Parser
  (Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe DeletedDiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> DeletedDiscount)
-> Parser Text
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe DeletedDiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> DeletedDiscount)
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 DeletedDiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> DeletedDiscount)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe DeletedDiscountPromotionCode'Variants
      -> Int
      -> Maybe Text
      -> DeletedDiscount)
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 DeletedDiscountPromotionCode'Variants
   -> Int
   -> Maybe Text
   -> DeletedDiscount)
-> Parser (Maybe Text)
-> Parser
     (Maybe DeletedDiscountPromotionCode'Variants
      -> Int -> Maybe Text -> DeletedDiscount)
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 DeletedDiscountPromotionCode'Variants
   -> Int -> Maybe Text -> DeletedDiscount)
-> Parser (Maybe DeletedDiscountPromotionCode'Variants)
-> Parser (Int -> Maybe Text -> DeletedDiscount)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text -> Parser (Maybe DeletedDiscountPromotionCode'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"promotion_code")) Parser (Int -> Maybe Text -> DeletedDiscount)
-> Parser Int -> Parser (Maybe Text -> DeletedDiscount)
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 -> DeletedDiscount)
-> Parser (Maybe Text) -> Parser DeletedDiscount
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 'DeletedDiscount' with all required fields.
mkDeletedDiscount ::
  -- | 'deletedDiscountCoupon'
  Coupon ->
  -- | 'deletedDiscountId'
  Data.Text.Internal.Text ->
  -- | 'deletedDiscountStart'
  GHC.Types.Int ->
  DeletedDiscount
mkDeletedDiscount :: Coupon -> Text -> Int -> DeletedDiscount
mkDeletedDiscount Coupon
deletedDiscountCoupon Text
deletedDiscountId Int
deletedDiscountStart =
  DeletedDiscount :: Maybe Text
-> Coupon
-> Maybe DeletedDiscountCustomer'Variants
-> Text
-> Maybe Text
-> Maybe Text
-> Maybe DeletedDiscountPromotionCode'Variants
-> Int
-> Maybe Text
-> DeletedDiscount
DeletedDiscount
    { deletedDiscountCheckoutSession :: Maybe Text
deletedDiscountCheckoutSession = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      deletedDiscountCoupon :: Coupon
deletedDiscountCoupon = Coupon
deletedDiscountCoupon,
      deletedDiscountCustomer :: Maybe DeletedDiscountCustomer'Variants
deletedDiscountCustomer = Maybe DeletedDiscountCustomer'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      deletedDiscountId :: Text
deletedDiscountId = Text
deletedDiscountId,
      deletedDiscountInvoice :: Maybe Text
deletedDiscountInvoice = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      deletedDiscountInvoiceItem :: Maybe Text
deletedDiscountInvoiceItem = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      deletedDiscountPromotionCode :: Maybe DeletedDiscountPromotionCode'Variants
deletedDiscountPromotionCode = Maybe DeletedDiscountPromotionCode'Variants
forall a. Maybe a
GHC.Maybe.Nothing,
      deletedDiscountStart :: Int
deletedDiscountStart = Int
deletedDiscountStart,
      deletedDiscountSubscription :: Maybe Text
deletedDiscountSubscription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

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

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

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

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

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

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