{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Operations.PostPromotionCodes where
import qualified Control.Monad.Fail
import qualified Control.Monad.Trans.Reader
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.Either
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 Data.Vector
import qualified GHC.Base
import qualified GHC.Classes
import qualified GHC.Int
import qualified GHC.Show
import qualified GHC.Types
import qualified Network.HTTP.Client
import qualified Network.HTTP.Client as Network.HTTP.Client.Request
import qualified Network.HTTP.Client as Network.HTTP.Client.Types
import qualified Network.HTTP.Simple
import qualified Network.HTTP.Types
import qualified Network.HTTP.Types as Network.HTTP.Types.Status
import qualified Network.HTTP.Types as Network.HTTP.Types.URI
import qualified StripeAPI.Common
import StripeAPI.Types
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
postPromotionCodes ::
forall m.
StripeAPI.Common.MonadHTTP m =>
PostPromotionCodesRequestBody ->
StripeAPI.Common.StripeT m (Network.HTTP.Client.Types.Response PostPromotionCodesResponse)
postPromotionCodes :: PostPromotionCodesRequestBody
-> StripeT m (Response PostPromotionCodesResponse)
postPromotionCodes PostPromotionCodesRequestBody
body =
(Response ByteString -> Response PostPromotionCodesResponse)
-> StripeT m (Response ByteString)
-> StripeT m (Response PostPromotionCodesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
( \Response ByteString
response_0 ->
(ByteString -> PostPromotionCodesResponse)
-> Response ByteString -> Response PostPromotionCodesResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
( (String -> PostPromotionCodesResponse)
-> (PostPromotionCodesResponse -> PostPromotionCodesResponse)
-> Either String PostPromotionCodesResponse
-> PostPromotionCodesResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostPromotionCodesResponse
PostPromotionCodesResponseError PostPromotionCodesResponse -> PostPromotionCodesResponse
forall a. a -> a
GHC.Base.id
(Either String PostPromotionCodesResponse
-> PostPromotionCodesResponse)
-> (ByteString -> Either String PostPromotionCodesResponse)
-> ByteString
-> PostPromotionCodesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. ( \Response ByteString
response ByteString
body ->
if
| (\Status
status_1 -> Status -> Int
Network.HTTP.Types.Status.statusCode Status
status_1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Int
200) (Response ByteString -> Status
forall body. Response body -> Status
Network.HTTP.Client.Types.responseStatus Response ByteString
response) ->
PromotionCode -> PostPromotionCodesResponse
PostPromotionCodesResponse200
(PromotionCode -> PostPromotionCodesResponse)
-> Either String PromotionCode
-> Either String PostPromotionCodesResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String PromotionCode
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
Data.Either.Either
GHC.Base.String
PromotionCode
)
| Bool -> Status -> Bool
forall a b. a -> b -> a
GHC.Base.const Bool
GHC.Types.True (Response ByteString -> Status
forall body. Response body -> Status
Network.HTTP.Client.Types.responseStatus Response ByteString
response) ->
Error -> PostPromotionCodesResponse
PostPromotionCodesResponseDefault
(Error -> PostPromotionCodesResponse)
-> Either String Error -> Either String PostPromotionCodesResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String Error
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
Data.Either.Either
GHC.Base.String
Error
)
| Bool
GHC.Base.otherwise -> String -> Either String PostPromotionCodesResponse
forall a b. a -> Either a b
Data.Either.Left String
"Missing default response type"
)
Response ByteString
response_0
)
Response ByteString
response_0
)
(Text
-> Text
-> [QueryParameter]
-> Maybe PostPromotionCodesRequestBody
-> RequestBodyEncoding
-> StripeT m (Response ByteString)
forall (m :: * -> *) body.
(MonadHTTP m, ToJSON body) =>
Text
-> Text
-> [QueryParameter]
-> Maybe body
-> RequestBodyEncoding
-> StripeT m (Response ByteString)
StripeAPI.Common.doBodyCallWithConfigurationM (Text -> Text
Data.Text.toUpper (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
GHC.Base.$ String -> Text
Data.Text.pack String
"POST") (String -> Text
Data.Text.pack String
"/v1/promotion_codes") [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty (PostPromotionCodesRequestBody
-> Maybe PostPromotionCodesRequestBody
forall a. a -> Maybe a
GHC.Maybe.Just PostPromotionCodesRequestBody
body) RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)
data PostPromotionCodesRequestBody = PostPromotionCodesRequestBody
{
PostPromotionCodesRequestBody -> Maybe Bool
postPromotionCodesRequestBodyActive :: (GHC.Maybe.Maybe GHC.Types.Bool),
PostPromotionCodesRequestBody -> Maybe Text
postPromotionCodesRequestBodyCode :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
PostPromotionCodesRequestBody -> Text
postPromotionCodesRequestBodyCoupon :: Data.Text.Internal.Text,
PostPromotionCodesRequestBody -> Maybe Text
postPromotionCodesRequestBodyCustomer :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
PostPromotionCodesRequestBody -> Maybe [Text]
postPromotionCodesRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
PostPromotionCodesRequestBody -> Maybe Int
postPromotionCodesRequestBodyExpiresAt :: (GHC.Maybe.Maybe GHC.Types.Int),
PostPromotionCodesRequestBody -> Maybe Int
postPromotionCodesRequestBodyMaxRedemptions :: (GHC.Maybe.Maybe GHC.Types.Int),
PostPromotionCodesRequestBody -> Maybe Object
postPromotionCodesRequestBodyMetadata :: (GHC.Maybe.Maybe Data.Aeson.Types.Internal.Object),
PostPromotionCodesRequestBody
-> Maybe PostPromotionCodesRequestBodyRestrictions'
postPromotionCodesRequestBodyRestrictions :: (GHC.Maybe.Maybe PostPromotionCodesRequestBodyRestrictions')
}
deriving
( Int -> PostPromotionCodesRequestBody -> ShowS
[PostPromotionCodesRequestBody] -> ShowS
PostPromotionCodesRequestBody -> String
(Int -> PostPromotionCodesRequestBody -> ShowS)
-> (PostPromotionCodesRequestBody -> String)
-> ([PostPromotionCodesRequestBody] -> ShowS)
-> Show PostPromotionCodesRequestBody
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostPromotionCodesRequestBody] -> ShowS
$cshowList :: [PostPromotionCodesRequestBody] -> ShowS
show :: PostPromotionCodesRequestBody -> String
$cshow :: PostPromotionCodesRequestBody -> String
showsPrec :: Int -> PostPromotionCodesRequestBody -> ShowS
$cshowsPrec :: Int -> PostPromotionCodesRequestBody -> ShowS
GHC.Show.Show,
PostPromotionCodesRequestBody
-> PostPromotionCodesRequestBody -> Bool
(PostPromotionCodesRequestBody
-> PostPromotionCodesRequestBody -> Bool)
-> (PostPromotionCodesRequestBody
-> PostPromotionCodesRequestBody -> Bool)
-> Eq PostPromotionCodesRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostPromotionCodesRequestBody
-> PostPromotionCodesRequestBody -> Bool
$c/= :: PostPromotionCodesRequestBody
-> PostPromotionCodesRequestBody -> Bool
== :: PostPromotionCodesRequestBody
-> PostPromotionCodesRequestBody -> Bool
$c== :: PostPromotionCodesRequestBody
-> PostPromotionCodesRequestBody -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON PostPromotionCodesRequestBody where
toJSON :: PostPromotionCodesRequestBody -> Value
toJSON PostPromotionCodesRequestBody
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"active" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe Bool
postPromotionCodesRequestBodyActive PostPromotionCodesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"code" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe Text
postPromotionCodesRequestBodyCode PostPromotionCodesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"coupon" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Text
postPromotionCodesRequestBodyCoupon PostPromotionCodesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"customer" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe Text
postPromotionCodesRequestBodyCustomer PostPromotionCodesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"expand" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe [Text]
postPromotionCodesRequestBodyExpand PostPromotionCodesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"expires_at" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe Int
postPromotionCodesRequestBodyExpiresAt PostPromotionCodesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"max_redemptions" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe Int
postPromotionCodesRequestBodyMaxRedemptions PostPromotionCodesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Maybe Object -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe Object
postPromotionCodesRequestBodyMetadata PostPromotionCodesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"restrictions" Text -> Maybe PostPromotionCodesRequestBodyRestrictions' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody
-> Maybe PostPromotionCodesRequestBodyRestrictions'
postPromotionCodesRequestBodyRestrictions PostPromotionCodesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: PostPromotionCodesRequestBody -> Encoding
toEncoding PostPromotionCodesRequestBody
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"active" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe Bool
postPromotionCodesRequestBodyActive PostPromotionCodesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"code" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe Text
postPromotionCodesRequestBodyCode PostPromotionCodesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"coupon" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Text
postPromotionCodesRequestBodyCoupon PostPromotionCodesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"customer" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe Text
postPromotionCodesRequestBodyCustomer PostPromotionCodesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"expand" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe [Text]
postPromotionCodesRequestBodyExpand PostPromotionCodesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"expires_at" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe Int
postPromotionCodesRequestBodyExpiresAt PostPromotionCodesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"max_redemptions" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe Int
postPromotionCodesRequestBodyMaxRedemptions PostPromotionCodesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text -> Maybe Object -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody -> Maybe Object
postPromotionCodesRequestBodyMetadata PostPromotionCodesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"restrictions" Text -> Maybe PostPromotionCodesRequestBodyRestrictions' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBody
-> Maybe PostPromotionCodesRequestBodyRestrictions'
postPromotionCodesRequestBodyRestrictions PostPromotionCodesRequestBody
obj)))))))))
instance Data.Aeson.Types.FromJSON.FromJSON PostPromotionCodesRequestBody where
parseJSON :: Value -> Parser PostPromotionCodesRequestBody
parseJSON = String
-> (Object -> Parser PostPromotionCodesRequestBody)
-> Value
-> Parser PostPromotionCodesRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostPromotionCodesRequestBody" (\Object
obj -> (((((((((Maybe Bool
-> Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
-> Parser
(Maybe Bool
-> Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Bool
-> Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody
PostPromotionCodesRequestBody Parser
(Maybe Bool
-> Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
-> Parser (Maybe Bool)
-> Parser
(Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"active")) Parser
(Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
-> Parser (Maybe Text)
-> Parser
(Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
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
"code")) Parser
(Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
-> Parser Text
-> Parser
(Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
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
"coupon")) Parser
(Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
-> Parser (Maybe Text)
-> Parser
(Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
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
"customer")) Parser
(Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
-> Parser (Maybe [Text])
-> Parser
(Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
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
"expand")) Parser
(Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
-> Parser (Maybe Int)
-> Parser
(Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"expires_at")) Parser
(Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
-> Parser (Maybe Int)
-> Parser
(Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"max_redemptions")) Parser
(Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
-> Parser (Maybe Object)
-> Parser
(Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Object)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"metadata")) Parser
(Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody)
-> Parser (Maybe PostPromotionCodesRequestBodyRestrictions')
-> Parser PostPromotionCodesRequestBody
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser (Maybe PostPromotionCodesRequestBodyRestrictions')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"restrictions"))
mkPostPromotionCodesRequestBody ::
Data.Text.Internal.Text ->
PostPromotionCodesRequestBody
mkPostPromotionCodesRequestBody :: Text -> PostPromotionCodesRequestBody
mkPostPromotionCodesRequestBody Text
postPromotionCodesRequestBodyCoupon =
PostPromotionCodesRequestBody :: Maybe Bool
-> Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Object
-> Maybe PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBody
PostPromotionCodesRequestBody
{ postPromotionCodesRequestBodyActive :: Maybe Bool
postPromotionCodesRequestBodyActive = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing,
postPromotionCodesRequestBodyCode :: Maybe Text
postPromotionCodesRequestBodyCode = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
postPromotionCodesRequestBodyCoupon :: Text
postPromotionCodesRequestBodyCoupon = Text
postPromotionCodesRequestBodyCoupon,
postPromotionCodesRequestBodyCustomer :: Maybe Text
postPromotionCodesRequestBodyCustomer = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
postPromotionCodesRequestBodyExpand :: Maybe [Text]
postPromotionCodesRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
postPromotionCodesRequestBodyExpiresAt :: Maybe Int
postPromotionCodesRequestBodyExpiresAt = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
postPromotionCodesRequestBodyMaxRedemptions :: Maybe Int
postPromotionCodesRequestBodyMaxRedemptions = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
postPromotionCodesRequestBodyMetadata :: Maybe Object
postPromotionCodesRequestBodyMetadata = Maybe Object
forall a. Maybe a
GHC.Maybe.Nothing,
postPromotionCodesRequestBodyRestrictions :: Maybe PostPromotionCodesRequestBodyRestrictions'
postPromotionCodesRequestBodyRestrictions = Maybe PostPromotionCodesRequestBodyRestrictions'
forall a. Maybe a
GHC.Maybe.Nothing
}
data PostPromotionCodesRequestBodyRestrictions' = PostPromotionCodesRequestBodyRestrictions'
{
PostPromotionCodesRequestBodyRestrictions' -> Maybe Bool
postPromotionCodesRequestBodyRestrictions'FirstTimeTransaction :: (GHC.Maybe.Maybe GHC.Types.Bool),
PostPromotionCodesRequestBodyRestrictions' -> Maybe Int
postPromotionCodesRequestBodyRestrictions'MinimumAmount :: (GHC.Maybe.Maybe GHC.Types.Int),
PostPromotionCodesRequestBodyRestrictions' -> Maybe Text
postPromotionCodesRequestBodyRestrictions'MinimumAmountCurrency :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
}
deriving
( Int -> PostPromotionCodesRequestBodyRestrictions' -> ShowS
[PostPromotionCodesRequestBodyRestrictions'] -> ShowS
PostPromotionCodesRequestBodyRestrictions' -> String
(Int -> PostPromotionCodesRequestBodyRestrictions' -> ShowS)
-> (PostPromotionCodesRequestBodyRestrictions' -> String)
-> ([PostPromotionCodesRequestBodyRestrictions'] -> ShowS)
-> Show PostPromotionCodesRequestBodyRestrictions'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostPromotionCodesRequestBodyRestrictions'] -> ShowS
$cshowList :: [PostPromotionCodesRequestBodyRestrictions'] -> ShowS
show :: PostPromotionCodesRequestBodyRestrictions' -> String
$cshow :: PostPromotionCodesRequestBodyRestrictions' -> String
showsPrec :: Int -> PostPromotionCodesRequestBodyRestrictions' -> ShowS
$cshowsPrec :: Int -> PostPromotionCodesRequestBodyRestrictions' -> ShowS
GHC.Show.Show,
PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBodyRestrictions' -> Bool
(PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBodyRestrictions' -> Bool)
-> (PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBodyRestrictions' -> Bool)
-> Eq PostPromotionCodesRequestBodyRestrictions'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBodyRestrictions' -> Bool
$c/= :: PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBodyRestrictions' -> Bool
== :: PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBodyRestrictions' -> Bool
$c== :: PostPromotionCodesRequestBodyRestrictions'
-> PostPromotionCodesRequestBodyRestrictions' -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON PostPromotionCodesRequestBodyRestrictions' where
toJSON :: PostPromotionCodesRequestBodyRestrictions' -> Value
toJSON PostPromotionCodesRequestBodyRestrictions'
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"first_time_transaction" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBodyRestrictions' -> Maybe Bool
postPromotionCodesRequestBodyRestrictions'FirstTimeTransaction PostPromotionCodesRequestBodyRestrictions'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"minimum_amount" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBodyRestrictions' -> Maybe Int
postPromotionCodesRequestBodyRestrictions'MinimumAmount PostPromotionCodesRequestBodyRestrictions'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"minimum_amount_currency" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBodyRestrictions' -> Maybe Text
postPromotionCodesRequestBodyRestrictions'MinimumAmountCurrency PostPromotionCodesRequestBodyRestrictions'
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: PostPromotionCodesRequestBodyRestrictions' -> Encoding
toEncoding PostPromotionCodesRequestBodyRestrictions'
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"first_time_transaction" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBodyRestrictions' -> Maybe Bool
postPromotionCodesRequestBodyRestrictions'FirstTimeTransaction PostPromotionCodesRequestBodyRestrictions'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"minimum_amount" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBodyRestrictions' -> Maybe Int
postPromotionCodesRequestBodyRestrictions'MinimumAmount PostPromotionCodesRequestBodyRestrictions'
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"minimum_amount_currency" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesRequestBodyRestrictions' -> Maybe Text
postPromotionCodesRequestBodyRestrictions'MinimumAmountCurrency PostPromotionCodesRequestBodyRestrictions'
obj)))
instance Data.Aeson.Types.FromJSON.FromJSON PostPromotionCodesRequestBodyRestrictions' where
parseJSON :: Value -> Parser PostPromotionCodesRequestBodyRestrictions'
parseJSON = String
-> (Object -> Parser PostPromotionCodesRequestBodyRestrictions')
-> Value
-> Parser PostPromotionCodesRequestBodyRestrictions'
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostPromotionCodesRequestBodyRestrictions'" (\Object
obj -> (((Maybe Bool
-> Maybe Int
-> Maybe Text
-> PostPromotionCodesRequestBodyRestrictions')
-> Parser
(Maybe Bool
-> Maybe Int
-> Maybe Text
-> PostPromotionCodesRequestBodyRestrictions')
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Bool
-> Maybe Int
-> Maybe Text
-> PostPromotionCodesRequestBodyRestrictions'
PostPromotionCodesRequestBodyRestrictions' Parser
(Maybe Bool
-> Maybe Int
-> Maybe Text
-> PostPromotionCodesRequestBodyRestrictions')
-> Parser (Maybe Bool)
-> Parser
(Maybe Int
-> Maybe Text -> PostPromotionCodesRequestBodyRestrictions')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"first_time_transaction")) Parser
(Maybe Int
-> Maybe Text -> PostPromotionCodesRequestBodyRestrictions')
-> Parser (Maybe Int)
-> Parser
(Maybe Text -> PostPromotionCodesRequestBodyRestrictions')
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"minimum_amount")) Parser (Maybe Text -> PostPromotionCodesRequestBodyRestrictions')
-> Parser (Maybe Text)
-> Parser PostPromotionCodesRequestBodyRestrictions'
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
"minimum_amount_currency"))
mkPostPromotionCodesRequestBodyRestrictions' :: PostPromotionCodesRequestBodyRestrictions'
mkPostPromotionCodesRequestBodyRestrictions' :: PostPromotionCodesRequestBodyRestrictions'
mkPostPromotionCodesRequestBodyRestrictions' =
PostPromotionCodesRequestBodyRestrictions' :: Maybe Bool
-> Maybe Int
-> Maybe Text
-> PostPromotionCodesRequestBodyRestrictions'
PostPromotionCodesRequestBodyRestrictions'
{ postPromotionCodesRequestBodyRestrictions'FirstTimeTransaction :: Maybe Bool
postPromotionCodesRequestBodyRestrictions'FirstTimeTransaction = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing,
postPromotionCodesRequestBodyRestrictions'MinimumAmount :: Maybe Int
postPromotionCodesRequestBodyRestrictions'MinimumAmount = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
postPromotionCodesRequestBodyRestrictions'MinimumAmountCurrency :: Maybe Text
postPromotionCodesRequestBodyRestrictions'MinimumAmountCurrency = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
}
data PostPromotionCodesResponse
=
PostPromotionCodesResponseError GHC.Base.String
|
PostPromotionCodesResponse200 PromotionCode
|
PostPromotionCodesResponseDefault Error
deriving (Int -> PostPromotionCodesResponse -> ShowS
[PostPromotionCodesResponse] -> ShowS
PostPromotionCodesResponse -> String
(Int -> PostPromotionCodesResponse -> ShowS)
-> (PostPromotionCodesResponse -> String)
-> ([PostPromotionCodesResponse] -> ShowS)
-> Show PostPromotionCodesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostPromotionCodesResponse] -> ShowS
$cshowList :: [PostPromotionCodesResponse] -> ShowS
show :: PostPromotionCodesResponse -> String
$cshow :: PostPromotionCodesResponse -> String
showsPrec :: Int -> PostPromotionCodesResponse -> ShowS
$cshowsPrec :: Int -> PostPromotionCodesResponse -> ShowS
GHC.Show.Show, PostPromotionCodesResponse -> PostPromotionCodesResponse -> Bool
(PostPromotionCodesResponse -> PostPromotionCodesResponse -> Bool)
-> (PostPromotionCodesResponse
-> PostPromotionCodesResponse -> Bool)
-> Eq PostPromotionCodesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostPromotionCodesResponse -> PostPromotionCodesResponse -> Bool
$c/= :: PostPromotionCodesResponse -> PostPromotionCodesResponse -> Bool
== :: PostPromotionCodesResponse -> PostPromotionCodesResponse -> Bool
$c== :: PostPromotionCodesResponse -> PostPromotionCodesResponse -> Bool
GHC.Classes.Eq)