{-# 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-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.JourneyPushMessage 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 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
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]
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
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. 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' {$sel:timeToLive:JourneyPushMessage' :: Maybe Text
timeToLive = 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 :: Lens' JourneyPushMessage (Maybe Text)
journeyPushMessage_timeToLive = 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 Data.FromJSON JourneyPushMessage where
  parseJSON :: Value -> Parser JourneyPushMessage
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"JourneyPushMessage"
      ( \Object
x ->
          Maybe Text -> JourneyPushMessage
JourneyPushMessage'
            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
"TimeToLive")
      )

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

instance Prelude.NFData JourneyPushMessage where
  rnf :: JourneyPushMessage -> ()
rnf JourneyPushMessage' {Maybe Text
timeToLive :: Maybe Text
$sel:timeToLive:JourneyPushMessage' :: JourneyPushMessage -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
timeToLive

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