{-# 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.UpdateCustomLineItemChargeDetails
-- 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.UpdateCustomLineItemChargeDetails where

import Amazonka.BillingConductor.Types.UpdateCustomLineItemFlatChargeDetails
import Amazonka.BillingConductor.Types.UpdateCustomLineItemPercentageChargeDetails
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 new charge details of a custom line item. This
-- should contain only one of @Flat@ or @Percentage@.
--
-- /See:/ 'newUpdateCustomLineItemChargeDetails' smart constructor.
data UpdateCustomLineItemChargeDetails = UpdateCustomLineItemChargeDetails'
  { -- | An @UpdateCustomLineItemFlatChargeDetails@ that describes the new charge
    -- details of a flat custom line item.
    UpdateCustomLineItemChargeDetails
-> Maybe UpdateCustomLineItemFlatChargeDetails
flat :: Prelude.Maybe UpdateCustomLineItemFlatChargeDetails,
    -- | An @UpdateCustomLineItemPercentageChargeDetails@ that describes the new
    -- charge details of a percentage custom line item.
    UpdateCustomLineItemChargeDetails
-> Maybe UpdateCustomLineItemPercentageChargeDetails
percentage :: Prelude.Maybe UpdateCustomLineItemPercentageChargeDetails
  }
  deriving (UpdateCustomLineItemChargeDetails
-> UpdateCustomLineItemChargeDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateCustomLineItemChargeDetails
-> UpdateCustomLineItemChargeDetails -> Bool
$c/= :: UpdateCustomLineItemChargeDetails
-> UpdateCustomLineItemChargeDetails -> Bool
== :: UpdateCustomLineItemChargeDetails
-> UpdateCustomLineItemChargeDetails -> Bool
$c== :: UpdateCustomLineItemChargeDetails
-> UpdateCustomLineItemChargeDetails -> Bool
Prelude.Eq, ReadPrec [UpdateCustomLineItemChargeDetails]
ReadPrec UpdateCustomLineItemChargeDetails
Int -> ReadS UpdateCustomLineItemChargeDetails
ReadS [UpdateCustomLineItemChargeDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateCustomLineItemChargeDetails]
$creadListPrec :: ReadPrec [UpdateCustomLineItemChargeDetails]
readPrec :: ReadPrec UpdateCustomLineItemChargeDetails
$creadPrec :: ReadPrec UpdateCustomLineItemChargeDetails
readList :: ReadS [UpdateCustomLineItemChargeDetails]
$creadList :: ReadS [UpdateCustomLineItemChargeDetails]
readsPrec :: Int -> ReadS UpdateCustomLineItemChargeDetails
$creadsPrec :: Int -> ReadS UpdateCustomLineItemChargeDetails
Prelude.Read, Int -> UpdateCustomLineItemChargeDetails -> ShowS
[UpdateCustomLineItemChargeDetails] -> ShowS
UpdateCustomLineItemChargeDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateCustomLineItemChargeDetails] -> ShowS
$cshowList :: [UpdateCustomLineItemChargeDetails] -> ShowS
show :: UpdateCustomLineItemChargeDetails -> String
$cshow :: UpdateCustomLineItemChargeDetails -> String
showsPrec :: Int -> UpdateCustomLineItemChargeDetails -> ShowS
$cshowsPrec :: Int -> UpdateCustomLineItemChargeDetails -> ShowS
Prelude.Show, forall x.
Rep UpdateCustomLineItemChargeDetails x
-> UpdateCustomLineItemChargeDetails
forall x.
UpdateCustomLineItemChargeDetails
-> Rep UpdateCustomLineItemChargeDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateCustomLineItemChargeDetails x
-> UpdateCustomLineItemChargeDetails
$cfrom :: forall x.
UpdateCustomLineItemChargeDetails
-> Rep UpdateCustomLineItemChargeDetails x
Prelude.Generic)

-- |
-- Create a value of 'UpdateCustomLineItemChargeDetails' 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', 'updateCustomLineItemChargeDetails_flat' - An @UpdateCustomLineItemFlatChargeDetails@ that describes the new charge
-- details of a flat custom line item.
--
-- 'percentage', 'updateCustomLineItemChargeDetails_percentage' - An @UpdateCustomLineItemPercentageChargeDetails@ that describes the new
-- charge details of a percentage custom line item.
newUpdateCustomLineItemChargeDetails ::
  UpdateCustomLineItemChargeDetails
newUpdateCustomLineItemChargeDetails :: UpdateCustomLineItemChargeDetails
newUpdateCustomLineItemChargeDetails =
  UpdateCustomLineItemChargeDetails'
    { $sel:flat:UpdateCustomLineItemChargeDetails' :: Maybe UpdateCustomLineItemFlatChargeDetails
flat =
        forall a. Maybe a
Prelude.Nothing,
      $sel:percentage:UpdateCustomLineItemChargeDetails' :: Maybe UpdateCustomLineItemPercentageChargeDetails
percentage = forall a. Maybe a
Prelude.Nothing
    }

-- | An @UpdateCustomLineItemFlatChargeDetails@ that describes the new charge
-- details of a flat custom line item.
updateCustomLineItemChargeDetails_flat :: Lens.Lens' UpdateCustomLineItemChargeDetails (Prelude.Maybe UpdateCustomLineItemFlatChargeDetails)
updateCustomLineItemChargeDetails_flat :: Lens'
  UpdateCustomLineItemChargeDetails
  (Maybe UpdateCustomLineItemFlatChargeDetails)
updateCustomLineItemChargeDetails_flat = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCustomLineItemChargeDetails' {Maybe UpdateCustomLineItemFlatChargeDetails
flat :: Maybe UpdateCustomLineItemFlatChargeDetails
$sel:flat:UpdateCustomLineItemChargeDetails' :: UpdateCustomLineItemChargeDetails
-> Maybe UpdateCustomLineItemFlatChargeDetails
flat} -> Maybe UpdateCustomLineItemFlatChargeDetails
flat) (\s :: UpdateCustomLineItemChargeDetails
s@UpdateCustomLineItemChargeDetails' {} Maybe UpdateCustomLineItemFlatChargeDetails
a -> UpdateCustomLineItemChargeDetails
s {$sel:flat:UpdateCustomLineItemChargeDetails' :: Maybe UpdateCustomLineItemFlatChargeDetails
flat = Maybe UpdateCustomLineItemFlatChargeDetails
a} :: UpdateCustomLineItemChargeDetails)

-- | An @UpdateCustomLineItemPercentageChargeDetails@ that describes the new
-- charge details of a percentage custom line item.
updateCustomLineItemChargeDetails_percentage :: Lens.Lens' UpdateCustomLineItemChargeDetails (Prelude.Maybe UpdateCustomLineItemPercentageChargeDetails)
updateCustomLineItemChargeDetails_percentage :: Lens'
  UpdateCustomLineItemChargeDetails
  (Maybe UpdateCustomLineItemPercentageChargeDetails)
updateCustomLineItemChargeDetails_percentage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCustomLineItemChargeDetails' {Maybe UpdateCustomLineItemPercentageChargeDetails
percentage :: Maybe UpdateCustomLineItemPercentageChargeDetails
$sel:percentage:UpdateCustomLineItemChargeDetails' :: UpdateCustomLineItemChargeDetails
-> Maybe UpdateCustomLineItemPercentageChargeDetails
percentage} -> Maybe UpdateCustomLineItemPercentageChargeDetails
percentage) (\s :: UpdateCustomLineItemChargeDetails
s@UpdateCustomLineItemChargeDetails' {} Maybe UpdateCustomLineItemPercentageChargeDetails
a -> UpdateCustomLineItemChargeDetails
s {$sel:percentage:UpdateCustomLineItemChargeDetails' :: Maybe UpdateCustomLineItemPercentageChargeDetails
percentage = Maybe UpdateCustomLineItemPercentageChargeDetails
a} :: UpdateCustomLineItemChargeDetails)

instance
  Prelude.Hashable
    UpdateCustomLineItemChargeDetails
  where
  hashWithSalt :: Int -> UpdateCustomLineItemChargeDetails -> Int
hashWithSalt
    Int
_salt
    UpdateCustomLineItemChargeDetails' {Maybe UpdateCustomLineItemFlatChargeDetails
Maybe UpdateCustomLineItemPercentageChargeDetails
percentage :: Maybe UpdateCustomLineItemPercentageChargeDetails
flat :: Maybe UpdateCustomLineItemFlatChargeDetails
$sel:percentage:UpdateCustomLineItemChargeDetails' :: UpdateCustomLineItemChargeDetails
-> Maybe UpdateCustomLineItemPercentageChargeDetails
$sel:flat:UpdateCustomLineItemChargeDetails' :: UpdateCustomLineItemChargeDetails
-> Maybe UpdateCustomLineItemFlatChargeDetails
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UpdateCustomLineItemFlatChargeDetails
flat
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UpdateCustomLineItemPercentageChargeDetails
percentage

instance
  Prelude.NFData
    UpdateCustomLineItemChargeDetails
  where
  rnf :: UpdateCustomLineItemChargeDetails -> ()
rnf UpdateCustomLineItemChargeDetails' {Maybe UpdateCustomLineItemFlatChargeDetails
Maybe UpdateCustomLineItemPercentageChargeDetails
percentage :: Maybe UpdateCustomLineItemPercentageChargeDetails
flat :: Maybe UpdateCustomLineItemFlatChargeDetails
$sel:percentage:UpdateCustomLineItemChargeDetails' :: UpdateCustomLineItemChargeDetails
-> Maybe UpdateCustomLineItemPercentageChargeDetails
$sel:flat:UpdateCustomLineItemChargeDetails' :: UpdateCustomLineItemChargeDetails
-> Maybe UpdateCustomLineItemFlatChargeDetails
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe UpdateCustomLineItemFlatChargeDetails
flat
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UpdateCustomLineItemPercentageChargeDetails
percentage

instance
  Data.ToJSON
    UpdateCustomLineItemChargeDetails
  where
  toJSON :: UpdateCustomLineItemChargeDetails -> Value
toJSON UpdateCustomLineItemChargeDetails' {Maybe UpdateCustomLineItemFlatChargeDetails
Maybe UpdateCustomLineItemPercentageChargeDetails
percentage :: Maybe UpdateCustomLineItemPercentageChargeDetails
flat :: Maybe UpdateCustomLineItemFlatChargeDetails
$sel:percentage:UpdateCustomLineItemChargeDetails' :: UpdateCustomLineItemChargeDetails
-> Maybe UpdateCustomLineItemPercentageChargeDetails
$sel:flat:UpdateCustomLineItemChargeDetails' :: UpdateCustomLineItemChargeDetails
-> Maybe UpdateCustomLineItemFlatChargeDetails
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Flat" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UpdateCustomLineItemFlatChargeDetails
flat,
            (Key
"Percentage" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UpdateCustomLineItemPercentageChargeDetails
percentage
          ]
      )