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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies a duration or a date and time that indicates when Amazon
-- Pinpoint determines whether an activity\'s conditions have been met or
-- an activity moves participants to the next activity in a journey.
--
-- /See:/ 'newWaitTime' smart constructor.
data WaitTime = WaitTime'
  { -- | The amount of time to wait, as a duration in ISO 8601 format, before
    -- determining whether the activity\'s conditions have been met or moving
    -- participants to the next activity in the journey.
    WaitTime -> Maybe Text
waitFor :: Prelude.Maybe Prelude.Text,
    -- | The date and time, in ISO 8601 format, when Amazon Pinpoint determines
    -- whether the activity\'s conditions have been met or the activity moves
    -- participants to the next activity in the journey.
    WaitTime -> Maybe Text
waitUntil :: Prelude.Maybe Prelude.Text
  }
  deriving (WaitTime -> WaitTime -> Bool
(WaitTime -> WaitTime -> Bool)
-> (WaitTime -> WaitTime -> Bool) -> Eq WaitTime
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WaitTime -> WaitTime -> Bool
$c/= :: WaitTime -> WaitTime -> Bool
== :: WaitTime -> WaitTime -> Bool
$c== :: WaitTime -> WaitTime -> Bool
Prelude.Eq, ReadPrec [WaitTime]
ReadPrec WaitTime
Int -> ReadS WaitTime
ReadS [WaitTime]
(Int -> ReadS WaitTime)
-> ReadS [WaitTime]
-> ReadPrec WaitTime
-> ReadPrec [WaitTime]
-> Read WaitTime
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WaitTime]
$creadListPrec :: ReadPrec [WaitTime]
readPrec :: ReadPrec WaitTime
$creadPrec :: ReadPrec WaitTime
readList :: ReadS [WaitTime]
$creadList :: ReadS [WaitTime]
readsPrec :: Int -> ReadS WaitTime
$creadsPrec :: Int -> ReadS WaitTime
Prelude.Read, Int -> WaitTime -> ShowS
[WaitTime] -> ShowS
WaitTime -> String
(Int -> WaitTime -> ShowS)
-> (WaitTime -> String) -> ([WaitTime] -> ShowS) -> Show WaitTime
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WaitTime] -> ShowS
$cshowList :: [WaitTime] -> ShowS
show :: WaitTime -> String
$cshow :: WaitTime -> String
showsPrec :: Int -> WaitTime -> ShowS
$cshowsPrec :: Int -> WaitTime -> ShowS
Prelude.Show, (forall x. WaitTime -> Rep WaitTime x)
-> (forall x. Rep WaitTime x -> WaitTime) -> Generic WaitTime
forall x. Rep WaitTime x -> WaitTime
forall x. WaitTime -> Rep WaitTime x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WaitTime x -> WaitTime
$cfrom :: forall x. WaitTime -> Rep WaitTime x
Prelude.Generic)

-- |
-- Create a value of 'WaitTime' 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:
--
-- 'waitFor', 'waitTime_waitFor' - The amount of time to wait, as a duration in ISO 8601 format, before
-- determining whether the activity\'s conditions have been met or moving
-- participants to the next activity in the journey.
--
-- 'waitUntil', 'waitTime_waitUntil' - The date and time, in ISO 8601 format, when Amazon Pinpoint determines
-- whether the activity\'s conditions have been met or the activity moves
-- participants to the next activity in the journey.
newWaitTime ::
  WaitTime
newWaitTime :: WaitTime
newWaitTime =
  WaitTime' :: Maybe Text -> Maybe Text -> WaitTime
WaitTime'
    { $sel:waitFor:WaitTime' :: Maybe Text
waitFor = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:waitUntil:WaitTime' :: Maybe Text
waitUntil = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The amount of time to wait, as a duration in ISO 8601 format, before
-- determining whether the activity\'s conditions have been met or moving
-- participants to the next activity in the journey.
waitTime_waitFor :: Lens.Lens' WaitTime (Prelude.Maybe Prelude.Text)
waitTime_waitFor :: (Maybe Text -> f (Maybe Text)) -> WaitTime -> f WaitTime
waitTime_waitFor = (WaitTime -> Maybe Text)
-> (WaitTime -> Maybe Text -> WaitTime)
-> Lens WaitTime WaitTime (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WaitTime' {Maybe Text
waitFor :: Maybe Text
$sel:waitFor:WaitTime' :: WaitTime -> Maybe Text
waitFor} -> Maybe Text
waitFor) (\s :: WaitTime
s@WaitTime' {} Maybe Text
a -> WaitTime
s {$sel:waitFor:WaitTime' :: Maybe Text
waitFor = Maybe Text
a} :: WaitTime)

-- | The date and time, in ISO 8601 format, when Amazon Pinpoint determines
-- whether the activity\'s conditions have been met or the activity moves
-- participants to the next activity in the journey.
waitTime_waitUntil :: Lens.Lens' WaitTime (Prelude.Maybe Prelude.Text)
waitTime_waitUntil :: (Maybe Text -> f (Maybe Text)) -> WaitTime -> f WaitTime
waitTime_waitUntil = (WaitTime -> Maybe Text)
-> (WaitTime -> Maybe Text -> WaitTime)
-> Lens WaitTime WaitTime (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WaitTime' {Maybe Text
waitUntil :: Maybe Text
$sel:waitUntil:WaitTime' :: WaitTime -> Maybe Text
waitUntil} -> Maybe Text
waitUntil) (\s :: WaitTime
s@WaitTime' {} Maybe Text
a -> WaitTime
s {$sel:waitUntil:WaitTime' :: Maybe Text
waitUntil = Maybe Text
a} :: WaitTime)

instance Core.FromJSON WaitTime where
  parseJSON :: Value -> Parser WaitTime
parseJSON =
    String -> (Object -> Parser WaitTime) -> Value -> Parser WaitTime
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WaitTime"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> WaitTime
WaitTime'
            (Maybe Text -> Maybe Text -> WaitTime)
-> Parser (Maybe Text) -> Parser (Maybe Text -> WaitTime)
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
"WaitFor")
            Parser (Maybe Text -> WaitTime)
-> Parser (Maybe Text) -> Parser WaitTime
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
"WaitUntil")
      )

instance Prelude.Hashable WaitTime

instance Prelude.NFData WaitTime

instance Core.ToJSON WaitTime where
  toJSON :: WaitTime -> Value
toJSON WaitTime' {Maybe Text
waitUntil :: Maybe Text
waitFor :: Maybe Text
$sel:waitUntil:WaitTime' :: WaitTime -> Maybe Text
$sel:waitFor:WaitTime' :: WaitTime -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"WaitFor" 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
waitFor,
            (Text
"WaitUntil" 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
waitUntil
          ]
      )