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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.Action
import qualified Amazonka.Prelude as Prelude

-- | Specifies the default settings and content for a message template that
-- can be used in messages that are sent through a push notification
-- channel.
--
-- /See:/ 'newDefaultPushNotificationTemplate' smart constructor.
data DefaultPushNotificationTemplate = DefaultPushNotificationTemplate'
  { -- | The message body to use in push notifications that are based on the
    -- message template.
    DefaultPushNotificationTemplate -> Maybe Text
body :: Prelude.Maybe Prelude.Text,
    -- | The URL to open in a recipient\'s default mobile browser, if a recipient
    -- taps a push notification that\'s based on the message template and the
    -- value of the Action property is URL.
    DefaultPushNotificationTemplate -> Maybe Text
url :: Prelude.Maybe Prelude.Text,
    -- | The sound to play when a recipient receives a push notification that\'s
    -- based on the message template. You can use the default stream or specify
    -- the file name of a sound resource that\'s bundled in your app. On an
    -- Android platform, the sound file must reside in \/res\/raw\/.
    --
    -- For an iOS platform, this value is the key for the name of a sound file
    -- in your app\'s main bundle or the Library\/Sounds folder in your app\'s
    -- data container. If the sound file can\'t be found or you specify default
    -- for the value, the system plays the default alert sound.
    DefaultPushNotificationTemplate -> Maybe Text
sound :: Prelude.Maybe Prelude.Text,
    -- | The action to occur if a recipient taps a push notification that\'s
    -- based on the message template. Valid values are:
    --
    -- -   OPEN_APP - Your app opens or it becomes the foreground app if it was
    --     sent to the background. This is the default action.
    --
    -- -   DEEP_LINK - Your app opens and displays a designated user interface
    --     in the app. This setting uses the deep-linking features of the iOS
    --     and Android platforms.
    --
    -- -   URL - The default mobile browser on the recipient\'s device opens
    --     and loads the web page at a URL that you specify.
    DefaultPushNotificationTemplate -> Maybe Action
action :: Prelude.Maybe Action,
    -- | The title to use in push notifications that are based on the message
    -- template. This title appears above the notification message on a
    -- recipient\'s device.
    DefaultPushNotificationTemplate -> Maybe Text
title :: Prelude.Maybe Prelude.Text
  }
  deriving (DefaultPushNotificationTemplate
-> DefaultPushNotificationTemplate -> Bool
(DefaultPushNotificationTemplate
 -> DefaultPushNotificationTemplate -> Bool)
-> (DefaultPushNotificationTemplate
    -> DefaultPushNotificationTemplate -> Bool)
-> Eq DefaultPushNotificationTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefaultPushNotificationTemplate
-> DefaultPushNotificationTemplate -> Bool
$c/= :: DefaultPushNotificationTemplate
-> DefaultPushNotificationTemplate -> Bool
== :: DefaultPushNotificationTemplate
-> DefaultPushNotificationTemplate -> Bool
$c== :: DefaultPushNotificationTemplate
-> DefaultPushNotificationTemplate -> Bool
Prelude.Eq, ReadPrec [DefaultPushNotificationTemplate]
ReadPrec DefaultPushNotificationTemplate
Int -> ReadS DefaultPushNotificationTemplate
ReadS [DefaultPushNotificationTemplate]
(Int -> ReadS DefaultPushNotificationTemplate)
-> ReadS [DefaultPushNotificationTemplate]
-> ReadPrec DefaultPushNotificationTemplate
-> ReadPrec [DefaultPushNotificationTemplate]
-> Read DefaultPushNotificationTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DefaultPushNotificationTemplate]
$creadListPrec :: ReadPrec [DefaultPushNotificationTemplate]
readPrec :: ReadPrec DefaultPushNotificationTemplate
$creadPrec :: ReadPrec DefaultPushNotificationTemplate
readList :: ReadS [DefaultPushNotificationTemplate]
$creadList :: ReadS [DefaultPushNotificationTemplate]
readsPrec :: Int -> ReadS DefaultPushNotificationTemplate
$creadsPrec :: Int -> ReadS DefaultPushNotificationTemplate
Prelude.Read, Int -> DefaultPushNotificationTemplate -> ShowS
[DefaultPushNotificationTemplate] -> ShowS
DefaultPushNotificationTemplate -> String
(Int -> DefaultPushNotificationTemplate -> ShowS)
-> (DefaultPushNotificationTemplate -> String)
-> ([DefaultPushNotificationTemplate] -> ShowS)
-> Show DefaultPushNotificationTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DefaultPushNotificationTemplate] -> ShowS
$cshowList :: [DefaultPushNotificationTemplate] -> ShowS
show :: DefaultPushNotificationTemplate -> String
$cshow :: DefaultPushNotificationTemplate -> String
showsPrec :: Int -> DefaultPushNotificationTemplate -> ShowS
$cshowsPrec :: Int -> DefaultPushNotificationTemplate -> ShowS
Prelude.Show, (forall x.
 DefaultPushNotificationTemplate
 -> Rep DefaultPushNotificationTemplate x)
-> (forall x.
    Rep DefaultPushNotificationTemplate x
    -> DefaultPushNotificationTemplate)
-> Generic DefaultPushNotificationTemplate
forall x.
Rep DefaultPushNotificationTemplate x
-> DefaultPushNotificationTemplate
forall x.
DefaultPushNotificationTemplate
-> Rep DefaultPushNotificationTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DefaultPushNotificationTemplate x
-> DefaultPushNotificationTemplate
$cfrom :: forall x.
DefaultPushNotificationTemplate
-> Rep DefaultPushNotificationTemplate x
Prelude.Generic)

-- |
-- Create a value of 'DefaultPushNotificationTemplate' 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:
--
-- 'body', 'defaultPushNotificationTemplate_body' - The message body to use in push notifications that are based on the
-- message template.
--
-- 'url', 'defaultPushNotificationTemplate_url' - The URL to open in a recipient\'s default mobile browser, if a recipient
-- taps a push notification that\'s based on the message template and the
-- value of the Action property is URL.
--
-- 'sound', 'defaultPushNotificationTemplate_sound' - The sound to play when a recipient receives a push notification that\'s
-- based on the message template. You can use the default stream or specify
-- the file name of a sound resource that\'s bundled in your app. On an
-- Android platform, the sound file must reside in \/res\/raw\/.
--
-- For an iOS platform, this value is the key for the name of a sound file
-- in your app\'s main bundle or the Library\/Sounds folder in your app\'s
-- data container. If the sound file can\'t be found or you specify default
-- for the value, the system plays the default alert sound.
--
-- 'action', 'defaultPushNotificationTemplate_action' - The action to occur if a recipient taps a push notification that\'s
-- based on the message template. Valid values are:
--
-- -   OPEN_APP - Your app opens or it becomes the foreground app if it was
--     sent to the background. This is the default action.
--
-- -   DEEP_LINK - Your app opens and displays a designated user interface
--     in the app. This setting uses the deep-linking features of the iOS
--     and Android platforms.
--
-- -   URL - The default mobile browser on the recipient\'s device opens
--     and loads the web page at a URL that you specify.
--
-- 'title', 'defaultPushNotificationTemplate_title' - The title to use in push notifications that are based on the message
-- template. This title appears above the notification message on a
-- recipient\'s device.
newDefaultPushNotificationTemplate ::
  DefaultPushNotificationTemplate
newDefaultPushNotificationTemplate :: DefaultPushNotificationTemplate
newDefaultPushNotificationTemplate =
  DefaultPushNotificationTemplate' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Action
-> Maybe Text
-> DefaultPushNotificationTemplate
DefaultPushNotificationTemplate'
    { $sel:body:DefaultPushNotificationTemplate' :: Maybe Text
body =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:url:DefaultPushNotificationTemplate' :: Maybe Text
url = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sound:DefaultPushNotificationTemplate' :: Maybe Text
sound = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:action:DefaultPushNotificationTemplate' :: Maybe Action
action = Maybe Action
forall a. Maybe a
Prelude.Nothing,
      $sel:title:DefaultPushNotificationTemplate' :: Maybe Text
title = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The message body to use in push notifications that are based on the
-- message template.
defaultPushNotificationTemplate_body :: Lens.Lens' DefaultPushNotificationTemplate (Prelude.Maybe Prelude.Text)
defaultPushNotificationTemplate_body :: (Maybe Text -> f (Maybe Text))
-> DefaultPushNotificationTemplate
-> f DefaultPushNotificationTemplate
defaultPushNotificationTemplate_body = (DefaultPushNotificationTemplate -> Maybe Text)
-> (DefaultPushNotificationTemplate
    -> Maybe Text -> DefaultPushNotificationTemplate)
-> Lens
     DefaultPushNotificationTemplate
     DefaultPushNotificationTemplate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefaultPushNotificationTemplate' {Maybe Text
body :: Maybe Text
$sel:body:DefaultPushNotificationTemplate' :: DefaultPushNotificationTemplate -> Maybe Text
body} -> Maybe Text
body) (\s :: DefaultPushNotificationTemplate
s@DefaultPushNotificationTemplate' {} Maybe Text
a -> DefaultPushNotificationTemplate
s {$sel:body:DefaultPushNotificationTemplate' :: Maybe Text
body = Maybe Text
a} :: DefaultPushNotificationTemplate)

-- | The URL to open in a recipient\'s default mobile browser, if a recipient
-- taps a push notification that\'s based on the message template and the
-- value of the Action property is URL.
defaultPushNotificationTemplate_url :: Lens.Lens' DefaultPushNotificationTemplate (Prelude.Maybe Prelude.Text)
defaultPushNotificationTemplate_url :: (Maybe Text -> f (Maybe Text))
-> DefaultPushNotificationTemplate
-> f DefaultPushNotificationTemplate
defaultPushNotificationTemplate_url = (DefaultPushNotificationTemplate -> Maybe Text)
-> (DefaultPushNotificationTemplate
    -> Maybe Text -> DefaultPushNotificationTemplate)
-> Lens
     DefaultPushNotificationTemplate
     DefaultPushNotificationTemplate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefaultPushNotificationTemplate' {Maybe Text
url :: Maybe Text
$sel:url:DefaultPushNotificationTemplate' :: DefaultPushNotificationTemplate -> Maybe Text
url} -> Maybe Text
url) (\s :: DefaultPushNotificationTemplate
s@DefaultPushNotificationTemplate' {} Maybe Text
a -> DefaultPushNotificationTemplate
s {$sel:url:DefaultPushNotificationTemplate' :: Maybe Text
url = Maybe Text
a} :: DefaultPushNotificationTemplate)

-- | The sound to play when a recipient receives a push notification that\'s
-- based on the message template. You can use the default stream or specify
-- the file name of a sound resource that\'s bundled in your app. On an
-- Android platform, the sound file must reside in \/res\/raw\/.
--
-- For an iOS platform, this value is the key for the name of a sound file
-- in your app\'s main bundle or the Library\/Sounds folder in your app\'s
-- data container. If the sound file can\'t be found or you specify default
-- for the value, the system plays the default alert sound.
defaultPushNotificationTemplate_sound :: Lens.Lens' DefaultPushNotificationTemplate (Prelude.Maybe Prelude.Text)
defaultPushNotificationTemplate_sound :: (Maybe Text -> f (Maybe Text))
-> DefaultPushNotificationTemplate
-> f DefaultPushNotificationTemplate
defaultPushNotificationTemplate_sound = (DefaultPushNotificationTemplate -> Maybe Text)
-> (DefaultPushNotificationTemplate
    -> Maybe Text -> DefaultPushNotificationTemplate)
-> Lens
     DefaultPushNotificationTemplate
     DefaultPushNotificationTemplate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefaultPushNotificationTemplate' {Maybe Text
sound :: Maybe Text
$sel:sound:DefaultPushNotificationTemplate' :: DefaultPushNotificationTemplate -> Maybe Text
sound} -> Maybe Text
sound) (\s :: DefaultPushNotificationTemplate
s@DefaultPushNotificationTemplate' {} Maybe Text
a -> DefaultPushNotificationTemplate
s {$sel:sound:DefaultPushNotificationTemplate' :: Maybe Text
sound = Maybe Text
a} :: DefaultPushNotificationTemplate)

-- | The action to occur if a recipient taps a push notification that\'s
-- based on the message template. Valid values are:
--
-- -   OPEN_APP - Your app opens or it becomes the foreground app if it was
--     sent to the background. This is the default action.
--
-- -   DEEP_LINK - Your app opens and displays a designated user interface
--     in the app. This setting uses the deep-linking features of the iOS
--     and Android platforms.
--
-- -   URL - The default mobile browser on the recipient\'s device opens
--     and loads the web page at a URL that you specify.
defaultPushNotificationTemplate_action :: Lens.Lens' DefaultPushNotificationTemplate (Prelude.Maybe Action)
defaultPushNotificationTemplate_action :: (Maybe Action -> f (Maybe Action))
-> DefaultPushNotificationTemplate
-> f DefaultPushNotificationTemplate
defaultPushNotificationTemplate_action = (DefaultPushNotificationTemplate -> Maybe Action)
-> (DefaultPushNotificationTemplate
    -> Maybe Action -> DefaultPushNotificationTemplate)
-> Lens
     DefaultPushNotificationTemplate
     DefaultPushNotificationTemplate
     (Maybe Action)
     (Maybe Action)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefaultPushNotificationTemplate' {Maybe Action
action :: Maybe Action
$sel:action:DefaultPushNotificationTemplate' :: DefaultPushNotificationTemplate -> Maybe Action
action} -> Maybe Action
action) (\s :: DefaultPushNotificationTemplate
s@DefaultPushNotificationTemplate' {} Maybe Action
a -> DefaultPushNotificationTemplate
s {$sel:action:DefaultPushNotificationTemplate' :: Maybe Action
action = Maybe Action
a} :: DefaultPushNotificationTemplate)

-- | The title to use in push notifications that are based on the message
-- template. This title appears above the notification message on a
-- recipient\'s device.
defaultPushNotificationTemplate_title :: Lens.Lens' DefaultPushNotificationTemplate (Prelude.Maybe Prelude.Text)
defaultPushNotificationTemplate_title :: (Maybe Text -> f (Maybe Text))
-> DefaultPushNotificationTemplate
-> f DefaultPushNotificationTemplate
defaultPushNotificationTemplate_title = (DefaultPushNotificationTemplate -> Maybe Text)
-> (DefaultPushNotificationTemplate
    -> Maybe Text -> DefaultPushNotificationTemplate)
-> Lens
     DefaultPushNotificationTemplate
     DefaultPushNotificationTemplate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DefaultPushNotificationTemplate' {Maybe Text
title :: Maybe Text
$sel:title:DefaultPushNotificationTemplate' :: DefaultPushNotificationTemplate -> Maybe Text
title} -> Maybe Text
title) (\s :: DefaultPushNotificationTemplate
s@DefaultPushNotificationTemplate' {} Maybe Text
a -> DefaultPushNotificationTemplate
s {$sel:title:DefaultPushNotificationTemplate' :: Maybe Text
title = Maybe Text
a} :: DefaultPushNotificationTemplate)

instance
  Core.FromJSON
    DefaultPushNotificationTemplate
  where
  parseJSON :: Value -> Parser DefaultPushNotificationTemplate
parseJSON =
    String
-> (Object -> Parser DefaultPushNotificationTemplate)
-> Value
-> Parser DefaultPushNotificationTemplate
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DefaultPushNotificationTemplate"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Action
-> Maybe Text
-> DefaultPushNotificationTemplate
DefaultPushNotificationTemplate'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Action
 -> Maybe Text
 -> DefaultPushNotificationTemplate)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Action
      -> Maybe Text
      -> DefaultPushNotificationTemplate)
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
"Body")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Action
   -> Maybe Text
   -> DefaultPushNotificationTemplate)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Action -> Maybe Text -> DefaultPushNotificationTemplate)
forall (f :: * -> *) a b. Applicative f => 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
"Url")
            Parser
  (Maybe Text
   -> Maybe Action -> Maybe Text -> DefaultPushNotificationTemplate)
-> Parser (Maybe Text)
-> Parser
     (Maybe Action -> Maybe Text -> DefaultPushNotificationTemplate)
forall (f :: * -> *) a b. Applicative f => 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
"Sound")
            Parser
  (Maybe Action -> Maybe Text -> DefaultPushNotificationTemplate)
-> Parser (Maybe Action)
-> Parser (Maybe Text -> DefaultPushNotificationTemplate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Action)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Action")
            Parser (Maybe Text -> DefaultPushNotificationTemplate)
-> Parser (Maybe Text) -> Parser DefaultPushNotificationTemplate
forall (f :: * -> *) a b. Applicative f => 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
"Title")
      )

instance
  Prelude.Hashable
    DefaultPushNotificationTemplate

instance
  Prelude.NFData
    DefaultPushNotificationTemplate

instance Core.ToJSON DefaultPushNotificationTemplate where
  toJSON :: DefaultPushNotificationTemplate -> Value
toJSON DefaultPushNotificationTemplate' {Maybe Text
Maybe Action
title :: Maybe Text
action :: Maybe Action
sound :: Maybe Text
url :: Maybe Text
body :: Maybe Text
$sel:title:DefaultPushNotificationTemplate' :: DefaultPushNotificationTemplate -> Maybe Text
$sel:action:DefaultPushNotificationTemplate' :: DefaultPushNotificationTemplate -> Maybe Action
$sel:sound:DefaultPushNotificationTemplate' :: DefaultPushNotificationTemplate -> Maybe Text
$sel:url:DefaultPushNotificationTemplate' :: DefaultPushNotificationTemplate -> Maybe Text
$sel:body:DefaultPushNotificationTemplate' :: DefaultPushNotificationTemplate -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Body" 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
body,
            (Text
"Url" 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
url,
            (Text
"Sound" 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
sound,
            (Text
"Action" Text -> Action -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Action -> Pair) -> Maybe Action -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Action
action,
            (Text
"Title" 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
title
          ]
      )