{-# 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 PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
module StripeAPI.Types.PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown 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 {-# SOURCE #-} StripeAPI.Types.LineItemsDiscountAmount
import {-# SOURCE #-} StripeAPI.Types.LineItemsTaxAmount
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.payment_pages_checkout_session_total_details_resource_breakdown@ in the specification.
data PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown = PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
  { -- | discounts: The aggregated line item discounts.
    PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> [LineItemsDiscountAmount]
paymentPagesCheckoutSessionTotalDetailsResourceBreakdownDiscounts :: ([LineItemsDiscountAmount]),
    -- | taxes: The aggregated line item tax amounts by rate.
    PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> [LineItemsTaxAmount]
paymentPagesCheckoutSessionTotalDetailsResourceBreakdownTaxes :: ([LineItemsTaxAmount])
  }
  deriving
    ( Int
-> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> ShowS
[PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown] -> ShowS
PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown -> String
(Int
 -> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
 -> ShowS)
-> (PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
    -> String)
-> ([PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown]
    -> ShowS)
-> Show PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown] -> ShowS
$cshowList :: [PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown] -> ShowS
show :: PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown -> String
$cshow :: PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown -> String
showsPrec :: Int
-> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> ShowS
$cshowsPrec :: Int
-> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> ShowS
GHC.Show.Show,
      PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown -> Bool
(PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
 -> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
 -> Bool)
-> (PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
    -> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
    -> Bool)
-> Eq PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown -> Bool
$c/= :: PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown -> Bool
== :: PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown -> Bool
$c== :: PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown where
  toJSON :: PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown -> Value
toJSON PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"discounts" Text -> [LineItemsDiscountAmount] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> [LineItemsDiscountAmount]
paymentPagesCheckoutSessionTotalDetailsResourceBreakdownDiscounts PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"taxes" Text -> [LineItemsTaxAmount] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> [LineItemsTaxAmount]
paymentPagesCheckoutSessionTotalDetailsResourceBreakdownTaxes PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> Encoding
toEncoding PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"discounts" Text -> [LineItemsDiscountAmount] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> [LineItemsDiscountAmount]
paymentPagesCheckoutSessionTotalDetailsResourceBreakdownDiscounts PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"taxes" Text -> [LineItemsTaxAmount] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
-> [LineItemsTaxAmount]
paymentPagesCheckoutSessionTotalDetailsResourceBreakdownTaxes PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
obj))

instance Data.Aeson.Types.FromJSON.FromJSON PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown where
  parseJSON :: Value
-> Parser PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
parseJSON = String
-> (Object
    -> Parser PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown)
-> Value
-> Parser PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown" (\Object
obj -> (([LineItemsDiscountAmount]
 -> [LineItemsTaxAmount]
 -> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown)
-> Parser
     ([LineItemsDiscountAmount]
      -> [LineItemsTaxAmount]
      -> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure [LineItemsDiscountAmount]
-> [LineItemsTaxAmount]
-> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown Parser
  ([LineItemsDiscountAmount]
   -> [LineItemsTaxAmount]
   -> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown)
-> Parser [LineItemsDiscountAmount]
-> Parser
     ([LineItemsTaxAmount]
      -> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser [LineItemsDiscountAmount]
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"discounts")) Parser
  ([LineItemsTaxAmount]
   -> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown)
-> Parser [LineItemsTaxAmount]
-> Parser PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser [LineItemsTaxAmount]
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"taxes"))

-- | Create a new 'PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown' with all required fields.
mkPaymentPagesCheckoutSessionTotalDetailsResourceBreakdown ::
  -- | 'paymentPagesCheckoutSessionTotalDetailsResourceBreakdownDiscounts'
  [LineItemsDiscountAmount] ->
  -- | 'paymentPagesCheckoutSessionTotalDetailsResourceBreakdownTaxes'
  [LineItemsTaxAmount] ->
  PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
mkPaymentPagesCheckoutSessionTotalDetailsResourceBreakdown :: [LineItemsDiscountAmount]
-> [LineItemsTaxAmount]
-> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
mkPaymentPagesCheckoutSessionTotalDetailsResourceBreakdown [LineItemsDiscountAmount]
paymentPagesCheckoutSessionTotalDetailsResourceBreakdownDiscounts [LineItemsTaxAmount]
paymentPagesCheckoutSessionTotalDetailsResourceBreakdownTaxes =
  PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown :: [LineItemsDiscountAmount]
-> [LineItemsTaxAmount]
-> PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown
    { paymentPagesCheckoutSessionTotalDetailsResourceBreakdownDiscounts :: [LineItemsDiscountAmount]
paymentPagesCheckoutSessionTotalDetailsResourceBreakdownDiscounts = [LineItemsDiscountAmount]
paymentPagesCheckoutSessionTotalDetailsResourceBreakdownDiscounts,
      paymentPagesCheckoutSessionTotalDetailsResourceBreakdownTaxes :: [LineItemsTaxAmount]
paymentPagesCheckoutSessionTotalDetailsResourceBreakdownTaxes = [LineItemsTaxAmount]
paymentPagesCheckoutSessionTotalDetailsResourceBreakdownTaxes
    }