{-# 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 CouponRedemption
module RecurlyClient.Types.CouponRedemption 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 {-# SOURCE #-} RecurlyClient.Types.AccountMini
import {-# SOURCE #-} RecurlyClient.Types.Coupon
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.CouponRedemption@ in the specification.
data CouponRedemption = CouponRedemption
    { CouponRedemption -> Maybe AccountMini
couponRedemptionAccount :: (GHC.Maybe.Maybe AccountMini)
    -- ^ account
    , CouponRedemption -> Maybe Coupon
couponRedemptionCoupon :: (GHC.Maybe.Maybe Coupon)
    -- ^ coupon
    , CouponRedemption -> Maybe JsonDateTime
couponRedemptionCreated_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ created_at
    , CouponRedemption -> Maybe Text
couponRedemptionCurrency :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ currency: 3-letter ISO 4217 currency code.
    --
    -- Constraints:
    --
    -- * Maximum length of 3
    , CouponRedemption -> Maybe Float
couponRedemptionDiscounted :: (GHC.Maybe.Maybe GHC.Types.Float)
    -- ^ discounted: The amount that was discounted upon the application of the coupon, formatted with the currency.
    , CouponRedemption -> Maybe Text
couponRedemptionId :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ id
    , CouponRedemption -> Maybe Text
couponRedemptionObject :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ object: Will always be \`coupon\`.
    , CouponRedemption -> Maybe JsonDateTime
couponRedemptionRemoved_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ removed_at: The date and time the redemption was removed from the account (un-redeemed).
    , CouponRedemption -> Maybe CouponRedemptionState
couponRedemptionState :: (GHC.Maybe.Maybe CouponRedemptionState)
    -- ^ state
    , CouponRedemption -> Maybe Text
couponRedemptionSubscription_id :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
    -- ^ subscription_id
    , CouponRedemption -> Maybe JsonDateTime
couponRedemptionUpdated_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
    -- ^ updated_at
    }
    deriving
        ( Int -> CouponRedemption -> ShowS
[CouponRedemption] -> ShowS
CouponRedemption -> String
(Int -> CouponRedemption -> ShowS)
-> (CouponRedemption -> String)
-> ([CouponRedemption] -> ShowS)
-> Show CouponRedemption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CouponRedemption -> ShowS
showsPrec :: Int -> CouponRedemption -> ShowS
$cshow :: CouponRedemption -> String
show :: CouponRedemption -> String
$cshowList :: [CouponRedemption] -> ShowS
showList :: [CouponRedemption] -> ShowS
GHC.Show.Show
        , CouponRedemption -> CouponRedemption -> Bool
(CouponRedemption -> CouponRedemption -> Bool)
-> (CouponRedemption -> CouponRedemption -> Bool)
-> Eq CouponRedemption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CouponRedemption -> CouponRedemption -> Bool
== :: CouponRedemption -> CouponRedemption -> Bool
$c/= :: CouponRedemption -> CouponRedemption -> Bool
/= :: CouponRedemption -> CouponRedemption -> Bool
GHC.Classes.Eq
        )

instance Data.Aeson.Types.ToJSON.ToJSON CouponRedemption where
    toJSON :: CouponRedemption -> Value
toJSON CouponRedemption
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Pair] -> (AccountMini -> [Pair]) -> Maybe AccountMini -> [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]) -> (AccountMini -> Pair) -> AccountMini -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"account" Key -> AccountMini -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (CouponRedemption -> Maybe AccountMini
couponRedemptionAccount CouponRedemption
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Coupon -> [Pair]) -> Maybe Coupon -> [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]) -> (Coupon -> Pair) -> Coupon -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"coupon" Key -> Coupon -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (CouponRedemption -> Maybe Coupon
couponRedemptionCoupon CouponRedemption
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..=)) (CouponRedemption -> Maybe JsonDateTime
couponRedemptionCreated_at CouponRedemption
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
"currency" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (CouponRedemption -> Maybe Text
couponRedemptionCurrency CouponRedemption
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Float -> [Pair]) -> Maybe Float -> [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]) -> (Float -> Pair) -> Float -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"discounted" Key -> Float -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (CouponRedemption -> Maybe Float
couponRedemptionDiscounted CouponRedemption
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..=)) (CouponRedemption -> Maybe Text
couponRedemptionId CouponRedemption
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..=)) (CouponRedemption -> Maybe Text
couponRedemptionObject CouponRedemption
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
"removed_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..=)) (CouponRedemption -> Maybe JsonDateTime
couponRedemptionRemoved_at CouponRedemption
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (CouponRedemptionState -> [Pair])
-> Maybe CouponRedemptionState
-> [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])
-> (CouponRedemptionState -> Pair)
-> CouponRedemptionState
-> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"state" Key -> CouponRedemptionState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (CouponRedemption -> Maybe CouponRedemptionState
couponRedemptionState CouponRedemption
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
"subscription_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..=)) (CouponRedemption -> Maybe Text
couponRedemptionSubscription_id CouponRedemption
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..=)) (CouponRedemption -> Maybe JsonDateTime
couponRedemptionUpdated_at CouponRedemption
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
    toEncoding :: CouponRedemption -> Encoding
toEncoding CouponRedemption
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]
-> (AccountMini -> [Series]) -> Maybe AccountMini -> [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])
-> (AccountMini -> Series) -> AccountMini -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"account" Key -> AccountMini -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (CouponRedemption -> Maybe AccountMini
couponRedemptionAccount CouponRedemption
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Coupon -> [Series]) -> Maybe Coupon -> [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]) -> (Coupon -> Series) -> Coupon -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"coupon" Key -> Coupon -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (CouponRedemption -> Maybe Coupon
couponRedemptionCoupon CouponRedemption
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..=)) (CouponRedemption -> Maybe JsonDateTime
couponRedemptionCreated_at CouponRedemption
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
"currency" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (CouponRedemption -> Maybe Text
couponRedemptionCurrency CouponRedemption
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Float -> [Series]) -> Maybe Float -> [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]) -> (Float -> Series) -> Float -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"discounted" Key -> Float -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (CouponRedemption -> Maybe Float
couponRedemptionDiscounted CouponRedemption
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..=)) (CouponRedemption -> Maybe Text
couponRedemptionId CouponRedemption
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..=)) (CouponRedemption -> Maybe Text
couponRedemptionObject CouponRedemption
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
"removed_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..=)) (CouponRedemption -> Maybe JsonDateTime
couponRedemptionRemoved_at CouponRedemption
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (CouponRedemptionState -> [Series])
-> Maybe CouponRedemptionState
-> [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])
-> (CouponRedemptionState -> Series)
-> CouponRedemptionState
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"state" Key -> CouponRedemptionState -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (CouponRedemption -> Maybe CouponRedemptionState
couponRedemptionState CouponRedemption
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
"subscription_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..=)) (CouponRedemption -> Maybe Text
couponRedemptionSubscription_id CouponRedemption
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..=)) (CouponRedemption -> Maybe JsonDateTime
couponRedemptionUpdated_at CouponRedemption
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON CouponRedemption where
    parseJSON :: Value -> Parser CouponRedemption
parseJSON = String
-> (Object -> Parser CouponRedemption)
-> Value
-> Parser CouponRedemption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"CouponRedemption" (\Object
obj -> (((((((((((Maybe AccountMini
 -> Maybe Coupon
 -> Maybe JsonDateTime
 -> Maybe Text
 -> Maybe Float
 -> Maybe Text
 -> Maybe Text
 -> Maybe JsonDateTime
 -> Maybe CouponRedemptionState
 -> Maybe Text
 -> Maybe JsonDateTime
 -> CouponRedemption)
-> Parser
     (Maybe AccountMini
      -> Maybe Coupon
      -> Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Float
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe CouponRedemptionState
      -> Maybe Text
      -> Maybe JsonDateTime
      -> CouponRedemption)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe AccountMini
-> Maybe Coupon
-> Maybe JsonDateTime
-> Maybe Text
-> Maybe Float
-> Maybe Text
-> Maybe Text
-> Maybe JsonDateTime
-> Maybe CouponRedemptionState
-> Maybe Text
-> Maybe JsonDateTime
-> CouponRedemption
CouponRedemption Parser
  (Maybe AccountMini
   -> Maybe Coupon
   -> Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Float
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe CouponRedemptionState
   -> Maybe Text
   -> Maybe JsonDateTime
   -> CouponRedemption)
-> Parser (Maybe AccountMini)
-> Parser
     (Maybe Coupon
      -> Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Float
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe CouponRedemptionState
      -> Maybe Text
      -> Maybe JsonDateTime
      -> CouponRedemption)
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 AccountMini)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"account")) Parser
  (Maybe Coupon
   -> Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Float
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe CouponRedemptionState
   -> Maybe Text
   -> Maybe JsonDateTime
   -> CouponRedemption)
-> Parser (Maybe Coupon)
-> Parser
     (Maybe JsonDateTime
      -> Maybe Text
      -> Maybe Float
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe CouponRedemptionState
      -> Maybe Text
      -> Maybe JsonDateTime
      -> CouponRedemption)
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 Coupon)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"coupon")) Parser
  (Maybe JsonDateTime
   -> Maybe Text
   -> Maybe Float
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe CouponRedemptionState
   -> Maybe Text
   -> Maybe JsonDateTime
   -> CouponRedemption)
-> Parser (Maybe JsonDateTime)
-> Parser
     (Maybe Text
      -> Maybe Float
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe CouponRedemptionState
      -> Maybe Text
      -> Maybe JsonDateTime
      -> CouponRedemption)
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 Text
   -> Maybe Float
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe CouponRedemptionState
   -> Maybe Text
   -> Maybe JsonDateTime
   -> CouponRedemption)
-> Parser (Maybe Text)
-> Parser
     (Maybe Float
      -> Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe CouponRedemptionState
      -> Maybe Text
      -> Maybe JsonDateTime
      -> CouponRedemption)
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
"currency")) Parser
  (Maybe Float
   -> Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe CouponRedemptionState
   -> Maybe Text
   -> Maybe JsonDateTime
   -> CouponRedemption)
-> Parser (Maybe Float)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe JsonDateTime
      -> Maybe CouponRedemptionState
      -> Maybe Text
      -> Maybe JsonDateTime
      -> CouponRedemption)
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 Float)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"discounted")) Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe JsonDateTime
   -> Maybe CouponRedemptionState
   -> Maybe Text
   -> Maybe JsonDateTime
   -> CouponRedemption)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe JsonDateTime
      -> Maybe CouponRedemptionState
      -> Maybe Text
      -> Maybe JsonDateTime
      -> CouponRedemption)
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 CouponRedemptionState
   -> Maybe Text
   -> Maybe JsonDateTime
   -> CouponRedemption)
-> Parser (Maybe Text)
-> Parser
     (Maybe JsonDateTime
      -> Maybe CouponRedemptionState
      -> Maybe Text
      -> Maybe JsonDateTime
      -> CouponRedemption)
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 CouponRedemptionState
   -> Maybe Text
   -> Maybe JsonDateTime
   -> CouponRedemption)
-> Parser (Maybe JsonDateTime)
-> Parser
     (Maybe CouponRedemptionState
      -> Maybe Text -> Maybe JsonDateTime -> CouponRedemption)
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
"removed_at")) Parser
  (Maybe CouponRedemptionState
   -> Maybe Text -> Maybe JsonDateTime -> CouponRedemption)
-> Parser (Maybe CouponRedemptionState)
-> Parser (Maybe Text -> Maybe JsonDateTime -> CouponRedemption)
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 CouponRedemptionState)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"state")) Parser (Maybe Text -> Maybe JsonDateTime -> CouponRedemption)
-> Parser (Maybe Text)
-> Parser (Maybe JsonDateTime -> CouponRedemption)
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
"subscription_id")) Parser (Maybe JsonDateTime -> CouponRedemption)
-> Parser (Maybe JsonDateTime) -> Parser CouponRedemption
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 'CouponRedemption' with all required fields.
mkCouponRedemption :: CouponRedemption
mkCouponRedemption :: CouponRedemption
mkCouponRedemption =
    CouponRedemption
        { couponRedemptionAccount :: Maybe AccountMini
couponRedemptionAccount = Maybe AccountMini
forall a. Maybe a
GHC.Maybe.Nothing
        , couponRedemptionCoupon :: Maybe Coupon
couponRedemptionCoupon = Maybe Coupon
forall a. Maybe a
GHC.Maybe.Nothing
        , couponRedemptionCreated_at :: Maybe JsonDateTime
couponRedemptionCreated_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , couponRedemptionCurrency :: Maybe Text
couponRedemptionCurrency = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , couponRedemptionDiscounted :: Maybe Float
couponRedemptionDiscounted = Maybe Float
forall a. Maybe a
GHC.Maybe.Nothing
        , couponRedemptionId :: Maybe Text
couponRedemptionId = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , couponRedemptionObject :: Maybe Text
couponRedemptionObject = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , couponRedemptionRemoved_at :: Maybe JsonDateTime
couponRedemptionRemoved_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        , couponRedemptionState :: Maybe CouponRedemptionState
couponRedemptionState = Maybe CouponRedemptionState
forall a. Maybe a
GHC.Maybe.Nothing
        , couponRedemptionSubscription_id :: Maybe Text
couponRedemptionSubscription_id = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
        , couponRedemptionUpdated_at :: Maybe JsonDateTime
couponRedemptionUpdated_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
        }

-- | Defines the enum schema located at @components.schemas.CouponRedemption.properties.state@ in the specification.
data CouponRedemptionState
    = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
      CouponRedemptionStateOther Data.Aeson.Types.Internal.Value
    | -- | This constructor can be used to send values to the server which are not present in the specification yet.
      CouponRedemptionStateTyped Data.Text.Internal.Text
    | -- | Represents the JSON value @"active"@
      CouponRedemptionStateEnumActive
    | -- | Represents the JSON value @"inactive"@
      CouponRedemptionStateEnumInactive
    deriving (Int -> CouponRedemptionState -> ShowS
[CouponRedemptionState] -> ShowS
CouponRedemptionState -> String
(Int -> CouponRedemptionState -> ShowS)
-> (CouponRedemptionState -> String)
-> ([CouponRedemptionState] -> ShowS)
-> Show CouponRedemptionState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CouponRedemptionState -> ShowS
showsPrec :: Int -> CouponRedemptionState -> ShowS
$cshow :: CouponRedemptionState -> String
show :: CouponRedemptionState -> String
$cshowList :: [CouponRedemptionState] -> ShowS
showList :: [CouponRedemptionState] -> ShowS
GHC.Show.Show, CouponRedemptionState -> CouponRedemptionState -> Bool
(CouponRedemptionState -> CouponRedemptionState -> Bool)
-> (CouponRedemptionState -> CouponRedemptionState -> Bool)
-> Eq CouponRedemptionState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CouponRedemptionState -> CouponRedemptionState -> Bool
== :: CouponRedemptionState -> CouponRedemptionState -> Bool
$c/= :: CouponRedemptionState -> CouponRedemptionState -> Bool
/= :: CouponRedemptionState -> CouponRedemptionState -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON CouponRedemptionState where
    toJSON :: CouponRedemptionState -> Value
toJSON (CouponRedemptionStateOther Value
val) = Value
val
    toJSON (CouponRedemptionStateTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
    toJSON (CouponRedemptionState
CouponRedemptionStateEnumActive) = Value
"active"
    toJSON (CouponRedemptionState
CouponRedemptionStateEnumInactive) = Value
"inactive"
instance Data.Aeson.Types.FromJSON.FromJSON CouponRedemptionState where
    parseJSON :: Value -> Parser CouponRedemptionState
parseJSON Value
val =
        CouponRedemptionState -> Parser CouponRedemptionState
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
"active" -> CouponRedemptionState
CouponRedemptionStateEnumActive
                | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"inactive" -> CouponRedemptionState
CouponRedemptionStateEnumInactive
                | Bool
GHC.Base.otherwise -> Value -> CouponRedemptionState
CouponRedemptionStateOther Value
val
            )