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

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

-- | Specifies the message configuration for a push notification that\'s sent
-- to participants in a journey.
--
-- /See:/ 'newJourneyPushMessage' smart constructor.
data JourneyPushMessage = JourneyPushMessage'
  { -- | The number of seconds that the push notification service should keep the
    -- message, if the service is unable to deliver the notification the first
    -- time. This value is converted to an expiration value when it\'s sent to
    -- a push-notification service. If this value is 0, the service treats the
    -- notification as if it expires immediately and the service doesn\'t store
    -- or try to deliver the notification again.
    --
    -- This value doesn\'t apply to messages that are sent through the Amazon
    -- Device Messaging (ADM) service.
    JourneyPushMessage -> Maybe Text
timeToLive :: Prelude.Maybe Prelude.Text
  }
  deriving (JourneyPushMessage -> JourneyPushMessage -> Bool
(JourneyPushMessage -> JourneyPushMessage -> Bool)
-> (JourneyPushMessage -> JourneyPushMessage -> Bool)
-> Eq JourneyPushMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JourneyPushMessage -> JourneyPushMessage -> Bool
$c/= :: JourneyPushMessage -> JourneyPushMessage -> Bool
== :: JourneyPushMessage -> JourneyPushMessage -> Bool
$c== :: JourneyPushMessage -> JourneyPushMessage -> Bool
Prelude.Eq, ReadPrec [JourneyPushMessage]
ReadPrec JourneyPushMessage
Int -> ReadS JourneyPushMessage
ReadS [JourneyPushMessage]
(Int -> ReadS JourneyPushMessage)
-> ReadS [JourneyPushMessage]
-> ReadPrec JourneyPushMessage
-> ReadPrec [JourneyPushMessage]
-> Read JourneyPushMessage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JourneyPushMessage]
$creadListPrec :: ReadPrec [JourneyPushMessage]
readPrec :: ReadPrec JourneyPushMessage
$creadPrec :: ReadPrec JourneyPushMessage
readList :: ReadS [JourneyPushMessage]
$creadList :: ReadS [JourneyPushMessage]
readsPrec :: Int -> ReadS JourneyPushMessage
$creadsPrec :: Int -> ReadS JourneyPushMessage
Prelude.Read, Int -> JourneyPushMessage -> ShowS
[JourneyPushMessage] -> ShowS
JourneyPushMessage -> String
(Int -> JourneyPushMessage -> ShowS)
-> (JourneyPushMessage -> String)
-> ([JourneyPushMessage] -> ShowS)
-> Show JourneyPushMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JourneyPushMessage] -> ShowS
$cshowList :: [JourneyPushMessage] -> ShowS
show :: JourneyPushMessage -> String
$cshow :: JourneyPushMessage -> String
showsPrec :: Int -> JourneyPushMessage -> ShowS
$cshowsPrec :: Int -> JourneyPushMessage -> ShowS
Prelude.Show, (forall x. JourneyPushMessage -> Rep JourneyPushMessage x)
-> (forall x. Rep JourneyPushMessage x -> JourneyPushMessage)
-> Generic JourneyPushMessage
forall x. Rep JourneyPushMessage x -> JourneyPushMessage
forall x. JourneyPushMessage -> Rep JourneyPushMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JourneyPushMessage x -> JourneyPushMessage
$cfrom :: forall x. JourneyPushMessage -> Rep JourneyPushMessage x
Prelude.Generic)

-- |
-- Create a value of 'JourneyPushMessage' 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:
--
-- 'timeToLive', 'journeyPushMessage_timeToLive' - The number of seconds that the push notification service should keep the
-- message, if the service is unable to deliver the notification the first
-- time. This value is converted to an expiration value when it\'s sent to
-- a push-notification service. If this value is 0, the service treats the
-- notification as if it expires immediately and the service doesn\'t store
-- or try to deliver the notification again.
--
-- This value doesn\'t apply to messages that are sent through the Amazon
-- Device Messaging (ADM) service.
newJourneyPushMessage ::
  JourneyPushMessage
newJourneyPushMessage :: JourneyPushMessage
newJourneyPushMessage =
  JourneyPushMessage' :: Maybe Text -> JourneyPushMessage
JourneyPushMessage' {$sel:timeToLive:JourneyPushMessage' :: Maybe Text
timeToLive = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The number of seconds that the push notification service should keep the
-- message, if the service is unable to deliver the notification the first
-- time. This value is converted to an expiration value when it\'s sent to
-- a push-notification service. If this value is 0, the service treats the
-- notification as if it expires immediately and the service doesn\'t store
-- or try to deliver the notification again.
--
-- This value doesn\'t apply to messages that are sent through the Amazon
-- Device Messaging (ADM) service.
journeyPushMessage_timeToLive :: Lens.Lens' JourneyPushMessage (Prelude.Maybe Prelude.Text)
journeyPushMessage_timeToLive :: (Maybe Text -> f (Maybe Text))
-> JourneyPushMessage -> f JourneyPushMessage
journeyPushMessage_timeToLive = (JourneyPushMessage -> Maybe Text)
-> (JourneyPushMessage -> Maybe Text -> JourneyPushMessage)
-> Lens
     JourneyPushMessage JourneyPushMessage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JourneyPushMessage' {Maybe Text
timeToLive :: Maybe Text
$sel:timeToLive:JourneyPushMessage' :: JourneyPushMessage -> Maybe Text
timeToLive} -> Maybe Text
timeToLive) (\s :: JourneyPushMessage
s@JourneyPushMessage' {} Maybe Text
a -> JourneyPushMessage
s {$sel:timeToLive:JourneyPushMessage' :: Maybe Text
timeToLive = Maybe Text
a} :: JourneyPushMessage)

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

instance Prelude.Hashable JourneyPushMessage

instance Prelude.NFData JourneyPushMessage

instance Core.ToJSON JourneyPushMessage where
  toJSON :: JourneyPushMessage -> Value
toJSON JourneyPushMessage' {Maybe Text
timeToLive :: Maybe Text
$sel:timeToLive:JourneyPushMessage' :: JourneyPushMessage -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"TimeToLive" 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
timeToLive]
      )