{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module RecurlyClient.Types.CouponMini 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.CouponDiscount
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
data CouponMini = CouponMini
{ CouponMini -> Maybe Text
couponMiniCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, CouponMini -> Maybe CouponMiniCoupon_type
couponMiniCoupon_type :: (GHC.Maybe.Maybe CouponMiniCoupon_type)
, CouponMini -> Maybe CouponDiscount
couponMiniDiscount :: (GHC.Maybe.Maybe CouponDiscount)
, CouponMini -> Maybe JsonDateTime
couponMiniExpired_at :: (GHC.Maybe.Maybe RecurlyClient.Common.JsonDateTime)
, CouponMini -> Maybe Text
couponMiniId :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, CouponMini -> Maybe Text
couponMiniName :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, CouponMini -> Maybe Text
couponMiniObject :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
, CouponMini -> Maybe CouponMiniState
couponMiniState :: (GHC.Maybe.Maybe CouponMiniState)
}
deriving
( Int -> CouponMini -> ShowS
[CouponMini] -> ShowS
CouponMini -> String
(Int -> CouponMini -> ShowS)
-> (CouponMini -> String)
-> ([CouponMini] -> ShowS)
-> Show CouponMini
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CouponMini -> ShowS
showsPrec :: Int -> CouponMini -> ShowS
$cshow :: CouponMini -> String
show :: CouponMini -> String
$cshowList :: [CouponMini] -> ShowS
showList :: [CouponMini] -> ShowS
GHC.Show.Show
, CouponMini -> CouponMini -> Bool
(CouponMini -> CouponMini -> Bool)
-> (CouponMini -> CouponMini -> Bool) -> Eq CouponMini
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CouponMini -> CouponMini -> Bool
== :: CouponMini -> CouponMini -> Bool
$c/= :: CouponMini -> CouponMini -> Bool
/= :: CouponMini -> CouponMini -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON CouponMini where
toJSON :: CouponMini -> Value
toJSON CouponMini
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
"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..=)) (CouponMini -> Maybe Text
couponMiniCode CouponMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (CouponMiniCoupon_type -> [Pair])
-> Maybe CouponMiniCoupon_type
-> [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])
-> (CouponMiniCoupon_type -> Pair)
-> CouponMiniCoupon_type
-> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"coupon_type" Key -> CouponMiniCoupon_type -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (CouponMini -> Maybe CouponMiniCoupon_type
couponMiniCoupon_type CouponMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (CouponDiscount -> [Pair]) -> Maybe CouponDiscount -> [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])
-> (CouponDiscount -> Pair) -> CouponDiscount -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"discount" Key -> CouponDiscount -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (CouponMini -> Maybe CouponDiscount
couponMiniDiscount CouponMini
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..=)) (CouponMini -> Maybe JsonDateTime
couponMiniExpired_at CouponMini
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..=)) (CouponMini -> Maybe Text
couponMiniId CouponMini
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
"name" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (CouponMini -> Maybe Text
couponMiniName CouponMini
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..=)) (CouponMini -> Maybe Text
couponMiniObject CouponMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (CouponMiniState -> [Pair]) -> Maybe CouponMiniState -> [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])
-> (CouponMiniState -> Pair) -> CouponMiniState -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"state" Key -> CouponMiniState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (CouponMini -> Maybe CouponMiniState
couponMiniState CouponMini
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
toEncoding :: CouponMini -> Encoding
toEncoding CouponMini
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
"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..=)) (CouponMini -> Maybe Text
couponMiniCode CouponMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (CouponMiniCoupon_type -> [Series])
-> Maybe CouponMiniCoupon_type
-> [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])
-> (CouponMiniCoupon_type -> Series)
-> CouponMiniCoupon_type
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"coupon_type" Key -> CouponMiniCoupon_type -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (CouponMini -> Maybe CouponMiniCoupon_type
couponMiniCoupon_type CouponMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (CouponDiscount -> [Series]) -> Maybe CouponDiscount -> [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])
-> (CouponDiscount -> Series) -> CouponDiscount -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"discount" Key -> CouponDiscount -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (CouponMini -> Maybe CouponDiscount
couponMiniDiscount CouponMini
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..=)) (CouponMini -> Maybe JsonDateTime
couponMiniExpired_at CouponMini
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..=)) (CouponMini -> Maybe Text
couponMiniId CouponMini
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
"name" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (CouponMini -> Maybe Text
couponMiniName CouponMini
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..=)) (CouponMini -> Maybe Text
couponMiniObject CouponMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (CouponMiniState -> [Series])
-> Maybe CouponMiniState
-> [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])
-> (CouponMiniState -> Series) -> CouponMiniState -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"state" Key -> CouponMiniState -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (CouponMini -> Maybe CouponMiniState
couponMiniState CouponMini
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON CouponMini where
parseJSON :: Value -> Parser CouponMini
parseJSON = String
-> (Object -> Parser CouponMini) -> Value -> Parser CouponMini
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"CouponMini" (\Object
obj -> ((((((((Maybe Text
-> Maybe CouponMiniCoupon_type
-> Maybe CouponDiscount
-> Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CouponMiniState
-> CouponMini)
-> Parser
(Maybe Text
-> Maybe CouponMiniCoupon_type
-> Maybe CouponDiscount
-> Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CouponMiniState
-> CouponMini)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Maybe CouponMiniCoupon_type
-> Maybe CouponDiscount
-> Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CouponMiniState
-> CouponMini
CouponMini Parser
(Maybe Text
-> Maybe CouponMiniCoupon_type
-> Maybe CouponDiscount
-> Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CouponMiniState
-> CouponMini)
-> Parser (Maybe Text)
-> Parser
(Maybe CouponMiniCoupon_type
-> Maybe CouponDiscount
-> Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CouponMiniState
-> CouponMini)
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 CouponMiniCoupon_type
-> Maybe CouponDiscount
-> Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CouponMiniState
-> CouponMini)
-> Parser (Maybe CouponMiniCoupon_type)
-> Parser
(Maybe CouponDiscount
-> Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CouponMiniState
-> CouponMini)
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 CouponMiniCoupon_type)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"coupon_type")) Parser
(Maybe CouponDiscount
-> Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CouponMiniState
-> CouponMini)
-> Parser (Maybe CouponDiscount)
-> Parser
(Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CouponMiniState
-> CouponMini)
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 CouponDiscount)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"discount")) Parser
(Maybe JsonDateTime
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CouponMiniState
-> CouponMini)
-> Parser (Maybe JsonDateTime)
-> Parser
(Maybe Text
-> Maybe Text -> Maybe Text -> Maybe CouponMiniState -> CouponMini)
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 Text -> Maybe CouponMiniState -> CouponMini)
-> Parser (Maybe Text)
-> Parser
(Maybe Text -> Maybe Text -> Maybe CouponMiniState -> CouponMini)
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 Text -> Maybe CouponMiniState -> CouponMini)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe CouponMiniState -> CouponMini)
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
"name")) Parser (Maybe Text -> Maybe CouponMiniState -> CouponMini)
-> Parser (Maybe Text)
-> Parser (Maybe CouponMiniState -> CouponMini)
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 CouponMiniState -> CouponMini)
-> Parser (Maybe CouponMiniState) -> Parser CouponMini
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 CouponMiniState)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"state"))
mkCouponMini :: CouponMini
mkCouponMini :: CouponMini
mkCouponMini =
CouponMini
{ couponMiniCode :: Maybe Text
couponMiniCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, couponMiniCoupon_type :: Maybe CouponMiniCoupon_type
couponMiniCoupon_type = Maybe CouponMiniCoupon_type
forall a. Maybe a
GHC.Maybe.Nothing
, couponMiniDiscount :: Maybe CouponDiscount
couponMiniDiscount = Maybe CouponDiscount
forall a. Maybe a
GHC.Maybe.Nothing
, couponMiniExpired_at :: Maybe JsonDateTime
couponMiniExpired_at = Maybe JsonDateTime
forall a. Maybe a
GHC.Maybe.Nothing
, couponMiniId :: Maybe Text
couponMiniId = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, couponMiniName :: Maybe Text
couponMiniName = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, couponMiniObject :: Maybe Text
couponMiniObject = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
, couponMiniState :: Maybe CouponMiniState
couponMiniState = Maybe CouponMiniState
forall a. Maybe a
GHC.Maybe.Nothing
}
data CouponMiniCoupon_type
=
CouponMiniCoupon_typeOther Data.Aeson.Types.Internal.Value
|
CouponMiniCoupon_typeTyped Data.Text.Internal.Text
|
CouponMiniCoupon_typeEnumBulk
|
CouponMiniCoupon_typeEnumSingle_code
deriving (Int -> CouponMiniCoupon_type -> ShowS
[CouponMiniCoupon_type] -> ShowS
CouponMiniCoupon_type -> String
(Int -> CouponMiniCoupon_type -> ShowS)
-> (CouponMiniCoupon_type -> String)
-> ([CouponMiniCoupon_type] -> ShowS)
-> Show CouponMiniCoupon_type
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CouponMiniCoupon_type -> ShowS
showsPrec :: Int -> CouponMiniCoupon_type -> ShowS
$cshow :: CouponMiniCoupon_type -> String
show :: CouponMiniCoupon_type -> String
$cshowList :: [CouponMiniCoupon_type] -> ShowS
showList :: [CouponMiniCoupon_type] -> ShowS
GHC.Show.Show, CouponMiniCoupon_type -> CouponMiniCoupon_type -> Bool
(CouponMiniCoupon_type -> CouponMiniCoupon_type -> Bool)
-> (CouponMiniCoupon_type -> CouponMiniCoupon_type -> Bool)
-> Eq CouponMiniCoupon_type
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CouponMiniCoupon_type -> CouponMiniCoupon_type -> Bool
== :: CouponMiniCoupon_type -> CouponMiniCoupon_type -> Bool
$c/= :: CouponMiniCoupon_type -> CouponMiniCoupon_type -> Bool
/= :: CouponMiniCoupon_type -> CouponMiniCoupon_type -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON CouponMiniCoupon_type where
toJSON :: CouponMiniCoupon_type -> Value
toJSON (CouponMiniCoupon_typeOther Value
val) = Value
val
toJSON (CouponMiniCoupon_typeTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (CouponMiniCoupon_type
CouponMiniCoupon_typeEnumBulk) = Value
"bulk"
toJSON (CouponMiniCoupon_type
CouponMiniCoupon_typeEnumSingle_code) = Value
"single_code"
instance Data.Aeson.Types.FromJSON.FromJSON CouponMiniCoupon_type where
parseJSON :: Value -> Parser CouponMiniCoupon_type
parseJSON Value
val =
CouponMiniCoupon_type -> Parser CouponMiniCoupon_type
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
"bulk" -> CouponMiniCoupon_type
CouponMiniCoupon_typeEnumBulk
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"single_code" -> CouponMiniCoupon_type
CouponMiniCoupon_typeEnumSingle_code
| Bool
GHC.Base.otherwise -> Value -> CouponMiniCoupon_type
CouponMiniCoupon_typeOther Value
val
)
data CouponMiniState
=
CouponMiniStateOther Data.Aeson.Types.Internal.Value
|
CouponMiniStateTyped Data.Text.Internal.Text
|
CouponMiniStateEnumExpired
|
CouponMiniStateEnumMaxed_out
|
CouponMiniStateEnumRedeemable
deriving (Int -> CouponMiniState -> ShowS
[CouponMiniState] -> ShowS
CouponMiniState -> String
(Int -> CouponMiniState -> ShowS)
-> (CouponMiniState -> String)
-> ([CouponMiniState] -> ShowS)
-> Show CouponMiniState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CouponMiniState -> ShowS
showsPrec :: Int -> CouponMiniState -> ShowS
$cshow :: CouponMiniState -> String
show :: CouponMiniState -> String
$cshowList :: [CouponMiniState] -> ShowS
showList :: [CouponMiniState] -> ShowS
GHC.Show.Show, CouponMiniState -> CouponMiniState -> Bool
(CouponMiniState -> CouponMiniState -> Bool)
-> (CouponMiniState -> CouponMiniState -> Bool)
-> Eq CouponMiniState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CouponMiniState -> CouponMiniState -> Bool
== :: CouponMiniState -> CouponMiniState -> Bool
$c/= :: CouponMiniState -> CouponMiniState -> Bool
/= :: CouponMiniState -> CouponMiniState -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON CouponMiniState where
toJSON :: CouponMiniState -> Value
toJSON (CouponMiniStateOther Value
val) = Value
val
toJSON (CouponMiniStateTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (CouponMiniState
CouponMiniStateEnumExpired) = Value
"expired"
toJSON (CouponMiniState
CouponMiniStateEnumMaxed_out) = Value
"maxed_out"
toJSON (CouponMiniState
CouponMiniStateEnumRedeemable) = Value
"redeemable"
instance Data.Aeson.Types.FromJSON.FromJSON CouponMiniState where
parseJSON :: Value -> Parser CouponMiniState
parseJSON Value
val =
CouponMiniState -> Parser CouponMiniState
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" -> CouponMiniState
CouponMiniStateEnumExpired
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"maxed_out" -> CouponMiniState
CouponMiniStateEnumMaxed_out
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"redeemable" -> CouponMiniState
CouponMiniStateEnumRedeemable
| Bool
GHC.Base.otherwise -> Value -> CouponMiniState
CouponMiniStateOther Value
val
)