{-# 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.Message
-- 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.Message 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 content and settings for a push notification that\'s sent
-- to recipients of a campaign.
--
-- /See:/ 'newMessage' smart constructor.
data Message = Message'
  { -- | Specifies whether the notification is a silent push notification, which
    -- is a push notification that doesn\'t display on a recipient\'s device.
    -- Silent push notifications can be used for cases such as updating an
    -- app\'s configuration, displaying messages in an in-app message center,
    -- or supporting phone home functionality.
    Message -> Maybe Bool
silentPush :: Prelude.Maybe Prelude.Bool,
    -- | The URL of the image to display as the push-notification icon, such as
    -- the icon for the app.
    Message -> Maybe Text
imageIconUrl :: Prelude.Maybe Prelude.Text,
    -- | The raw, JSON-formatted string to use as the payload for the
    -- notification message. If specified, this value overrides all other
    -- content for the message.
    Message -> Maybe Text
rawContent :: Prelude.Maybe Prelude.Text,
    -- | The body of the notification message. The maximum number of characters
    -- is 200.
    Message -> Maybe Text
body :: Prelude.Maybe Prelude.Text,
    -- | 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.
    Message -> Maybe Int
timeToLive :: Prelude.Maybe Prelude.Int,
    -- | The URL of the image to display as the small, push-notification icon,
    -- such as a small version of the icon for the app.
    Message -> Maybe Text
imageSmallIconUrl :: Prelude.Maybe Prelude.Text,
    -- | The JSON payload to use for a silent push notification.
    Message -> Maybe Text
jsonBody :: Prelude.Maybe Prelude.Text,
    -- | The URL to open in a recipient\'s default mobile browser, if a recipient
    -- taps the push notification and the value of the Action property is URL.
    Message -> Maybe Text
url :: Prelude.Maybe Prelude.Text,
    -- | The action to occur if a recipient taps the push notification. 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 iOS and
    --     Android.
    --
    -- -   URL - The default mobile browser on the recipient\'s device opens
    --     and loads the web page at a URL that you specify.
    Message -> Maybe Action
action :: Prelude.Maybe Action,
    -- | The URL of an image to display in the push notification.
    Message -> Maybe Text
imageUrl :: Prelude.Maybe Prelude.Text,
    -- | The URL of the image or video to display in the push notification.
    Message -> Maybe Text
mediaUrl :: Prelude.Maybe Prelude.Text,
    -- | The title to display above the notification message on a recipient\'s
    -- device.
    Message -> Maybe Text
title :: Prelude.Maybe Prelude.Text
  }
  deriving (Message -> Message -> Bool
(Message -> Message -> Bool)
-> (Message -> Message -> Bool) -> Eq Message
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Message -> Message -> Bool
$c/= :: Message -> Message -> Bool
== :: Message -> Message -> Bool
$c== :: Message -> Message -> Bool
Prelude.Eq, ReadPrec [Message]
ReadPrec Message
Int -> ReadS Message
ReadS [Message]
(Int -> ReadS Message)
-> ReadS [Message]
-> ReadPrec Message
-> ReadPrec [Message]
-> Read Message
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Message]
$creadListPrec :: ReadPrec [Message]
readPrec :: ReadPrec Message
$creadPrec :: ReadPrec Message
readList :: ReadS [Message]
$creadList :: ReadS [Message]
readsPrec :: Int -> ReadS Message
$creadsPrec :: Int -> ReadS Message
Prelude.Read, Int -> Message -> ShowS
[Message] -> ShowS
Message -> String
(Int -> Message -> ShowS)
-> (Message -> String) -> ([Message] -> ShowS) -> Show Message
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Message] -> ShowS
$cshowList :: [Message] -> ShowS
show :: Message -> String
$cshow :: Message -> String
showsPrec :: Int -> Message -> ShowS
$cshowsPrec :: Int -> Message -> ShowS
Prelude.Show, (forall x. Message -> Rep Message x)
-> (forall x. Rep Message x -> Message) -> Generic Message
forall x. Rep Message x -> Message
forall x. Message -> Rep Message x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Message x -> Message
$cfrom :: forall x. Message -> Rep Message x
Prelude.Generic)

-- |
-- Create a value of 'Message' 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:
--
-- 'silentPush', 'message_silentPush' - Specifies whether the notification is a silent push notification, which
-- is a push notification that doesn\'t display on a recipient\'s device.
-- Silent push notifications can be used for cases such as updating an
-- app\'s configuration, displaying messages in an in-app message center,
-- or supporting phone home functionality.
--
-- 'imageIconUrl', 'message_imageIconUrl' - The URL of the image to display as the push-notification icon, such as
-- the icon for the app.
--
-- 'rawContent', 'message_rawContent' - The raw, JSON-formatted string to use as the payload for the
-- notification message. If specified, this value overrides all other
-- content for the message.
--
-- 'body', 'message_body' - The body of the notification message. The maximum number of characters
-- is 200.
--
-- 'timeToLive', 'message_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.
--
-- 'imageSmallIconUrl', 'message_imageSmallIconUrl' - The URL of the image to display as the small, push-notification icon,
-- such as a small version of the icon for the app.
--
-- 'jsonBody', 'message_jsonBody' - The JSON payload to use for a silent push notification.
--
-- 'url', 'message_url' - The URL to open in a recipient\'s default mobile browser, if a recipient
-- taps the push notification and the value of the Action property is URL.
--
-- 'action', 'message_action' - The action to occur if a recipient taps the push notification. 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 iOS and
--     Android.
--
-- -   URL - The default mobile browser on the recipient\'s device opens
--     and loads the web page at a URL that you specify.
--
-- 'imageUrl', 'message_imageUrl' - The URL of an image to display in the push notification.
--
-- 'mediaUrl', 'message_mediaUrl' - The URL of the image or video to display in the push notification.
--
-- 'title', 'message_title' - The title to display above the notification message on a recipient\'s
-- device.
newMessage ::
  Message
newMessage :: Message
newMessage =
  Message' :: Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Action
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Message
Message'
    { $sel:silentPush:Message' :: Maybe Bool
silentPush = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:imageIconUrl:Message' :: Maybe Text
imageIconUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:rawContent:Message' :: Maybe Text
rawContent = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:body:Message' :: Maybe Text
body = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:timeToLive:Message' :: Maybe Int
timeToLive = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:imageSmallIconUrl:Message' :: Maybe Text
imageSmallIconUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jsonBody:Message' :: Maybe Text
jsonBody = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:url:Message' :: Maybe Text
url = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:action:Message' :: Maybe Action
action = Maybe Action
forall a. Maybe a
Prelude.Nothing,
      $sel:imageUrl:Message' :: Maybe Text
imageUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:mediaUrl:Message' :: Maybe Text
mediaUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:title:Message' :: Maybe Text
title = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether the notification is a silent push notification, which
-- is a push notification that doesn\'t display on a recipient\'s device.
-- Silent push notifications can be used for cases such as updating an
-- app\'s configuration, displaying messages in an in-app message center,
-- or supporting phone home functionality.
message_silentPush :: Lens.Lens' Message (Prelude.Maybe Prelude.Bool)
message_silentPush :: (Maybe Bool -> f (Maybe Bool)) -> Message -> f Message
message_silentPush = (Message -> Maybe Bool)
-> (Message -> Maybe Bool -> Message)
-> Lens Message Message (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Bool
silentPush :: Maybe Bool
$sel:silentPush:Message' :: Message -> Maybe Bool
silentPush} -> Maybe Bool
silentPush) (\s :: Message
s@Message' {} Maybe Bool
a -> Message
s {$sel:silentPush:Message' :: Maybe Bool
silentPush = Maybe Bool
a} :: Message)

-- | The URL of the image to display as the push-notification icon, such as
-- the icon for the app.
message_imageIconUrl :: Lens.Lens' Message (Prelude.Maybe Prelude.Text)
message_imageIconUrl :: (Maybe Text -> f (Maybe Text)) -> Message -> f Message
message_imageIconUrl = (Message -> Maybe Text)
-> (Message -> Maybe Text -> Message)
-> Lens Message Message (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Text
imageIconUrl :: Maybe Text
$sel:imageIconUrl:Message' :: Message -> Maybe Text
imageIconUrl} -> Maybe Text
imageIconUrl) (\s :: Message
s@Message' {} Maybe Text
a -> Message
s {$sel:imageIconUrl:Message' :: Maybe Text
imageIconUrl = Maybe Text
a} :: Message)

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

-- | The body of the notification message. The maximum number of characters
-- is 200.
message_body :: Lens.Lens' Message (Prelude.Maybe Prelude.Text)
message_body :: (Maybe Text -> f (Maybe Text)) -> Message -> f Message
message_body = (Message -> Maybe Text)
-> (Message -> Maybe Text -> Message)
-> Lens Message Message (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Text
body :: Maybe Text
$sel:body:Message' :: Message -> Maybe Text
body} -> Maybe Text
body) (\s :: Message
s@Message' {} Maybe Text
a -> Message
s {$sel:body:Message' :: Maybe Text
body = Maybe Text
a} :: Message)

-- | 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.
message_timeToLive :: Lens.Lens' Message (Prelude.Maybe Prelude.Int)
message_timeToLive :: (Maybe Int -> f (Maybe Int)) -> Message -> f Message
message_timeToLive = (Message -> Maybe Int)
-> (Message -> Maybe Int -> Message)
-> Lens Message Message (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Int
timeToLive :: Maybe Int
$sel:timeToLive:Message' :: Message -> Maybe Int
timeToLive} -> Maybe Int
timeToLive) (\s :: Message
s@Message' {} Maybe Int
a -> Message
s {$sel:timeToLive:Message' :: Maybe Int
timeToLive = Maybe Int
a} :: Message)

-- | The URL of the image to display as the small, push-notification icon,
-- such as a small version of the icon for the app.
message_imageSmallIconUrl :: Lens.Lens' Message (Prelude.Maybe Prelude.Text)
message_imageSmallIconUrl :: (Maybe Text -> f (Maybe Text)) -> Message -> f Message
message_imageSmallIconUrl = (Message -> Maybe Text)
-> (Message -> Maybe Text -> Message)
-> Lens Message Message (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Text
imageSmallIconUrl :: Maybe Text
$sel:imageSmallIconUrl:Message' :: Message -> Maybe Text
imageSmallIconUrl} -> Maybe Text
imageSmallIconUrl) (\s :: Message
s@Message' {} Maybe Text
a -> Message
s {$sel:imageSmallIconUrl:Message' :: Maybe Text
imageSmallIconUrl = Maybe Text
a} :: Message)

-- | The JSON payload to use for a silent push notification.
message_jsonBody :: Lens.Lens' Message (Prelude.Maybe Prelude.Text)
message_jsonBody :: (Maybe Text -> f (Maybe Text)) -> Message -> f Message
message_jsonBody = (Message -> Maybe Text)
-> (Message -> Maybe Text -> Message)
-> Lens Message Message (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Text
jsonBody :: Maybe Text
$sel:jsonBody:Message' :: Message -> Maybe Text
jsonBody} -> Maybe Text
jsonBody) (\s :: Message
s@Message' {} Maybe Text
a -> Message
s {$sel:jsonBody:Message' :: Maybe Text
jsonBody = Maybe Text
a} :: Message)

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

-- | The action to occur if a recipient taps the push notification. 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 iOS and
--     Android.
--
-- -   URL - The default mobile browser on the recipient\'s device opens
--     and loads the web page at a URL that you specify.
message_action :: Lens.Lens' Message (Prelude.Maybe Action)
message_action :: (Maybe Action -> f (Maybe Action)) -> Message -> f Message
message_action = (Message -> Maybe Action)
-> (Message -> Maybe Action -> Message)
-> Lens Message Message (Maybe Action) (Maybe Action)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Action
action :: Maybe Action
$sel:action:Message' :: Message -> Maybe Action
action} -> Maybe Action
action) (\s :: Message
s@Message' {} Maybe Action
a -> Message
s {$sel:action:Message' :: Maybe Action
action = Maybe Action
a} :: Message)

-- | The URL of an image to display in the push notification.
message_imageUrl :: Lens.Lens' Message (Prelude.Maybe Prelude.Text)
message_imageUrl :: (Maybe Text -> f (Maybe Text)) -> Message -> f Message
message_imageUrl = (Message -> Maybe Text)
-> (Message -> Maybe Text -> Message)
-> Lens Message Message (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Text
imageUrl :: Maybe Text
$sel:imageUrl:Message' :: Message -> Maybe Text
imageUrl} -> Maybe Text
imageUrl) (\s :: Message
s@Message' {} Maybe Text
a -> Message
s {$sel:imageUrl:Message' :: Maybe Text
imageUrl = Maybe Text
a} :: Message)

-- | The URL of the image or video to display in the push notification.
message_mediaUrl :: Lens.Lens' Message (Prelude.Maybe Prelude.Text)
message_mediaUrl :: (Maybe Text -> f (Maybe Text)) -> Message -> f Message
message_mediaUrl = (Message -> Maybe Text)
-> (Message -> Maybe Text -> Message)
-> Lens Message Message (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Text
mediaUrl :: Maybe Text
$sel:mediaUrl:Message' :: Message -> Maybe Text
mediaUrl} -> Maybe Text
mediaUrl) (\s :: Message
s@Message' {} Maybe Text
a -> Message
s {$sel:mediaUrl:Message' :: Maybe Text
mediaUrl = Maybe Text
a} :: Message)

-- | The title to display above the notification message on a recipient\'s
-- device.
message_title :: Lens.Lens' Message (Prelude.Maybe Prelude.Text)
message_title :: (Maybe Text -> f (Maybe Text)) -> Message -> f Message
message_title = (Message -> Maybe Text)
-> (Message -> Maybe Text -> Message)
-> Lens Message Message (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Maybe Text
title :: Maybe Text
$sel:title:Message' :: Message -> Maybe Text
title} -> Maybe Text
title) (\s :: Message
s@Message' {} Maybe Text
a -> Message
s {$sel:title:Message' :: Maybe Text
title = Maybe Text
a} :: Message)

instance Core.FromJSON Message where
  parseJSON :: Value -> Parser Message
parseJSON =
    String -> (Object -> Parser Message) -> Value -> Parser Message
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Message"
      ( \Object
x ->
          Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Action
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Message
Message'
            (Maybe Bool
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Int
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Action
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Message)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Action
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Message)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SilentPush")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Action
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Message)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Action
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Message)
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
"ImageIconUrl")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Action
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Message)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Action
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Message)
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
"RawContent")
            Parser
  (Maybe Text
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Action
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Message)
-> Parser (Maybe Text)
-> Parser
     (Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Action
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Message)
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 Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Action
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Message)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Action
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Message)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TimeToLive")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Action
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Message)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Action
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Message)
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
"ImageSmallIconUrl")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Action
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Message)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Action
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Message)
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
"JsonBody")
            Parser
  (Maybe Text
   -> Maybe Action
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Message)
-> Parser (Maybe Text)
-> Parser
     (Maybe Action -> Maybe Text -> Maybe Text -> Maybe Text -> Message)
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 Action -> Maybe Text -> Maybe Text -> Maybe Text -> Message)
-> Parser (Maybe Action)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Message)
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 -> Maybe Text -> Message)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Message)
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
"ImageUrl")
            Parser (Maybe Text -> Maybe Text -> Message)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Message)
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 -> Message)
-> Parser (Maybe Text) -> Parser Message
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 Message

instance Prelude.NFData Message

instance Core.ToJSON Message where
  toJSON :: Message -> Value
toJSON Message' {Maybe Bool
Maybe Int
Maybe Text
Maybe Action
title :: Maybe Text
mediaUrl :: Maybe Text
imageUrl :: Maybe Text
action :: Maybe Action
url :: Maybe Text
jsonBody :: Maybe Text
imageSmallIconUrl :: Maybe Text
timeToLive :: Maybe Int
body :: Maybe Text
rawContent :: Maybe Text
imageIconUrl :: Maybe Text
silentPush :: Maybe Bool
$sel:title:Message' :: Message -> Maybe Text
$sel:mediaUrl:Message' :: Message -> Maybe Text
$sel:imageUrl:Message' :: Message -> Maybe Text
$sel:action:Message' :: Message -> Maybe Action
$sel:url:Message' :: Message -> Maybe Text
$sel:jsonBody:Message' :: Message -> Maybe Text
$sel:imageSmallIconUrl:Message' :: Message -> Maybe Text
$sel:timeToLive:Message' :: Message -> Maybe Int
$sel:body:Message' :: Message -> Maybe Text
$sel:rawContent:Message' :: Message -> Maybe Text
$sel:imageIconUrl:Message' :: Message -> Maybe Text
$sel:silentPush:Message' :: Message -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SilentPush" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
silentPush,
            (Text
"ImageIconUrl" 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
imageIconUrl,
            (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
"TimeToLive" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
timeToLive,
            (Text
"ImageSmallIconUrl" 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
imageSmallIconUrl,
            (Text
"JsonBody" 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
jsonBody,
            (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
"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
"ImageUrl" 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
imageUrl,
            (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
          ]
      )