{-# 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-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.WaitTime 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 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
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]
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
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. 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'
    { $sel:waitFor:WaitTime' :: Maybe Text
waitFor = forall a. Maybe a
Prelude.Nothing,
      $sel:waitUntil:WaitTime' :: Maybe Text
waitUntil = 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 :: Lens' WaitTime (Maybe Text)
waitTime_waitFor = 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 :: Lens' WaitTime (Maybe Text)
waitTime_waitUntil = 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 Data.FromJSON WaitTime where
  parseJSON :: Value -> Parser WaitTime
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WaitTime"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> WaitTime
WaitTime'
            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
"WaitFor")
            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
"WaitUntil")
      )

instance Prelude.Hashable WaitTime where
  hashWithSalt :: Int -> WaitTime -> Int
hashWithSalt Int
_salt WaitTime' {Maybe Text
waitUntil :: Maybe Text
waitFor :: Maybe Text
$sel:waitUntil:WaitTime' :: WaitTime -> Maybe Text
$sel:waitFor:WaitTime' :: WaitTime -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
waitFor
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
waitUntil

instance Prelude.NFData WaitTime where
  rnf :: WaitTime -> ()
rnf WaitTime' {Maybe Text
waitUntil :: Maybe Text
waitFor :: Maybe Text
$sel:waitUntil:WaitTime' :: WaitTime -> Maybe Text
$sel:waitFor:WaitTime' :: WaitTime -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
waitFor
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
waitUntil

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"WaitFor" 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
waitFor,
            (Key
"WaitUntil" 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
waitUntil
          ]
      )