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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pinpoint.Types.CampaignEventFilter
import Amazonka.Pinpoint.Types.QuietTime
import qualified Amazonka.Prelude as Prelude

-- | Schedule of the campaign.
--
-- /See:/ 'newInAppCampaignSchedule' smart constructor.
data InAppCampaignSchedule = InAppCampaignSchedule'
  { -- | The scheduled time after which the in-app message should not be shown.
    -- Timestamp is in ISO 8601 format.
    InAppCampaignSchedule -> Maybe Text
endDate :: Prelude.Maybe Prelude.Text,
    -- | The event filter the SDK has to use to show the in-app message in the
    -- application.
    InAppCampaignSchedule -> Maybe CampaignEventFilter
eventFilter :: Prelude.Maybe CampaignEventFilter,
    -- | Time during which the in-app message should not be shown to the user.
    InAppCampaignSchedule -> Maybe QuietTime
quietTime :: Prelude.Maybe QuietTime
  }
  deriving (InAppCampaignSchedule -> InAppCampaignSchedule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InAppCampaignSchedule -> InAppCampaignSchedule -> Bool
$c/= :: InAppCampaignSchedule -> InAppCampaignSchedule -> Bool
== :: InAppCampaignSchedule -> InAppCampaignSchedule -> Bool
$c== :: InAppCampaignSchedule -> InAppCampaignSchedule -> Bool
Prelude.Eq, ReadPrec [InAppCampaignSchedule]
ReadPrec InAppCampaignSchedule
Int -> ReadS InAppCampaignSchedule
ReadS [InAppCampaignSchedule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InAppCampaignSchedule]
$creadListPrec :: ReadPrec [InAppCampaignSchedule]
readPrec :: ReadPrec InAppCampaignSchedule
$creadPrec :: ReadPrec InAppCampaignSchedule
readList :: ReadS [InAppCampaignSchedule]
$creadList :: ReadS [InAppCampaignSchedule]
readsPrec :: Int -> ReadS InAppCampaignSchedule
$creadsPrec :: Int -> ReadS InAppCampaignSchedule
Prelude.Read, Int -> InAppCampaignSchedule -> ShowS
[InAppCampaignSchedule] -> ShowS
InAppCampaignSchedule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InAppCampaignSchedule] -> ShowS
$cshowList :: [InAppCampaignSchedule] -> ShowS
show :: InAppCampaignSchedule -> String
$cshow :: InAppCampaignSchedule -> String
showsPrec :: Int -> InAppCampaignSchedule -> ShowS
$cshowsPrec :: Int -> InAppCampaignSchedule -> ShowS
Prelude.Show, forall x. Rep InAppCampaignSchedule x -> InAppCampaignSchedule
forall x. InAppCampaignSchedule -> Rep InAppCampaignSchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InAppCampaignSchedule x -> InAppCampaignSchedule
$cfrom :: forall x. InAppCampaignSchedule -> Rep InAppCampaignSchedule x
Prelude.Generic)

-- |
-- Create a value of 'InAppCampaignSchedule' 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:
--
-- 'endDate', 'inAppCampaignSchedule_endDate' - The scheduled time after which the in-app message should not be shown.
-- Timestamp is in ISO 8601 format.
--
-- 'eventFilter', 'inAppCampaignSchedule_eventFilter' - The event filter the SDK has to use to show the in-app message in the
-- application.
--
-- 'quietTime', 'inAppCampaignSchedule_quietTime' - Time during which the in-app message should not be shown to the user.
newInAppCampaignSchedule ::
  InAppCampaignSchedule
newInAppCampaignSchedule :: InAppCampaignSchedule
newInAppCampaignSchedule =
  InAppCampaignSchedule'
    { $sel:endDate:InAppCampaignSchedule' :: Maybe Text
endDate = forall a. Maybe a
Prelude.Nothing,
      $sel:eventFilter:InAppCampaignSchedule' :: Maybe CampaignEventFilter
eventFilter = forall a. Maybe a
Prelude.Nothing,
      $sel:quietTime:InAppCampaignSchedule' :: Maybe QuietTime
quietTime = forall a. Maybe a
Prelude.Nothing
    }

-- | The scheduled time after which the in-app message should not be shown.
-- Timestamp is in ISO 8601 format.
inAppCampaignSchedule_endDate :: Lens.Lens' InAppCampaignSchedule (Prelude.Maybe Prelude.Text)
inAppCampaignSchedule_endDate :: Lens' InAppCampaignSchedule (Maybe Text)
inAppCampaignSchedule_endDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppCampaignSchedule' {Maybe Text
endDate :: Maybe Text
$sel:endDate:InAppCampaignSchedule' :: InAppCampaignSchedule -> Maybe Text
endDate} -> Maybe Text
endDate) (\s :: InAppCampaignSchedule
s@InAppCampaignSchedule' {} Maybe Text
a -> InAppCampaignSchedule
s {$sel:endDate:InAppCampaignSchedule' :: Maybe Text
endDate = Maybe Text
a} :: InAppCampaignSchedule)

-- | The event filter the SDK has to use to show the in-app message in the
-- application.
inAppCampaignSchedule_eventFilter :: Lens.Lens' InAppCampaignSchedule (Prelude.Maybe CampaignEventFilter)
inAppCampaignSchedule_eventFilter :: Lens' InAppCampaignSchedule (Maybe CampaignEventFilter)
inAppCampaignSchedule_eventFilter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppCampaignSchedule' {Maybe CampaignEventFilter
eventFilter :: Maybe CampaignEventFilter
$sel:eventFilter:InAppCampaignSchedule' :: InAppCampaignSchedule -> Maybe CampaignEventFilter
eventFilter} -> Maybe CampaignEventFilter
eventFilter) (\s :: InAppCampaignSchedule
s@InAppCampaignSchedule' {} Maybe CampaignEventFilter
a -> InAppCampaignSchedule
s {$sel:eventFilter:InAppCampaignSchedule' :: Maybe CampaignEventFilter
eventFilter = Maybe CampaignEventFilter
a} :: InAppCampaignSchedule)

-- | Time during which the in-app message should not be shown to the user.
inAppCampaignSchedule_quietTime :: Lens.Lens' InAppCampaignSchedule (Prelude.Maybe QuietTime)
inAppCampaignSchedule_quietTime :: Lens' InAppCampaignSchedule (Maybe QuietTime)
inAppCampaignSchedule_quietTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InAppCampaignSchedule' {Maybe QuietTime
quietTime :: Maybe QuietTime
$sel:quietTime:InAppCampaignSchedule' :: InAppCampaignSchedule -> Maybe QuietTime
quietTime} -> Maybe QuietTime
quietTime) (\s :: InAppCampaignSchedule
s@InAppCampaignSchedule' {} Maybe QuietTime
a -> InAppCampaignSchedule
s {$sel:quietTime:InAppCampaignSchedule' :: Maybe QuietTime
quietTime = Maybe QuietTime
a} :: InAppCampaignSchedule)

instance Data.FromJSON InAppCampaignSchedule where
  parseJSON :: Value -> Parser InAppCampaignSchedule
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InAppCampaignSchedule"
      ( \Object
x ->
          Maybe Text
-> Maybe CampaignEventFilter
-> Maybe QuietTime
-> InAppCampaignSchedule
InAppCampaignSchedule'
            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
"EndDate")
            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
"EventFilter")
            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
"QuietTime")
      )

instance Prelude.Hashable InAppCampaignSchedule where
  hashWithSalt :: Int -> InAppCampaignSchedule -> Int
hashWithSalt Int
_salt InAppCampaignSchedule' {Maybe Text
Maybe QuietTime
Maybe CampaignEventFilter
quietTime :: Maybe QuietTime
eventFilter :: Maybe CampaignEventFilter
endDate :: Maybe Text
$sel:quietTime:InAppCampaignSchedule' :: InAppCampaignSchedule -> Maybe QuietTime
$sel:eventFilter:InAppCampaignSchedule' :: InAppCampaignSchedule -> Maybe CampaignEventFilter
$sel:endDate:InAppCampaignSchedule' :: InAppCampaignSchedule -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
endDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CampaignEventFilter
eventFilter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QuietTime
quietTime

instance Prelude.NFData InAppCampaignSchedule where
  rnf :: InAppCampaignSchedule -> ()
rnf InAppCampaignSchedule' {Maybe Text
Maybe QuietTime
Maybe CampaignEventFilter
quietTime :: Maybe QuietTime
eventFilter :: Maybe CampaignEventFilter
endDate :: Maybe Text
$sel:quietTime:InAppCampaignSchedule' :: InAppCampaignSchedule -> Maybe QuietTime
$sel:eventFilter:InAppCampaignSchedule' :: InAppCampaignSchedule -> Maybe CampaignEventFilter
$sel:endDate:InAppCampaignSchedule' :: InAppCampaignSchedule -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
endDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CampaignEventFilter
eventFilter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe QuietTime
quietTime