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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.WaitTime
import qualified Amazonka.Prelude as Prelude

-- | Specifies the settings for a wait activity in a journey. This type of
-- activity waits for a certain amount of time or until a specific date and
-- time before moving participants to the next activity in a journey.
--
-- /See:/ 'newWaitActivity' smart constructor.
data WaitActivity = WaitActivity'
  { -- | The unique identifier for the next activity to perform, after performing
    -- the wait activity.
    WaitActivity -> Maybe Text
nextActivity :: Prelude.Maybe Prelude.Text,
    -- | The amount of time to wait or the date and time when the activity moves
    -- participants to the next activity in the journey.
    WaitActivity -> Maybe WaitTime
waitTime :: Prelude.Maybe WaitTime
  }
  deriving (WaitActivity -> WaitActivity -> Bool
(WaitActivity -> WaitActivity -> Bool)
-> (WaitActivity -> WaitActivity -> Bool) -> Eq WaitActivity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WaitActivity -> WaitActivity -> Bool
$c/= :: WaitActivity -> WaitActivity -> Bool
== :: WaitActivity -> WaitActivity -> Bool
$c== :: WaitActivity -> WaitActivity -> Bool
Prelude.Eq, ReadPrec [WaitActivity]
ReadPrec WaitActivity
Int -> ReadS WaitActivity
ReadS [WaitActivity]
(Int -> ReadS WaitActivity)
-> ReadS [WaitActivity]
-> ReadPrec WaitActivity
-> ReadPrec [WaitActivity]
-> Read WaitActivity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WaitActivity]
$creadListPrec :: ReadPrec [WaitActivity]
readPrec :: ReadPrec WaitActivity
$creadPrec :: ReadPrec WaitActivity
readList :: ReadS [WaitActivity]
$creadList :: ReadS [WaitActivity]
readsPrec :: Int -> ReadS WaitActivity
$creadsPrec :: Int -> ReadS WaitActivity
Prelude.Read, Int -> WaitActivity -> ShowS
[WaitActivity] -> ShowS
WaitActivity -> String
(Int -> WaitActivity -> ShowS)
-> (WaitActivity -> String)
-> ([WaitActivity] -> ShowS)
-> Show WaitActivity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WaitActivity] -> ShowS
$cshowList :: [WaitActivity] -> ShowS
show :: WaitActivity -> String
$cshow :: WaitActivity -> String
showsPrec :: Int -> WaitActivity -> ShowS
$cshowsPrec :: Int -> WaitActivity -> ShowS
Prelude.Show, (forall x. WaitActivity -> Rep WaitActivity x)
-> (forall x. Rep WaitActivity x -> WaitActivity)
-> Generic WaitActivity
forall x. Rep WaitActivity x -> WaitActivity
forall x. WaitActivity -> Rep WaitActivity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WaitActivity x -> WaitActivity
$cfrom :: forall x. WaitActivity -> Rep WaitActivity x
Prelude.Generic)

-- |
-- Create a value of 'WaitActivity' 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:
--
-- 'nextActivity', 'waitActivity_nextActivity' - The unique identifier for the next activity to perform, after performing
-- the wait activity.
--
-- 'waitTime', 'waitActivity_waitTime' - The amount of time to wait or the date and time when the activity moves
-- participants to the next activity in the journey.
newWaitActivity ::
  WaitActivity
newWaitActivity :: WaitActivity
newWaitActivity =
  WaitActivity' :: Maybe Text -> Maybe WaitTime -> WaitActivity
WaitActivity'
    { $sel:nextActivity:WaitActivity' :: Maybe Text
nextActivity = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:waitTime:WaitActivity' :: Maybe WaitTime
waitTime = Maybe WaitTime
forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier for the next activity to perform, after performing
-- the wait activity.
waitActivity_nextActivity :: Lens.Lens' WaitActivity (Prelude.Maybe Prelude.Text)
waitActivity_nextActivity :: (Maybe Text -> f (Maybe Text)) -> WaitActivity -> f WaitActivity
waitActivity_nextActivity = (WaitActivity -> Maybe Text)
-> (WaitActivity -> Maybe Text -> WaitActivity)
-> Lens WaitActivity WaitActivity (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WaitActivity' {Maybe Text
nextActivity :: Maybe Text
$sel:nextActivity:WaitActivity' :: WaitActivity -> Maybe Text
nextActivity} -> Maybe Text
nextActivity) (\s :: WaitActivity
s@WaitActivity' {} Maybe Text
a -> WaitActivity
s {$sel:nextActivity:WaitActivity' :: Maybe Text
nextActivity = Maybe Text
a} :: WaitActivity)

-- | The amount of time to wait or the date and time when the activity moves
-- participants to the next activity in the journey.
waitActivity_waitTime :: Lens.Lens' WaitActivity (Prelude.Maybe WaitTime)
waitActivity_waitTime :: (Maybe WaitTime -> f (Maybe WaitTime))
-> WaitActivity -> f WaitActivity
waitActivity_waitTime = (WaitActivity -> Maybe WaitTime)
-> (WaitActivity -> Maybe WaitTime -> WaitActivity)
-> Lens WaitActivity WaitActivity (Maybe WaitTime) (Maybe WaitTime)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WaitActivity' {Maybe WaitTime
waitTime :: Maybe WaitTime
$sel:waitTime:WaitActivity' :: WaitActivity -> Maybe WaitTime
waitTime} -> Maybe WaitTime
waitTime) (\s :: WaitActivity
s@WaitActivity' {} Maybe WaitTime
a -> WaitActivity
s {$sel:waitTime:WaitActivity' :: Maybe WaitTime
waitTime = Maybe WaitTime
a} :: WaitActivity)

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

instance Prelude.Hashable WaitActivity

instance Prelude.NFData WaitActivity

instance Core.ToJSON WaitActivity where
  toJSON :: WaitActivity -> Value
toJSON WaitActivity' {Maybe Text
Maybe WaitTime
waitTime :: Maybe WaitTime
nextActivity :: Maybe Text
$sel:waitTime:WaitActivity' :: WaitActivity -> Maybe WaitTime
$sel:nextActivity:WaitActivity' :: WaitActivity -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextActivity" 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
nextActivity,
            (Text
"WaitTime" Text -> WaitTime -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (WaitTime -> Pair) -> Maybe WaitTime -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe WaitTime
waitTime
          ]
      )