{-# 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 postTaxRates module StripeAPI.Operations.PostTaxRates 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/tax_rates -- -- \

Creates a new tax rate.\<\/p> postTaxRates :: forall m. StripeAPI.Common.MonadHTTP m => -- | The request body to send PostTaxRatesRequestBody -> -- | Monadic computation which returns the result of the operation StripeAPI.Common.ClientT m (Network.HTTP.Client.Types.Response PostTaxRatesResponse) postTaxRates body = GHC.Base.fmap ( \response_0 -> GHC.Base.fmap ( Data.Either.either PostTaxRatesResponseError 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) -> PostTaxRatesResponse200 Data.Functor.<$> ( Data.Aeson.eitherDecodeStrict body :: Data.Either.Either GHC.Base.String TaxRate ) | GHC.Base.const GHC.Types.True (Network.HTTP.Client.Types.responseStatus response) -> PostTaxRatesResponseDefault 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/tax_rates") GHC.Base.mempty (GHC.Maybe.Just body) StripeAPI.Common.RequestBodyEncodingFormData) -- | Defines the object schema located at @paths.\/v1\/tax_rates.POST.requestBody.content.application\/x-www-form-urlencoded.schema@ in the specification. data PostTaxRatesRequestBody = PostTaxRatesRequestBody { -- | active: Flag determining whether the tax rate is active or inactive (archived). Inactive tax rates cannot be used with new applications or Checkout Sessions, but will still work for subscriptions and invoices that already have it set. postTaxRatesRequestBodyActive :: (GHC.Maybe.Maybe GHC.Types.Bool), -- | country: Two-letter country code ([ISO 3166-1 alpha-2](https:\/\/en.wikipedia.org\/wiki\/ISO_3166-1_alpha-2)). -- -- Constraints: -- -- * Maximum length of 5000 postTaxRatesRequestBodyCountry :: (GHC.Maybe.Maybe Data.Text.Internal.Text), -- | description: An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers. -- -- Constraints: -- -- * Maximum length of 5000 postTaxRatesRequestBodyDescription :: (GHC.Maybe.Maybe Data.Text.Internal.Text), -- | display_name: The display name of the tax rate, which will be shown to users. -- -- Constraints: -- -- * Maximum length of 50 postTaxRatesRequestBodyDisplayName :: Data.Text.Internal.Text, -- | expand: Specifies which fields in the response should be expanded. postTaxRatesRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])), -- | inclusive: This specifies if the tax rate is inclusive or exclusive. postTaxRatesRequestBodyInclusive :: GHC.Types.Bool, -- | jurisdiction: The jurisdiction for the tax rate. You can use this label field for tax reporting purposes. It also appears on your customer’s invoice. -- -- Constraints: -- -- * Maximum length of 50 postTaxRatesRequestBodyJurisdiction :: (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\`. postTaxRatesRequestBodyMetadata :: (GHC.Maybe.Maybe Data.Aeson.Types.Internal.Object), -- | percentage: This represents the tax rate percent out of 100. postTaxRatesRequestBodyPercentage :: GHC.Types.Double, -- | state: [ISO 3166-2 subdivision code](https:\/\/en.wikipedia.org\/wiki\/ISO_3166-2:US), without country prefix. For example, \"NY\" for New York, United States. -- -- Constraints: -- -- * Maximum length of 2 postTaxRatesRequestBodyState :: (GHC.Maybe.Maybe Data.Text.Internal.Text), -- | tax_type: The high-level tax type, such as \`vat\` or \`sales_tax\`. postTaxRatesRequestBodyTaxType :: (GHC.Maybe.Maybe PostTaxRatesRequestBodyTaxType') } deriving ( GHC.Show.Show, GHC.Classes.Eq ) instance Data.Aeson.Types.ToJSON.ToJSON PostTaxRatesRequestBody where toJSON obj = Data.Aeson.Types.Internal.object ("active" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyActive obj : "country" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyCountry obj : "description" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyDescription obj : "display_name" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyDisplayName obj : "expand" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyExpand obj : "inclusive" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyInclusive obj : "jurisdiction" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyJurisdiction obj : "metadata" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyMetadata obj : "percentage" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyPercentage obj : "state" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyState obj : "tax_type" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyTaxType obj : GHC.Base.mempty) toEncoding obj = Data.Aeson.Encoding.Internal.pairs (("active" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyActive obj) GHC.Base.<> (("country" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyCountry obj) GHC.Base.<> (("description" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyDescription obj) GHC.Base.<> (("display_name" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyDisplayName obj) GHC.Base.<> (("expand" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyExpand obj) GHC.Base.<> (("inclusive" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyInclusive obj) GHC.Base.<> (("jurisdiction" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyJurisdiction obj) GHC.Base.<> (("metadata" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyMetadata obj) GHC.Base.<> (("percentage" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyPercentage obj) GHC.Base.<> (("state" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyState obj) GHC.Base.<> ("tax_type" Data.Aeson.Types.ToJSON..= postTaxRatesRequestBodyTaxType obj))))))))))) instance Data.Aeson.Types.FromJSON.FromJSON PostTaxRatesRequestBody where parseJSON = Data.Aeson.Types.FromJSON.withObject "PostTaxRatesRequestBody" (\obj -> ((((((((((GHC.Base.pure PostTaxRatesRequestBody GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "active")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "country")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "description")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "display_name")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "expand")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "inclusive")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "jurisdiction")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "metadata")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "percentage")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "state")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..:? "tax_type")) -- | Create a new 'PostTaxRatesRequestBody' with all required fields. mkPostTaxRatesRequestBody :: -- | 'postTaxRatesRequestBodyDisplayName' Data.Text.Internal.Text -> -- | 'postTaxRatesRequestBodyInclusive' GHC.Types.Bool -> -- | 'postTaxRatesRequestBodyPercentage' GHC.Types.Double -> PostTaxRatesRequestBody mkPostTaxRatesRequestBody postTaxRatesRequestBodyDisplayName postTaxRatesRequestBodyInclusive postTaxRatesRequestBodyPercentage = PostTaxRatesRequestBody { postTaxRatesRequestBodyActive = GHC.Maybe.Nothing, postTaxRatesRequestBodyCountry = GHC.Maybe.Nothing, postTaxRatesRequestBodyDescription = GHC.Maybe.Nothing, postTaxRatesRequestBodyDisplayName = postTaxRatesRequestBodyDisplayName, postTaxRatesRequestBodyExpand = GHC.Maybe.Nothing, postTaxRatesRequestBodyInclusive = postTaxRatesRequestBodyInclusive, postTaxRatesRequestBodyJurisdiction = GHC.Maybe.Nothing, postTaxRatesRequestBodyMetadata = GHC.Maybe.Nothing, postTaxRatesRequestBodyPercentage = postTaxRatesRequestBodyPercentage, postTaxRatesRequestBodyState = GHC.Maybe.Nothing, postTaxRatesRequestBodyTaxType = GHC.Maybe.Nothing } -- | Defines the enum schema located at @paths.\/v1\/tax_rates.POST.requestBody.content.application\/x-www-form-urlencoded.schema.properties.tax_type@ in the specification. -- -- The high-level tax type, such as \`vat\` or \`sales_tax\`. data PostTaxRatesRequestBodyTaxType' = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification. PostTaxRatesRequestBodyTaxType'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. PostTaxRatesRequestBodyTaxType'Typed Data.Text.Internal.Text | -- | Represents the JSON value @"gst"@ PostTaxRatesRequestBodyTaxType'EnumGst | -- | Represents the JSON value @"hst"@ PostTaxRatesRequestBodyTaxType'EnumHst | -- | Represents the JSON value @"pst"@ PostTaxRatesRequestBodyTaxType'EnumPst | -- | Represents the JSON value @"qst"@ PostTaxRatesRequestBodyTaxType'EnumQst | -- | Represents the JSON value @"sales_tax"@ PostTaxRatesRequestBodyTaxType'EnumSalesTax | -- | Represents the JSON value @"vat"@ PostTaxRatesRequestBodyTaxType'EnumVat deriving (GHC.Show.Show, GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON PostTaxRatesRequestBodyTaxType' where toJSON (PostTaxRatesRequestBodyTaxType'Other val) = val toJSON (PostTaxRatesRequestBodyTaxType'Typed val) = Data.Aeson.Types.ToJSON.toJSON val toJSON (PostTaxRatesRequestBodyTaxType'EnumGst) = "gst" toJSON (PostTaxRatesRequestBodyTaxType'EnumHst) = "hst" toJSON (PostTaxRatesRequestBodyTaxType'EnumPst) = "pst" toJSON (PostTaxRatesRequestBodyTaxType'EnumQst) = "qst" toJSON (PostTaxRatesRequestBodyTaxType'EnumSalesTax) = "sales_tax" toJSON (PostTaxRatesRequestBodyTaxType'EnumVat) = "vat" instance Data.Aeson.Types.FromJSON.FromJSON PostTaxRatesRequestBodyTaxType' where parseJSON val = GHC.Base.pure ( if | val GHC.Classes.== "gst" -> PostTaxRatesRequestBodyTaxType'EnumGst | val GHC.Classes.== "hst" -> PostTaxRatesRequestBodyTaxType'EnumHst | val GHC.Classes.== "pst" -> PostTaxRatesRequestBodyTaxType'EnumPst | val GHC.Classes.== "qst" -> PostTaxRatesRequestBodyTaxType'EnumQst | val GHC.Classes.== "sales_tax" -> PostTaxRatesRequestBodyTaxType'EnumSalesTax | val GHC.Classes.== "vat" -> PostTaxRatesRequestBodyTaxType'EnumVat | GHC.Base.otherwise -> PostTaxRatesRequestBodyTaxType'Other val ) -- | Represents a response of the operation 'postTaxRates'. -- -- 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), 'PostTaxRatesResponseError' is used. data PostTaxRatesResponse = -- | Means either no matching case available or a parse error PostTaxRatesResponseError GHC.Base.String | -- | Successful response. PostTaxRatesResponse200 TaxRate | -- | Error response. PostTaxRatesResponseDefault Error deriving (GHC.Show.Show, GHC.Classes.Eq)