{-# 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 types generated from the schema TaxRate
module StripeAPI.Types.TaxRate where

import qualified Control.Monad.Fail
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.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 GHC.Base
import qualified GHC.Classes
import qualified GHC.Int
import qualified GHC.Show
import qualified GHC.Types
import qualified StripeAPI.Common
import StripeAPI.TypeAlias
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.tax_rate@ in the specification.
--
-- Tax rates can be applied to [invoices](https:\/\/stripe.com\/docs\/billing\/invoices\/tax-rates), [subscriptions](https:\/\/stripe.com\/docs\/billing\/subscriptions\/taxes) and [Checkout Sessions](https:\/\/stripe.com\/docs\/payments\/checkout\/set-up-a-subscription\#tax-rates) to collect tax.
--
-- Related guide: [Tax Rates](https:\/\/stripe.com\/docs\/billing\/taxes\/tax-rates).
data TaxRate = TaxRate
  { -- | active: Defaults to \`true\`. When set to \`false\`, this tax rate cannot be used with new applications or Checkout Sessions, but will still work for subscriptions and invoices that already have it set.
    TaxRate -> Bool
taxRateActive :: 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
    TaxRate -> Maybe Text
taxRateCountry :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | created: Time at which the object was created. Measured in seconds since the Unix epoch.
    TaxRate -> Int
taxRateCreated :: GHC.Types.Int,
    -- | 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
    TaxRate -> Maybe Text
taxRateDescription :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | display_name: The display name of the tax rates as it will appear to your customer on their receipt email, PDF, and the hosted invoice page.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    TaxRate -> Text
taxRateDisplayName :: Data.Text.Internal.Text,
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    TaxRate -> Text
taxRateId :: Data.Text.Internal.Text,
    -- | inclusive: This specifies if the tax rate is inclusive or exclusive.
    TaxRate -> Bool
taxRateInclusive :: 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 5000
    TaxRate -> Maybe Text
taxRateJurisdiction :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | livemode: Has the value \`true\` if the object exists in live mode or the value \`false\` if the object exists in test mode.
    TaxRate -> Bool
taxRateLivemode :: GHC.Types.Bool,
    -- | 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.
    TaxRate -> Maybe Object
taxRateMetadata :: (GHC.Maybe.Maybe Data.Aeson.Types.Internal.Object),
    -- | percentage: This represents the tax rate percent out of 100.
    TaxRate -> Double
taxRatePercentage :: 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 5000
    TaxRate -> Maybe Text
taxRateState :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | tax_type: The high-level tax type, such as \`vat\` or \`sales_tax\`.
    TaxRate -> Maybe TaxRateTaxType'
taxRateTaxType :: (GHC.Maybe.Maybe TaxRateTaxType')
  }
  deriving
    ( Int -> TaxRate -> ShowS
[TaxRate] -> ShowS
TaxRate -> String
(Int -> TaxRate -> ShowS)
-> (TaxRate -> String) -> ([TaxRate] -> ShowS) -> Show TaxRate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TaxRate] -> ShowS
$cshowList :: [TaxRate] -> ShowS
show :: TaxRate -> String
$cshow :: TaxRate -> String
showsPrec :: Int -> TaxRate -> ShowS
$cshowsPrec :: Int -> TaxRate -> ShowS
GHC.Show.Show,
      TaxRate -> TaxRate -> Bool
(TaxRate -> TaxRate -> Bool)
-> (TaxRate -> TaxRate -> Bool) -> Eq TaxRate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TaxRate -> TaxRate -> Bool
$c/= :: TaxRate -> TaxRate -> Bool
== :: TaxRate -> TaxRate -> Bool
$c== :: TaxRate -> TaxRate -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON TaxRate where
  toJSON :: TaxRate -> Value
toJSON TaxRate
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"active" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxRate -> Bool
taxRateActive TaxRate
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..= TaxRate -> Maybe Text
taxRateCountry TaxRate
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"created" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxRate -> Int
taxRateCreated TaxRate
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..= TaxRate -> Maybe Text
taxRateDescription TaxRate
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..= TaxRate -> Text
taxRateDisplayName TaxRate
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxRate -> Text
taxRateId TaxRate
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..= TaxRate -> Bool
taxRateInclusive TaxRate
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..= TaxRate -> Maybe Text
taxRateJurisdiction TaxRate
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"livemode" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxRate -> Bool
taxRateLivemode TaxRate
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..= TaxRate -> Maybe Object
taxRateMetadata TaxRate
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..= TaxRate -> Double
taxRatePercentage TaxRate
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..= TaxRate -> Maybe Text
taxRateState TaxRate
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"tax_type" Text -> Maybe TaxRateTaxType' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxRate -> Maybe TaxRateTaxType'
taxRateTaxType TaxRate
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"object" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"tax_rate" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: TaxRate -> Encoding
toEncoding TaxRate
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"active" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxRate -> Bool
taxRateActive TaxRate
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..= TaxRate -> Maybe Text
taxRateCountry TaxRate
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"created" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxRate -> Int
taxRateCreated TaxRate
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..= TaxRate -> Maybe Text
taxRateDescription TaxRate
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..= TaxRate -> Text
taxRateDisplayName TaxRate
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"id" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxRate -> Text
taxRateId TaxRate
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..= TaxRate -> Bool
taxRateInclusive TaxRate
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..= TaxRate -> Maybe Text
taxRateJurisdiction TaxRate
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"livemode" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxRate -> Bool
taxRateLivemode TaxRate
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..= TaxRate -> Maybe Object
taxRateMetadata TaxRate
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..= TaxRate -> Double
taxRatePercentage TaxRate
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..= TaxRate -> Maybe Text
taxRateState TaxRate
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"tax_type" Text -> Maybe TaxRateTaxType' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxRate -> Maybe TaxRateTaxType'
taxRateTaxType TaxRate
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"object" Text -> Value -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"tax_rate"))))))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON TaxRate where
  parseJSON :: Value -> Parser TaxRate
parseJSON = String -> (Object -> Parser TaxRate) -> Value -> Parser TaxRate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"TaxRate" (\Object
obj -> (((((((((((((Bool
 -> Maybe Text
 -> Int
 -> Maybe Text
 -> Text
 -> Text
 -> Bool
 -> Maybe Text
 -> Bool
 -> Maybe Object
 -> Double
 -> Maybe Text
 -> Maybe TaxRateTaxType'
 -> TaxRate)
-> Parser
     (Bool
      -> Maybe Text
      -> Int
      -> Maybe Text
      -> Text
      -> Text
      -> Bool
      -> Maybe Text
      -> Bool
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe TaxRateTaxType'
      -> TaxRate)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Bool
-> Maybe Text
-> Int
-> Maybe Text
-> Text
-> Text
-> Bool
-> Maybe Text
-> Bool
-> Maybe Object
-> Double
-> Maybe Text
-> Maybe TaxRateTaxType'
-> TaxRate
TaxRate Parser
  (Bool
   -> Maybe Text
   -> Int
   -> Maybe Text
   -> Text
   -> Text
   -> Bool
   -> Maybe Text
   -> Bool
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe TaxRateTaxType'
   -> TaxRate)
-> Parser Bool
-> Parser
     (Maybe Text
      -> Int
      -> Maybe Text
      -> Text
      -> Text
      -> Bool
      -> Maybe Text
      -> Bool
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe TaxRateTaxType'
      -> TaxRate)
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
"active")) Parser
  (Maybe Text
   -> Int
   -> Maybe Text
   -> Text
   -> Text
   -> Bool
   -> Maybe Text
   -> Bool
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe TaxRateTaxType'
   -> TaxRate)
-> Parser (Maybe Text)
-> Parser
     (Int
      -> Maybe Text
      -> Text
      -> Text
      -> Bool
      -> Maybe Text
      -> Bool
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe TaxRateTaxType'
      -> TaxRate)
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
  (Int
   -> Maybe Text
   -> Text
   -> Text
   -> Bool
   -> Maybe Text
   -> Bool
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe TaxRateTaxType'
   -> TaxRate)
-> Parser Int
-> Parser
     (Maybe Text
      -> Text
      -> Text
      -> Bool
      -> Maybe Text
      -> Bool
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe TaxRateTaxType'
      -> TaxRate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"created")) Parser
  (Maybe Text
   -> Text
   -> Text
   -> Bool
   -> Maybe Text
   -> Bool
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe TaxRateTaxType'
   -> TaxRate)
-> Parser (Maybe Text)
-> Parser
     (Text
      -> Text
      -> Bool
      -> Maybe Text
      -> Bool
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe TaxRateTaxType'
      -> TaxRate)
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
   -> Text
   -> Bool
   -> Maybe Text
   -> Bool
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe TaxRateTaxType'
   -> TaxRate)
-> Parser Text
-> Parser
     (Text
      -> Bool
      -> Maybe Text
      -> Bool
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe TaxRateTaxType'
      -> TaxRate)
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
  (Text
   -> Bool
   -> Maybe Text
   -> Bool
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe TaxRateTaxType'
   -> TaxRate)
-> Parser Text
-> Parser
     (Bool
      -> Maybe Text
      -> Bool
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe TaxRateTaxType'
      -> TaxRate)
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
"id")) Parser
  (Bool
   -> Maybe Text
   -> Bool
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe TaxRateTaxType'
   -> TaxRate)
-> Parser Bool
-> Parser
     (Maybe Text
      -> Bool
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe TaxRateTaxType'
      -> TaxRate)
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
   -> Bool
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe TaxRateTaxType'
   -> TaxRate)
-> Parser (Maybe Text)
-> Parser
     (Bool
      -> Maybe Object
      -> Double
      -> Maybe Text
      -> Maybe TaxRateTaxType'
      -> TaxRate)
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
  (Bool
   -> Maybe Object
   -> Double
   -> Maybe Text
   -> Maybe TaxRateTaxType'
   -> TaxRate)
-> Parser Bool
-> Parser
     (Maybe Object
      -> Double -> Maybe Text -> Maybe TaxRateTaxType' -> TaxRate)
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
"livemode")) Parser
  (Maybe Object
   -> Double -> Maybe Text -> Maybe TaxRateTaxType' -> TaxRate)
-> Parser (Maybe Object)
-> Parser
     (Double -> Maybe Text -> Maybe TaxRateTaxType' -> TaxRate)
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 TaxRateTaxType' -> TaxRate)
-> Parser Double
-> Parser (Maybe Text -> Maybe TaxRateTaxType' -> TaxRate)
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 TaxRateTaxType' -> TaxRate)
-> Parser (Maybe Text) -> Parser (Maybe TaxRateTaxType' -> TaxRate)
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 TaxRateTaxType' -> TaxRate)
-> Parser (Maybe TaxRateTaxType') -> Parser TaxRate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe TaxRateTaxType')
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"tax_type"))

-- | Create a new 'TaxRate' with all required fields.
mkTaxRate ::
  -- | 'taxRateActive'
  GHC.Types.Bool ->
  -- | 'taxRateCreated'
  GHC.Types.Int ->
  -- | 'taxRateDisplayName'
  Data.Text.Internal.Text ->
  -- | 'taxRateId'
  Data.Text.Internal.Text ->
  -- | 'taxRateInclusive'
  GHC.Types.Bool ->
  -- | 'taxRateLivemode'
  GHC.Types.Bool ->
  -- | 'taxRatePercentage'
  GHC.Types.Double ->
  TaxRate
mkTaxRate :: Bool -> Int -> Text -> Text -> Bool -> Bool -> Double -> TaxRate
mkTaxRate Bool
taxRateActive Int
taxRateCreated Text
taxRateDisplayName Text
taxRateId Bool
taxRateInclusive Bool
taxRateLivemode Double
taxRatePercentage =
  TaxRate :: Bool
-> Maybe Text
-> Int
-> Maybe Text
-> Text
-> Text
-> Bool
-> Maybe Text
-> Bool
-> Maybe Object
-> Double
-> Maybe Text
-> Maybe TaxRateTaxType'
-> TaxRate
TaxRate
    { taxRateActive :: Bool
taxRateActive = Bool
taxRateActive,
      taxRateCountry :: Maybe Text
taxRateCountry = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      taxRateCreated :: Int
taxRateCreated = Int
taxRateCreated,
      taxRateDescription :: Maybe Text
taxRateDescription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      taxRateDisplayName :: Text
taxRateDisplayName = Text
taxRateDisplayName,
      taxRateId :: Text
taxRateId = Text
taxRateId,
      taxRateInclusive :: Bool
taxRateInclusive = Bool
taxRateInclusive,
      taxRateJurisdiction :: Maybe Text
taxRateJurisdiction = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      taxRateLivemode :: Bool
taxRateLivemode = Bool
taxRateLivemode,
      taxRateMetadata :: Maybe Object
taxRateMetadata = Maybe Object
forall a. Maybe a
GHC.Maybe.Nothing,
      taxRatePercentage :: Double
taxRatePercentage = Double
taxRatePercentage,
      taxRateState :: Maybe Text
taxRateState = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      taxRateTaxType :: Maybe TaxRateTaxType'
taxRateTaxType = Maybe TaxRateTaxType'
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the enum schema located at @components.schemas.tax_rate.properties.tax_type@ in the specification.
--
-- The high-level tax type, such as \`vat\` or \`sales_tax\`.
data TaxRateTaxType'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    TaxRateTaxType'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.
    TaxRateTaxType'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"gst"@
    TaxRateTaxType'EnumGst
  | -- | Represents the JSON value @"hst"@
    TaxRateTaxType'EnumHst
  | -- | Represents the JSON value @"pst"@
    TaxRateTaxType'EnumPst
  | -- | Represents the JSON value @"qst"@
    TaxRateTaxType'EnumQst
  | -- | Represents the JSON value @"sales_tax"@
    TaxRateTaxType'EnumSalesTax
  | -- | Represents the JSON value @"vat"@
    TaxRateTaxType'EnumVat
  deriving (Int -> TaxRateTaxType' -> ShowS
[TaxRateTaxType'] -> ShowS
TaxRateTaxType' -> String
(Int -> TaxRateTaxType' -> ShowS)
-> (TaxRateTaxType' -> String)
-> ([TaxRateTaxType'] -> ShowS)
-> Show TaxRateTaxType'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TaxRateTaxType'] -> ShowS
$cshowList :: [TaxRateTaxType'] -> ShowS
show :: TaxRateTaxType' -> String
$cshow :: TaxRateTaxType' -> String
showsPrec :: Int -> TaxRateTaxType' -> ShowS
$cshowsPrec :: Int -> TaxRateTaxType' -> ShowS
GHC.Show.Show, TaxRateTaxType' -> TaxRateTaxType' -> Bool
(TaxRateTaxType' -> TaxRateTaxType' -> Bool)
-> (TaxRateTaxType' -> TaxRateTaxType' -> Bool)
-> Eq TaxRateTaxType'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TaxRateTaxType' -> TaxRateTaxType' -> Bool
$c/= :: TaxRateTaxType' -> TaxRateTaxType' -> Bool
== :: TaxRateTaxType' -> TaxRateTaxType' -> Bool
$c== :: TaxRateTaxType' -> TaxRateTaxType' -> Bool
GHC.Classes.Eq)

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

instance Data.Aeson.Types.FromJSON.FromJSON TaxRateTaxType' where
  parseJSON :: Value -> Parser TaxRateTaxType'
parseJSON Value
val =
    TaxRateTaxType' -> Parser TaxRateTaxType'
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" -> TaxRateTaxType'
TaxRateTaxType'EnumGst
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"hst" -> TaxRateTaxType'
TaxRateTaxType'EnumHst
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"pst" -> TaxRateTaxType'
TaxRateTaxType'EnumPst
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"qst" -> TaxRateTaxType'
TaxRateTaxType'EnumQst
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"sales_tax" -> TaxRateTaxType'
TaxRateTaxType'EnumSalesTax
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"vat" -> TaxRateTaxType'
TaxRateTaxType'EnumVat
            | Bool
GHC.Base.otherwise -> Value -> TaxRateTaxType'
TaxRateTaxType'Other Value
val
      )