{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.SetTextMessageSpendLimitOverride
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Sets an account level monthly spend limit override for sending text
-- messages. The requested spend limit must be less than or equal to the
-- @MaxLimit@, which is set by Amazon Web Services.
module Amazonka.PinpointSmsVoiceV2.SetTextMessageSpendLimitOverride
  ( -- * Creating a Request
    SetTextMessageSpendLimitOverride (..),
    newSetTextMessageSpendLimitOverride,

    -- * Request Lenses
    setTextMessageSpendLimitOverride_monthlyLimit,

    -- * Destructuring the Response
    SetTextMessageSpendLimitOverrideResponse (..),
    newSetTextMessageSpendLimitOverrideResponse,

    -- * Response Lenses
    setTextMessageSpendLimitOverrideResponse_monthlyLimit,
    setTextMessageSpendLimitOverrideResponse_httpStatus,
  )
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
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newSetTextMessageSpendLimitOverride' smart constructor.
data SetTextMessageSpendLimitOverride = SetTextMessageSpendLimitOverride'
  { -- | The new monthly limit to enforce on text messages.
    SetTextMessageSpendLimitOverride -> Natural
monthlyLimit :: Prelude.Natural
  }
  deriving (SetTextMessageSpendLimitOverride
-> SetTextMessageSpendLimitOverride -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetTextMessageSpendLimitOverride
-> SetTextMessageSpendLimitOverride -> Bool
$c/= :: SetTextMessageSpendLimitOverride
-> SetTextMessageSpendLimitOverride -> Bool
== :: SetTextMessageSpendLimitOverride
-> SetTextMessageSpendLimitOverride -> Bool
$c== :: SetTextMessageSpendLimitOverride
-> SetTextMessageSpendLimitOverride -> Bool
Prelude.Eq, ReadPrec [SetTextMessageSpendLimitOverride]
ReadPrec SetTextMessageSpendLimitOverride
Int -> ReadS SetTextMessageSpendLimitOverride
ReadS [SetTextMessageSpendLimitOverride]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetTextMessageSpendLimitOverride]
$creadListPrec :: ReadPrec [SetTextMessageSpendLimitOverride]
readPrec :: ReadPrec SetTextMessageSpendLimitOverride
$creadPrec :: ReadPrec SetTextMessageSpendLimitOverride
readList :: ReadS [SetTextMessageSpendLimitOverride]
$creadList :: ReadS [SetTextMessageSpendLimitOverride]
readsPrec :: Int -> ReadS SetTextMessageSpendLimitOverride
$creadsPrec :: Int -> ReadS SetTextMessageSpendLimitOverride
Prelude.Read, Int -> SetTextMessageSpendLimitOverride -> ShowS
[SetTextMessageSpendLimitOverride] -> ShowS
SetTextMessageSpendLimitOverride -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetTextMessageSpendLimitOverride] -> ShowS
$cshowList :: [SetTextMessageSpendLimitOverride] -> ShowS
show :: SetTextMessageSpendLimitOverride -> String
$cshow :: SetTextMessageSpendLimitOverride -> String
showsPrec :: Int -> SetTextMessageSpendLimitOverride -> ShowS
$cshowsPrec :: Int -> SetTextMessageSpendLimitOverride -> ShowS
Prelude.Show, forall x.
Rep SetTextMessageSpendLimitOverride x
-> SetTextMessageSpendLimitOverride
forall x.
SetTextMessageSpendLimitOverride
-> Rep SetTextMessageSpendLimitOverride x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SetTextMessageSpendLimitOverride x
-> SetTextMessageSpendLimitOverride
$cfrom :: forall x.
SetTextMessageSpendLimitOverride
-> Rep SetTextMessageSpendLimitOverride x
Prelude.Generic)

-- |
-- Create a value of 'SetTextMessageSpendLimitOverride' 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:
--
-- 'monthlyLimit', 'setTextMessageSpendLimitOverride_monthlyLimit' - The new monthly limit to enforce on text messages.
newSetTextMessageSpendLimitOverride ::
  -- | 'monthlyLimit'
  Prelude.Natural ->
  SetTextMessageSpendLimitOverride
newSetTextMessageSpendLimitOverride :: Natural -> SetTextMessageSpendLimitOverride
newSetTextMessageSpendLimitOverride Natural
pMonthlyLimit_ =
  SetTextMessageSpendLimitOverride'
    { $sel:monthlyLimit:SetTextMessageSpendLimitOverride' :: Natural
monthlyLimit =
        Natural
pMonthlyLimit_
    }

-- | The new monthly limit to enforce on text messages.
setTextMessageSpendLimitOverride_monthlyLimit :: Lens.Lens' SetTextMessageSpendLimitOverride Prelude.Natural
setTextMessageSpendLimitOverride_monthlyLimit :: Lens' SetTextMessageSpendLimitOverride Natural
setTextMessageSpendLimitOverride_monthlyLimit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetTextMessageSpendLimitOverride' {Natural
monthlyLimit :: Natural
$sel:monthlyLimit:SetTextMessageSpendLimitOverride' :: SetTextMessageSpendLimitOverride -> Natural
monthlyLimit} -> Natural
monthlyLimit) (\s :: SetTextMessageSpendLimitOverride
s@SetTextMessageSpendLimitOverride' {} Natural
a -> SetTextMessageSpendLimitOverride
s {$sel:monthlyLimit:SetTextMessageSpendLimitOverride' :: Natural
monthlyLimit = Natural
a} :: SetTextMessageSpendLimitOverride)

instance
  Core.AWSRequest
    SetTextMessageSpendLimitOverride
  where
  type
    AWSResponse SetTextMessageSpendLimitOverride =
      SetTextMessageSpendLimitOverrideResponse
  request :: (Service -> Service)
-> SetTextMessageSpendLimitOverride
-> Request SetTextMessageSpendLimitOverride
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy SetTextMessageSpendLimitOverride
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse SetTextMessageSpendLimitOverride)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Natural -> Int -> SetTextMessageSpendLimitOverrideResponse
SetTextMessageSpendLimitOverrideResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"MonthlyLimit")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    SetTextMessageSpendLimitOverride
  where
  hashWithSalt :: Int -> SetTextMessageSpendLimitOverride -> Int
hashWithSalt
    Int
_salt
    SetTextMessageSpendLimitOverride' {Natural
monthlyLimit :: Natural
$sel:monthlyLimit:SetTextMessageSpendLimitOverride' :: SetTextMessageSpendLimitOverride -> Natural
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
monthlyLimit

instance
  Prelude.NFData
    SetTextMessageSpendLimitOverride
  where
  rnf :: SetTextMessageSpendLimitOverride -> ()
rnf SetTextMessageSpendLimitOverride' {Natural
monthlyLimit :: Natural
$sel:monthlyLimit:SetTextMessageSpendLimitOverride' :: SetTextMessageSpendLimitOverride -> Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Natural
monthlyLimit

instance
  Data.ToHeaders
    SetTextMessageSpendLimitOverride
  where
  toHeaders :: SetTextMessageSpendLimitOverride -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"PinpointSMSVoiceV2.SetTextMessageSpendLimitOverride" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON SetTextMessageSpendLimitOverride where
  toJSON :: SetTextMessageSpendLimitOverride -> Value
toJSON SetTextMessageSpendLimitOverride' {Natural
monthlyLimit :: Natural
$sel:monthlyLimit:SetTextMessageSpendLimitOverride' :: SetTextMessageSpendLimitOverride -> Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"MonthlyLimit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
monthlyLimit)]
      )

instance Data.ToPath SetTextMessageSpendLimitOverride where
  toPath :: SetTextMessageSpendLimitOverride -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance
  Data.ToQuery
    SetTextMessageSpendLimitOverride
  where
  toQuery :: SetTextMessageSpendLimitOverride -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newSetTextMessageSpendLimitOverrideResponse' smart constructor.
data SetTextMessageSpendLimitOverrideResponse = SetTextMessageSpendLimitOverrideResponse'
  { -- | The current monthly limit to enforce on sending text messages.
    SetTextMessageSpendLimitOverrideResponse -> Maybe Natural
monthlyLimit :: Prelude.Maybe Prelude.Natural,
    -- | The response's http status code.
    SetTextMessageSpendLimitOverrideResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SetTextMessageSpendLimitOverrideResponse
-> SetTextMessageSpendLimitOverrideResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetTextMessageSpendLimitOverrideResponse
-> SetTextMessageSpendLimitOverrideResponse -> Bool
$c/= :: SetTextMessageSpendLimitOverrideResponse
-> SetTextMessageSpendLimitOverrideResponse -> Bool
== :: SetTextMessageSpendLimitOverrideResponse
-> SetTextMessageSpendLimitOverrideResponse -> Bool
$c== :: SetTextMessageSpendLimitOverrideResponse
-> SetTextMessageSpendLimitOverrideResponse -> Bool
Prelude.Eq, ReadPrec [SetTextMessageSpendLimitOverrideResponse]
ReadPrec SetTextMessageSpendLimitOverrideResponse
Int -> ReadS SetTextMessageSpendLimitOverrideResponse
ReadS [SetTextMessageSpendLimitOverrideResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetTextMessageSpendLimitOverrideResponse]
$creadListPrec :: ReadPrec [SetTextMessageSpendLimitOverrideResponse]
readPrec :: ReadPrec SetTextMessageSpendLimitOverrideResponse
$creadPrec :: ReadPrec SetTextMessageSpendLimitOverrideResponse
readList :: ReadS [SetTextMessageSpendLimitOverrideResponse]
$creadList :: ReadS [SetTextMessageSpendLimitOverrideResponse]
readsPrec :: Int -> ReadS SetTextMessageSpendLimitOverrideResponse
$creadsPrec :: Int -> ReadS SetTextMessageSpendLimitOverrideResponse
Prelude.Read, Int -> SetTextMessageSpendLimitOverrideResponse -> ShowS
[SetTextMessageSpendLimitOverrideResponse] -> ShowS
SetTextMessageSpendLimitOverrideResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetTextMessageSpendLimitOverrideResponse] -> ShowS
$cshowList :: [SetTextMessageSpendLimitOverrideResponse] -> ShowS
show :: SetTextMessageSpendLimitOverrideResponse -> String
$cshow :: SetTextMessageSpendLimitOverrideResponse -> String
showsPrec :: Int -> SetTextMessageSpendLimitOverrideResponse -> ShowS
$cshowsPrec :: Int -> SetTextMessageSpendLimitOverrideResponse -> ShowS
Prelude.Show, forall x.
Rep SetTextMessageSpendLimitOverrideResponse x
-> SetTextMessageSpendLimitOverrideResponse
forall x.
SetTextMessageSpendLimitOverrideResponse
-> Rep SetTextMessageSpendLimitOverrideResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SetTextMessageSpendLimitOverrideResponse x
-> SetTextMessageSpendLimitOverrideResponse
$cfrom :: forall x.
SetTextMessageSpendLimitOverrideResponse
-> Rep SetTextMessageSpendLimitOverrideResponse x
Prelude.Generic)

-- |
-- Create a value of 'SetTextMessageSpendLimitOverrideResponse' 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:
--
-- 'monthlyLimit', 'setTextMessageSpendLimitOverrideResponse_monthlyLimit' - The current monthly limit to enforce on sending text messages.
--
-- 'httpStatus', 'setTextMessageSpendLimitOverrideResponse_httpStatus' - The response's http status code.
newSetTextMessageSpendLimitOverrideResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SetTextMessageSpendLimitOverrideResponse
newSetTextMessageSpendLimitOverrideResponse :: Int -> SetTextMessageSpendLimitOverrideResponse
newSetTextMessageSpendLimitOverrideResponse
  Int
pHttpStatus_ =
    SetTextMessageSpendLimitOverrideResponse'
      { $sel:monthlyLimit:SetTextMessageSpendLimitOverrideResponse' :: Maybe Natural
monthlyLimit =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:SetTextMessageSpendLimitOverrideResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The current monthly limit to enforce on sending text messages.
setTextMessageSpendLimitOverrideResponse_monthlyLimit :: Lens.Lens' SetTextMessageSpendLimitOverrideResponse (Prelude.Maybe Prelude.Natural)
setTextMessageSpendLimitOverrideResponse_monthlyLimit :: Lens' SetTextMessageSpendLimitOverrideResponse (Maybe Natural)
setTextMessageSpendLimitOverrideResponse_monthlyLimit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetTextMessageSpendLimitOverrideResponse' {Maybe Natural
monthlyLimit :: Maybe Natural
$sel:monthlyLimit:SetTextMessageSpendLimitOverrideResponse' :: SetTextMessageSpendLimitOverrideResponse -> Maybe Natural
monthlyLimit} -> Maybe Natural
monthlyLimit) (\s :: SetTextMessageSpendLimitOverrideResponse
s@SetTextMessageSpendLimitOverrideResponse' {} Maybe Natural
a -> SetTextMessageSpendLimitOverrideResponse
s {$sel:monthlyLimit:SetTextMessageSpendLimitOverrideResponse' :: Maybe Natural
monthlyLimit = Maybe Natural
a} :: SetTextMessageSpendLimitOverrideResponse)

-- | The response's http status code.
setTextMessageSpendLimitOverrideResponse_httpStatus :: Lens.Lens' SetTextMessageSpendLimitOverrideResponse Prelude.Int
setTextMessageSpendLimitOverrideResponse_httpStatus :: Lens' SetTextMessageSpendLimitOverrideResponse Int
setTextMessageSpendLimitOverrideResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetTextMessageSpendLimitOverrideResponse' {Int
httpStatus :: Int
$sel:httpStatus:SetTextMessageSpendLimitOverrideResponse' :: SetTextMessageSpendLimitOverrideResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SetTextMessageSpendLimitOverrideResponse
s@SetTextMessageSpendLimitOverrideResponse' {} Int
a -> SetTextMessageSpendLimitOverrideResponse
s {$sel:httpStatus:SetTextMessageSpendLimitOverrideResponse' :: Int
httpStatus = Int
a} :: SetTextMessageSpendLimitOverrideResponse)

instance
  Prelude.NFData
    SetTextMessageSpendLimitOverrideResponse
  where
  rnf :: SetTextMessageSpendLimitOverrideResponse -> ()
rnf SetTextMessageSpendLimitOverrideResponse' {Int
Maybe Natural
httpStatus :: Int
monthlyLimit :: Maybe Natural
$sel:httpStatus:SetTextMessageSpendLimitOverrideResponse' :: SetTextMessageSpendLimitOverrideResponse -> Int
$sel:monthlyLimit:SetTextMessageSpendLimitOverrideResponse' :: SetTextMessageSpendLimitOverrideResponse -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
monthlyLimit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus