{-# 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 CreditNoteTaxAmount module StripeAPI.Types.CreditNoteTaxAmount 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.Foldable import qualified Data.Functor import qualified Data.Maybe 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 {-# SOURCE #-} StripeAPI.Types.TaxRate import qualified Prelude as GHC.Integer.Type import qualified Prelude as GHC.Maybe -- | Defines the object schema located at @components.schemas.credit_note_tax_amount@ in the specification. data CreditNoteTaxAmount = CreditNoteTaxAmount { -- | amount: The amount, in %s, of the tax. creditNoteTaxAmountAmount :: GHC.Types.Int, -- | inclusive: Whether this tax amount is inclusive or exclusive. creditNoteTaxAmountInclusive :: GHC.Types.Bool, -- | tax_rate: The tax rate that was applied to get this tax amount. creditNoteTaxAmountTaxRate :: CreditNoteTaxAmountTaxRate'Variants } deriving ( GHC.Show.Show, GHC.Classes.Eq ) instance Data.Aeson.Types.ToJSON.ToJSON CreditNoteTaxAmount where toJSON obj = Data.Aeson.Types.Internal.object (Data.Foldable.concat (["amount" Data.Aeson.Types.ToJSON..= creditNoteTaxAmountAmount obj] : ["inclusive" Data.Aeson.Types.ToJSON..= creditNoteTaxAmountInclusive obj] : ["tax_rate" Data.Aeson.Types.ToJSON..= creditNoteTaxAmountTaxRate obj] : GHC.Base.mempty)) toEncoding obj = Data.Aeson.Encoding.Internal.pairs (GHC.Base.mconcat (Data.Foldable.concat (["amount" Data.Aeson.Types.ToJSON..= creditNoteTaxAmountAmount obj] : ["inclusive" Data.Aeson.Types.ToJSON..= creditNoteTaxAmountInclusive obj] : ["tax_rate" Data.Aeson.Types.ToJSON..= creditNoteTaxAmountTaxRate obj] : GHC.Base.mempty))) instance Data.Aeson.Types.FromJSON.FromJSON CreditNoteTaxAmount where parseJSON = Data.Aeson.Types.FromJSON.withObject "CreditNoteTaxAmount" (\obj -> ((GHC.Base.pure CreditNoteTaxAmount GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "amount")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "inclusive")) GHC.Base.<*> (obj Data.Aeson.Types.FromJSON..: "tax_rate")) -- | Create a new 'CreditNoteTaxAmount' with all required fields. mkCreditNoteTaxAmount :: -- | 'creditNoteTaxAmountAmount' GHC.Types.Int -> -- | 'creditNoteTaxAmountInclusive' GHC.Types.Bool -> -- | 'creditNoteTaxAmountTaxRate' CreditNoteTaxAmountTaxRate'Variants -> CreditNoteTaxAmount mkCreditNoteTaxAmount creditNoteTaxAmountAmount creditNoteTaxAmountInclusive creditNoteTaxAmountTaxRate = CreditNoteTaxAmount { creditNoteTaxAmountAmount = creditNoteTaxAmountAmount, creditNoteTaxAmountInclusive = creditNoteTaxAmountInclusive, creditNoteTaxAmountTaxRate = creditNoteTaxAmountTaxRate } -- | Defines the oneOf schema located at @components.schemas.credit_note_tax_amount.properties.tax_rate.anyOf@ in the specification. -- -- The tax rate that was applied to get this tax amount. data CreditNoteTaxAmountTaxRate'Variants = CreditNoteTaxAmountTaxRate'Text Data.Text.Internal.Text | CreditNoteTaxAmountTaxRate'TaxRate TaxRate deriving (GHC.Show.Show, GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON CreditNoteTaxAmountTaxRate'Variants where toJSON (CreditNoteTaxAmountTaxRate'Text a) = Data.Aeson.Types.ToJSON.toJSON a toJSON (CreditNoteTaxAmountTaxRate'TaxRate a) = Data.Aeson.Types.ToJSON.toJSON a instance Data.Aeson.Types.FromJSON.FromJSON CreditNoteTaxAmountTaxRate'Variants where parseJSON val = case (CreditNoteTaxAmountTaxRate'Text Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CreditNoteTaxAmountTaxRate'TaxRate 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