{-# 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.JourneyLimits
-- 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.JourneyLimits 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

-- | Specifies limits on the messages that a journey can send and the number
-- of times participants can enter a journey.
--
-- /See:/ 'newJourneyLimits' smart constructor.
data JourneyLimits = JourneyLimits'
  { -- | The maximum number of messages that the journey can send to a single
    -- participant during a 24-hour period. The maximum value is 100.
    JourneyLimits -> Maybe Int
dailyCap :: Prelude.Maybe Prelude.Int,
    -- | The maximum number of times that a participant can enter the journey.
    -- The maximum value is 100. To allow participants to enter the journey an
    -- unlimited number of times, set this value to 0.
    JourneyLimits -> Maybe Int
endpointReentryCap :: Prelude.Maybe Prelude.Int,
    -- | Minimum time that must pass before an endpoint can re-enter a given
    -- journey. The duration should use an ISO 8601 format, such as PT1H.
    JourneyLimits -> Maybe Text
endpointReentryInterval :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of messages that the journey can send each second.
    JourneyLimits -> Maybe Int
messagesPerSecond :: Prelude.Maybe Prelude.Int
  }
  deriving (JourneyLimits -> JourneyLimits -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JourneyLimits -> JourneyLimits -> Bool
$c/= :: JourneyLimits -> JourneyLimits -> Bool
== :: JourneyLimits -> JourneyLimits -> Bool
$c== :: JourneyLimits -> JourneyLimits -> Bool
Prelude.Eq, ReadPrec [JourneyLimits]
ReadPrec JourneyLimits
Int -> ReadS JourneyLimits
ReadS [JourneyLimits]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JourneyLimits]
$creadListPrec :: ReadPrec [JourneyLimits]
readPrec :: ReadPrec JourneyLimits
$creadPrec :: ReadPrec JourneyLimits
readList :: ReadS [JourneyLimits]
$creadList :: ReadS [JourneyLimits]
readsPrec :: Int -> ReadS JourneyLimits
$creadsPrec :: Int -> ReadS JourneyLimits
Prelude.Read, Int -> JourneyLimits -> ShowS
[JourneyLimits] -> ShowS
JourneyLimits -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JourneyLimits] -> ShowS
$cshowList :: [JourneyLimits] -> ShowS
show :: JourneyLimits -> String
$cshow :: JourneyLimits -> String
showsPrec :: Int -> JourneyLimits -> ShowS
$cshowsPrec :: Int -> JourneyLimits -> ShowS
Prelude.Show, forall x. Rep JourneyLimits x -> JourneyLimits
forall x. JourneyLimits -> Rep JourneyLimits x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JourneyLimits x -> JourneyLimits
$cfrom :: forall x. JourneyLimits -> Rep JourneyLimits x
Prelude.Generic)

-- |
-- Create a value of 'JourneyLimits' 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:
--
-- 'dailyCap', 'journeyLimits_dailyCap' - The maximum number of messages that the journey can send to a single
-- participant during a 24-hour period. The maximum value is 100.
--
-- 'endpointReentryCap', 'journeyLimits_endpointReentryCap' - The maximum number of times that a participant can enter the journey.
-- The maximum value is 100. To allow participants to enter the journey an
-- unlimited number of times, set this value to 0.
--
-- 'endpointReentryInterval', 'journeyLimits_endpointReentryInterval' - Minimum time that must pass before an endpoint can re-enter a given
-- journey. The duration should use an ISO 8601 format, such as PT1H.
--
-- 'messagesPerSecond', 'journeyLimits_messagesPerSecond' - The maximum number of messages that the journey can send each second.
newJourneyLimits ::
  JourneyLimits
newJourneyLimits :: JourneyLimits
newJourneyLimits =
  JourneyLimits'
    { $sel:dailyCap:JourneyLimits' :: Maybe Int
dailyCap = forall a. Maybe a
Prelude.Nothing,
      $sel:endpointReentryCap:JourneyLimits' :: Maybe Int
endpointReentryCap = forall a. Maybe a
Prelude.Nothing,
      $sel:endpointReentryInterval:JourneyLimits' :: Maybe Text
endpointReentryInterval = forall a. Maybe a
Prelude.Nothing,
      $sel:messagesPerSecond:JourneyLimits' :: Maybe Int
messagesPerSecond = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of messages that the journey can send to a single
-- participant during a 24-hour period. The maximum value is 100.
journeyLimits_dailyCap :: Lens.Lens' JourneyLimits (Prelude.Maybe Prelude.Int)
journeyLimits_dailyCap :: Lens' JourneyLimits (Maybe Int)
journeyLimits_dailyCap = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JourneyLimits' {Maybe Int
dailyCap :: Maybe Int
$sel:dailyCap:JourneyLimits' :: JourneyLimits -> Maybe Int
dailyCap} -> Maybe Int
dailyCap) (\s :: JourneyLimits
s@JourneyLimits' {} Maybe Int
a -> JourneyLimits
s {$sel:dailyCap:JourneyLimits' :: Maybe Int
dailyCap = Maybe Int
a} :: JourneyLimits)

-- | The maximum number of times that a participant can enter the journey.
-- The maximum value is 100. To allow participants to enter the journey an
-- unlimited number of times, set this value to 0.
journeyLimits_endpointReentryCap :: Lens.Lens' JourneyLimits (Prelude.Maybe Prelude.Int)
journeyLimits_endpointReentryCap :: Lens' JourneyLimits (Maybe Int)
journeyLimits_endpointReentryCap = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JourneyLimits' {Maybe Int
endpointReentryCap :: Maybe Int
$sel:endpointReentryCap:JourneyLimits' :: JourneyLimits -> Maybe Int
endpointReentryCap} -> Maybe Int
endpointReentryCap) (\s :: JourneyLimits
s@JourneyLimits' {} Maybe Int
a -> JourneyLimits
s {$sel:endpointReentryCap:JourneyLimits' :: Maybe Int
endpointReentryCap = Maybe Int
a} :: JourneyLimits)

-- | Minimum time that must pass before an endpoint can re-enter a given
-- journey. The duration should use an ISO 8601 format, such as PT1H.
journeyLimits_endpointReentryInterval :: Lens.Lens' JourneyLimits (Prelude.Maybe Prelude.Text)
journeyLimits_endpointReentryInterval :: Lens' JourneyLimits (Maybe Text)
journeyLimits_endpointReentryInterval = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JourneyLimits' {Maybe Text
endpointReentryInterval :: Maybe Text
$sel:endpointReentryInterval:JourneyLimits' :: JourneyLimits -> Maybe Text
endpointReentryInterval} -> Maybe Text
endpointReentryInterval) (\s :: JourneyLimits
s@JourneyLimits' {} Maybe Text
a -> JourneyLimits
s {$sel:endpointReentryInterval:JourneyLimits' :: Maybe Text
endpointReentryInterval = Maybe Text
a} :: JourneyLimits)

-- | The maximum number of messages that the journey can send each second.
journeyLimits_messagesPerSecond :: Lens.Lens' JourneyLimits (Prelude.Maybe Prelude.Int)
journeyLimits_messagesPerSecond :: Lens' JourneyLimits (Maybe Int)
journeyLimits_messagesPerSecond = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JourneyLimits' {Maybe Int
messagesPerSecond :: Maybe Int
$sel:messagesPerSecond:JourneyLimits' :: JourneyLimits -> Maybe Int
messagesPerSecond} -> Maybe Int
messagesPerSecond) (\s :: JourneyLimits
s@JourneyLimits' {} Maybe Int
a -> JourneyLimits
s {$sel:messagesPerSecond:JourneyLimits' :: Maybe Int
messagesPerSecond = Maybe Int
a} :: JourneyLimits)

instance Data.FromJSON JourneyLimits where
  parseJSON :: Value -> Parser JourneyLimits
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"JourneyLimits"
      ( \Object
x ->
          Maybe Int -> Maybe Int -> Maybe Text -> Maybe Int -> JourneyLimits
JourneyLimits'
            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
"DailyCap")
            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
"EndpointReentryCap")
            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
"EndpointReentryInterval")
            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")
      )

instance Prelude.Hashable JourneyLimits where
  hashWithSalt :: Int -> JourneyLimits -> Int
hashWithSalt Int
_salt JourneyLimits' {Maybe Int
Maybe Text
messagesPerSecond :: Maybe Int
endpointReentryInterval :: Maybe Text
endpointReentryCap :: Maybe Int
dailyCap :: Maybe Int
$sel:messagesPerSecond:JourneyLimits' :: JourneyLimits -> Maybe Int
$sel:endpointReentryInterval:JourneyLimits' :: JourneyLimits -> Maybe Text
$sel:endpointReentryCap:JourneyLimits' :: JourneyLimits -> Maybe Int
$sel:dailyCap:JourneyLimits' :: JourneyLimits -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
dailyCap
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
endpointReentryCap
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
endpointReentryInterval
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
messagesPerSecond

instance Prelude.NFData JourneyLimits where
  rnf :: JourneyLimits -> ()
rnf JourneyLimits' {Maybe Int
Maybe Text
messagesPerSecond :: Maybe Int
endpointReentryInterval :: Maybe Text
endpointReentryCap :: Maybe Int
dailyCap :: Maybe Int
$sel:messagesPerSecond:JourneyLimits' :: JourneyLimits -> Maybe Int
$sel:endpointReentryInterval:JourneyLimits' :: JourneyLimits -> Maybe Text
$sel:endpointReentryCap:JourneyLimits' :: JourneyLimits -> Maybe Int
$sel:dailyCap:JourneyLimits' :: JourneyLimits -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
dailyCap
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
endpointReentryCap
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
endpointReentryInterval
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
messagesPerSecond

instance Data.ToJSON JourneyLimits where
  toJSON :: JourneyLimits -> Value
toJSON JourneyLimits' {Maybe Int
Maybe Text
messagesPerSecond :: Maybe Int
endpointReentryInterval :: Maybe Text
endpointReentryCap :: Maybe Int
dailyCap :: Maybe Int
$sel:messagesPerSecond:JourneyLimits' :: JourneyLimits -> Maybe Int
$sel:endpointReentryInterval:JourneyLimits' :: JourneyLimits -> Maybe Text
$sel:endpointReentryCap:JourneyLimits' :: JourneyLimits -> Maybe Int
$sel:dailyCap:JourneyLimits' :: JourneyLimits -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DailyCap" 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
dailyCap,
            (Key
"EndpointReentryCap" 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
endpointReentryCap,
            (Key
"EndpointReentryInterval" 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 Text
endpointReentryInterval,
            (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
          ]
      )