{-# 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 CreditNoteLineItem
module StripeAPI.Types.CreditNoteLineItem 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.CreditNoteTaxAmount
import {-# SOURCE #-} StripeAPI.Types.DiscountsResourceDiscountAmount
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_line_item@ in the specification.
data CreditNoteLineItem = CreditNoteLineItem
  { -- | amount: The integer amount in %s representing the gross amount being credited for this line item, excluding (exclusive) tax and discounts.
    CreditNoteLineItem -> Int
creditNoteLineItemAmount :: GHC.Types.Int,
    -- | description: Description of the item being credited.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    CreditNoteLineItem -> Maybe Text
creditNoteLineItemDescription :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | discount_amount: The integer amount in %s representing the discount being credited for this line item.
    CreditNoteLineItem -> Int
creditNoteLineItemDiscountAmount :: GHC.Types.Int,
    -- | discount_amounts: The amount of discount calculated per discount for this line item
    CreditNoteLineItem -> [DiscountsResourceDiscountAmount]
creditNoteLineItemDiscountAmounts :: ([DiscountsResourceDiscountAmount]),
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    CreditNoteLineItem -> Text
creditNoteLineItemId :: Data.Text.Internal.Text,
    -- | invoice_line_item: ID of the invoice line item being credited
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    CreditNoteLineItem -> Maybe Text
creditNoteLineItemInvoiceLineItem :: (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.
    CreditNoteLineItem -> Bool
creditNoteLineItemLivemode :: GHC.Types.Bool,
    -- | quantity: The number of units of product being credited.
    CreditNoteLineItem -> Maybe Int
creditNoteLineItemQuantity :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | tax_amounts: The amount of tax calculated per tax rate for this line item
    CreditNoteLineItem -> [CreditNoteTaxAmount]
creditNoteLineItemTaxAmounts :: ([CreditNoteTaxAmount]),
    -- | tax_rates: The tax rates which apply to the line item.
    CreditNoteLineItem -> [TaxRate]
creditNoteLineItemTaxRates :: ([TaxRate]),
    -- | type: The type of the credit note line item, one of \`invoice_line_item\` or \`custom_line_item\`. When the type is \`invoice_line_item\` there is an additional \`invoice_line_item\` property on the resource the value of which is the id of the credited line item on the invoice.
    CreditNoteLineItem -> CreditNoteLineItemType'
creditNoteLineItemType :: CreditNoteLineItemType',
    -- | unit_amount: The cost of each unit of product being credited.
    CreditNoteLineItem -> Maybe Int
creditNoteLineItemUnitAmount :: (GHC.Maybe.Maybe GHC.Types.Int),
    -- | unit_amount_decimal: Same as \`unit_amount\`, but contains a decimal value with at most 12 decimal places.
    CreditNoteLineItem -> Maybe Text
creditNoteLineItemUnitAmountDecimal :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> CreditNoteLineItem -> ShowS
[CreditNoteLineItem] -> ShowS
CreditNoteLineItem -> String
(Int -> CreditNoteLineItem -> ShowS)
-> (CreditNoteLineItem -> String)
-> ([CreditNoteLineItem] -> ShowS)
-> Show CreditNoteLineItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreditNoteLineItem] -> ShowS
$cshowList :: [CreditNoteLineItem] -> ShowS
show :: CreditNoteLineItem -> String
$cshow :: CreditNoteLineItem -> String
showsPrec :: Int -> CreditNoteLineItem -> ShowS
$cshowsPrec :: Int -> CreditNoteLineItem -> ShowS
GHC.Show.Show,
      CreditNoteLineItem -> CreditNoteLineItem -> Bool
(CreditNoteLineItem -> CreditNoteLineItem -> Bool)
-> (CreditNoteLineItem -> CreditNoteLineItem -> Bool)
-> Eq CreditNoteLineItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreditNoteLineItem -> CreditNoteLineItem -> Bool
$c/= :: CreditNoteLineItem -> CreditNoteLineItem -> Bool
== :: CreditNoteLineItem -> CreditNoteLineItem -> Bool
$c== :: CreditNoteLineItem -> CreditNoteLineItem -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON CreditNoteLineItem where
  toJSON :: CreditNoteLineItem -> Value
toJSON CreditNoteLineItem
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"amount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> Int
creditNoteLineItemAmount CreditNoteLineItem
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..= CreditNoteLineItem -> Maybe Text
creditNoteLineItemDescription CreditNoteLineItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"discount_amount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> Int
creditNoteLineItemDiscountAmount CreditNoteLineItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"discount_amounts" Text -> [DiscountsResourceDiscountAmount] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> [DiscountsResourceDiscountAmount]
creditNoteLineItemDiscountAmounts CreditNoteLineItem
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..= CreditNoteLineItem -> Text
creditNoteLineItemId CreditNoteLineItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"invoice_line_item" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> Maybe Text
creditNoteLineItemInvoiceLineItem CreditNoteLineItem
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..= CreditNoteLineItem -> Bool
creditNoteLineItemLivemode CreditNoteLineItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"quantity" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> Maybe Int
creditNoteLineItemQuantity CreditNoteLineItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"tax_amounts" Text -> [CreditNoteTaxAmount] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> [CreditNoteTaxAmount]
creditNoteLineItemTaxAmounts CreditNoteLineItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"tax_rates" Text -> [TaxRate] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> [TaxRate]
creditNoteLineItemTaxRates CreditNoteLineItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"type" Text -> CreditNoteLineItemType' -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> CreditNoteLineItemType'
creditNoteLineItemType CreditNoteLineItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"unit_amount" Text -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> Maybe Int
creditNoteLineItemUnitAmount CreditNoteLineItem
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"unit_amount_decimal" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> Maybe Text
creditNoteLineItemUnitAmountDecimal CreditNoteLineItem
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
"credit_note_line_item" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: CreditNoteLineItem -> Encoding
toEncoding CreditNoteLineItem
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"amount" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> Int
creditNoteLineItemAmount CreditNoteLineItem
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..= CreditNoteLineItem -> Maybe Text
creditNoteLineItemDescription CreditNoteLineItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"discount_amount" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> Int
creditNoteLineItemDiscountAmount CreditNoteLineItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"discount_amounts" Text -> [DiscountsResourceDiscountAmount] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> [DiscountsResourceDiscountAmount]
creditNoteLineItemDiscountAmounts CreditNoteLineItem
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..= CreditNoteLineItem -> Text
creditNoteLineItemId CreditNoteLineItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"invoice_line_item" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> Maybe Text
creditNoteLineItemInvoiceLineItem CreditNoteLineItem
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..= CreditNoteLineItem -> Bool
creditNoteLineItemLivemode CreditNoteLineItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"quantity" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> Maybe Int
creditNoteLineItemQuantity CreditNoteLineItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"tax_amounts" Text -> [CreditNoteTaxAmount] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> [CreditNoteTaxAmount]
creditNoteLineItemTaxAmounts CreditNoteLineItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"tax_rates" Text -> [TaxRate] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> [TaxRate]
creditNoteLineItemTaxRates CreditNoteLineItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"type" Text -> CreditNoteLineItemType' -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> CreditNoteLineItemType'
creditNoteLineItemType CreditNoteLineItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"unit_amount" Text -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> Maybe Int
creditNoteLineItemUnitAmount CreditNoteLineItem
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"unit_amount_decimal" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= CreditNoteLineItem -> Maybe Text
creditNoteLineItemUnitAmountDecimal CreditNoteLineItem
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
"credit_note_line_item"))))))))))))))

instance Data.Aeson.Types.FromJSON.FromJSON CreditNoteLineItem where
  parseJSON :: Value -> Parser CreditNoteLineItem
parseJSON = String
-> (Object -> Parser CreditNoteLineItem)
-> Value
-> Parser CreditNoteLineItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"CreditNoteLineItem" (\Object
obj -> (((((((((((((Int
 -> Maybe Text
 -> Int
 -> [DiscountsResourceDiscountAmount]
 -> Text
 -> Maybe Text
 -> Bool
 -> Maybe Int
 -> [CreditNoteTaxAmount]
 -> [TaxRate]
 -> CreditNoteLineItemType'
 -> Maybe Int
 -> Maybe Text
 -> CreditNoteLineItem)
-> Parser
     (Int
      -> Maybe Text
      -> Int
      -> [DiscountsResourceDiscountAmount]
      -> Text
      -> Maybe Text
      -> Bool
      -> Maybe Int
      -> [CreditNoteTaxAmount]
      -> [TaxRate]
      -> CreditNoteLineItemType'
      -> Maybe Int
      -> Maybe Text
      -> CreditNoteLineItem)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Int
-> Maybe Text
-> Int
-> [DiscountsResourceDiscountAmount]
-> Text
-> Maybe Text
-> Bool
-> Maybe Int
-> [CreditNoteTaxAmount]
-> [TaxRate]
-> CreditNoteLineItemType'
-> Maybe Int
-> Maybe Text
-> CreditNoteLineItem
CreditNoteLineItem Parser
  (Int
   -> Maybe Text
   -> Int
   -> [DiscountsResourceDiscountAmount]
   -> Text
   -> Maybe Text
   -> Bool
   -> Maybe Int
   -> [CreditNoteTaxAmount]
   -> [TaxRate]
   -> CreditNoteLineItemType'
   -> Maybe Int
   -> Maybe Text
   -> CreditNoteLineItem)
-> Parser Int
-> Parser
     (Maybe Text
      -> Int
      -> [DiscountsResourceDiscountAmount]
      -> Text
      -> Maybe Text
      -> Bool
      -> Maybe Int
      -> [CreditNoteTaxAmount]
      -> [TaxRate]
      -> CreditNoteLineItemType'
      -> Maybe Int
      -> Maybe Text
      -> CreditNoteLineItem)
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
"amount")) Parser
  (Maybe Text
   -> Int
   -> [DiscountsResourceDiscountAmount]
   -> Text
   -> Maybe Text
   -> Bool
   -> Maybe Int
   -> [CreditNoteTaxAmount]
   -> [TaxRate]
   -> CreditNoteLineItemType'
   -> Maybe Int
   -> Maybe Text
   -> CreditNoteLineItem)
-> Parser (Maybe Text)
-> Parser
     (Int
      -> [DiscountsResourceDiscountAmount]
      -> Text
      -> Maybe Text
      -> Bool
      -> Maybe Int
      -> [CreditNoteTaxAmount]
      -> [TaxRate]
      -> CreditNoteLineItemType'
      -> Maybe Int
      -> Maybe Text
      -> CreditNoteLineItem)
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
  (Int
   -> [DiscountsResourceDiscountAmount]
   -> Text
   -> Maybe Text
   -> Bool
   -> Maybe Int
   -> [CreditNoteTaxAmount]
   -> [TaxRate]
   -> CreditNoteLineItemType'
   -> Maybe Int
   -> Maybe Text
   -> CreditNoteLineItem)
-> Parser Int
-> Parser
     ([DiscountsResourceDiscountAmount]
      -> Text
      -> Maybe Text
      -> Bool
      -> Maybe Int
      -> [CreditNoteTaxAmount]
      -> [TaxRate]
      -> CreditNoteLineItemType'
      -> Maybe Int
      -> Maybe Text
      -> CreditNoteLineItem)
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
"discount_amount")) Parser
  ([DiscountsResourceDiscountAmount]
   -> Text
   -> Maybe Text
   -> Bool
   -> Maybe Int
   -> [CreditNoteTaxAmount]
   -> [TaxRate]
   -> CreditNoteLineItemType'
   -> Maybe Int
   -> Maybe Text
   -> CreditNoteLineItem)
-> Parser [DiscountsResourceDiscountAmount]
-> Parser
     (Text
      -> Maybe Text
      -> Bool
      -> Maybe Int
      -> [CreditNoteTaxAmount]
      -> [TaxRate]
      -> CreditNoteLineItemType'
      -> Maybe Int
      -> Maybe Text
      -> CreditNoteLineItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser [DiscountsResourceDiscountAmount]
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"discount_amounts")) Parser
  (Text
   -> Maybe Text
   -> Bool
   -> Maybe Int
   -> [CreditNoteTaxAmount]
   -> [TaxRate]
   -> CreditNoteLineItemType'
   -> Maybe Int
   -> Maybe Text
   -> CreditNoteLineItem)
-> Parser Text
-> Parser
     (Maybe Text
      -> Bool
      -> Maybe Int
      -> [CreditNoteTaxAmount]
      -> [TaxRate]
      -> CreditNoteLineItemType'
      -> Maybe Int
      -> Maybe Text
      -> CreditNoteLineItem)
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
  (Maybe Text
   -> Bool
   -> Maybe Int
   -> [CreditNoteTaxAmount]
   -> [TaxRate]
   -> CreditNoteLineItemType'
   -> Maybe Int
   -> Maybe Text
   -> CreditNoteLineItem)
-> Parser (Maybe Text)
-> Parser
     (Bool
      -> Maybe Int
      -> [CreditNoteTaxAmount]
      -> [TaxRate]
      -> CreditNoteLineItemType'
      -> Maybe Int
      -> Maybe Text
      -> CreditNoteLineItem)
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
"invoice_line_item")) Parser
  (Bool
   -> Maybe Int
   -> [CreditNoteTaxAmount]
   -> [TaxRate]
   -> CreditNoteLineItemType'
   -> Maybe Int
   -> Maybe Text
   -> CreditNoteLineItem)
-> Parser Bool
-> Parser
     (Maybe Int
      -> [CreditNoteTaxAmount]
      -> [TaxRate]
      -> CreditNoteLineItemType'
      -> Maybe Int
      -> Maybe Text
      -> CreditNoteLineItem)
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 Int
   -> [CreditNoteTaxAmount]
   -> [TaxRate]
   -> CreditNoteLineItemType'
   -> Maybe Int
   -> Maybe Text
   -> CreditNoteLineItem)
-> Parser (Maybe Int)
-> Parser
     ([CreditNoteTaxAmount]
      -> [TaxRate]
      -> CreditNoteLineItemType'
      -> Maybe Int
      -> Maybe Text
      -> CreditNoteLineItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"quantity")) Parser
  ([CreditNoteTaxAmount]
   -> [TaxRate]
   -> CreditNoteLineItemType'
   -> Maybe Int
   -> Maybe Text
   -> CreditNoteLineItem)
-> Parser [CreditNoteTaxAmount]
-> Parser
     ([TaxRate]
      -> CreditNoteLineItemType'
      -> Maybe Int
      -> Maybe Text
      -> CreditNoteLineItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser [CreditNoteTaxAmount]
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"tax_amounts")) Parser
  ([TaxRate]
   -> CreditNoteLineItemType'
   -> Maybe Int
   -> Maybe Text
   -> CreditNoteLineItem)
-> Parser [TaxRate]
-> Parser
     (CreditNoteLineItemType'
      -> Maybe Int -> Maybe Text -> CreditNoteLineItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser [TaxRate]
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"tax_rates")) Parser
  (CreditNoteLineItemType'
   -> Maybe Int -> Maybe Text -> CreditNoteLineItem)
-> Parser CreditNoteLineItemType'
-> Parser (Maybe Int -> Maybe Text -> CreditNoteLineItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser CreditNoteLineItemType'
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"type")) Parser (Maybe Int -> Maybe Text -> CreditNoteLineItem)
-> Parser (Maybe Int) -> Parser (Maybe Text -> CreditNoteLineItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"unit_amount")) Parser (Maybe Text -> CreditNoteLineItem)
-> Parser (Maybe Text) -> Parser CreditNoteLineItem
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
"unit_amount_decimal"))

-- | Create a new 'CreditNoteLineItem' with all required fields.
mkCreditNoteLineItem ::
  -- | 'creditNoteLineItemAmount'
  GHC.Types.Int ->
  -- | 'creditNoteLineItemDiscountAmount'
  GHC.Types.Int ->
  -- | 'creditNoteLineItemDiscountAmounts'
  [DiscountsResourceDiscountAmount] ->
  -- | 'creditNoteLineItemId'
  Data.Text.Internal.Text ->
  -- | 'creditNoteLineItemLivemode'
  GHC.Types.Bool ->
  -- | 'creditNoteLineItemTaxAmounts'
  [CreditNoteTaxAmount] ->
  -- | 'creditNoteLineItemTaxRates'
  [TaxRate] ->
  -- | 'creditNoteLineItemType'
  CreditNoteLineItemType' ->
  CreditNoteLineItem
mkCreditNoteLineItem :: Int
-> Int
-> [DiscountsResourceDiscountAmount]
-> Text
-> Bool
-> [CreditNoteTaxAmount]
-> [TaxRate]
-> CreditNoteLineItemType'
-> CreditNoteLineItem
mkCreditNoteLineItem Int
creditNoteLineItemAmount Int
creditNoteLineItemDiscountAmount [DiscountsResourceDiscountAmount]
creditNoteLineItemDiscountAmounts Text
creditNoteLineItemId Bool
creditNoteLineItemLivemode [CreditNoteTaxAmount]
creditNoteLineItemTaxAmounts [TaxRate]
creditNoteLineItemTaxRates CreditNoteLineItemType'
creditNoteLineItemType =
  CreditNoteLineItem :: Int
-> Maybe Text
-> Int
-> [DiscountsResourceDiscountAmount]
-> Text
-> Maybe Text
-> Bool
-> Maybe Int
-> [CreditNoteTaxAmount]
-> [TaxRate]
-> CreditNoteLineItemType'
-> Maybe Int
-> Maybe Text
-> CreditNoteLineItem
CreditNoteLineItem
    { creditNoteLineItemAmount :: Int
creditNoteLineItemAmount = Int
creditNoteLineItemAmount,
      creditNoteLineItemDescription :: Maybe Text
creditNoteLineItemDescription = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      creditNoteLineItemDiscountAmount :: Int
creditNoteLineItemDiscountAmount = Int
creditNoteLineItemDiscountAmount,
      creditNoteLineItemDiscountAmounts :: [DiscountsResourceDiscountAmount]
creditNoteLineItemDiscountAmounts = [DiscountsResourceDiscountAmount]
creditNoteLineItemDiscountAmounts,
      creditNoteLineItemId :: Text
creditNoteLineItemId = Text
creditNoteLineItemId,
      creditNoteLineItemInvoiceLineItem :: Maybe Text
creditNoteLineItemInvoiceLineItem = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      creditNoteLineItemLivemode :: Bool
creditNoteLineItemLivemode = Bool
creditNoteLineItemLivemode,
      creditNoteLineItemQuantity :: Maybe Int
creditNoteLineItemQuantity = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      creditNoteLineItemTaxAmounts :: [CreditNoteTaxAmount]
creditNoteLineItemTaxAmounts = [CreditNoteTaxAmount]
creditNoteLineItemTaxAmounts,
      creditNoteLineItemTaxRates :: [TaxRate]
creditNoteLineItemTaxRates = [TaxRate]
creditNoteLineItemTaxRates,
      creditNoteLineItemType :: CreditNoteLineItemType'
creditNoteLineItemType = CreditNoteLineItemType'
creditNoteLineItemType,
      creditNoteLineItemUnitAmount :: Maybe Int
creditNoteLineItemUnitAmount = Maybe Int
forall a. Maybe a
GHC.Maybe.Nothing,
      creditNoteLineItemUnitAmountDecimal :: Maybe Text
creditNoteLineItemUnitAmountDecimal = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }

-- | Defines the enum schema located at @components.schemas.credit_note_line_item.properties.type@ in the specification.
--
-- The type of the credit note line item, one of \`invoice_line_item\` or \`custom_line_item\`. When the type is \`invoice_line_item\` there is an additional \`invoice_line_item\` property on the resource the value of which is the id of the credited line item on the invoice.
data CreditNoteLineItemType'
  = -- | This case is used if the value encountered during decoding does not match any of the provided cases in the specification.
    CreditNoteLineItemType'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.
    CreditNoteLineItemType'Typed Data.Text.Internal.Text
  | -- | Represents the JSON value @"custom_line_item"@
    CreditNoteLineItemType'EnumCustomLineItem
  | -- | Represents the JSON value @"invoice_line_item"@
    CreditNoteLineItemType'EnumInvoiceLineItem
  deriving (Int -> CreditNoteLineItemType' -> ShowS
[CreditNoteLineItemType'] -> ShowS
CreditNoteLineItemType' -> String
(Int -> CreditNoteLineItemType' -> ShowS)
-> (CreditNoteLineItemType' -> String)
-> ([CreditNoteLineItemType'] -> ShowS)
-> Show CreditNoteLineItemType'
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreditNoteLineItemType'] -> ShowS
$cshowList :: [CreditNoteLineItemType'] -> ShowS
show :: CreditNoteLineItemType' -> String
$cshow :: CreditNoteLineItemType' -> String
showsPrec :: Int -> CreditNoteLineItemType' -> ShowS
$cshowsPrec :: Int -> CreditNoteLineItemType' -> ShowS
GHC.Show.Show, CreditNoteLineItemType' -> CreditNoteLineItemType' -> Bool
(CreditNoteLineItemType' -> CreditNoteLineItemType' -> Bool)
-> (CreditNoteLineItemType' -> CreditNoteLineItemType' -> Bool)
-> Eq CreditNoteLineItemType'
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreditNoteLineItemType' -> CreditNoteLineItemType' -> Bool
$c/= :: CreditNoteLineItemType' -> CreditNoteLineItemType' -> Bool
== :: CreditNoteLineItemType' -> CreditNoteLineItemType' -> Bool
$c== :: CreditNoteLineItemType' -> CreditNoteLineItemType' -> Bool
GHC.Classes.Eq)

instance Data.Aeson.Types.ToJSON.ToJSON CreditNoteLineItemType' where
  toJSON :: CreditNoteLineItemType' -> Value
toJSON (CreditNoteLineItemType'Other Value
val) = Value
val
  toJSON (CreditNoteLineItemType'Typed Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
  toJSON (CreditNoteLineItemType'
CreditNoteLineItemType'EnumCustomLineItem) = Value
"custom_line_item"
  toJSON (CreditNoteLineItemType'
CreditNoteLineItemType'EnumInvoiceLineItem) = Value
"invoice_line_item"

instance Data.Aeson.Types.FromJSON.FromJSON CreditNoteLineItemType' where
  parseJSON :: Value -> Parser CreditNoteLineItemType'
parseJSON Value
val =
    CreditNoteLineItemType' -> Parser CreditNoteLineItemType'
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
"custom_line_item" -> CreditNoteLineItemType'
CreditNoteLineItemType'EnumCustomLineItem
            | Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"invoice_line_item" -> CreditNoteLineItemType'
CreditNoteLineItemType'EnumInvoiceLineItem
            | Bool
GHC.Base.otherwise -> Value -> CreditNoteLineItemType'
CreditNoteLineItemType'Other Value
val
      )