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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.CampaignCustomMessage
import Amazonka.Pinpoint.Types.CampaignEmailMessage
import Amazonka.Pinpoint.Types.CampaignInAppMessage
import Amazonka.Pinpoint.Types.CampaignSmsMessage
import Amazonka.Pinpoint.Types.Message
import qualified Amazonka.Prelude as Prelude

-- | Specifies the message configuration settings for a campaign.
--
-- /See:/ 'newMessageConfiguration' smart constructor.
data MessageConfiguration = MessageConfiguration'
  { -- | The message that the campaign sends through the APNs (Apple Push
    -- Notification service) channel. If specified, this message overrides the
    -- default message.
    MessageConfiguration -> Maybe Message
aPNSMessage :: Prelude.Maybe Message,
    -- | The message that the campaign sends through the GCM channel, which
    -- enables Amazon Pinpoint to send push notifications through the Firebase
    -- Cloud Messaging (FCM), formerly Google Cloud Messaging (GCM), service.
    -- If specified, this message overrides the default message.
    MessageConfiguration -> Maybe Message
gCMMessage :: Prelude.Maybe Message,
    -- | The default message that the campaign sends through all the channels
    -- that are configured for the campaign.
    MessageConfiguration -> Maybe Message
defaultMessage :: Prelude.Maybe Message,
    -- | The message that the campaign sends through a custom channel, as
    -- specified by the delivery configuration (CustomDeliveryConfiguration)
    -- settings for the campaign. If specified, this message overrides the
    -- default message.
    MessageConfiguration -> Maybe CampaignCustomMessage
customMessage :: Prelude.Maybe CampaignCustomMessage,
    -- | The message that the campaign sends through the ADM (Amazon Device
    -- Messaging) channel. If specified, this message overrides the default
    -- message.
    MessageConfiguration -> Maybe Message
aDMMessage :: Prelude.Maybe Message,
    -- | The message that the campaign sends through the SMS channel. If
    -- specified, this message overrides the default message.
    MessageConfiguration -> Maybe CampaignSmsMessage
sMSMessage :: Prelude.Maybe CampaignSmsMessage,
    -- | The message that the campaign sends through the email channel. If
    -- specified, this message overrides the default message.
    MessageConfiguration -> Maybe CampaignEmailMessage
emailMessage :: Prelude.Maybe CampaignEmailMessage,
    -- | The in-app message configuration.
    MessageConfiguration -> Maybe CampaignInAppMessage
inAppMessage :: Prelude.Maybe CampaignInAppMessage,
    -- | The message that the campaign sends through the Baidu (Baidu Cloud Push)
    -- channel. If specified, this message overrides the default message.
    MessageConfiguration -> Maybe Message
baiduMessage :: Prelude.Maybe Message
  }
  deriving (MessageConfiguration -> MessageConfiguration -> Bool
(MessageConfiguration -> MessageConfiguration -> Bool)
-> (MessageConfiguration -> MessageConfiguration -> Bool)
-> Eq MessageConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MessageConfiguration -> MessageConfiguration -> Bool
$c/= :: MessageConfiguration -> MessageConfiguration -> Bool
== :: MessageConfiguration -> MessageConfiguration -> Bool
$c== :: MessageConfiguration -> MessageConfiguration -> Bool
Prelude.Eq, ReadPrec [MessageConfiguration]
ReadPrec MessageConfiguration
Int -> ReadS MessageConfiguration
ReadS [MessageConfiguration]
(Int -> ReadS MessageConfiguration)
-> ReadS [MessageConfiguration]
-> ReadPrec MessageConfiguration
-> ReadPrec [MessageConfiguration]
-> Read MessageConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MessageConfiguration]
$creadListPrec :: ReadPrec [MessageConfiguration]
readPrec :: ReadPrec MessageConfiguration
$creadPrec :: ReadPrec MessageConfiguration
readList :: ReadS [MessageConfiguration]
$creadList :: ReadS [MessageConfiguration]
readsPrec :: Int -> ReadS MessageConfiguration
$creadsPrec :: Int -> ReadS MessageConfiguration
Prelude.Read, Int -> MessageConfiguration -> ShowS
[MessageConfiguration] -> ShowS
MessageConfiguration -> String
(Int -> MessageConfiguration -> ShowS)
-> (MessageConfiguration -> String)
-> ([MessageConfiguration] -> ShowS)
-> Show MessageConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MessageConfiguration] -> ShowS
$cshowList :: [MessageConfiguration] -> ShowS
show :: MessageConfiguration -> String
$cshow :: MessageConfiguration -> String
showsPrec :: Int -> MessageConfiguration -> ShowS
$cshowsPrec :: Int -> MessageConfiguration -> ShowS
Prelude.Show, (forall x. MessageConfiguration -> Rep MessageConfiguration x)
-> (forall x. Rep MessageConfiguration x -> MessageConfiguration)
-> Generic MessageConfiguration
forall x. Rep MessageConfiguration x -> MessageConfiguration
forall x. MessageConfiguration -> Rep MessageConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MessageConfiguration x -> MessageConfiguration
$cfrom :: forall x. MessageConfiguration -> Rep MessageConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'MessageConfiguration' 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:
--
-- 'aPNSMessage', 'messageConfiguration_aPNSMessage' - The message that the campaign sends through the APNs (Apple Push
-- Notification service) channel. If specified, this message overrides the
-- default message.
--
-- 'gCMMessage', 'messageConfiguration_gCMMessage' - The message that the campaign sends through the GCM channel, which
-- enables Amazon Pinpoint to send push notifications through the Firebase
-- Cloud Messaging (FCM), formerly Google Cloud Messaging (GCM), service.
-- If specified, this message overrides the default message.
--
-- 'defaultMessage', 'messageConfiguration_defaultMessage' - The default message that the campaign sends through all the channels
-- that are configured for the campaign.
--
-- 'customMessage', 'messageConfiguration_customMessage' - The message that the campaign sends through a custom channel, as
-- specified by the delivery configuration (CustomDeliveryConfiguration)
-- settings for the campaign. If specified, this message overrides the
-- default message.
--
-- 'aDMMessage', 'messageConfiguration_aDMMessage' - The message that the campaign sends through the ADM (Amazon Device
-- Messaging) channel. If specified, this message overrides the default
-- message.
--
-- 'sMSMessage', 'messageConfiguration_sMSMessage' - The message that the campaign sends through the SMS channel. If
-- specified, this message overrides the default message.
--
-- 'emailMessage', 'messageConfiguration_emailMessage' - The message that the campaign sends through the email channel. If
-- specified, this message overrides the default message.
--
-- 'inAppMessage', 'messageConfiguration_inAppMessage' - The in-app message configuration.
--
-- 'baiduMessage', 'messageConfiguration_baiduMessage' - The message that the campaign sends through the Baidu (Baidu Cloud Push)
-- channel. If specified, this message overrides the default message.
newMessageConfiguration ::
  MessageConfiguration
newMessageConfiguration :: MessageConfiguration
newMessageConfiguration =
  MessageConfiguration' :: Maybe Message
-> Maybe Message
-> Maybe Message
-> Maybe CampaignCustomMessage
-> Maybe Message
-> Maybe CampaignSmsMessage
-> Maybe CampaignEmailMessage
-> Maybe CampaignInAppMessage
-> Maybe Message
-> MessageConfiguration
MessageConfiguration'
    { $sel:aPNSMessage:MessageConfiguration' :: Maybe Message
aPNSMessage =
        Maybe Message
forall a. Maybe a
Prelude.Nothing,
      $sel:gCMMessage:MessageConfiguration' :: Maybe Message
gCMMessage = Maybe Message
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultMessage:MessageConfiguration' :: Maybe Message
defaultMessage = Maybe Message
forall a. Maybe a
Prelude.Nothing,
      $sel:customMessage:MessageConfiguration' :: Maybe CampaignCustomMessage
customMessage = Maybe CampaignCustomMessage
forall a. Maybe a
Prelude.Nothing,
      $sel:aDMMessage:MessageConfiguration' :: Maybe Message
aDMMessage = Maybe Message
forall a. Maybe a
Prelude.Nothing,
      $sel:sMSMessage:MessageConfiguration' :: Maybe CampaignSmsMessage
sMSMessage = Maybe CampaignSmsMessage
forall a. Maybe a
Prelude.Nothing,
      $sel:emailMessage:MessageConfiguration' :: Maybe CampaignEmailMessage
emailMessage = Maybe CampaignEmailMessage
forall a. Maybe a
Prelude.Nothing,
      $sel:inAppMessage:MessageConfiguration' :: Maybe CampaignInAppMessage
inAppMessage = Maybe CampaignInAppMessage
forall a. Maybe a
Prelude.Nothing,
      $sel:baiduMessage:MessageConfiguration' :: Maybe Message
baiduMessage = Maybe Message
forall a. Maybe a
Prelude.Nothing
    }

-- | The message that the campaign sends through the APNs (Apple Push
-- Notification service) channel. If specified, this message overrides the
-- default message.
messageConfiguration_aPNSMessage :: Lens.Lens' MessageConfiguration (Prelude.Maybe Message)
messageConfiguration_aPNSMessage :: (Maybe Message -> f (Maybe Message))
-> MessageConfiguration -> f MessageConfiguration
messageConfiguration_aPNSMessage = (MessageConfiguration -> Maybe Message)
-> (MessageConfiguration -> Maybe Message -> MessageConfiguration)
-> Lens
     MessageConfiguration
     MessageConfiguration
     (Maybe Message)
     (Maybe Message)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageConfiguration' {Maybe Message
aPNSMessage :: Maybe Message
$sel:aPNSMessage:MessageConfiguration' :: MessageConfiguration -> Maybe Message
aPNSMessage} -> Maybe Message
aPNSMessage) (\s :: MessageConfiguration
s@MessageConfiguration' {} Maybe Message
a -> MessageConfiguration
s {$sel:aPNSMessage:MessageConfiguration' :: Maybe Message
aPNSMessage = Maybe Message
a} :: MessageConfiguration)

-- | The message that the campaign sends through the GCM channel, which
-- enables Amazon Pinpoint to send push notifications through the Firebase
-- Cloud Messaging (FCM), formerly Google Cloud Messaging (GCM), service.
-- If specified, this message overrides the default message.
messageConfiguration_gCMMessage :: Lens.Lens' MessageConfiguration (Prelude.Maybe Message)
messageConfiguration_gCMMessage :: (Maybe Message -> f (Maybe Message))
-> MessageConfiguration -> f MessageConfiguration
messageConfiguration_gCMMessage = (MessageConfiguration -> Maybe Message)
-> (MessageConfiguration -> Maybe Message -> MessageConfiguration)
-> Lens
     MessageConfiguration
     MessageConfiguration
     (Maybe Message)
     (Maybe Message)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageConfiguration' {Maybe Message
gCMMessage :: Maybe Message
$sel:gCMMessage:MessageConfiguration' :: MessageConfiguration -> Maybe Message
gCMMessage} -> Maybe Message
gCMMessage) (\s :: MessageConfiguration
s@MessageConfiguration' {} Maybe Message
a -> MessageConfiguration
s {$sel:gCMMessage:MessageConfiguration' :: Maybe Message
gCMMessage = Maybe Message
a} :: MessageConfiguration)

-- | The default message that the campaign sends through all the channels
-- that are configured for the campaign.
messageConfiguration_defaultMessage :: Lens.Lens' MessageConfiguration (Prelude.Maybe Message)
messageConfiguration_defaultMessage :: (Maybe Message -> f (Maybe Message))
-> MessageConfiguration -> f MessageConfiguration
messageConfiguration_defaultMessage = (MessageConfiguration -> Maybe Message)
-> (MessageConfiguration -> Maybe Message -> MessageConfiguration)
-> Lens
     MessageConfiguration
     MessageConfiguration
     (Maybe Message)
     (Maybe Message)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageConfiguration' {Maybe Message
defaultMessage :: Maybe Message
$sel:defaultMessage:MessageConfiguration' :: MessageConfiguration -> Maybe Message
defaultMessage} -> Maybe Message
defaultMessage) (\s :: MessageConfiguration
s@MessageConfiguration' {} Maybe Message
a -> MessageConfiguration
s {$sel:defaultMessage:MessageConfiguration' :: Maybe Message
defaultMessage = Maybe Message
a} :: MessageConfiguration)

-- | The message that the campaign sends through a custom channel, as
-- specified by the delivery configuration (CustomDeliveryConfiguration)
-- settings for the campaign. If specified, this message overrides the
-- default message.
messageConfiguration_customMessage :: Lens.Lens' MessageConfiguration (Prelude.Maybe CampaignCustomMessage)
messageConfiguration_customMessage :: (Maybe CampaignCustomMessage -> f (Maybe CampaignCustomMessage))
-> MessageConfiguration -> f MessageConfiguration
messageConfiguration_customMessage = (MessageConfiguration -> Maybe CampaignCustomMessage)
-> (MessageConfiguration
    -> Maybe CampaignCustomMessage -> MessageConfiguration)
-> Lens
     MessageConfiguration
     MessageConfiguration
     (Maybe CampaignCustomMessage)
     (Maybe CampaignCustomMessage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageConfiguration' {Maybe CampaignCustomMessage
customMessage :: Maybe CampaignCustomMessage
$sel:customMessage:MessageConfiguration' :: MessageConfiguration -> Maybe CampaignCustomMessage
customMessage} -> Maybe CampaignCustomMessage
customMessage) (\s :: MessageConfiguration
s@MessageConfiguration' {} Maybe CampaignCustomMessage
a -> MessageConfiguration
s {$sel:customMessage:MessageConfiguration' :: Maybe CampaignCustomMessage
customMessage = Maybe CampaignCustomMessage
a} :: MessageConfiguration)

-- | The message that the campaign sends through the ADM (Amazon Device
-- Messaging) channel. If specified, this message overrides the default
-- message.
messageConfiguration_aDMMessage :: Lens.Lens' MessageConfiguration (Prelude.Maybe Message)
messageConfiguration_aDMMessage :: (Maybe Message -> f (Maybe Message))
-> MessageConfiguration -> f MessageConfiguration
messageConfiguration_aDMMessage = (MessageConfiguration -> Maybe Message)
-> (MessageConfiguration -> Maybe Message -> MessageConfiguration)
-> Lens
     MessageConfiguration
     MessageConfiguration
     (Maybe Message)
     (Maybe Message)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageConfiguration' {Maybe Message
aDMMessage :: Maybe Message
$sel:aDMMessage:MessageConfiguration' :: MessageConfiguration -> Maybe Message
aDMMessage} -> Maybe Message
aDMMessage) (\s :: MessageConfiguration
s@MessageConfiguration' {} Maybe Message
a -> MessageConfiguration
s {$sel:aDMMessage:MessageConfiguration' :: Maybe Message
aDMMessage = Maybe Message
a} :: MessageConfiguration)

-- | The message that the campaign sends through the SMS channel. If
-- specified, this message overrides the default message.
messageConfiguration_sMSMessage :: Lens.Lens' MessageConfiguration (Prelude.Maybe CampaignSmsMessage)
messageConfiguration_sMSMessage :: (Maybe CampaignSmsMessage -> f (Maybe CampaignSmsMessage))
-> MessageConfiguration -> f MessageConfiguration
messageConfiguration_sMSMessage = (MessageConfiguration -> Maybe CampaignSmsMessage)
-> (MessageConfiguration
    -> Maybe CampaignSmsMessage -> MessageConfiguration)
-> Lens
     MessageConfiguration
     MessageConfiguration
     (Maybe CampaignSmsMessage)
     (Maybe CampaignSmsMessage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageConfiguration' {Maybe CampaignSmsMessage
sMSMessage :: Maybe CampaignSmsMessage
$sel:sMSMessage:MessageConfiguration' :: MessageConfiguration -> Maybe CampaignSmsMessage
sMSMessage} -> Maybe CampaignSmsMessage
sMSMessage) (\s :: MessageConfiguration
s@MessageConfiguration' {} Maybe CampaignSmsMessage
a -> MessageConfiguration
s {$sel:sMSMessage:MessageConfiguration' :: Maybe CampaignSmsMessage
sMSMessage = Maybe CampaignSmsMessage
a} :: MessageConfiguration)

-- | The message that the campaign sends through the email channel. If
-- specified, this message overrides the default message.
messageConfiguration_emailMessage :: Lens.Lens' MessageConfiguration (Prelude.Maybe CampaignEmailMessage)
messageConfiguration_emailMessage :: (Maybe CampaignEmailMessage -> f (Maybe CampaignEmailMessage))
-> MessageConfiguration -> f MessageConfiguration
messageConfiguration_emailMessage = (MessageConfiguration -> Maybe CampaignEmailMessage)
-> (MessageConfiguration
    -> Maybe CampaignEmailMessage -> MessageConfiguration)
-> Lens
     MessageConfiguration
     MessageConfiguration
     (Maybe CampaignEmailMessage)
     (Maybe CampaignEmailMessage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageConfiguration' {Maybe CampaignEmailMessage
emailMessage :: Maybe CampaignEmailMessage
$sel:emailMessage:MessageConfiguration' :: MessageConfiguration -> Maybe CampaignEmailMessage
emailMessage} -> Maybe CampaignEmailMessage
emailMessage) (\s :: MessageConfiguration
s@MessageConfiguration' {} Maybe CampaignEmailMessage
a -> MessageConfiguration
s {$sel:emailMessage:MessageConfiguration' :: Maybe CampaignEmailMessage
emailMessage = Maybe CampaignEmailMessage
a} :: MessageConfiguration)

-- | The in-app message configuration.
messageConfiguration_inAppMessage :: Lens.Lens' MessageConfiguration (Prelude.Maybe CampaignInAppMessage)
messageConfiguration_inAppMessage :: (Maybe CampaignInAppMessage -> f (Maybe CampaignInAppMessage))
-> MessageConfiguration -> f MessageConfiguration
messageConfiguration_inAppMessage = (MessageConfiguration -> Maybe CampaignInAppMessage)
-> (MessageConfiguration
    -> Maybe CampaignInAppMessage -> MessageConfiguration)
-> Lens
     MessageConfiguration
     MessageConfiguration
     (Maybe CampaignInAppMessage)
     (Maybe CampaignInAppMessage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageConfiguration' {Maybe CampaignInAppMessage
inAppMessage :: Maybe CampaignInAppMessage
$sel:inAppMessage:MessageConfiguration' :: MessageConfiguration -> Maybe CampaignInAppMessage
inAppMessage} -> Maybe CampaignInAppMessage
inAppMessage) (\s :: MessageConfiguration
s@MessageConfiguration' {} Maybe CampaignInAppMessage
a -> MessageConfiguration
s {$sel:inAppMessage:MessageConfiguration' :: Maybe CampaignInAppMessage
inAppMessage = Maybe CampaignInAppMessage
a} :: MessageConfiguration)

-- | The message that the campaign sends through the Baidu (Baidu Cloud Push)
-- channel. If specified, this message overrides the default message.
messageConfiguration_baiduMessage :: Lens.Lens' MessageConfiguration (Prelude.Maybe Message)
messageConfiguration_baiduMessage :: (Maybe Message -> f (Maybe Message))
-> MessageConfiguration -> f MessageConfiguration
messageConfiguration_baiduMessage = (MessageConfiguration -> Maybe Message)
-> (MessageConfiguration -> Maybe Message -> MessageConfiguration)
-> Lens
     MessageConfiguration
     MessageConfiguration
     (Maybe Message)
     (Maybe Message)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageConfiguration' {Maybe Message
baiduMessage :: Maybe Message
$sel:baiduMessage:MessageConfiguration' :: MessageConfiguration -> Maybe Message
baiduMessage} -> Maybe Message
baiduMessage) (\s :: MessageConfiguration
s@MessageConfiguration' {} Maybe Message
a -> MessageConfiguration
s {$sel:baiduMessage:MessageConfiguration' :: Maybe Message
baiduMessage = Maybe Message
a} :: MessageConfiguration)

instance Core.FromJSON MessageConfiguration where
  parseJSON :: Value -> Parser MessageConfiguration
parseJSON =
    String
-> (Object -> Parser MessageConfiguration)
-> Value
-> Parser MessageConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MessageConfiguration"
      ( \Object
x ->
          Maybe Message
-> Maybe Message
-> Maybe Message
-> Maybe CampaignCustomMessage
-> Maybe Message
-> Maybe CampaignSmsMessage
-> Maybe CampaignEmailMessage
-> Maybe CampaignInAppMessage
-> Maybe Message
-> MessageConfiguration
MessageConfiguration'
            (Maybe Message
 -> Maybe Message
 -> Maybe Message
 -> Maybe CampaignCustomMessage
 -> Maybe Message
 -> Maybe CampaignSmsMessage
 -> Maybe CampaignEmailMessage
 -> Maybe CampaignInAppMessage
 -> Maybe Message
 -> MessageConfiguration)
-> Parser (Maybe Message)
-> Parser
     (Maybe Message
      -> Maybe Message
      -> Maybe CampaignCustomMessage
      -> Maybe Message
      -> Maybe CampaignSmsMessage
      -> Maybe CampaignEmailMessage
      -> Maybe CampaignInAppMessage
      -> Maybe Message
      -> MessageConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Message)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"APNSMessage")
            Parser
  (Maybe Message
   -> Maybe Message
   -> Maybe CampaignCustomMessage
   -> Maybe Message
   -> Maybe CampaignSmsMessage
   -> Maybe CampaignEmailMessage
   -> Maybe CampaignInAppMessage
   -> Maybe Message
   -> MessageConfiguration)
-> Parser (Maybe Message)
-> Parser
     (Maybe Message
      -> Maybe CampaignCustomMessage
      -> Maybe Message
      -> Maybe CampaignSmsMessage
      -> Maybe CampaignEmailMessage
      -> Maybe CampaignInAppMessage
      -> Maybe Message
      -> MessageConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Message)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GCMMessage")
            Parser
  (Maybe Message
   -> Maybe CampaignCustomMessage
   -> Maybe Message
   -> Maybe CampaignSmsMessage
   -> Maybe CampaignEmailMessage
   -> Maybe CampaignInAppMessage
   -> Maybe Message
   -> MessageConfiguration)
-> Parser (Maybe Message)
-> Parser
     (Maybe CampaignCustomMessage
      -> Maybe Message
      -> Maybe CampaignSmsMessage
      -> Maybe CampaignEmailMessage
      -> Maybe CampaignInAppMessage
      -> Maybe Message
      -> MessageConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Message)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DefaultMessage")
            Parser
  (Maybe CampaignCustomMessage
   -> Maybe Message
   -> Maybe CampaignSmsMessage
   -> Maybe CampaignEmailMessage
   -> Maybe CampaignInAppMessage
   -> Maybe Message
   -> MessageConfiguration)
-> Parser (Maybe CampaignCustomMessage)
-> Parser
     (Maybe Message
      -> Maybe CampaignSmsMessage
      -> Maybe CampaignEmailMessage
      -> Maybe CampaignInAppMessage
      -> Maybe Message
      -> MessageConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CampaignCustomMessage)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CustomMessage")
            Parser
  (Maybe Message
   -> Maybe CampaignSmsMessage
   -> Maybe CampaignEmailMessage
   -> Maybe CampaignInAppMessage
   -> Maybe Message
   -> MessageConfiguration)
-> Parser (Maybe Message)
-> Parser
     (Maybe CampaignSmsMessage
      -> Maybe CampaignEmailMessage
      -> Maybe CampaignInAppMessage
      -> Maybe Message
      -> MessageConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Message)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ADMMessage")
            Parser
  (Maybe CampaignSmsMessage
   -> Maybe CampaignEmailMessage
   -> Maybe CampaignInAppMessage
   -> Maybe Message
   -> MessageConfiguration)
-> Parser (Maybe CampaignSmsMessage)
-> Parser
     (Maybe CampaignEmailMessage
      -> Maybe CampaignInAppMessage
      -> Maybe Message
      -> MessageConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CampaignSmsMessage)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SMSMessage")
            Parser
  (Maybe CampaignEmailMessage
   -> Maybe CampaignInAppMessage
   -> Maybe Message
   -> MessageConfiguration)
-> Parser (Maybe CampaignEmailMessage)
-> Parser
     (Maybe CampaignInAppMessage
      -> Maybe Message -> MessageConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CampaignEmailMessage)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EmailMessage")
            Parser
  (Maybe CampaignInAppMessage
   -> Maybe Message -> MessageConfiguration)
-> Parser (Maybe CampaignInAppMessage)
-> Parser (Maybe Message -> MessageConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CampaignInAppMessage)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InAppMessage")
            Parser (Maybe Message -> MessageConfiguration)
-> Parser (Maybe Message) -> Parser MessageConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Message)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BaiduMessage")
      )

instance Prelude.Hashable MessageConfiguration

instance Prelude.NFData MessageConfiguration

instance Core.ToJSON MessageConfiguration where
  toJSON :: MessageConfiguration -> Value
toJSON MessageConfiguration' {Maybe CampaignCustomMessage
Maybe CampaignEmailMessage
Maybe Message
Maybe CampaignSmsMessage
Maybe CampaignInAppMessage
baiduMessage :: Maybe Message
inAppMessage :: Maybe CampaignInAppMessage
emailMessage :: Maybe CampaignEmailMessage
sMSMessage :: Maybe CampaignSmsMessage
aDMMessage :: Maybe Message
customMessage :: Maybe CampaignCustomMessage
defaultMessage :: Maybe Message
gCMMessage :: Maybe Message
aPNSMessage :: Maybe Message
$sel:baiduMessage:MessageConfiguration' :: MessageConfiguration -> Maybe Message
$sel:inAppMessage:MessageConfiguration' :: MessageConfiguration -> Maybe CampaignInAppMessage
$sel:emailMessage:MessageConfiguration' :: MessageConfiguration -> Maybe CampaignEmailMessage
$sel:sMSMessage:MessageConfiguration' :: MessageConfiguration -> Maybe CampaignSmsMessage
$sel:aDMMessage:MessageConfiguration' :: MessageConfiguration -> Maybe Message
$sel:customMessage:MessageConfiguration' :: MessageConfiguration -> Maybe CampaignCustomMessage
$sel:defaultMessage:MessageConfiguration' :: MessageConfiguration -> Maybe Message
$sel:gCMMessage:MessageConfiguration' :: MessageConfiguration -> Maybe Message
$sel:aPNSMessage:MessageConfiguration' :: MessageConfiguration -> Maybe Message
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"APNSMessage" Text -> Message -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Message -> Pair) -> Maybe Message -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Message
aPNSMessage,
            (Text
"GCMMessage" Text -> Message -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Message -> Pair) -> Maybe Message -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Message
gCMMessage,
            (Text
"DefaultMessage" Text -> Message -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Message -> Pair) -> Maybe Message -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Message
defaultMessage,
            (Text
"CustomMessage" Text -> CampaignCustomMessage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CampaignCustomMessage -> Pair)
-> Maybe CampaignCustomMessage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CampaignCustomMessage
customMessage,
            (Text
"ADMMessage" Text -> Message -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Message -> Pair) -> Maybe Message -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Message
aDMMessage,
            (Text
"SMSMessage" Text -> CampaignSmsMessage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CampaignSmsMessage -> Pair)
-> Maybe CampaignSmsMessage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CampaignSmsMessage
sMSMessage,
            (Text
"EmailMessage" Text -> CampaignEmailMessage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CampaignEmailMessage -> Pair)
-> Maybe CampaignEmailMessage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CampaignEmailMessage
emailMessage,
            (Text
"InAppMessage" Text -> CampaignInAppMessage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CampaignInAppMessage -> Pair)
-> Maybe CampaignInAppMessage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CampaignInAppMessage
inAppMessage,
            (Text
"BaiduMessage" Text -> Message -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Message -> Pair) -> Maybe Message -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Message
baiduMessage
          ]
      )