{-# 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.Pinpoint.Types.CampaignLimits
-- 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.Pinpoint.Types.CampaignLimits where

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

-- | For a campaign, specifies limits on the messages that the campaign can
-- send. For an application, specifies the default limits for messages that
-- campaigns in the application can send.
--
-- /See:/ 'newCampaignLimits' smart constructor.
data CampaignLimits = CampaignLimits'
  { -- | The maximum number of messages that a campaign can send to a single
    -- endpoint during a 24-hour period. For an application, this value
    -- specifies the default limit for the number of messages that campaigns
    -- and journeys can send to a single endpoint during a 24-hour period. The
    -- maximum value is 100.
    CampaignLimits -> Maybe Int
daily :: Prelude.Maybe Prelude.Int,
    -- | The maximum amount of time, in seconds, that a campaign can attempt to
    -- deliver a message after the scheduled start time for the campaign. The
    -- minimum value is 60 seconds.
    CampaignLimits -> Maybe Int
maximumDuration :: Prelude.Maybe Prelude.Int,
    -- | The maximum number of messages that a campaign can send each second. For
    -- an application, this value specifies the default limit for the number of
    -- messages that campaigns can send each second. The minimum value is 50.
    -- The maximum value is 20,000.
    CampaignLimits -> Maybe Int
messagesPerSecond :: Prelude.Maybe Prelude.Int,
    -- | The maximum total number of messages that the campaign can send per user
    -- session.
    CampaignLimits -> Maybe Int
session :: Prelude.Maybe Prelude.Int,
    -- | The maximum number of messages that a campaign can send to a single
    -- endpoint during the course of the campaign. If a campaign recurs, this
    -- setting applies to all runs of the campaign. The maximum value is 100.
    CampaignLimits -> Maybe Int
total :: Prelude.Maybe Prelude.Int
  }
  deriving (CampaignLimits -> CampaignLimits -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CampaignLimits -> CampaignLimits -> Bool
$c/= :: CampaignLimits -> CampaignLimits -> Bool
== :: CampaignLimits -> CampaignLimits -> Bool
$c== :: CampaignLimits -> CampaignLimits -> Bool
Prelude.Eq, ReadPrec [CampaignLimits]
ReadPrec CampaignLimits
Int -> ReadS CampaignLimits
ReadS [CampaignLimits]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CampaignLimits]
$creadListPrec :: ReadPrec [CampaignLimits]
readPrec :: ReadPrec CampaignLimits
$creadPrec :: ReadPrec CampaignLimits
readList :: ReadS [CampaignLimits]
$creadList :: ReadS [CampaignLimits]
readsPrec :: Int -> ReadS CampaignLimits
$creadsPrec :: Int -> ReadS CampaignLimits
Prelude.Read, Int -> CampaignLimits -> ShowS
[CampaignLimits] -> ShowS
CampaignLimits -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CampaignLimits] -> ShowS
$cshowList :: [CampaignLimits] -> ShowS
show :: CampaignLimits -> String
$cshow :: CampaignLimits -> String
showsPrec :: Int -> CampaignLimits -> ShowS
$cshowsPrec :: Int -> CampaignLimits -> ShowS
Prelude.Show, forall x. Rep CampaignLimits x -> CampaignLimits
forall x. CampaignLimits -> Rep CampaignLimits x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CampaignLimits x -> CampaignLimits
$cfrom :: forall x. CampaignLimits -> Rep CampaignLimits x
Prelude.Generic)

-- |
-- Create a value of 'CampaignLimits' 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:
--
-- 'daily', 'campaignLimits_daily' - The maximum number of messages that a campaign can send to a single
-- endpoint during a 24-hour period. For an application, this value
-- specifies the default limit for the number of messages that campaigns
-- and journeys can send to a single endpoint during a 24-hour period. The
-- maximum value is 100.
--
-- 'maximumDuration', 'campaignLimits_maximumDuration' - The maximum amount of time, in seconds, that a campaign can attempt to
-- deliver a message after the scheduled start time for the campaign. The
-- minimum value is 60 seconds.
--
-- 'messagesPerSecond', 'campaignLimits_messagesPerSecond' - The maximum number of messages that a campaign can send each second. For
-- an application, this value specifies the default limit for the number of
-- messages that campaigns can send each second. The minimum value is 50.
-- The maximum value is 20,000.
--
-- 'session', 'campaignLimits_session' - The maximum total number of messages that the campaign can send per user
-- session.
--
-- 'total', 'campaignLimits_total' - The maximum number of messages that a campaign can send to a single
-- endpoint during the course of the campaign. If a campaign recurs, this
-- setting applies to all runs of the campaign. The maximum value is 100.
newCampaignLimits ::
  CampaignLimits
newCampaignLimits :: CampaignLimits
newCampaignLimits =
  CampaignLimits'
    { $sel:daily:CampaignLimits' :: Maybe Int
daily = forall a. Maybe a
Prelude.Nothing,
      $sel:maximumDuration:CampaignLimits' :: Maybe Int
maximumDuration = forall a. Maybe a
Prelude.Nothing,
      $sel:messagesPerSecond:CampaignLimits' :: Maybe Int
messagesPerSecond = forall a. Maybe a
Prelude.Nothing,
      $sel:session:CampaignLimits' :: Maybe Int
session = forall a. Maybe a
Prelude.Nothing,
      $sel:total:CampaignLimits' :: Maybe Int
total = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of messages that a campaign can send to a single
-- endpoint during a 24-hour period. For an application, this value
-- specifies the default limit for the number of messages that campaigns
-- and journeys can send to a single endpoint during a 24-hour period. The
-- maximum value is 100.
campaignLimits_daily :: Lens.Lens' CampaignLimits (Prelude.Maybe Prelude.Int)
campaignLimits_daily :: Lens' CampaignLimits (Maybe Int)
campaignLimits_daily = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignLimits' {Maybe Int
daily :: Maybe Int
$sel:daily:CampaignLimits' :: CampaignLimits -> Maybe Int
daily} -> Maybe Int
daily) (\s :: CampaignLimits
s@CampaignLimits' {} Maybe Int
a -> CampaignLimits
s {$sel:daily:CampaignLimits' :: Maybe Int
daily = Maybe Int
a} :: CampaignLimits)

-- | The maximum amount of time, in seconds, that a campaign can attempt to
-- deliver a message after the scheduled start time for the campaign. The
-- minimum value is 60 seconds.
campaignLimits_maximumDuration :: Lens.Lens' CampaignLimits (Prelude.Maybe Prelude.Int)
campaignLimits_maximumDuration :: Lens' CampaignLimits (Maybe Int)
campaignLimits_maximumDuration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignLimits' {Maybe Int
maximumDuration :: Maybe Int
$sel:maximumDuration:CampaignLimits' :: CampaignLimits -> Maybe Int
maximumDuration} -> Maybe Int
maximumDuration) (\s :: CampaignLimits
s@CampaignLimits' {} Maybe Int
a -> CampaignLimits
s {$sel:maximumDuration:CampaignLimits' :: Maybe Int
maximumDuration = Maybe Int
a} :: CampaignLimits)

-- | The maximum number of messages that a campaign can send each second. For
-- an application, this value specifies the default limit for the number of
-- messages that campaigns can send each second. The minimum value is 50.
-- The maximum value is 20,000.
campaignLimits_messagesPerSecond :: Lens.Lens' CampaignLimits (Prelude.Maybe Prelude.Int)
campaignLimits_messagesPerSecond :: Lens' CampaignLimits (Maybe Int)
campaignLimits_messagesPerSecond = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignLimits' {Maybe Int
messagesPerSecond :: Maybe Int
$sel:messagesPerSecond:CampaignLimits' :: CampaignLimits -> Maybe Int
messagesPerSecond} -> Maybe Int
messagesPerSecond) (\s :: CampaignLimits
s@CampaignLimits' {} Maybe Int
a -> CampaignLimits
s {$sel:messagesPerSecond:CampaignLimits' :: Maybe Int
messagesPerSecond = Maybe Int
a} :: CampaignLimits)

-- | The maximum total number of messages that the campaign can send per user
-- session.
campaignLimits_session :: Lens.Lens' CampaignLimits (Prelude.Maybe Prelude.Int)
campaignLimits_session :: Lens' CampaignLimits (Maybe Int)
campaignLimits_session = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignLimits' {Maybe Int
session :: Maybe Int
$sel:session:CampaignLimits' :: CampaignLimits -> Maybe Int
session} -> Maybe Int
session) (\s :: CampaignLimits
s@CampaignLimits' {} Maybe Int
a -> CampaignLimits
s {$sel:session:CampaignLimits' :: Maybe Int
session = Maybe Int
a} :: CampaignLimits)

-- | The maximum number of messages that a campaign can send to a single
-- endpoint during the course of the campaign. If a campaign recurs, this
-- setting applies to all runs of the campaign. The maximum value is 100.
campaignLimits_total :: Lens.Lens' CampaignLimits (Prelude.Maybe Prelude.Int)
campaignLimits_total :: Lens' CampaignLimits (Maybe Int)
campaignLimits_total = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignLimits' {Maybe Int
total :: Maybe Int
$sel:total:CampaignLimits' :: CampaignLimits -> Maybe Int
total} -> Maybe Int
total) (\s :: CampaignLimits
s@CampaignLimits' {} Maybe Int
a -> CampaignLimits
s {$sel:total:CampaignLimits' :: Maybe Int
total = Maybe Int
a} :: CampaignLimits)

instance Data.FromJSON CampaignLimits where
  parseJSON :: Value -> Parser CampaignLimits
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CampaignLimits"
      ( \Object
x ->
          Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> CampaignLimits
CampaignLimits'
            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
"Daily")
            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
"MaximumDuration")
            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
"MessagesPerSecond")
            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
"Session")
            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
"Total")
      )

instance Prelude.Hashable CampaignLimits where
  hashWithSalt :: Int -> CampaignLimits -> Int
hashWithSalt Int
_salt CampaignLimits' {Maybe Int
total :: Maybe Int
session :: Maybe Int
messagesPerSecond :: Maybe Int
maximumDuration :: Maybe Int
daily :: Maybe Int
$sel:total:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:session:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:messagesPerSecond:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:maximumDuration:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:daily:CampaignLimits' :: CampaignLimits -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
daily
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maximumDuration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
messagesPerSecond
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
session
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
total

instance Prelude.NFData CampaignLimits where
  rnf :: CampaignLimits -> ()
rnf CampaignLimits' {Maybe Int
total :: Maybe Int
session :: Maybe Int
messagesPerSecond :: Maybe Int
maximumDuration :: Maybe Int
daily :: Maybe Int
$sel:total:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:session:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:messagesPerSecond:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:maximumDuration:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:daily:CampaignLimits' :: CampaignLimits -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
daily
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maximumDuration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
messagesPerSecond
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
session
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
total

instance Data.ToJSON CampaignLimits where
  toJSON :: CampaignLimits -> Value
toJSON CampaignLimits' {Maybe Int
total :: Maybe Int
session :: Maybe Int
messagesPerSecond :: Maybe Int
maximumDuration :: Maybe Int
daily :: Maybe Int
$sel:total:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:session:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:messagesPerSecond:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:maximumDuration:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:daily:CampaignLimits' :: CampaignLimits -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Daily" 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 Int
daily,
            (Key
"MaximumDuration" 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 Int
maximumDuration,
            (Key
"MessagesPerSecond" 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 Int
messagesPerSecond,
            (Key
"Session" 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 Int
session,
            (Key
"Total" 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 Int
total
          ]
      )