{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.BillingConductor.Types.ListCustomLineItemChargeDetails
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.BillingConductor.Types.ListCustomLineItemChargeDetails where

import Amazonka.BillingConductor.Types.CustomLineItemType
import Amazonka.BillingConductor.Types.ListCustomLineItemFlatChargeDetails
import Amazonka.BillingConductor.Types.ListCustomLineItemPercentageChargeDetails
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A representation of the charge details of a custom line item.
--
-- /See:/ 'newListCustomLineItemChargeDetails' smart constructor.
data ListCustomLineItemChargeDetails = ListCustomLineItemChargeDetails'
  { -- | A @ListCustomLineItemFlatChargeDetails@ that describes the charge
    -- details of a flat custom line item.
    ListCustomLineItemChargeDetails
-> Maybe ListCustomLineItemFlatChargeDetails
flat :: Prelude.Maybe ListCustomLineItemFlatChargeDetails,
    -- | A @ListCustomLineItemPercentageChargeDetails@ that describes the charge
    -- details of a percentage custom line item.
    ListCustomLineItemChargeDetails
-> Maybe ListCustomLineItemPercentageChargeDetails
percentage :: Prelude.Maybe ListCustomLineItemPercentageChargeDetails,
    -- | The type of the custom line item that indicates whether the charge is a
    -- @fee@ or @credit@.
    ListCustomLineItemChargeDetails -> CustomLineItemType
type' :: CustomLineItemType
  }
  deriving (ListCustomLineItemChargeDetails
-> ListCustomLineItemChargeDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCustomLineItemChargeDetails
-> ListCustomLineItemChargeDetails -> Bool
$c/= :: ListCustomLineItemChargeDetails
-> ListCustomLineItemChargeDetails -> Bool
== :: ListCustomLineItemChargeDetails
-> ListCustomLineItemChargeDetails -> Bool
$c== :: ListCustomLineItemChargeDetails
-> ListCustomLineItemChargeDetails -> Bool
Prelude.Eq, ReadPrec [ListCustomLineItemChargeDetails]
ReadPrec ListCustomLineItemChargeDetails
Int -> ReadS ListCustomLineItemChargeDetails
ReadS [ListCustomLineItemChargeDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCustomLineItemChargeDetails]
$creadListPrec :: ReadPrec [ListCustomLineItemChargeDetails]
readPrec :: ReadPrec ListCustomLineItemChargeDetails
$creadPrec :: ReadPrec ListCustomLineItemChargeDetails
readList :: ReadS [ListCustomLineItemChargeDetails]
$creadList :: ReadS [ListCustomLineItemChargeDetails]
readsPrec :: Int -> ReadS ListCustomLineItemChargeDetails
$creadsPrec :: Int -> ReadS ListCustomLineItemChargeDetails
Prelude.Read, Int -> ListCustomLineItemChargeDetails -> ShowS
[ListCustomLineItemChargeDetails] -> ShowS
ListCustomLineItemChargeDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCustomLineItemChargeDetails] -> ShowS
$cshowList :: [ListCustomLineItemChargeDetails] -> ShowS
show :: ListCustomLineItemChargeDetails -> String
$cshow :: ListCustomLineItemChargeDetails -> String
showsPrec :: Int -> ListCustomLineItemChargeDetails -> ShowS
$cshowsPrec :: Int -> ListCustomLineItemChargeDetails -> ShowS
Prelude.Show, forall x.
Rep ListCustomLineItemChargeDetails x
-> ListCustomLineItemChargeDetails
forall x.
ListCustomLineItemChargeDetails
-> Rep ListCustomLineItemChargeDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListCustomLineItemChargeDetails x
-> ListCustomLineItemChargeDetails
$cfrom :: forall x.
ListCustomLineItemChargeDetails
-> Rep ListCustomLineItemChargeDetails x
Prelude.Generic)

-- |
-- Create a value of 'ListCustomLineItemChargeDetails' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'flat', 'listCustomLineItemChargeDetails_flat' - A @ListCustomLineItemFlatChargeDetails@ that describes the charge
-- details of a flat custom line item.
--
-- 'percentage', 'listCustomLineItemChargeDetails_percentage' - A @ListCustomLineItemPercentageChargeDetails@ that describes the charge
-- details of a percentage custom line item.
--
-- 'type'', 'listCustomLineItemChargeDetails_type' - The type of the custom line item that indicates whether the charge is a
-- @fee@ or @credit@.
newListCustomLineItemChargeDetails ::
  -- | 'type''
  CustomLineItemType ->
  ListCustomLineItemChargeDetails
newListCustomLineItemChargeDetails :: CustomLineItemType -> ListCustomLineItemChargeDetails
newListCustomLineItemChargeDetails CustomLineItemType
pType_ =
  ListCustomLineItemChargeDetails'
    { $sel:flat:ListCustomLineItemChargeDetails' :: Maybe ListCustomLineItemFlatChargeDetails
flat =
        forall a. Maybe a
Prelude.Nothing,
      $sel:percentage:ListCustomLineItemChargeDetails' :: Maybe ListCustomLineItemPercentageChargeDetails
percentage = forall a. Maybe a
Prelude.Nothing,
      $sel:type':ListCustomLineItemChargeDetails' :: CustomLineItemType
type' = CustomLineItemType
pType_
    }

-- | A @ListCustomLineItemFlatChargeDetails@ that describes the charge
-- details of a flat custom line item.
listCustomLineItemChargeDetails_flat :: Lens.Lens' ListCustomLineItemChargeDetails (Prelude.Maybe ListCustomLineItemFlatChargeDetails)
listCustomLineItemChargeDetails_flat :: Lens'
  ListCustomLineItemChargeDetails
  (Maybe ListCustomLineItemFlatChargeDetails)
listCustomLineItemChargeDetails_flat = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomLineItemChargeDetails' {Maybe ListCustomLineItemFlatChargeDetails
flat :: Maybe ListCustomLineItemFlatChargeDetails
$sel:flat:ListCustomLineItemChargeDetails' :: ListCustomLineItemChargeDetails
-> Maybe ListCustomLineItemFlatChargeDetails
flat} -> Maybe ListCustomLineItemFlatChargeDetails
flat) (\s :: ListCustomLineItemChargeDetails
s@ListCustomLineItemChargeDetails' {} Maybe ListCustomLineItemFlatChargeDetails
a -> ListCustomLineItemChargeDetails
s {$sel:flat:ListCustomLineItemChargeDetails' :: Maybe ListCustomLineItemFlatChargeDetails
flat = Maybe ListCustomLineItemFlatChargeDetails
a} :: ListCustomLineItemChargeDetails)

-- | A @ListCustomLineItemPercentageChargeDetails@ that describes the charge
-- details of a percentage custom line item.
listCustomLineItemChargeDetails_percentage :: Lens.Lens' ListCustomLineItemChargeDetails (Prelude.Maybe ListCustomLineItemPercentageChargeDetails)
listCustomLineItemChargeDetails_percentage :: Lens'
  ListCustomLineItemChargeDetails
  (Maybe ListCustomLineItemPercentageChargeDetails)
listCustomLineItemChargeDetails_percentage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomLineItemChargeDetails' {Maybe ListCustomLineItemPercentageChargeDetails
percentage :: Maybe ListCustomLineItemPercentageChargeDetails
$sel:percentage:ListCustomLineItemChargeDetails' :: ListCustomLineItemChargeDetails
-> Maybe ListCustomLineItemPercentageChargeDetails
percentage} -> Maybe ListCustomLineItemPercentageChargeDetails
percentage) (\s :: ListCustomLineItemChargeDetails
s@ListCustomLineItemChargeDetails' {} Maybe ListCustomLineItemPercentageChargeDetails
a -> ListCustomLineItemChargeDetails
s {$sel:percentage:ListCustomLineItemChargeDetails' :: Maybe ListCustomLineItemPercentageChargeDetails
percentage = Maybe ListCustomLineItemPercentageChargeDetails
a} :: ListCustomLineItemChargeDetails)

-- | The type of the custom line item that indicates whether the charge is a
-- @fee@ or @credit@.
listCustomLineItemChargeDetails_type :: Lens.Lens' ListCustomLineItemChargeDetails CustomLineItemType
listCustomLineItemChargeDetails_type :: Lens' ListCustomLineItemChargeDetails CustomLineItemType
listCustomLineItemChargeDetails_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCustomLineItemChargeDetails' {CustomLineItemType
type' :: CustomLineItemType
$sel:type':ListCustomLineItemChargeDetails' :: ListCustomLineItemChargeDetails -> CustomLineItemType
type'} -> CustomLineItemType
type') (\s :: ListCustomLineItemChargeDetails
s@ListCustomLineItemChargeDetails' {} CustomLineItemType
a -> ListCustomLineItemChargeDetails
s {$sel:type':ListCustomLineItemChargeDetails' :: CustomLineItemType
type' = CustomLineItemType
a} :: ListCustomLineItemChargeDetails)

instance
  Data.FromJSON
    ListCustomLineItemChargeDetails
  where
  parseJSON :: Value -> Parser ListCustomLineItemChargeDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ListCustomLineItemChargeDetails"
      ( \Object
x ->
          Maybe ListCustomLineItemFlatChargeDetails
-> Maybe ListCustomLineItemPercentageChargeDetails
-> CustomLineItemType
-> ListCustomLineItemChargeDetails
ListCustomLineItemChargeDetails'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Flat")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Percentage")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Type")
      )

instance
  Prelude.Hashable
    ListCustomLineItemChargeDetails
  where
  hashWithSalt :: Int -> ListCustomLineItemChargeDetails -> Int
hashWithSalt
    Int
_salt
    ListCustomLineItemChargeDetails' {Maybe ListCustomLineItemFlatChargeDetails
Maybe ListCustomLineItemPercentageChargeDetails
CustomLineItemType
type' :: CustomLineItemType
percentage :: Maybe ListCustomLineItemPercentageChargeDetails
flat :: Maybe ListCustomLineItemFlatChargeDetails
$sel:type':ListCustomLineItemChargeDetails' :: ListCustomLineItemChargeDetails -> CustomLineItemType
$sel:percentage:ListCustomLineItemChargeDetails' :: ListCustomLineItemChargeDetails
-> Maybe ListCustomLineItemPercentageChargeDetails
$sel:flat:ListCustomLineItemChargeDetails' :: ListCustomLineItemChargeDetails
-> Maybe ListCustomLineItemFlatChargeDetails
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ListCustomLineItemFlatChargeDetails
flat
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ListCustomLineItemPercentageChargeDetails
percentage
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CustomLineItemType
type'

instance
  Prelude.NFData
    ListCustomLineItemChargeDetails
  where
  rnf :: ListCustomLineItemChargeDetails -> ()
rnf ListCustomLineItemChargeDetails' {Maybe ListCustomLineItemFlatChargeDetails
Maybe ListCustomLineItemPercentageChargeDetails
CustomLineItemType
type' :: CustomLineItemType
percentage :: Maybe ListCustomLineItemPercentageChargeDetails
flat :: Maybe ListCustomLineItemFlatChargeDetails
$sel:type':ListCustomLineItemChargeDetails' :: ListCustomLineItemChargeDetails -> CustomLineItemType
$sel:percentage:ListCustomLineItemChargeDetails' :: ListCustomLineItemChargeDetails
-> Maybe ListCustomLineItemPercentageChargeDetails
$sel:flat:ListCustomLineItemChargeDetails' :: ListCustomLineItemChargeDetails
-> Maybe ListCustomLineItemFlatChargeDetails
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ListCustomLineItemFlatChargeDetails
flat
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ListCustomLineItemPercentageChargeDetails
percentage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CustomLineItemType
type'