{-# 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.APNSPushNotificationTemplate
-- 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.APNSPushNotificationTemplate 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 channel-specific content and settings for a message template
-- that can be used in push notifications that are sent through the APNs
-- (Apple Push Notification service) channel.
--
-- /See:/ 'newAPNSPushNotificationTemplate' smart constructor.
data APNSPushNotificationTemplate = APNSPushNotificationTemplate'
  { -- | The raw, JSON-formatted string to use as the payload for push
    -- notifications that are based on the message template. If specified, this
    -- value overrides all other content for the message template.
    APNSPushNotificationTemplate -> Maybe Text
rawContent :: Prelude.Maybe Prelude.Text,
    -- | The message body to use in push notifications that are based on the
    -- message template.
    APNSPushNotificationTemplate -> Maybe Text
body :: Prelude.Maybe Prelude.Text,
    -- | The URL to open in the 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.
    APNSPushNotificationTemplate -> Maybe Text
url :: Prelude.Maybe Prelude.Text,
    -- | The key for the sound to play when the recipient receives a push
    -- notification that\'s based on the message template. The value for this
    -- key is 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.
    APNSPushNotificationTemplate -> 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
    --     platform.
    --
    -- -   URL - The default mobile browser on the recipient\'s device opens
    --     and loads the web page at a URL that you specify.
    APNSPushNotificationTemplate -> Maybe Action
action :: Prelude.Maybe Action,
    -- | The URL of an image or video to display in push notifications that are
    -- based on the message template.
    APNSPushNotificationTemplate -> Maybe Text
mediaUrl :: Prelude.Maybe Prelude.Text,
    -- | 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.
    APNSPushNotificationTemplate -> Maybe Text
title :: Prelude.Maybe Prelude.Text
  }
  deriving (APNSPushNotificationTemplate
-> APNSPushNotificationTemplate -> Bool
(APNSPushNotificationTemplate
 -> APNSPushNotificationTemplate -> Bool)
-> (APNSPushNotificationTemplate
    -> APNSPushNotificationTemplate -> Bool)
-> Eq APNSPushNotificationTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: APNSPushNotificationTemplate
-> APNSPushNotificationTemplate -> Bool
$c/= :: APNSPushNotificationTemplate
-> APNSPushNotificationTemplate -> Bool
== :: APNSPushNotificationTemplate
-> APNSPushNotificationTemplate -> Bool
$c== :: APNSPushNotificationTemplate
-> APNSPushNotificationTemplate -> Bool
Prelude.Eq, ReadPrec [APNSPushNotificationTemplate]
ReadPrec APNSPushNotificationTemplate
Int -> ReadS APNSPushNotificationTemplate
ReadS [APNSPushNotificationTemplate]
(Int -> ReadS APNSPushNotificationTemplate)
-> ReadS [APNSPushNotificationTemplate]
-> ReadPrec APNSPushNotificationTemplate
-> ReadPrec [APNSPushNotificationTemplate]
-> Read APNSPushNotificationTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [APNSPushNotificationTemplate]
$creadListPrec :: ReadPrec [APNSPushNotificationTemplate]
readPrec :: ReadPrec APNSPushNotificationTemplate
$creadPrec :: ReadPrec APNSPushNotificationTemplate
readList :: ReadS [APNSPushNotificationTemplate]
$creadList :: ReadS [APNSPushNotificationTemplate]
readsPrec :: Int -> ReadS APNSPushNotificationTemplate
$creadsPrec :: Int -> ReadS APNSPushNotificationTemplate
Prelude.Read, Int -> APNSPushNotificationTemplate -> ShowS
[APNSPushNotificationTemplate] -> ShowS
APNSPushNotificationTemplate -> String
(Int -> APNSPushNotificationTemplate -> ShowS)
-> (APNSPushNotificationTemplate -> String)
-> ([APNSPushNotificationTemplate] -> ShowS)
-> Show APNSPushNotificationTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [APNSPushNotificationTemplate] -> ShowS
$cshowList :: [APNSPushNotificationTemplate] -> ShowS
show :: APNSPushNotificationTemplate -> String
$cshow :: APNSPushNotificationTemplate -> String
showsPrec :: Int -> APNSPushNotificationTemplate -> ShowS
$cshowsPrec :: Int -> APNSPushNotificationTemplate -> ShowS
Prelude.Show, (forall x.
 APNSPushNotificationTemplate -> Rep APNSPushNotificationTemplate x)
-> (forall x.
    Rep APNSPushNotificationTemplate x -> APNSPushNotificationTemplate)
-> Generic APNSPushNotificationTemplate
forall x.
Rep APNSPushNotificationTemplate x -> APNSPushNotificationTemplate
forall x.
APNSPushNotificationTemplate -> Rep APNSPushNotificationTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep APNSPushNotificationTemplate x -> APNSPushNotificationTemplate
$cfrom :: forall x.
APNSPushNotificationTemplate -> Rep APNSPushNotificationTemplate x
Prelude.Generic)

-- |
-- Create a value of 'APNSPushNotificationTemplate' 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:
--
-- 'rawContent', 'aPNSPushNotificationTemplate_rawContent' - The raw, JSON-formatted string to use as the payload for push
-- notifications that are based on the message template. If specified, this
-- value overrides all other content for the message template.
--
-- 'body', 'aPNSPushNotificationTemplate_body' - The message body to use in push notifications that are based on the
-- message template.
--
-- 'url', 'aPNSPushNotificationTemplate_url' - The URL to open in the 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', 'aPNSPushNotificationTemplate_sound' - The key for the sound to play when the recipient receives a push
-- notification that\'s based on the message template. The value for this
-- key is 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', 'aPNSPushNotificationTemplate_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
--     platform.
--
-- -   URL - The default mobile browser on the recipient\'s device opens
--     and loads the web page at a URL that you specify.
--
-- 'mediaUrl', 'aPNSPushNotificationTemplate_mediaUrl' - The URL of an image or video to display in push notifications that are
-- based on the message template.
--
-- 'title', 'aPNSPushNotificationTemplate_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.
newAPNSPushNotificationTemplate ::
  APNSPushNotificationTemplate
newAPNSPushNotificationTemplate :: APNSPushNotificationTemplate
newAPNSPushNotificationTemplate =
  APNSPushNotificationTemplate' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Action
-> Maybe Text
-> Maybe Text
-> APNSPushNotificationTemplate
APNSPushNotificationTemplate'
    { $sel:rawContent:APNSPushNotificationTemplate' :: Maybe Text
rawContent =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:body:APNSPushNotificationTemplate' :: Maybe Text
body = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:url:APNSPushNotificationTemplate' :: Maybe Text
url = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sound:APNSPushNotificationTemplate' :: Maybe Text
sound = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:action:APNSPushNotificationTemplate' :: Maybe Action
action = Maybe Action
forall a. Maybe a
Prelude.Nothing,
      $sel:mediaUrl:APNSPushNotificationTemplate' :: Maybe Text
mediaUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:title:APNSPushNotificationTemplate' :: Maybe Text
title = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The raw, JSON-formatted string to use as the payload for push
-- notifications that are based on the message template. If specified, this
-- value overrides all other content for the message template.
aPNSPushNotificationTemplate_rawContent :: Lens.Lens' APNSPushNotificationTemplate (Prelude.Maybe Prelude.Text)
aPNSPushNotificationTemplate_rawContent :: (Maybe Text -> f (Maybe Text))
-> APNSPushNotificationTemplate -> f APNSPushNotificationTemplate
aPNSPushNotificationTemplate_rawContent = (APNSPushNotificationTemplate -> Maybe Text)
-> (APNSPushNotificationTemplate
    -> Maybe Text -> APNSPushNotificationTemplate)
-> Lens
     APNSPushNotificationTemplate
     APNSPushNotificationTemplate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\APNSPushNotificationTemplate' {Maybe Text
rawContent :: Maybe Text
$sel:rawContent:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Text
rawContent} -> Maybe Text
rawContent) (\s :: APNSPushNotificationTemplate
s@APNSPushNotificationTemplate' {} Maybe Text
a -> APNSPushNotificationTemplate
s {$sel:rawContent:APNSPushNotificationTemplate' :: Maybe Text
rawContent = Maybe Text
a} :: APNSPushNotificationTemplate)

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

-- | The URL to open in the 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.
aPNSPushNotificationTemplate_url :: Lens.Lens' APNSPushNotificationTemplate (Prelude.Maybe Prelude.Text)
aPNSPushNotificationTemplate_url :: (Maybe Text -> f (Maybe Text))
-> APNSPushNotificationTemplate -> f APNSPushNotificationTemplate
aPNSPushNotificationTemplate_url = (APNSPushNotificationTemplate -> Maybe Text)
-> (APNSPushNotificationTemplate
    -> Maybe Text -> APNSPushNotificationTemplate)
-> Lens
     APNSPushNotificationTemplate
     APNSPushNotificationTemplate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\APNSPushNotificationTemplate' {Maybe Text
url :: Maybe Text
$sel:url:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Text
url} -> Maybe Text
url) (\s :: APNSPushNotificationTemplate
s@APNSPushNotificationTemplate' {} Maybe Text
a -> APNSPushNotificationTemplate
s {$sel:url:APNSPushNotificationTemplate' :: Maybe Text
url = Maybe Text
a} :: APNSPushNotificationTemplate)

-- | The key for the sound to play when the recipient receives a push
-- notification that\'s based on the message template. The value for this
-- key is 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.
aPNSPushNotificationTemplate_sound :: Lens.Lens' APNSPushNotificationTemplate (Prelude.Maybe Prelude.Text)
aPNSPushNotificationTemplate_sound :: (Maybe Text -> f (Maybe Text))
-> APNSPushNotificationTemplate -> f APNSPushNotificationTemplate
aPNSPushNotificationTemplate_sound = (APNSPushNotificationTemplate -> Maybe Text)
-> (APNSPushNotificationTemplate
    -> Maybe Text -> APNSPushNotificationTemplate)
-> Lens
     APNSPushNotificationTemplate
     APNSPushNotificationTemplate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\APNSPushNotificationTemplate' {Maybe Text
sound :: Maybe Text
$sel:sound:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Text
sound} -> Maybe Text
sound) (\s :: APNSPushNotificationTemplate
s@APNSPushNotificationTemplate' {} Maybe Text
a -> APNSPushNotificationTemplate
s {$sel:sound:APNSPushNotificationTemplate' :: Maybe Text
sound = Maybe Text
a} :: APNSPushNotificationTemplate)

-- | 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
--     platform.
--
-- -   URL - The default mobile browser on the recipient\'s device opens
--     and loads the web page at a URL that you specify.
aPNSPushNotificationTemplate_action :: Lens.Lens' APNSPushNotificationTemplate (Prelude.Maybe Action)
aPNSPushNotificationTemplate_action :: (Maybe Action -> f (Maybe Action))
-> APNSPushNotificationTemplate -> f APNSPushNotificationTemplate
aPNSPushNotificationTemplate_action = (APNSPushNotificationTemplate -> Maybe Action)
-> (APNSPushNotificationTemplate
    -> Maybe Action -> APNSPushNotificationTemplate)
-> Lens
     APNSPushNotificationTemplate
     APNSPushNotificationTemplate
     (Maybe Action)
     (Maybe Action)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\APNSPushNotificationTemplate' {Maybe Action
action :: Maybe Action
$sel:action:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Action
action} -> Maybe Action
action) (\s :: APNSPushNotificationTemplate
s@APNSPushNotificationTemplate' {} Maybe Action
a -> APNSPushNotificationTemplate
s {$sel:action:APNSPushNotificationTemplate' :: Maybe Action
action = Maybe Action
a} :: APNSPushNotificationTemplate)

-- | The URL of an image or video to display in push notifications that are
-- based on the message template.
aPNSPushNotificationTemplate_mediaUrl :: Lens.Lens' APNSPushNotificationTemplate (Prelude.Maybe Prelude.Text)
aPNSPushNotificationTemplate_mediaUrl :: (Maybe Text -> f (Maybe Text))
-> APNSPushNotificationTemplate -> f APNSPushNotificationTemplate
aPNSPushNotificationTemplate_mediaUrl = (APNSPushNotificationTemplate -> Maybe Text)
-> (APNSPushNotificationTemplate
    -> Maybe Text -> APNSPushNotificationTemplate)
-> Lens
     APNSPushNotificationTemplate
     APNSPushNotificationTemplate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\APNSPushNotificationTemplate' {Maybe Text
mediaUrl :: Maybe Text
$sel:mediaUrl:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Text
mediaUrl} -> Maybe Text
mediaUrl) (\s :: APNSPushNotificationTemplate
s@APNSPushNotificationTemplate' {} Maybe Text
a -> APNSPushNotificationTemplate
s {$sel:mediaUrl:APNSPushNotificationTemplate' :: Maybe Text
mediaUrl = Maybe Text
a} :: APNSPushNotificationTemplate)

-- | 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.
aPNSPushNotificationTemplate_title :: Lens.Lens' APNSPushNotificationTemplate (Prelude.Maybe Prelude.Text)
aPNSPushNotificationTemplate_title :: (Maybe Text -> f (Maybe Text))
-> APNSPushNotificationTemplate -> f APNSPushNotificationTemplate
aPNSPushNotificationTemplate_title = (APNSPushNotificationTemplate -> Maybe Text)
-> (APNSPushNotificationTemplate
    -> Maybe Text -> APNSPushNotificationTemplate)
-> Lens
     APNSPushNotificationTemplate
     APNSPushNotificationTemplate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\APNSPushNotificationTemplate' {Maybe Text
title :: Maybe Text
$sel:title:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Text
title} -> Maybe Text
title) (\s :: APNSPushNotificationTemplate
s@APNSPushNotificationTemplate' {} Maybe Text
a -> APNSPushNotificationTemplate
s {$sel:title:APNSPushNotificationTemplate' :: Maybe Text
title = Maybe Text
a} :: APNSPushNotificationTemplate)

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

instance Prelude.NFData APNSPushNotificationTemplate

instance Core.ToJSON APNSPushNotificationTemplate where
  toJSON :: APNSPushNotificationTemplate -> Value
toJSON APNSPushNotificationTemplate' {Maybe Text
Maybe Action
title :: Maybe Text
mediaUrl :: Maybe Text
action :: Maybe Action
sound :: Maybe Text
url :: Maybe Text
body :: Maybe Text
rawContent :: Maybe Text
$sel:title:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Text
$sel:mediaUrl:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Text
$sel:action:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Action
$sel:sound:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Text
$sel:url:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Text
$sel:body:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Text
$sel:rawContent:APNSPushNotificationTemplate' :: APNSPushNotificationTemplate -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RawContent" 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
rawContent,
            (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
"MediaUrl" 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
mediaUrl,
            (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
          ]
      )