{-# 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
--
-- \<p>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.StripeT m (Network.HTTP.Client.Types.Response PostTaxRatesResponse)
postTaxRates :: PostTaxRatesRequestBody
-> StripeT m (Response PostTaxRatesResponse)
postTaxRates PostTaxRatesRequestBody
body =
  (Response ByteString -> Response PostTaxRatesResponse)
-> StripeT m (Response ByteString)
-> StripeT m (Response PostTaxRatesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
    ( \Response ByteString
response_0 ->
        (ByteString -> PostTaxRatesResponse)
-> Response ByteString -> Response PostTaxRatesResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
          ( (String -> PostTaxRatesResponse)
-> (PostTaxRatesResponse -> PostTaxRatesResponse)
-> Either String PostTaxRatesResponse
-> PostTaxRatesResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostTaxRatesResponse
PostTaxRatesResponseError PostTaxRatesResponse -> PostTaxRatesResponse
forall a. a -> a
GHC.Base.id
              (Either String PostTaxRatesResponse -> PostTaxRatesResponse)
-> (ByteString -> Either String PostTaxRatesResponse)
-> ByteString
-> PostTaxRatesResponse
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) ->
                                   TaxRate -> PostTaxRatesResponse
PostTaxRatesResponse200
                                     (TaxRate -> PostTaxRatesResponse)
-> Either String TaxRate -> Either String PostTaxRatesResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String TaxRate
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
                                                          Data.Either.Either
                                                            GHC.Base.String
                                                            TaxRate
                                                      )
                                 | 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 -> PostTaxRatesResponse
PostTaxRatesResponseDefault
                                     (Error -> PostTaxRatesResponse)
-> Either String Error -> Either String PostTaxRatesResponse
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 PostTaxRatesResponse
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 PostTaxRatesRequestBody
-> 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/tax_rates") [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty (PostTaxRatesRequestBody -> Maybe PostTaxRatesRequestBody
forall a. a -> Maybe a
GHC.Maybe.Just PostTaxRatesRequestBody
body) RequestBodyEncoding
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.
    PostTaxRatesRequestBody -> Maybe Bool
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
    PostTaxRatesRequestBody -> Maybe Text
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
    PostTaxRatesRequestBody -> Maybe Text
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
    PostTaxRatesRequestBody -> Text
postTaxRatesRequestBodyDisplayName :: Data.Text.Internal.Text,
    -- | expand: Specifies which fields in the response should be expanded.
    PostTaxRatesRequestBody -> Maybe [Text]
postTaxRatesRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
    -- | inclusive: This specifies if the tax rate is inclusive or exclusive.
    PostTaxRatesRequestBody -> Bool
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
    PostTaxRatesRequestBody -> Maybe Text
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\`.
    PostTaxRatesRequestBody -> Maybe Object
postTaxRatesRequestBodyMetadata :: (GHC.Maybe.Maybe Data.Aeson.Types.Internal.Object),
    -- | percentage: This represents the tax rate percent out of 100.
    PostTaxRatesRequestBody -> Double
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
    PostTaxRatesRequestBody -> Maybe Text
postTaxRatesRequestBodyState :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | tax_type: The high-level tax type, such as \`vat\` or \`sales_tax\`.
    PostTaxRatesRequestBody -> Maybe PostTaxRatesRequestBodyTaxType'
postTaxRatesRequestBodyTaxType :: (GHC.Maybe.Maybe PostTaxRatesRequestBodyTaxType')
  }
  deriving
    ( Int -> PostTaxRatesRequestBody -> ShowS
[PostTaxRatesRequestBody] -> ShowS
PostTaxRatesRequestBody -> String
(Int -> PostTaxRatesRequestBody -> ShowS)
-> (PostTaxRatesRequestBody -> String)
-> ([PostTaxRatesRequestBody] -> ShowS)
-> Show PostTaxRatesRequestBody
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostTaxRatesRequestBody] -> ShowS
$cshowList :: [PostTaxRatesRequestBody] -> ShowS
show :: PostTaxRatesRequestBody -> String
$cshow :: PostTaxRatesRequestBody -> String
showsPrec :: Int -> PostTaxRatesRequestBody -> ShowS
$cshowsPrec :: Int -> PostTaxRatesRequestBody -> ShowS
GHC.Show.Show,
      PostTaxRatesRequestBody -> PostTaxRatesRequestBody -> Bool
(PostTaxRatesRequestBody -> PostTaxRatesRequestBody -> Bool)
-> (PostTaxRatesRequestBody -> PostTaxRatesRequestBody -> Bool)
-> Eq PostTaxRatesRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTaxRatesRequestBody -> PostTaxRatesRequestBody -> Bool
$c/= :: PostTaxRatesRequestBody -> PostTaxRatesRequestBody -> Bool
== :: PostTaxRatesRequestBody -> PostTaxRatesRequestBody -> Bool
$c== :: PostTaxRatesRequestBody -> PostTaxRatesRequestBody -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PostTaxRatesRequestBody where
  toJSON :: PostTaxRatesRequestBody -> Value
toJSON PostTaxRatesRequestBody
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..= PostTaxRatesRequestBody -> Maybe Bool
postTaxRatesRequestBodyActive PostTaxRatesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"country" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Maybe Text
postTaxRatesRequestBodyCountry PostTaxRatesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"description" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Maybe Text
postTaxRatesRequestBodyDescription PostTaxRatesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"display_name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Text
postTaxRatesRequestBodyDisplayName PostTaxRatesRequestBody
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..= PostTaxRatesRequestBody -> Maybe [Text]
postTaxRatesRequestBodyExpand PostTaxRatesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"inclusive" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Bool
postTaxRatesRequestBodyInclusive PostTaxRatesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"jurisdiction" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Maybe Text
postTaxRatesRequestBodyJurisdiction PostTaxRatesRequestBody
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..= PostTaxRatesRequestBody -> Maybe Object
postTaxRatesRequestBodyMetadata PostTaxRatesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"percentage" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Double
postTaxRatesRequestBodyPercentage PostTaxRatesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"state" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Maybe Text
postTaxRatesRequestBodyState PostTaxRatesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"tax_type" Text -> Maybe PostTaxRatesRequestBodyTaxType' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Maybe PostTaxRatesRequestBodyTaxType'
postTaxRatesRequestBodyTaxType PostTaxRatesRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PostTaxRatesRequestBody -> Encoding
toEncoding PostTaxRatesRequestBody
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..= PostTaxRatesRequestBody -> Maybe Bool
postTaxRatesRequestBodyActive PostTaxRatesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"country" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Maybe Text
postTaxRatesRequestBodyCountry PostTaxRatesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"description" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Maybe Text
postTaxRatesRequestBodyDescription PostTaxRatesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"display_name" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Text
postTaxRatesRequestBodyDisplayName PostTaxRatesRequestBody
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..= PostTaxRatesRequestBody -> Maybe [Text]
postTaxRatesRequestBodyExpand PostTaxRatesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"inclusive" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Bool
postTaxRatesRequestBodyInclusive PostTaxRatesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"jurisdiction" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Maybe Text
postTaxRatesRequestBodyJurisdiction PostTaxRatesRequestBody
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..= PostTaxRatesRequestBody -> Maybe Object
postTaxRatesRequestBodyMetadata PostTaxRatesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"percentage" Text -> Double -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Double
postTaxRatesRequestBodyPercentage PostTaxRatesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"state" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Maybe Text
postTaxRatesRequestBodyState PostTaxRatesRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"tax_type" Text -> Maybe PostTaxRatesRequestBodyTaxType' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostTaxRatesRequestBody -> Maybe PostTaxRatesRequestBodyTaxType'
postTaxRatesRequestBodyTaxType PostTaxRatesRequestBody
obj)))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON PostTaxRatesRequestBody where
  parseJSON :: Value -> Parser PostTaxRatesRequestBody
parseJSON = String
-> (Object -> Parser PostTaxRatesRequestBody)
-> Value
-> Parser PostTaxRatesRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostTaxRatesRequestBody" (\Object
obj -> (((((((((((Maybe Bool
 -> Maybe Text
 -> Maybe Text
 -> Text
 -> Maybe [Text]
 -> Bool
 -> Maybe Text
 -> Maybe Object
 -> Double
 -> Maybe Text
 -> Maybe PostTaxRatesRequestBodyTaxType'
 -> PostTaxRatesRequestBody)
-> Parser
     (Maybe Bool
      -> Maybe Text
      -> Maybe Text
      -> Text
      -> Maybe [Text]
      -> Bool
      -> Maybe Text
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe PostTaxRatesRequestBodyTaxType'
      -> PostTaxRatesRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Bool
-> Maybe Text
-> Maybe Text
-> Text
-> Maybe [Text]
-> Bool
-> Maybe Text
-> Maybe Object
-> Double
-> Maybe Text
-> Maybe PostTaxRatesRequestBodyTaxType'
-> PostTaxRatesRequestBody
PostTaxRatesRequestBody Parser
  (Maybe Bool
   -> Maybe Text
   -> Maybe Text
   -> Text
   -> Maybe [Text]
   -> Bool
   -> Maybe Text
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe PostTaxRatesRequestBodyTaxType'
   -> PostTaxRatesRequestBody)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Text
      -> Maybe [Text]
      -> Bool
      -> Maybe Text
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe PostTaxRatesRequestBodyTaxType'
      -> PostTaxRatesRequestBody)
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 Text
   -> Text
   -> Maybe [Text]
   -> Bool
   -> Maybe Text
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe PostTaxRatesRequestBodyTaxType'
   -> PostTaxRatesRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Text
      -> Maybe [Text]
      -> Bool
      -> Maybe Text
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe PostTaxRatesRequestBodyTaxType'
      -> PostTaxRatesRequestBody)
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
"country")) Parser
  (Maybe Text
   -> Text
   -> Maybe [Text]
   -> Bool
   -> Maybe Text
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe PostTaxRatesRequestBodyTaxType'
   -> PostTaxRatesRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Text
      -> Maybe [Text]
      -> Bool
      -> Maybe Text
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe PostTaxRatesRequestBodyTaxType'
      -> PostTaxRatesRequestBody)
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
"description")) Parser
  (Text
   -> Maybe [Text]
   -> Bool
   -> Maybe Text
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe PostTaxRatesRequestBodyTaxType'
   -> PostTaxRatesRequestBody)
-> Parser Text
-> Parser
     (Maybe [Text]
      -> Bool
      -> Maybe Text
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe PostTaxRatesRequestBodyTaxType'
      -> PostTaxRatesRequestBody)
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
"display_name")) Parser
  (Maybe [Text]
   -> Bool
   -> Maybe Text
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe PostTaxRatesRequestBodyTaxType'
   -> PostTaxRatesRequestBody)
-> Parser (Maybe [Text])
-> Parser
     (Bool
      -> Maybe Text
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe PostTaxRatesRequestBodyTaxType'
      -> PostTaxRatesRequestBody)
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
  (Bool
   -> Maybe Text
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe PostTaxRatesRequestBodyTaxType'
   -> PostTaxRatesRequestBody)
-> Parser Bool
-> Parser
     (Maybe Text
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe PostTaxRatesRequestBodyTaxType'
      -> PostTaxRatesRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"inclusive")) Parser
  (Maybe Text
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe PostTaxRatesRequestBodyTaxType'
   -> PostTaxRatesRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe PostTaxRatesRequestBodyTaxType'
      -> PostTaxRatesRequestBody)
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
"jurisdiction")) Parser
  (Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe PostTaxRatesRequestBodyTaxType'
   -> PostTaxRatesRequestBody)
-> Parser (Maybe Object)
-> Parser
     (Double
      -> Maybe Text
      -> Maybe PostTaxRatesRequestBodyTaxType'
      -> PostTaxRatesRequestBody)
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
  (Double
   -> Maybe Text
   -> Maybe PostTaxRatesRequestBodyTaxType'
   -> PostTaxRatesRequestBody)
-> Parser Double
-> Parser
     (Maybe Text
      -> Maybe PostTaxRatesRequestBodyTaxType'
      -> PostTaxRatesRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"percentage")) Parser
  (Maybe Text
   -> Maybe PostTaxRatesRequestBodyTaxType'
   -> PostTaxRatesRequestBody)
-> Parser (Maybe Text)
-> Parser
     (Maybe PostTaxRatesRequestBodyTaxType' -> PostTaxRatesRequestBody)
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
"state")) Parser
  (Maybe PostTaxRatesRequestBodyTaxType' -> PostTaxRatesRequestBody)
-> Parser (Maybe PostTaxRatesRequestBodyTaxType')
-> Parser PostTaxRatesRequestBody
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe PostTaxRatesRequestBodyTaxType')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"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 :: Text -> Bool -> Double -> PostTaxRatesRequestBody
mkPostTaxRatesRequestBody Text
postTaxRatesRequestBodyDisplayName Bool
postTaxRatesRequestBodyInclusive Double
postTaxRatesRequestBodyPercentage =
  PostTaxRatesRequestBody :: Maybe Bool
-> Maybe Text
-> Maybe Text
-> Text
-> Maybe [Text]
-> Bool
-> Maybe Text
-> Maybe Object
-> Double
-> Maybe Text
-> Maybe PostTaxRatesRequestBodyTaxType'
-> PostTaxRatesRequestBody
PostTaxRatesRequestBody
    { postTaxRatesRequestBodyActive :: Maybe Bool
postTaxRatesRequestBodyActive = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing,
      postTaxRatesRequestBodyCountry :: Maybe Text
postTaxRatesRequestBodyCountry = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postTaxRatesRequestBodyDescription :: Maybe Text
postTaxRatesRequestBodyDescription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postTaxRatesRequestBodyDisplayName :: Text
postTaxRatesRequestBodyDisplayName = Text
postTaxRatesRequestBodyDisplayName,
      postTaxRatesRequestBodyExpand :: Maybe [Text]
postTaxRatesRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
      postTaxRatesRequestBodyInclusive :: Bool
postTaxRatesRequestBodyInclusive = Bool
postTaxRatesRequestBodyInclusive,
      postTaxRatesRequestBodyJurisdiction :: Maybe Text
postTaxRatesRequestBodyJurisdiction = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postTaxRatesRequestBodyMetadata :: Maybe Object
postTaxRatesRequestBodyMetadata = Maybe Object
forall a. Maybe a
GHC.Maybe.Nothing,
      postTaxRatesRequestBodyPercentage :: Double
postTaxRatesRequestBodyPercentage = Double
postTaxRatesRequestBodyPercentage,
      postTaxRatesRequestBodyState :: Maybe Text
postTaxRatesRequestBodyState = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      postTaxRatesRequestBodyTaxType :: Maybe PostTaxRatesRequestBodyTaxType'
postTaxRatesRequestBodyTaxType = Maybe PostTaxRatesRequestBodyTaxType'
forall a. Maybe a
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 (Int -> PostTaxRatesRequestBodyTaxType' -> ShowS
[PostTaxRatesRequestBodyTaxType'] -> ShowS
PostTaxRatesRequestBodyTaxType' -> String
(Int -> PostTaxRatesRequestBodyTaxType' -> ShowS)
-> (PostTaxRatesRequestBodyTaxType' -> String)
-> ([PostTaxRatesRequestBodyTaxType'] -> ShowS)
-> Show PostTaxRatesRequestBodyTaxType'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostTaxRatesRequestBodyTaxType'] -> ShowS
$cshowList :: [PostTaxRatesRequestBodyTaxType'] -> ShowS
show :: PostTaxRatesRequestBodyTaxType' -> String
$cshow :: PostTaxRatesRequestBodyTaxType' -> String
showsPrec :: Int -> PostTaxRatesRequestBodyTaxType' -> ShowS
$cshowsPrec :: Int -> PostTaxRatesRequestBodyTaxType' -> ShowS
GHC.Show.Show, PostTaxRatesRequestBodyTaxType'
-> PostTaxRatesRequestBodyTaxType' -> Bool
(PostTaxRatesRequestBodyTaxType'
 -> PostTaxRatesRequestBodyTaxType' -> Bool)
-> (PostTaxRatesRequestBodyTaxType'
    -> PostTaxRatesRequestBodyTaxType' -> Bool)
-> Eq PostTaxRatesRequestBodyTaxType'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTaxRatesRequestBodyTaxType'
-> PostTaxRatesRequestBodyTaxType' -> Bool
$c/= :: PostTaxRatesRequestBodyTaxType'
-> PostTaxRatesRequestBodyTaxType' -> Bool
== :: PostTaxRatesRequestBodyTaxType'
-> PostTaxRatesRequestBodyTaxType' -> Bool
$c== :: PostTaxRatesRequestBodyTaxType'
-> PostTaxRatesRequestBodyTaxType' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON PostTaxRatesRequestBodyTaxType' where
  toJSON :: PostTaxRatesRequestBodyTaxType' -> Value
toJSON (PostTaxRatesRequestBodyTaxType'Other Value
val) = Value
val
  toJSON (PostTaxRatesRequestBodyTaxType'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'EnumGst) = Value
"gst"
  toJSON (PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'EnumHst) = Value
"hst"
  toJSON (PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'EnumPst) = Value
"pst"
  toJSON (PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'EnumQst) = Value
"qst"
  toJSON (PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'EnumSalesTax) = Value
"sales_tax"
  toJSON (PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'EnumVat) = Value
"vat"

instance Data.Aeson.Types.FromJSON.FromJSON PostTaxRatesRequestBodyTaxType' where
  parseJSON :: Value -> Parser PostTaxRatesRequestBodyTaxType'
parseJSON Value
val =
    PostTaxRatesRequestBodyTaxType'
-> Parser PostTaxRatesRequestBodyTaxType'
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
"gst" -> PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'EnumGst
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"hst" -> PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'EnumHst
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"pst" -> PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'EnumPst
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"qst" -> PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'EnumQst
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"sales_tax" -> PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'EnumSalesTax
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"vat" -> PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'EnumVat
            | Bool
GHC.Base.otherwise -> Value -> PostTaxRatesRequestBodyTaxType'
PostTaxRatesRequestBodyTaxType'Other Value
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 (Int -> PostTaxRatesResponse -> ShowS
[PostTaxRatesResponse] -> ShowS
PostTaxRatesResponse -> String
(Int -> PostTaxRatesResponse -> ShowS)
-> (PostTaxRatesResponse -> String)
-> ([PostTaxRatesResponse] -> ShowS)
-> Show PostTaxRatesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostTaxRatesResponse] -> ShowS
$cshowList :: [PostTaxRatesResponse] -> ShowS
show :: PostTaxRatesResponse -> String
$cshow :: PostTaxRatesResponse -> String
showsPrec :: Int -> PostTaxRatesResponse -> ShowS
$cshowsPrec :: Int -> PostTaxRatesResponse -> ShowS
GHC.Show.Show, PostTaxRatesResponse -> PostTaxRatesResponse -> Bool
(PostTaxRatesResponse -> PostTaxRatesResponse -> Bool)
-> (PostTaxRatesResponse -> PostTaxRatesResponse -> Bool)
-> Eq PostTaxRatesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostTaxRatesResponse -> PostTaxRatesResponse -> Bool
$c/= :: PostTaxRatesResponse -> PostTaxRatesResponse -> Bool
== :: PostTaxRatesResponse -> PostTaxRatesResponse -> Bool
$c== :: PostTaxRatesResponse -> PostTaxRatesResponse -> Bool
GHC.Classes.Eq)