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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 each second.
    JourneyLimits -> Maybe Int
messagesPerSecond :: 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 to a single
    -- participant during a 24-hour period. The maximum value is 100.
    JourneyLimits -> Maybe Int
dailyCap :: Prelude.Maybe Prelude.Int
  }
  deriving (JourneyLimits -> JourneyLimits -> Bool
(JourneyLimits -> JourneyLimits -> Bool)
-> (JourneyLimits -> JourneyLimits -> Bool) -> Eq JourneyLimits
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]
(Int -> ReadS JourneyLimits)
-> ReadS [JourneyLimits]
-> ReadPrec JourneyLimits
-> ReadPrec [JourneyLimits]
-> Read 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
(Int -> JourneyLimits -> ShowS)
-> (JourneyLimits -> String)
-> ([JourneyLimits] -> ShowS)
-> Show JourneyLimits
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. JourneyLimits -> Rep JourneyLimits x)
-> (forall x. Rep JourneyLimits x -> JourneyLimits)
-> Generic JourneyLimits
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:
--
-- 'messagesPerSecond', 'journeyLimits_messagesPerSecond' - The maximum number of messages that the journey can send each second.
--
-- '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.
--
-- '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.
newJourneyLimits ::
  JourneyLimits
newJourneyLimits :: JourneyLimits
newJourneyLimits =
  JourneyLimits' :: Maybe Int -> Maybe Int -> Maybe Text -> Maybe Int -> JourneyLimits
JourneyLimits'
    { $sel:messagesPerSecond:JourneyLimits' :: Maybe Int
messagesPerSecond = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:endpointReentryCap:JourneyLimits' :: Maybe Int
endpointReentryCap = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:endpointReentryInterval:JourneyLimits' :: Maybe Text
endpointReentryInterval = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dailyCap:JourneyLimits' :: Maybe Int
dailyCap = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of messages that the journey can send each second.
journeyLimits_messagesPerSecond :: Lens.Lens' JourneyLimits (Prelude.Maybe Prelude.Int)
journeyLimits_messagesPerSecond :: (Maybe Int -> f (Maybe Int)) -> JourneyLimits -> f JourneyLimits
journeyLimits_messagesPerSecond = (JourneyLimits -> Maybe Int)
-> (JourneyLimits -> Maybe Int -> JourneyLimits)
-> Lens JourneyLimits JourneyLimits (Maybe Int) (Maybe Int)
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)

-- | 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 :: (Maybe Int -> f (Maybe Int)) -> JourneyLimits -> f JourneyLimits
journeyLimits_endpointReentryCap = (JourneyLimits -> Maybe Int)
-> (JourneyLimits -> Maybe Int -> JourneyLimits)
-> Lens JourneyLimits JourneyLimits (Maybe Int) (Maybe Int)
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 :: (Maybe Text -> f (Maybe Text)) -> JourneyLimits -> f JourneyLimits
journeyLimits_endpointReentryInterval = (JourneyLimits -> Maybe Text)
-> (JourneyLimits -> Maybe Text -> JourneyLimits)
-> Lens JourneyLimits JourneyLimits (Maybe Text) (Maybe Text)
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 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 :: (Maybe Int -> f (Maybe Int)) -> JourneyLimits -> f JourneyLimits
journeyLimits_dailyCap = (JourneyLimits -> Maybe Int)
-> (JourneyLimits -> Maybe Int -> JourneyLimits)
-> Lens JourneyLimits JourneyLimits (Maybe Int) (Maybe Int)
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)

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

instance Prelude.Hashable JourneyLimits

instance Prelude.NFData JourneyLimits

instance Core.ToJSON JourneyLimits where
  toJSON :: JourneyLimits -> Value
toJSON JourneyLimits' {Maybe Int
Maybe Text
dailyCap :: Maybe Int
endpointReentryInterval :: Maybe Text
endpointReentryCap :: Maybe Int
messagesPerSecond :: Maybe Int
$sel:dailyCap:JourneyLimits' :: JourneyLimits -> Maybe Int
$sel:endpointReentryInterval:JourneyLimits' :: JourneyLimits -> Maybe Text
$sel:endpointReentryCap:JourneyLimits' :: JourneyLimits -> Maybe Int
$sel:messagesPerSecond:JourneyLimits' :: JourneyLimits -> 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
"EndpointReentryCap" 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
endpointReentryCap,
            (Text
"EndpointReentryInterval" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
endpointReentryInterval,
            (Text
"DailyCap" 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
dailyCap
          ]
      )