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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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,
    -- | Time during which the in-app message should not be shown to the user.
    InAppCampaignSchedule -> Maybe QuietTime
quietTime :: Prelude.Maybe QuietTime,
    -- | The event filter the SDK has to use to show the in-app message in the
    -- application.
    InAppCampaignSchedule -> Maybe CampaignEventFilter
eventFilter :: Prelude.Maybe CampaignEventFilter
  }
  deriving (InAppCampaignSchedule -> InAppCampaignSchedule -> Bool
(InAppCampaignSchedule -> InAppCampaignSchedule -> Bool)
-> (InAppCampaignSchedule -> InAppCampaignSchedule -> Bool)
-> Eq InAppCampaignSchedule
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]
(Int -> ReadS InAppCampaignSchedule)
-> ReadS [InAppCampaignSchedule]
-> ReadPrec InAppCampaignSchedule
-> ReadPrec [InAppCampaignSchedule]
-> Read 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
(Int -> InAppCampaignSchedule -> ShowS)
-> (InAppCampaignSchedule -> String)
-> ([InAppCampaignSchedule] -> ShowS)
-> Show InAppCampaignSchedule
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. InAppCampaignSchedule -> Rep InAppCampaignSchedule x)
-> (forall x. Rep InAppCampaignSchedule x -> InAppCampaignSchedule)
-> Generic InAppCampaignSchedule
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.
--
-- 'quietTime', 'inAppCampaignSchedule_quietTime' - Time during which the in-app message should not be shown to the user.
--
-- 'eventFilter', 'inAppCampaignSchedule_eventFilter' - The event filter the SDK has to use to show the in-app message in the
-- application.
newInAppCampaignSchedule ::
  InAppCampaignSchedule
newInAppCampaignSchedule :: InAppCampaignSchedule
newInAppCampaignSchedule =
  InAppCampaignSchedule' :: Maybe Text
-> Maybe QuietTime
-> Maybe CampaignEventFilter
-> InAppCampaignSchedule
InAppCampaignSchedule'
    { $sel:endDate:InAppCampaignSchedule' :: Maybe Text
endDate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:quietTime:InAppCampaignSchedule' :: Maybe QuietTime
quietTime = Maybe QuietTime
forall a. Maybe a
Prelude.Nothing,
      $sel:eventFilter:InAppCampaignSchedule' :: Maybe CampaignEventFilter
eventFilter = Maybe CampaignEventFilter
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 :: (Maybe Text -> f (Maybe Text))
-> InAppCampaignSchedule -> f InAppCampaignSchedule
inAppCampaignSchedule_endDate = (InAppCampaignSchedule -> Maybe Text)
-> (InAppCampaignSchedule -> Maybe Text -> InAppCampaignSchedule)
-> Lens
     InAppCampaignSchedule
     InAppCampaignSchedule
     (Maybe Text)
     (Maybe Text)
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)

-- | Time during which the in-app message should not be shown to the user.
inAppCampaignSchedule_quietTime :: Lens.Lens' InAppCampaignSchedule (Prelude.Maybe QuietTime)
inAppCampaignSchedule_quietTime :: (Maybe QuietTime -> f (Maybe QuietTime))
-> InAppCampaignSchedule -> f InAppCampaignSchedule
inAppCampaignSchedule_quietTime = (InAppCampaignSchedule -> Maybe QuietTime)
-> (InAppCampaignSchedule
    -> Maybe QuietTime -> InAppCampaignSchedule)
-> Lens
     InAppCampaignSchedule
     InAppCampaignSchedule
     (Maybe QuietTime)
     (Maybe 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)

-- | 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 :: (Maybe CampaignEventFilter -> f (Maybe CampaignEventFilter))
-> InAppCampaignSchedule -> f InAppCampaignSchedule
inAppCampaignSchedule_eventFilter = (InAppCampaignSchedule -> Maybe CampaignEventFilter)
-> (InAppCampaignSchedule
    -> Maybe CampaignEventFilter -> InAppCampaignSchedule)
-> Lens
     InAppCampaignSchedule
     InAppCampaignSchedule
     (Maybe CampaignEventFilter)
     (Maybe CampaignEventFilter)
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)

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

instance Prelude.Hashable InAppCampaignSchedule

instance Prelude.NFData InAppCampaignSchedule