{-# LANGUAGE ExplicitForAll #-}
{-# 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 different functions to run the operation postPromotionCodesPromotionCode
module StripeAPI.Operations.PostPromotionCodesPromotionCode 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

-- | > POST /v1/promotion_codes/{promotion_code}
--
-- \<p>Updates the specified promotion code by setting the values of the parameters passed. Most fields are, by design, not editable.\<\/p>
postPromotionCodesPromotionCode ::
  forall m.
  StripeAPI.Common.MonadHTTP m =>
  -- | promotion_code | Constraints: Maximum length of 5000
  Data.Text.Internal.Text ->
  -- | The request body to send
  GHC.Maybe.Maybe PostPromotionCodesPromotionCodeRequestBody ->
  -- | Monadic computation which returns the result of the operation
  StripeAPI.Common.ClientT m (Network.HTTP.Client.Types.Response PostPromotionCodesPromotionCodeResponse)
postPromotionCodesPromotionCode :: Text
-> Maybe PostPromotionCodesPromotionCodeRequestBody
-> ClientT m (Response PostPromotionCodesPromotionCodeResponse)
postPromotionCodesPromotionCode
  Text
promotionCode
  Maybe PostPromotionCodesPromotionCodeRequestBody
body =
    (Response ByteString
 -> Response PostPromotionCodesPromotionCodeResponse)
-> ClientT m (Response ByteString)
-> ClientT m (Response PostPromotionCodesPromotionCodeResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
      ( \Response ByteString
response_0 ->
          (ByteString -> PostPromotionCodesPromotionCodeResponse)
-> Response ByteString
-> Response PostPromotionCodesPromotionCodeResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
            ( (String -> PostPromotionCodesPromotionCodeResponse)
-> (PostPromotionCodesPromotionCodeResponse
    -> PostPromotionCodesPromotionCodeResponse)
-> Either String PostPromotionCodesPromotionCodeResponse
-> PostPromotionCodesPromotionCodeResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostPromotionCodesPromotionCodeResponse
PostPromotionCodesPromotionCodeResponseError PostPromotionCodesPromotionCodeResponse
-> PostPromotionCodesPromotionCodeResponse
forall a. a -> a
GHC.Base.id
                (Either String PostPromotionCodesPromotionCodeResponse
 -> PostPromotionCodesPromotionCodeResponse)
-> (ByteString
    -> Either String PostPromotionCodesPromotionCodeResponse)
-> ByteString
-> PostPromotionCodesPromotionCodeResponse
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 -> PostPromotionCodesPromotionCodeResponse
PostPromotionCodesPromotionCodeResponse200
                                       (PromotionCode -> PostPromotionCodesPromotionCodeResponse)
-> Either String PromotionCode
-> Either String PostPromotionCodesPromotionCodeResponse
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 -> PostPromotionCodesPromotionCodeResponse
PostPromotionCodesPromotionCodeResponseDefault
                                       (Error -> PostPromotionCodesPromotionCodeResponse)
-> Either String Error
-> Either String PostPromotionCodesPromotionCodeResponse
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 PostPromotionCodesPromotionCodeResponse
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 PostPromotionCodesPromotionCodeRequestBody
-> RequestBodyEncoding
-> ClientT m (Response ByteString)
forall (m :: * -> *) body.
(MonadHTTP m, ToJSON body) =>
Text
-> Text
-> [QueryParameter]
-> Maybe body
-> RequestBodyEncoding
-> ClientT 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/" String -> String -> String
forall a. [a] -> [a] -> [a]
GHC.Base.++ (ByteString -> String
Data.ByteString.Char8.unpack (Bool -> ByteString -> ByteString
Network.HTTP.Types.URI.urlEncode Bool
GHC.Types.True (ByteString -> ByteString) -> ByteString -> ByteString
forall a b. (a -> b) -> a -> b
GHC.Base.$ (String -> ByteString
Data.ByteString.Char8.pack (String -> ByteString) -> String -> ByteString
forall a b. (a -> b) -> a -> b
GHC.Base.$ Text -> String
forall a. StringifyModel a => a -> String
StripeAPI.Common.stringifyModel Text
promotionCode)) String -> String -> String
forall a. [a] -> [a] -> [a]
GHC.Base.++ String
""))) [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty Maybe PostPromotionCodesPromotionCodeRequestBody
body RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)

-- | Defines the object schema located at @paths.\/v1\/promotion_codes\/{promotion_code}.POST.requestBody.content.application\/x-www-form-urlencoded.schema@ in the specification.
data PostPromotionCodesPromotionCodeRequestBody = PostPromotionCodesPromotionCodeRequestBody
  { -- | active: Whether the promotion code is currently active. A promotion code can only be reactivated when the coupon is still valid and the promotion code is otherwise redeemable.
    PostPromotionCodesPromotionCodeRequestBody -> Maybe Bool
postPromotionCodesPromotionCodeRequestBodyActive :: (GHC.Maybe.Maybe GHC.Types.Bool),
    -- | expand: Specifies which fields in the response should be expanded.
    PostPromotionCodesPromotionCodeRequestBody -> Maybe [Text]
postPromotionCodesPromotionCodeRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
    -- | metadata: Set of [key-value pairs](https:\/\/stripe.com\/docs\/api\/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to \`metadata\`.
    PostPromotionCodesPromotionCodeRequestBody
-> Maybe
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
postPromotionCodesPromotionCodeRequestBodyMetadata :: (GHC.Maybe.Maybe PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants)
  }
  deriving
    ( Int
-> PostPromotionCodesPromotionCodeRequestBody -> String -> String
[PostPromotionCodesPromotionCodeRequestBody] -> String -> String
PostPromotionCodesPromotionCodeRequestBody -> String
(Int
 -> PostPromotionCodesPromotionCodeRequestBody -> String -> String)
-> (PostPromotionCodesPromotionCodeRequestBody -> String)
-> ([PostPromotionCodesPromotionCodeRequestBody]
    -> String -> String)
-> Show PostPromotionCodesPromotionCodeRequestBody
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostPromotionCodesPromotionCodeRequestBody] -> String -> String
$cshowList :: [PostPromotionCodesPromotionCodeRequestBody] -> String -> String
show :: PostPromotionCodesPromotionCodeRequestBody -> String
$cshow :: PostPromotionCodesPromotionCodeRequestBody -> String
showsPrec :: Int
-> PostPromotionCodesPromotionCodeRequestBody -> String -> String
$cshowsPrec :: Int
-> PostPromotionCodesPromotionCodeRequestBody -> String -> String
GHC.Show.Show,
      PostPromotionCodesPromotionCodeRequestBody
-> PostPromotionCodesPromotionCodeRequestBody -> Bool
(PostPromotionCodesPromotionCodeRequestBody
 -> PostPromotionCodesPromotionCodeRequestBody -> Bool)
-> (PostPromotionCodesPromotionCodeRequestBody
    -> PostPromotionCodesPromotionCodeRequestBody -> Bool)
-> Eq PostPromotionCodesPromotionCodeRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostPromotionCodesPromotionCodeRequestBody
-> PostPromotionCodesPromotionCodeRequestBody -> Bool
$c/= :: PostPromotionCodesPromotionCodeRequestBody
-> PostPromotionCodesPromotionCodeRequestBody -> Bool
== :: PostPromotionCodesPromotionCodeRequestBody
-> PostPromotionCodesPromotionCodeRequestBody -> Bool
$c== :: PostPromotionCodesPromotionCodeRequestBody
-> PostPromotionCodesPromotionCodeRequestBody -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PostPromotionCodesPromotionCodeRequestBody where
  toJSON :: PostPromotionCodesPromotionCodeRequestBody -> Value
toJSON PostPromotionCodesPromotionCodeRequestBody
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..= PostPromotionCodesPromotionCodeRequestBody -> Maybe Bool
postPromotionCodesPromotionCodeRequestBodyActive PostPromotionCodesPromotionCodeRequestBody
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..= PostPromotionCodesPromotionCodeRequestBody -> Maybe [Text]
postPromotionCodesPromotionCodeRequestBodyExpand PostPromotionCodesPromotionCodeRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text
-> Maybe
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesPromotionCodeRequestBody
-> Maybe
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
postPromotionCodesPromotionCodeRequestBodyMetadata PostPromotionCodesPromotionCodeRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PostPromotionCodesPromotionCodeRequestBody -> Encoding
toEncoding PostPromotionCodesPromotionCodeRequestBody
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..= PostPromotionCodesPromotionCodeRequestBody -> Maybe Bool
postPromotionCodesPromotionCodeRequestBodyActive PostPromotionCodesPromotionCodeRequestBody
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..= PostPromotionCodesPromotionCodeRequestBody -> Maybe [Text]
postPromotionCodesPromotionCodeRequestBodyExpand PostPromotionCodesPromotionCodeRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"metadata" Text
-> Maybe
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostPromotionCodesPromotionCodeRequestBody
-> Maybe
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
postPromotionCodesPromotionCodeRequestBodyMetadata PostPromotionCodesPromotionCodeRequestBody
obj)))

instance Data.Aeson.Types.FromJSON.FromJSON PostPromotionCodesPromotionCodeRequestBody where
  parseJSON :: Value -> Parser PostPromotionCodesPromotionCodeRequestBody
parseJSON = String
-> (Object -> Parser PostPromotionCodesPromotionCodeRequestBody)
-> Value
-> Parser PostPromotionCodesPromotionCodeRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostPromotionCodesPromotionCodeRequestBody" (\Object
obj -> (((Maybe Bool
 -> Maybe [Text]
 -> Maybe
      PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
 -> PostPromotionCodesPromotionCodeRequestBody)
-> Parser
     (Maybe Bool
      -> Maybe [Text]
      -> Maybe
           PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
      -> PostPromotionCodesPromotionCodeRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Bool
-> Maybe [Text]
-> Maybe
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> PostPromotionCodesPromotionCodeRequestBody
PostPromotionCodesPromotionCodeRequestBody Parser
  (Maybe Bool
   -> Maybe [Text]
   -> Maybe
        PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
   -> PostPromotionCodesPromotionCodeRequestBody)
-> Parser (Maybe Bool)
-> Parser
     (Maybe [Text]
      -> Maybe
           PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
      -> PostPromotionCodesPromotionCodeRequestBody)
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]
   -> Maybe
        PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
   -> PostPromotionCodesPromotionCodeRequestBody)
-> Parser (Maybe [Text])
-> Parser
     (Maybe PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
      -> PostPromotionCodesPromotionCodeRequestBody)
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 PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
   -> PostPromotionCodesPromotionCodeRequestBody)
-> Parser
     (Maybe PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants)
-> Parser PostPromotionCodesPromotionCodeRequestBody
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object
-> Text
-> Parser
     (Maybe PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"metadata"))

-- | Create a new 'PostPromotionCodesPromotionCodeRequestBody' with all required fields.
mkPostPromotionCodesPromotionCodeRequestBody :: PostPromotionCodesPromotionCodeRequestBody
mkPostPromotionCodesPromotionCodeRequestBody :: PostPromotionCodesPromotionCodeRequestBody
mkPostPromotionCodesPromotionCodeRequestBody =
  PostPromotionCodesPromotionCodeRequestBody :: Maybe Bool
-> Maybe [Text]
-> Maybe
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> PostPromotionCodesPromotionCodeRequestBody
PostPromotionCodesPromotionCodeRequestBody
    { postPromotionCodesPromotionCodeRequestBodyActive :: Maybe Bool
postPromotionCodesPromotionCodeRequestBodyActive = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing,
      postPromotionCodesPromotionCodeRequestBodyExpand :: Maybe [Text]
postPromotionCodesPromotionCodeRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      postPromotionCodesPromotionCodeRequestBodyMetadata :: Maybe PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
postPromotionCodesPromotionCodeRequestBodyMetadata = Maybe PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the oneOf schema located at @paths.\/v1\/promotion_codes\/{promotion_code}.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.metadata.anyOf@ in the specification.
--
-- Set of [key-value pairs](https:\/\/stripe.com\/docs\/api\/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to \`metadata\`.
data PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
  = -- | Represents the JSON value @""@
    PostPromotionCodesPromotionCodeRequestBodyMetadata'EmptyString
  | PostPromotionCodesPromotionCodeRequestBodyMetadata'Object Data.Aeson.Types.Internal.Object
  deriving (Int
-> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> String
-> String
[PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants]
-> String -> String
PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> String
(Int
 -> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
 -> String
 -> String)
-> (PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
    -> String)
-> ([PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants]
    -> String -> String)
-> Show PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants]
-> String -> String
$cshowList :: [PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants]
-> String -> String
show :: PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> String
$cshow :: PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> String
showsPrec :: Int
-> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> String
-> String
$cshowsPrec :: Int
-> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> String
-> String
GHC.Show.Show, PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> Bool
(PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
 -> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
 -> Bool)
-> (PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
    -> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
    -> Bool)
-> Eq PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> Bool
$c/= :: PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> Bool
== :: PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> Bool
$c== :: PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants where
  toJSON :: PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> Value
toJSON (PostPromotionCodesPromotionCodeRequestBodyMetadata'Object Object
a) = Object -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Object
a
  toJSON (PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
PostPromotionCodesPromotionCodeRequestBodyMetadata'EmptyString) = Value
""

instance Data.Aeson.Types.FromJSON.FromJSON PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants where
  parseJSON :: Value
-> Parser
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
parseJSON Value
val =
    if
        | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"" -> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> Parser
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
PostPromotionCodesPromotionCodeRequestBodyMetadata'EmptyString
        | Bool
GHC.Base.otherwise -> case (Object
-> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
PostPromotionCodesPromotionCodeRequestBodyMetadata'Object (Object
 -> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants)
-> Result Object
-> Result
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> Value -> Result Object
forall a. FromJSON a => Value -> Result a
Data.Aeson.Types.FromJSON.fromJSON Value
val) Result PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> Result
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> Result
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
GHC.Base.<|> String
-> Result
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
forall a. String -> Result a
Data.Aeson.Types.Internal.Error String
"No variant matched" of
          Data.Aeson.Types.Internal.Success PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
a -> PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
-> Parser
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
a
          Data.Aeson.Types.Internal.Error String
a -> String
-> Parser
     PostPromotionCodesPromotionCodeRequestBodyMetadata'Variants
forall (m :: * -> *) a. MonadFail m => String -> m a
Control.Monad.Fail.fail String
a

-- | Represents a response of the operation 'postPromotionCodesPromotionCode'.
--
-- The response constructor is chosen by the status code of the response. If no case matches (no specific case for the response code, no range case, no default case), 'PostPromotionCodesPromotionCodeResponseError' is used.
data PostPromotionCodesPromotionCodeResponse
  = -- | Means either no matching case available or a parse error
    PostPromotionCodesPromotionCodeResponseError GHC.Base.String
  | -- | Successful response.
    PostPromotionCodesPromotionCodeResponse200 PromotionCode
  | -- | Error response.
    PostPromotionCodesPromotionCodeResponseDefault Error
  deriving (Int -> PostPromotionCodesPromotionCodeResponse -> String -> String
[PostPromotionCodesPromotionCodeResponse] -> String -> String
PostPromotionCodesPromotionCodeResponse -> String
(Int
 -> PostPromotionCodesPromotionCodeResponse -> String -> String)
-> (PostPromotionCodesPromotionCodeResponse -> String)
-> ([PostPromotionCodesPromotionCodeResponse] -> String -> String)
-> Show PostPromotionCodesPromotionCodeResponse
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [PostPromotionCodesPromotionCodeResponse] -> String -> String
$cshowList :: [PostPromotionCodesPromotionCodeResponse] -> String -> String
show :: PostPromotionCodesPromotionCodeResponse -> String
$cshow :: PostPromotionCodesPromotionCodeResponse -> String
showsPrec :: Int -> PostPromotionCodesPromotionCodeResponse -> String -> String
$cshowsPrec :: Int -> PostPromotionCodesPromotionCodeResponse -> String -> String
GHC.Show.Show, PostPromotionCodesPromotionCodeResponse
-> PostPromotionCodesPromotionCodeResponse -> Bool
(PostPromotionCodesPromotionCodeResponse
 -> PostPromotionCodesPromotionCodeResponse -> Bool)
-> (PostPromotionCodesPromotionCodeResponse
    -> PostPromotionCodesPromotionCodeResponse -> Bool)
-> Eq PostPromotionCodesPromotionCodeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostPromotionCodesPromotionCodeResponse
-> PostPromotionCodesPromotionCodeResponse -> Bool
$c/= :: PostPromotionCodesPromotionCodeResponse
-> PostPromotionCodesPromotionCodeResponse -> Bool
== :: PostPromotionCodesPromotionCodeResponse
-> PostPromotionCodesPromotionCodeResponse -> Bool
$c== :: PostPromotionCodesPromotionCodeResponse
-> PostPromotionCodesPromotionCodeResponse -> Bool
GHC.Classes.Eq)