{-# 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 postPricesPrice module StripeAPI.Operations.PostPricesPrice 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/prices/{price} -- -- \

Updates the specified price by setting the values of the parameters passed. Any parameters not provided are left unchanged.\<\/p> postPricesPrice :: forall m. StripeAPI.Common.MonadHTTP m => -- | price | Constraints: Maximum length of 5000 Data.Text.Internal.Text -> -- | The request body to send GHC.Maybe.Maybe PostPricesPriceRequestBody -> -- | Monadic computation which returns the result of the operation StripeAPI.Common.ClientT m (Network.HTTP.Client.Types.Response PostPricesPriceResponse) postPricesPrice price body = GHC.Base.fmap ( \response_0 -> GHC.Base.fmap ( Data.Either.either PostPricesPriceResponseError GHC.Base.id GHC.Base.. ( \response body -> if | (\status_1 -> Network.HTTP.Types.Status.statusCode status_1 GHC.Classes.== 200) (Network.HTTP.Client.Types.responseStatus response) -> PostPricesPriceResponse200 Data.Functor.<$> ( Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String Price ) | GHC.Base.const GHC.Types.True (Network.HTTP.Client.Types.responseStatus response) -> PostPricesPriceResponseDefault Data.Functor.<$> ( Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String Error ) | GHC.Base.otherwise -> Data.Either.Left "Missing default response type" ) response_0 ) response_0 ) (StripeAPI.Common.doBodyCallWithConfigurationM (Data.Text.toUpper GHC.Base.$ Data.Text.pack "POST") (Data.Text.pack ("/v1/prices/" GHC.Base.++ (Data.ByteString.Char8.unpack (Network.HTTP.Types.URI.urlEncode GHC.Types.True GHC.Base.$ (Data.ByteString.Char8.pack GHC.Base.$ StripeAPI.Common.stringifyModel price)) GHC.Base.++ ""))) GHC.Base.mempty body StripeAPI.Common.RequestBodyEncodingFormData) -- | Defines the object schema located at @paths.\/v1\/prices\/{price}.POST.requestBody.content.application\/x-www-form-urlencoded.schema@ in the specification. data PostPricesPriceRequestBody = PostPricesPriceRequestBody { -- | active: Whether the price can be used for new purchases. Defaults to \`true\`. postPricesPriceRequestBodyActive :: (GHC.Maybe.Maybe GHC.Types.Bool), -- | expand: Specifies which fields in the response should be expanded. postPricesPriceRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])), -- | lookup_key: A lookup key used to retrieve prices dynamically from a static string. -- -- Constraints: -- -- * Maximum length of 5000 postPricesPriceRequestBodyLookupKey :: (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\`. postPricesPriceRequestBodyMetadata :: (GHC.Maybe.Maybe PostPricesPriceRequestBodyMetadata'Variants), -- | nickname: A brief description of the price, hidden from customers. -- -- Constraints: -- -- * Maximum length of 5000 postPricesPriceRequestBodyNickname :: (GHC.Maybe.Maybe Data.Text.Internal.Text), -- | tax_behavior: Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of \`inclusive\`, \`exclusive\`, or \`unspecified\`. Once specified as either \`inclusive\` or \`exclusive\`, it cannot be changed. postPricesPriceRequestBodyTaxBehavior :: (GHC.Maybe.Maybe PostPricesPriceRequestBodyTaxBehavior'), -- | transfer_lookup_key: If set to true, will atomically remove the lookup key from the existing price, and assign it to this price. postPricesPriceRequestBodyTransferLookupKey :: (GHC.Maybe.Maybe GHC.Types.Bool) } deriving ( GHC.Show.Show, GHC.Classes.Eq ) instance Data.Aeson.Types.ToJSON.ToJSON PostPricesPriceRequestBody where toJSON obj = Data.Aeson.Types.Internal.object ("active" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyActive obj : "expand" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyExpand obj : "lookup_key" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyLookupKey obj : "metadata" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyMetadata obj : "nickname" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyNickname obj : "tax_behavior" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyTaxBehavior obj : "transfer_lookup_key" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyTransferLookupKey obj : GHC.Base.mempty) toEncoding obj = Data.Aeson.Encoding.Internal.pairs (("active" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyActive obj) GHC.Base.<> (("expand" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyExpand obj) GHC.Base.<> (("lookup_key" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyLookupKey obj) GHC.Base.<> (("metadata" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyMetadata obj) GHC.Base.<> (("nickname" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyNickname obj) GHC.Base.<> (("tax_behavior" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyTaxBehavior obj) GHC.Base.<> ("transfer_lookup_key" Data.Aeson.Types.ToJSON..= postPricesPriceRequestBodyTransferLookupKey obj))))))) instance Data.Aeson.Types.FromJSON.FromJSON PostPricesPriceRequestBody where parseJSON = Data.Aeson.Types.FromJSON.withObject "PostPricesPriceRequestBody" (\obj -> ((((((GHC.Base.pure PostPricesPriceRequestBody GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "active")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "expand")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "lookup_key")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "metadata")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "nickname")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "tax_behavior")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "transfer_lookup_key")) -- | Create a new 'PostPricesPriceRequestBody' with all required fields. mkPostPricesPriceRequestBody :: PostPricesPriceRequestBody mkPostPricesPriceRequestBody = PostPricesPriceRequestBody { postPricesPriceRequestBodyActive = GHC.Maybe.Nothing, postPricesPriceRequestBodyExpand = GHC.Maybe.Nothing, postPricesPriceRequestBodyLookupKey = GHC.Maybe.Nothing, postPricesPriceRequestBodyMetadata = GHC.Maybe.Nothing, postPricesPriceRequestBodyNickname = GHC.Maybe.Nothing, postPricesPriceRequestBodyTaxBehavior = GHC.Maybe.Nothing, postPricesPriceRequestBodyTransferLookupKey = GHC.Maybe.Nothing } -- | Defines the oneOf schema located at @paths.\/v1\/prices\/{price}.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 PostPricesPriceRequestBodyMetadata'Variants = -- | Represents the JSON value @""@ PostPricesPriceRequestBodyMetadata'EmptyString | PostPricesPriceRequestBodyMetadata'Object Data.Aeson.Types.Internal.Object deriving (GHC.Show.Show, GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON PostPricesPriceRequestBodyMetadata'Variants where toJSON (PostPricesPriceRequestBodyMetadata'Object a) = Data.Aeson.Types.ToJSON.toJSON a toJSON (PostPricesPriceRequestBodyMetadata'EmptyString) = "" instance Data.Aeson.Types.FromJSON.FromJSON PostPricesPriceRequestBodyMetadata'Variants where parseJSON val = if | val GHC.Classes.== "" -> GHC.Base.pure PostPricesPriceRequestBodyMetadata'EmptyString | GHC.Base.otherwise -> case (PostPricesPriceRequestBodyMetadata'Object Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> Data.Aeson.Types.Internal.Error "No variant matched" of Data.Aeson.Types.Internal.Success a -> GHC.Base.pure a Data.Aeson.Types.Internal.Error a -> Control.Monad.Fail.fail a -- | Defines the enum schema located at @paths.\/v1\/prices\/{price}.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.tax_behavior@ in the specification. -- -- Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of \`inclusive\`, \`exclusive\`, or \`unspecified\`. Once specified as either \`inclusive\` or \`exclusive\`, it cannot be changed. data PostPricesPriceRequestBodyTaxBehavior' = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification. PostPricesPriceRequestBodyTaxBehavior'Other Data.Aeson.Types.Internal.Value | -- | This constructor can be used to send values to the server which are not present in the specification yet. PostPricesPriceRequestBodyTaxBehavior'Typed Data.Text.Internal.Text | -- | Represents the JSON value @"exclusive"@ PostPricesPriceRequestBodyTaxBehavior'EnumExclusive | -- | Represents the JSON value @"inclusive"@ PostPricesPriceRequestBodyTaxBehavior'EnumInclusive | -- | Represents the JSON value @"unspecified"@ PostPricesPriceRequestBodyTaxBehavior'EnumUnspecified deriving (GHC.Show.Show, GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON PostPricesPriceRequestBodyTaxBehavior' where toJSON (PostPricesPriceRequestBodyTaxBehavior'Other val) = val toJSON (PostPricesPriceRequestBodyTaxBehavior'Typed val) = Data.Aeson.Types.ToJSON.toJSON val toJSON (PostPricesPriceRequestBodyTaxBehavior'EnumExclusive) = "exclusive" toJSON (PostPricesPriceRequestBodyTaxBehavior'EnumInclusive) = "inclusive" toJSON (PostPricesPriceRequestBodyTaxBehavior'EnumUnspecified) = "unspecified" instance Data.Aeson.Types.FromJSON.FromJSON PostPricesPriceRequestBodyTaxBehavior' where parseJSON val = GHC.Base.pure ( if | val GHC.Classes.== "exclusive" -> PostPricesPriceRequestBodyTaxBehavior'EnumExclusive | val GHC.Classes.== "inclusive" -> PostPricesPriceRequestBodyTaxBehavior'EnumInclusive | val GHC.Classes.== "unspecified" -> PostPricesPriceRequestBodyTaxBehavior'EnumUnspecified | GHC.Base.otherwise -> PostPricesPriceRequestBodyTaxBehavior'Other val ) -- | Represents a response of the operation 'postPricesPrice'. -- -- 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), 'PostPricesPriceResponseError' is used. data PostPricesPriceResponse = -- | Means either no matching case available or a parse error PostPricesPriceResponseError GHC.Base.String | -- | Successful response. PostPricesPriceResponse200 Price | -- | Error response. PostPricesPriceResponseDefault Error deriving (GHC.Show.Show, GHC.Classes.Eq)