{-# 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 UniqueCouponCode
module RecurlyClient.Types.UniqueCouponCode 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
import qualified Data.ByteString as Data.ByteString.Internal
import qualified Data.Foldable
import qualified Data.Functor
import qualified Data.Maybe
import qualified Data.Scientific
import qualified Data.Text
import qualified Data.Text as 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 RecurlyClient.Common
import RecurlyClient.TypeAlias
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

{- | Defines the object schema located at @components.schemas.UniqueCouponCode@ in the specification.

A unique coupon code for a bulk coupon.
-}
data UniqueCouponCode = UniqueCouponCode
    { UniqueCouponCode -> Maybe Text
uniqueCouponCodeBulk_coupon_code :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ bulk_coupon_code: The Coupon code of the parent Bulk Coupon
    , UniqueCouponCode -> Maybe Text
uniqueCouponCodeBulk_coupon_id :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ bulk_coupon_id: The Coupon ID of the parent Bulk Coupon
    , UniqueCouponCode -> Maybe Text
uniqueCouponCodeCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ code: The code the customer enters to redeem the coupon.
    , UniqueCouponCode -> Maybe JsonDateTime
uniqueCouponCodeCreated_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ created_at
    , UniqueCouponCode -> Maybe JsonDateTime
uniqueCouponCodeExpired_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ expired_at: The date and time the coupon was expired early or reached its \`max_redemptions\`.
    , UniqueCouponCode -> Maybe Text
uniqueCouponCodeId :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ id
    , UniqueCouponCode -> Maybe Text
uniqueCouponCodeObject :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ object
    , UniqueCouponCode -> Maybe JsonDateTime
uniqueCouponCodeRedeemed_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ redeemed_at: The date and time the unique coupon code was redeemed.
    , UniqueCouponCode -> Maybe UniqueCouponCodeState
uniqueCouponCodeState :: (GHC.Maybe.Maybe UniqueCouponCodeState)
    -- ^ state: Indicates if the unique coupon code is redeemable or why not.
    , UniqueCouponCode -> Maybe JsonDateTime
uniqueCouponCodeUpdated_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ updated_at
    }
    deriving
        ( Int -> UniqueCouponCode -> ShowS
[UniqueCouponCode] -> ShowS
UniqueCouponCode -> String
(Int -> UniqueCouponCode -> ShowS)
-> (UniqueCouponCode -> String)
-> ([UniqueCouponCode] -> ShowS)
-> Show UniqueCouponCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UniqueCouponCode -> ShowS
showsPrec :: Int -> UniqueCouponCode -> ShowS
$cshow :: UniqueCouponCode -> String
show :: UniqueCouponCode -> String
$cshowList :: [UniqueCouponCode] -> ShowS
showList :: [UniqueCouponCode] -> ShowS
GHC.Show.Show
        , UniqueCouponCode -> UniqueCouponCode -> Bool
(UniqueCouponCode -> UniqueCouponCode -> Bool)
-> (UniqueCouponCode -> UniqueCouponCode -> Bool)
-> Eq UniqueCouponCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UniqueCouponCode -> UniqueCouponCode -> Bool
== :: UniqueCouponCode -> UniqueCouponCode -> Bool
$c/= :: UniqueCouponCode -> UniqueCouponCode -> Bool
/= :: UniqueCouponCode -> UniqueCouponCode -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON UniqueCouponCode where
    toJSON :: UniqueCouponCode -> Value
toJSON UniqueCouponCode
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"bulk_coupon_code" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe Text
uniqueCouponCodeBulk_coupon_code UniqueCouponCode
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"bulk_coupon_id" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe Text
uniqueCouponCodeBulk_coupon_id UniqueCouponCode
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"code" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe Text
uniqueCouponCodeCode UniqueCouponCode
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (JsonDateTime -> [Pair]) -> Maybe JsonDateTime -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (JsonDateTime -> Pair) -> JsonDateTime -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"created_at" Key -> JsonDateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe JsonDateTime
uniqueCouponCodeCreated_at UniqueCouponCode
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (JsonDateTime -> [Pair]) -> Maybe JsonDateTime -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (JsonDateTime -> Pair) -> JsonDateTime -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"expired_at" Key -> JsonDateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe JsonDateTime
uniqueCouponCodeExpired_at UniqueCouponCode
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"id" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe Text
uniqueCouponCodeId UniqueCouponCode
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"object" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe Text
uniqueCouponCodeObject UniqueCouponCode
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (JsonDateTime -> [Pair]) -> Maybe JsonDateTime -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (JsonDateTime -> Pair) -> JsonDateTime -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"redeemed_at" Key -> JsonDateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe JsonDateTime
uniqueCouponCodeRedeemed_at UniqueCouponCode
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (UniqueCouponCodeState -> [Pair])
-> Maybe UniqueCouponCodeState
-> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (UniqueCouponCodeState -> Pair)
-> UniqueCouponCodeState
-> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"state" Key -> UniqueCouponCodeState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe UniqueCouponCodeState
uniqueCouponCodeState UniqueCouponCode
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (JsonDateTime -> [Pair]) -> Maybe JsonDateTime -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (JsonDateTime -> Pair) -> JsonDateTime -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"updated_at" Key -> JsonDateTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe JsonDateTime
uniqueCouponCodeUpdated_at UniqueCouponCode
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: UniqueCouponCode -> Encoding
toEncoding UniqueCouponCode
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ([Series] -> Series
forall a. Monoid a => [a] -> a
GHC.Base.mconcat ([[Series]] -> [Series]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"bulk_coupon_code" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe Text
uniqueCouponCodeBulk_coupon_code UniqueCouponCode
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"bulk_coupon_id" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe Text
uniqueCouponCodeBulk_coupon_id UniqueCouponCode
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"code" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe Text
uniqueCouponCodeCode UniqueCouponCode
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (JsonDateTime -> [Series]) -> Maybe JsonDateTime -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (JsonDateTime -> Series) -> JsonDateTime -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"created_at" Key -> JsonDateTime -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe JsonDateTime
uniqueCouponCodeCreated_at UniqueCouponCode
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (JsonDateTime -> [Series]) -> Maybe JsonDateTime -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (JsonDateTime -> Series) -> JsonDateTime -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"expired_at" Key -> JsonDateTime -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe JsonDateTime
uniqueCouponCodeExpired_at UniqueCouponCode
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"id" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe Text
uniqueCouponCodeId UniqueCouponCode
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"object" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe Text
uniqueCouponCodeObject UniqueCouponCode
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (JsonDateTime -> [Series]) -> Maybe JsonDateTime -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (JsonDateTime -> Series) -> JsonDateTime -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"redeemed_at" Key -> JsonDateTime -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe JsonDateTime
uniqueCouponCodeRedeemed_at UniqueCouponCode
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (UniqueCouponCodeState -> [Series])
-> Maybe UniqueCouponCodeState
-> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (UniqueCouponCodeState -> Series)
-> UniqueCouponCodeState
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"state" Key -> UniqueCouponCodeState -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe UniqueCouponCodeState
uniqueCouponCodeState UniqueCouponCode
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (JsonDateTime -> [Series]) -> Maybe JsonDateTime -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (JsonDateTime -> Series) -> JsonDateTime -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"updated_at" Key -> JsonDateTime -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (UniqueCouponCode -> Maybe JsonDateTime
uniqueCouponCodeUpdated_at UniqueCouponCode
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON UniqueCouponCode where
    parseJSON :: Value -> Parser UniqueCouponCode
parseJSON = String
-> (Object -> Parser UniqueCouponCode)
-> Value
-> Parser UniqueCouponCode
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"UniqueCouponCode" (\Object
obj -> ((((((((((Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe JsonDateTime
 -> Maybe JsonDateTime
 -> Maybe Text
 -> Maybe Text
 -> Maybe JsonDateTime
 -> Maybe UniqueCouponCodeState
 -> Maybe JsonDateTime
 -> UniqueCouponCode)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe UniqueCouponCodeState
      -> Maybe JsonDateTime
      -> UniqueCouponCode)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe JsonDateTime
-> Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe JsonDateTime
-> Maybe UniqueCouponCodeState
-> Maybe JsonDateTime
-> UniqueCouponCode
UniqueCouponCode Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe UniqueCouponCodeState
   -> Maybe JsonDateTime
   -> UniqueCouponCode)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe UniqueCouponCodeState
      -> Maybe JsonDateTime
      -> UniqueCouponCode)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"bulk_coupon_code")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe UniqueCouponCodeState
   -> Maybe JsonDateTime
   -> UniqueCouponCode)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe UniqueCouponCodeState
      -> Maybe JsonDateTime
      -> UniqueCouponCode)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"bulk_coupon_id")) Parser
  (Maybe Text
   -> Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe UniqueCouponCodeState
   -> Maybe JsonDateTime
   -> UniqueCouponCode)
-> Parser (Maybe Text)
-> Parser
     (Maybe JsonDateTime
      -> Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe UniqueCouponCodeState
      -> Maybe JsonDateTime
      -> UniqueCouponCode)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"code")) Parser
  (Maybe JsonDateTime
   -> Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe UniqueCouponCodeState
   -> Maybe JsonDateTime
   -> UniqueCouponCode)
-> Parser (Maybe JsonDateTime)
-> Parser
     (Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe UniqueCouponCodeState
      -> Maybe JsonDateTime
      -> UniqueCouponCode)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe JsonDateTime)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"created_at")) Parser
  (Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe UniqueCouponCodeState
   -> Maybe JsonDateTime
   -> UniqueCouponCode)
-> Parser (Maybe JsonDateTime)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe UniqueCouponCodeState
      -> Maybe JsonDateTime
      -> UniqueCouponCode)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe JsonDateTime)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"expired_at")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe UniqueCouponCodeState
   -> Maybe JsonDateTime
   -> UniqueCouponCode)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe JsonDateTime
      -> Maybe UniqueCouponCodeState
      -> Maybe JsonDateTime
      -> UniqueCouponCode)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"id")) Parser
  (Maybe Text
   -> Maybe JsonDateTime
   -> Maybe UniqueCouponCodeState
   -> Maybe JsonDateTime
   -> UniqueCouponCode)
-> Parser (Maybe Text)
-> Parser
     (Maybe JsonDateTime
      -> Maybe UniqueCouponCodeState
      -> Maybe JsonDateTime
      -> UniqueCouponCode)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"object")) Parser
  (Maybe JsonDateTime
   -> Maybe UniqueCouponCodeState
   -> Maybe JsonDateTime
   -> UniqueCouponCode)
-> Parser (Maybe JsonDateTime)
-> Parser
     (Maybe UniqueCouponCodeState
      -> Maybe JsonDateTime -> UniqueCouponCode)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe JsonDateTime)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"redeemed_at")) Parser
  (Maybe UniqueCouponCodeState
   -> Maybe JsonDateTime -> UniqueCouponCode)
-> Parser (Maybe UniqueCouponCodeState)
-> Parser (Maybe JsonDateTime -> UniqueCouponCode)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe UniqueCouponCodeState)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"state")) Parser (Maybe JsonDateTime -> UniqueCouponCode)
-> Parser (Maybe JsonDateTime) -> Parser UniqueCouponCode
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe JsonDateTime)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"updated_at"))

-- | Create a new 'UniqueCouponCode' with all required fields.
mkUniqueCouponCode :: UniqueCouponCode
mkUniqueCouponCode :: UniqueCouponCode
mkUniqueCouponCode =
    UniqueCouponCode
        { uniqueCouponCodeBulk_coupon_code :: Maybe Text
uniqueCouponCodeBulk_coupon_code = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , uniqueCouponCodeBulk_coupon_id :: Maybe Text
uniqueCouponCodeBulk_coupon_id = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , uniqueCouponCodeCode :: Maybe Text
uniqueCouponCodeCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , uniqueCouponCodeCreated_at :: Maybe JsonDateTime
uniqueCouponCodeCreated_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , uniqueCouponCodeExpired_at :: Maybe JsonDateTime
uniqueCouponCodeExpired_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , uniqueCouponCodeId :: Maybe Text
uniqueCouponCodeId = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , uniqueCouponCodeObject :: Maybe Text
uniqueCouponCodeObject = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , uniqueCouponCodeRedeemed_at :: Maybe JsonDateTime
uniqueCouponCodeRedeemed_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , uniqueCouponCodeState :: Maybe UniqueCouponCodeState
uniqueCouponCodeState = Maybe UniqueCouponCodeState
forall a. Maybe a
GHC.Maybe.Nothing
        , uniqueCouponCodeUpdated_at :: Maybe JsonDateTime
uniqueCouponCodeUpdated_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        }

{- | Defines the enum schema located at @components.schemas.UniqueCouponCode.properties.state@ in the specification.

Indicates if the unique coupon code is redeemable or why not.
-}
data UniqueCouponCodeState
    = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
      UniqueCouponCodeStateOther Data.Aeson.Types.Internal.Value
    | -- | This constructor can be used to send values to the server which are not present in the specification yet.
      UniqueCouponCodeStateTyped Data.Text.Internal.Text
    | -- | Represents the JSON value @"expired"@
      UniqueCouponCodeStateEnumExpired
    | -- | Represents the JSON value @"inactive"@
      UniqueCouponCodeStateEnumInactive
    | -- | Represents the JSON value @"maxed_out"@
      UniqueCouponCodeStateEnumMaxed_out
    | -- | Represents the JSON value @"redeemable"@
      UniqueCouponCodeStateEnumRedeemable
    deriving (Int -> UniqueCouponCodeState -> ShowS
[UniqueCouponCodeState] -> ShowS
UniqueCouponCodeState -> String
(Int -> UniqueCouponCodeState -> ShowS)
-> (UniqueCouponCodeState -> String)
-> ([UniqueCouponCodeState] -> ShowS)
-> Show UniqueCouponCodeState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UniqueCouponCodeState -> ShowS
showsPrec :: Int -> UniqueCouponCodeState -> ShowS
$cshow :: UniqueCouponCodeState -> String
show :: UniqueCouponCodeState -> String
$cshowList :: [UniqueCouponCodeState] -> ShowS
showList :: [UniqueCouponCodeState] -> ShowS
GHC.Show.Show, UniqueCouponCodeState -> UniqueCouponCodeState -> Bool
(UniqueCouponCodeState -> UniqueCouponCodeState -> Bool)
-> (UniqueCouponCodeState -> UniqueCouponCodeState -> Bool)
-> Eq UniqueCouponCodeState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UniqueCouponCodeState -> UniqueCouponCodeState -> Bool
== :: UniqueCouponCodeState -> UniqueCouponCodeState -> Bool
$c/= :: UniqueCouponCodeState -> UniqueCouponCodeState -> Bool
/= :: UniqueCouponCodeState -> UniqueCouponCodeState -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON UniqueCouponCodeState where
    toJSON :: UniqueCouponCodeState -> Value
toJSON (UniqueCouponCodeStateOther Value
val) = Value
val
    toJSON (UniqueCouponCodeStateTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
    toJSON (UniqueCouponCodeState
UniqueCouponCodeStateEnumExpired) = Value
"expired"
    toJSON (UniqueCouponCodeState
UniqueCouponCodeStateEnumInactive) = Value
"inactive"
    toJSON (UniqueCouponCodeState
UniqueCouponCodeStateEnumMaxed_out) = Value
"maxed_out"
    toJSON (UniqueCouponCodeState
UniqueCouponCodeStateEnumRedeemable) = Value
"redeemable"
instance Data.Aeson.Types.FromJSON.FromJSON UniqueCouponCodeState where
    parseJSON :: Value -> Parser UniqueCouponCodeState
parseJSON Value
val =
        UniqueCouponCodeState -> Parser UniqueCouponCodeState
forall a. a -> Parser a
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
"expired" -> UniqueCouponCodeState
UniqueCouponCodeStateEnumExpired
                | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"inactive" -> UniqueCouponCodeState
UniqueCouponCodeStateEnumInactive
                | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"maxed_out" -> UniqueCouponCodeState
UniqueCouponCodeStateEnumMaxed_out
                | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"redeemable" -> UniqueCouponCodeState
UniqueCouponCodeStateEnumRedeemable
                | Bool
GHC.Base.otherwise -> Value -> UniqueCouponCodeState
UniqueCouponCodeStateOther Value
val
            )