{-# 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.PinpointSmsVoiceV2.Types.SpendLimit
-- 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.PinpointSmsVoiceV2.Types.SpendLimit where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.PinpointSmsVoiceV2.Types.SpendLimitName
import qualified Amazonka.Prelude as Prelude

-- | Describes the current Amazon Pinpoint monthly spend limits for sending
-- voice and text messages. For more information on increasing your monthly
-- spend limit, see
-- <https://docs.aws.amazon.com/pinpoint/latest/userguide/channels-sms-awssupport-spend-threshold.html Requesting increases to your monthly SMS spending quota for Amazon Pinpoint>
-- in the /Amazon Pinpoint User Guide/.
--
-- /See:/ 'newSpendLimit' smart constructor.
data SpendLimit = SpendLimit'
  { -- | The name for the SpendLimit.
    SpendLimit -> SpendLimitName
name :: SpendLimitName,
    -- | The maximum amount of money, in US dollars, that you want to be able to
    -- spend sending messages each month. This value has to be less than or
    -- equal to the amount in @MaxLimit@. To use this custom limit,
    -- @Overridden@ must be set to true.
    SpendLimit -> Integer
enforcedLimit :: Prelude.Integer,
    -- | The maximum amount of money that you are able to spend to send messages
    -- each month, in US dollars.
    SpendLimit -> Integer
maxLimit :: Prelude.Integer,
    -- | When set to @True@, the value that has been specified in the
    -- @EnforcedLimit@ is used to determine the maximum amount in US dollars
    -- that can be spent to send messages each month, in US dollars.
    SpendLimit -> Bool
overridden :: Prelude.Bool
  }
  deriving (SpendLimit -> SpendLimit -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SpendLimit -> SpendLimit -> Bool
$c/= :: SpendLimit -> SpendLimit -> Bool
== :: SpendLimit -> SpendLimit -> Bool
$c== :: SpendLimit -> SpendLimit -> Bool
Prelude.Eq, ReadPrec [SpendLimit]
ReadPrec SpendLimit
Int -> ReadS SpendLimit
ReadS [SpendLimit]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SpendLimit]
$creadListPrec :: ReadPrec [SpendLimit]
readPrec :: ReadPrec SpendLimit
$creadPrec :: ReadPrec SpendLimit
readList :: ReadS [SpendLimit]
$creadList :: ReadS [SpendLimit]
readsPrec :: Int -> ReadS SpendLimit
$creadsPrec :: Int -> ReadS SpendLimit
Prelude.Read, Int -> SpendLimit -> ShowS
[SpendLimit] -> ShowS
SpendLimit -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SpendLimit] -> ShowS
$cshowList :: [SpendLimit] -> ShowS
show :: SpendLimit -> String
$cshow :: SpendLimit -> String
showsPrec :: Int -> SpendLimit -> ShowS
$cshowsPrec :: Int -> SpendLimit -> ShowS
Prelude.Show, forall x. Rep SpendLimit x -> SpendLimit
forall x. SpendLimit -> Rep SpendLimit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SpendLimit x -> SpendLimit
$cfrom :: forall x. SpendLimit -> Rep SpendLimit x
Prelude.Generic)

-- |
-- Create a value of 'SpendLimit' 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:
--
-- 'name', 'spendLimit_name' - The name for the SpendLimit.
--
-- 'enforcedLimit', 'spendLimit_enforcedLimit' - The maximum amount of money, in US dollars, that you want to be able to
-- spend sending messages each month. This value has to be less than or
-- equal to the amount in @MaxLimit@. To use this custom limit,
-- @Overridden@ must be set to true.
--
-- 'maxLimit', 'spendLimit_maxLimit' - The maximum amount of money that you are able to spend to send messages
-- each month, in US dollars.
--
-- 'overridden', 'spendLimit_overridden' - When set to @True@, the value that has been specified in the
-- @EnforcedLimit@ is used to determine the maximum amount in US dollars
-- that can be spent to send messages each month, in US dollars.
newSpendLimit ::
  -- | 'name'
  SpendLimitName ->
  -- | 'enforcedLimit'
  Prelude.Integer ->
  -- | 'maxLimit'
  Prelude.Integer ->
  -- | 'overridden'
  Prelude.Bool ->
  SpendLimit
newSpendLimit :: SpendLimitName -> Integer -> Integer -> Bool -> SpendLimit
newSpendLimit
  SpendLimitName
pName_
  Integer
pEnforcedLimit_
  Integer
pMaxLimit_
  Bool
pOverridden_ =
    SpendLimit'
      { $sel:name:SpendLimit' :: SpendLimitName
name = SpendLimitName
pName_,
        $sel:enforcedLimit:SpendLimit' :: Integer
enforcedLimit = Integer
pEnforcedLimit_,
        $sel:maxLimit:SpendLimit' :: Integer
maxLimit = Integer
pMaxLimit_,
        $sel:overridden:SpendLimit' :: Bool
overridden = Bool
pOverridden_
      }

-- | The name for the SpendLimit.
spendLimit_name :: Lens.Lens' SpendLimit SpendLimitName
spendLimit_name :: Lens' SpendLimit SpendLimitName
spendLimit_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpendLimit' {SpendLimitName
name :: SpendLimitName
$sel:name:SpendLimit' :: SpendLimit -> SpendLimitName
name} -> SpendLimitName
name) (\s :: SpendLimit
s@SpendLimit' {} SpendLimitName
a -> SpendLimit
s {$sel:name:SpendLimit' :: SpendLimitName
name = SpendLimitName
a} :: SpendLimit)

-- | The maximum amount of money, in US dollars, that you want to be able to
-- spend sending messages each month. This value has to be less than or
-- equal to the amount in @MaxLimit@. To use this custom limit,
-- @Overridden@ must be set to true.
spendLimit_enforcedLimit :: Lens.Lens' SpendLimit Prelude.Integer
spendLimit_enforcedLimit :: Lens' SpendLimit Integer
spendLimit_enforcedLimit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpendLimit' {Integer
enforcedLimit :: Integer
$sel:enforcedLimit:SpendLimit' :: SpendLimit -> Integer
enforcedLimit} -> Integer
enforcedLimit) (\s :: SpendLimit
s@SpendLimit' {} Integer
a -> SpendLimit
s {$sel:enforcedLimit:SpendLimit' :: Integer
enforcedLimit = Integer
a} :: SpendLimit)

-- | The maximum amount of money that you are able to spend to send messages
-- each month, in US dollars.
spendLimit_maxLimit :: Lens.Lens' SpendLimit Prelude.Integer
spendLimit_maxLimit :: Lens' SpendLimit Integer
spendLimit_maxLimit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpendLimit' {Integer
maxLimit :: Integer
$sel:maxLimit:SpendLimit' :: SpendLimit -> Integer
maxLimit} -> Integer
maxLimit) (\s :: SpendLimit
s@SpendLimit' {} Integer
a -> SpendLimit
s {$sel:maxLimit:SpendLimit' :: Integer
maxLimit = Integer
a} :: SpendLimit)

-- | When set to @True@, the value that has been specified in the
-- @EnforcedLimit@ is used to determine the maximum amount in US dollars
-- that can be spent to send messages each month, in US dollars.
spendLimit_overridden :: Lens.Lens' SpendLimit Prelude.Bool
spendLimit_overridden :: Lens' SpendLimit Bool
spendLimit_overridden = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpendLimit' {Bool
overridden :: Bool
$sel:overridden:SpendLimit' :: SpendLimit -> Bool
overridden} -> Bool
overridden) (\s :: SpendLimit
s@SpendLimit' {} Bool
a -> SpendLimit
s {$sel:overridden:SpendLimit' :: Bool
overridden = Bool
a} :: SpendLimit)

instance Data.FromJSON SpendLimit where
  parseJSON :: Value -> Parser SpendLimit
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SpendLimit"
      ( \Object
x ->
          SpendLimitName -> Integer -> Integer -> Bool -> SpendLimit
SpendLimit'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            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
"EnforcedLimit")
            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
"MaxLimit")
            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
"Overridden")
      )

instance Prelude.Hashable SpendLimit where
  hashWithSalt :: Int -> SpendLimit -> Int
hashWithSalt Int
_salt SpendLimit' {Bool
Integer
SpendLimitName
overridden :: Bool
maxLimit :: Integer
enforcedLimit :: Integer
name :: SpendLimitName
$sel:overridden:SpendLimit' :: SpendLimit -> Bool
$sel:maxLimit:SpendLimit' :: SpendLimit -> Integer
$sel:enforcedLimit:SpendLimit' :: SpendLimit -> Integer
$sel:name:SpendLimit' :: SpendLimit -> SpendLimitName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SpendLimitName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Integer
enforcedLimit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Integer
maxLimit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
overridden

instance Prelude.NFData SpendLimit where
  rnf :: SpendLimit -> ()
rnf SpendLimit' {Bool
Integer
SpendLimitName
overridden :: Bool
maxLimit :: Integer
enforcedLimit :: Integer
name :: SpendLimitName
$sel:overridden:SpendLimit' :: SpendLimit -> Bool
$sel:maxLimit:SpendLimit' :: SpendLimit -> Integer
$sel:enforcedLimit:SpendLimit' :: SpendLimit -> Integer
$sel:name:SpendLimit' :: SpendLimit -> SpendLimitName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf SpendLimitName
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
enforcedLimit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
maxLimit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
overridden