{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Pinpoint.Types.CampaignLimits where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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 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 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,
    -- | The maximum total number of messages that the campaign can send per user
    -- session.
    CampaignLimits -> Maybe Int
session :: 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
  }
  deriving (CampaignLimits -> CampaignLimits -> Bool
(CampaignLimits -> CampaignLimits -> Bool)
-> (CampaignLimits -> CampaignLimits -> Bool) -> Eq CampaignLimits
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]
(Int -> ReadS CampaignLimits)
-> ReadS [CampaignLimits]
-> ReadPrec CampaignLimits
-> ReadPrec [CampaignLimits]
-> Read 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
(Int -> CampaignLimits -> ShowS)
-> (CampaignLimits -> String)
-> ([CampaignLimits] -> ShowS)
-> Show CampaignLimits
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. CampaignLimits -> Rep CampaignLimits x)
-> (forall x. Rep CampaignLimits x -> CampaignLimits)
-> Generic CampaignLimits
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:
--
-- '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.
--
-- '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.
--
-- '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.
--
-- 'session', 'campaignLimits_session' - The maximum total number of messages that the campaign can send per user
-- session.
--
-- '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.
newCampaignLimits ::
  CampaignLimits
newCampaignLimits :: CampaignLimits
newCampaignLimits =
  CampaignLimits' :: Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> CampaignLimits
CampaignLimits'
    { $sel:messagesPerSecond:CampaignLimits' :: Maybe Int
messagesPerSecond =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:daily:CampaignLimits' :: Maybe Int
daily = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:total:CampaignLimits' :: Maybe Int
total = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:session:CampaignLimits' :: Maybe Int
session = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:maximumDuration:CampaignLimits' :: Maybe Int
maximumDuration = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Int -> f (Maybe Int)) -> CampaignLimits -> f CampaignLimits
campaignLimits_messagesPerSecond = (CampaignLimits -> Maybe Int)
-> (CampaignLimits -> Maybe Int -> CampaignLimits)
-> Lens CampaignLimits CampaignLimits (Maybe Int) (Maybe Int)
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 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 :: (Maybe Int -> f (Maybe Int)) -> CampaignLimits -> f CampaignLimits
campaignLimits_daily = (CampaignLimits -> Maybe Int)
-> (CampaignLimits -> Maybe Int -> CampaignLimits)
-> Lens CampaignLimits CampaignLimits (Maybe Int) (Maybe Int)
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 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 :: (Maybe Int -> f (Maybe Int)) -> CampaignLimits -> f CampaignLimits
campaignLimits_total = (CampaignLimits -> Maybe Int)
-> (CampaignLimits -> Maybe Int -> CampaignLimits)
-> Lens CampaignLimits CampaignLimits (Maybe Int) (Maybe Int)
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)

-- | 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 :: (Maybe Int -> f (Maybe Int)) -> CampaignLimits -> f CampaignLimits
campaignLimits_session = (CampaignLimits -> Maybe Int)
-> (CampaignLimits -> Maybe Int -> CampaignLimits)
-> Lens CampaignLimits CampaignLimits (Maybe Int) (Maybe Int)
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 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 :: (Maybe Int -> f (Maybe Int)) -> CampaignLimits -> f CampaignLimits
campaignLimits_maximumDuration = (CampaignLimits -> Maybe Int)
-> (CampaignLimits -> Maybe Int -> CampaignLimits)
-> Lens CampaignLimits CampaignLimits (Maybe Int) (Maybe Int)
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)

instance Core.FromJSON CampaignLimits where
  parseJSON :: Value -> Parser CampaignLimits
parseJSON =
    String
-> (Object -> Parser CampaignLimits)
-> Value
-> Parser CampaignLimits
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CampaignLimits"
      ( \Object
x ->
          Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> CampaignLimits
CampaignLimits'
            (Maybe Int
 -> Maybe Int
 -> Maybe Int
 -> Maybe Int
 -> Maybe Int
 -> CampaignLimits)
-> Parser (Maybe Int)
-> Parser
     (Maybe Int
      -> Maybe Int -> Maybe Int -> Maybe Int -> CampaignLimits)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MessagesPerSecond")
            Parser
  (Maybe Int
   -> Maybe Int -> Maybe Int -> Maybe Int -> CampaignLimits)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> Maybe Int -> Maybe Int -> CampaignLimits)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Daily")
            Parser (Maybe Int -> Maybe Int -> Maybe Int -> CampaignLimits)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> Maybe Int -> CampaignLimits)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Total")
            Parser (Maybe Int -> Maybe Int -> CampaignLimits)
-> Parser (Maybe Int) -> Parser (Maybe Int -> CampaignLimits)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Session")
            Parser (Maybe Int -> CampaignLimits)
-> Parser (Maybe Int) -> Parser CampaignLimits
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaximumDuration")
      )

instance Prelude.Hashable CampaignLimits

instance Prelude.NFData CampaignLimits

instance Core.ToJSON CampaignLimits where
  toJSON :: CampaignLimits -> Value
toJSON CampaignLimits' {Maybe Int
maximumDuration :: Maybe Int
session :: Maybe Int
total :: Maybe Int
daily :: Maybe Int
messagesPerSecond :: Maybe Int
$sel:maximumDuration:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:session:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:total:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:daily:CampaignLimits' :: CampaignLimits -> Maybe Int
$sel:messagesPerSecond:CampaignLimits' :: CampaignLimits -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MessagesPerSecond" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
messagesPerSecond,
            (Text
"Daily" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
daily,
            (Text
"Total" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
total,
            (Text
"Session" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
session,
            (Text
"MaximumDuration" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maximumDuration
          ]
      )