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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the content and \"From\" address for an email message that\'s
-- sent to recipients of a campaign.
--
-- /See:/ 'newCampaignEmailMessage' smart constructor.
data CampaignEmailMessage = CampaignEmailMessage'
  { -- | The body of the email for recipients whose email clients don\'t render
    -- HTML content.
    CampaignEmailMessage -> Maybe Text
body :: Prelude.Maybe Prelude.Text,
    -- | The verified email address to send the email from. The default address
    -- is the FromAddress specified for the email channel for the application.
    CampaignEmailMessage -> Maybe Text
fromAddress :: Prelude.Maybe Prelude.Text,
    -- | The body of the email, in HTML format, for recipients whose email
    -- clients render HTML content.
    CampaignEmailMessage -> Maybe Text
htmlBody :: Prelude.Maybe Prelude.Text,
    -- | The subject line, or title, of the email.
    CampaignEmailMessage -> Maybe Text
title :: Prelude.Maybe Prelude.Text
  }
  deriving (CampaignEmailMessage -> CampaignEmailMessage -> Bool
(CampaignEmailMessage -> CampaignEmailMessage -> Bool)
-> (CampaignEmailMessage -> CampaignEmailMessage -> Bool)
-> Eq CampaignEmailMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CampaignEmailMessage -> CampaignEmailMessage -> Bool
$c/= :: CampaignEmailMessage -> CampaignEmailMessage -> Bool
== :: CampaignEmailMessage -> CampaignEmailMessage -> Bool
$c== :: CampaignEmailMessage -> CampaignEmailMessage -> Bool
Prelude.Eq, ReadPrec [CampaignEmailMessage]
ReadPrec CampaignEmailMessage
Int -> ReadS CampaignEmailMessage
ReadS [CampaignEmailMessage]
(Int -> ReadS CampaignEmailMessage)
-> ReadS [CampaignEmailMessage]
-> ReadPrec CampaignEmailMessage
-> ReadPrec [CampaignEmailMessage]
-> Read CampaignEmailMessage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CampaignEmailMessage]
$creadListPrec :: ReadPrec [CampaignEmailMessage]
readPrec :: ReadPrec CampaignEmailMessage
$creadPrec :: ReadPrec CampaignEmailMessage
readList :: ReadS [CampaignEmailMessage]
$creadList :: ReadS [CampaignEmailMessage]
readsPrec :: Int -> ReadS CampaignEmailMessage
$creadsPrec :: Int -> ReadS CampaignEmailMessage
Prelude.Read, Int -> CampaignEmailMessage -> ShowS
[CampaignEmailMessage] -> ShowS
CampaignEmailMessage -> String
(Int -> CampaignEmailMessage -> ShowS)
-> (CampaignEmailMessage -> String)
-> ([CampaignEmailMessage] -> ShowS)
-> Show CampaignEmailMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CampaignEmailMessage] -> ShowS
$cshowList :: [CampaignEmailMessage] -> ShowS
show :: CampaignEmailMessage -> String
$cshow :: CampaignEmailMessage -> String
showsPrec :: Int -> CampaignEmailMessage -> ShowS
$cshowsPrec :: Int -> CampaignEmailMessage -> ShowS
Prelude.Show, (forall x. CampaignEmailMessage -> Rep CampaignEmailMessage x)
-> (forall x. Rep CampaignEmailMessage x -> CampaignEmailMessage)
-> Generic CampaignEmailMessage
forall x. Rep CampaignEmailMessage x -> CampaignEmailMessage
forall x. CampaignEmailMessage -> Rep CampaignEmailMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CampaignEmailMessage x -> CampaignEmailMessage
$cfrom :: forall x. CampaignEmailMessage -> Rep CampaignEmailMessage x
Prelude.Generic)

-- |
-- Create a value of 'CampaignEmailMessage' 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', 'campaignEmailMessage_body' - The body of the email for recipients whose email clients don\'t render
-- HTML content.
--
-- 'fromAddress', 'campaignEmailMessage_fromAddress' - The verified email address to send the email from. The default address
-- is the FromAddress specified for the email channel for the application.
--
-- 'htmlBody', 'campaignEmailMessage_htmlBody' - The body of the email, in HTML format, for recipients whose email
-- clients render HTML content.
--
-- 'title', 'campaignEmailMessage_title' - The subject line, or title, of the email.
newCampaignEmailMessage ::
  CampaignEmailMessage
newCampaignEmailMessage :: CampaignEmailMessage
newCampaignEmailMessage =
  CampaignEmailMessage' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> CampaignEmailMessage
CampaignEmailMessage'
    { $sel:body:CampaignEmailMessage' :: Maybe Text
body = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fromAddress:CampaignEmailMessage' :: Maybe Text
fromAddress = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:htmlBody:CampaignEmailMessage' :: Maybe Text
htmlBody = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:title:CampaignEmailMessage' :: Maybe Text
title = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The body of the email for recipients whose email clients don\'t render
-- HTML content.
campaignEmailMessage_body :: Lens.Lens' CampaignEmailMessage (Prelude.Maybe Prelude.Text)
campaignEmailMessage_body :: (Maybe Text -> f (Maybe Text))
-> CampaignEmailMessage -> f CampaignEmailMessage
campaignEmailMessage_body = (CampaignEmailMessage -> Maybe Text)
-> (CampaignEmailMessage -> Maybe Text -> CampaignEmailMessage)
-> Lens
     CampaignEmailMessage CampaignEmailMessage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignEmailMessage' {Maybe Text
body :: Maybe Text
$sel:body:CampaignEmailMessage' :: CampaignEmailMessage -> Maybe Text
body} -> Maybe Text
body) (\s :: CampaignEmailMessage
s@CampaignEmailMessage' {} Maybe Text
a -> CampaignEmailMessage
s {$sel:body:CampaignEmailMessage' :: Maybe Text
body = Maybe Text
a} :: CampaignEmailMessage)

-- | The verified email address to send the email from. The default address
-- is the FromAddress specified for the email channel for the application.
campaignEmailMessage_fromAddress :: Lens.Lens' CampaignEmailMessage (Prelude.Maybe Prelude.Text)
campaignEmailMessage_fromAddress :: (Maybe Text -> f (Maybe Text))
-> CampaignEmailMessage -> f CampaignEmailMessage
campaignEmailMessage_fromAddress = (CampaignEmailMessage -> Maybe Text)
-> (CampaignEmailMessage -> Maybe Text -> CampaignEmailMessage)
-> Lens
     CampaignEmailMessage CampaignEmailMessage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignEmailMessage' {Maybe Text
fromAddress :: Maybe Text
$sel:fromAddress:CampaignEmailMessage' :: CampaignEmailMessage -> Maybe Text
fromAddress} -> Maybe Text
fromAddress) (\s :: CampaignEmailMessage
s@CampaignEmailMessage' {} Maybe Text
a -> CampaignEmailMessage
s {$sel:fromAddress:CampaignEmailMessage' :: Maybe Text
fromAddress = Maybe Text
a} :: CampaignEmailMessage)

-- | The body of the email, in HTML format, for recipients whose email
-- clients render HTML content.
campaignEmailMessage_htmlBody :: Lens.Lens' CampaignEmailMessage (Prelude.Maybe Prelude.Text)
campaignEmailMessage_htmlBody :: (Maybe Text -> f (Maybe Text))
-> CampaignEmailMessage -> f CampaignEmailMessage
campaignEmailMessage_htmlBody = (CampaignEmailMessage -> Maybe Text)
-> (CampaignEmailMessage -> Maybe Text -> CampaignEmailMessage)
-> Lens
     CampaignEmailMessage CampaignEmailMessage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignEmailMessage' {Maybe Text
htmlBody :: Maybe Text
$sel:htmlBody:CampaignEmailMessage' :: CampaignEmailMessage -> Maybe Text
htmlBody} -> Maybe Text
htmlBody) (\s :: CampaignEmailMessage
s@CampaignEmailMessage' {} Maybe Text
a -> CampaignEmailMessage
s {$sel:htmlBody:CampaignEmailMessage' :: Maybe Text
htmlBody = Maybe Text
a} :: CampaignEmailMessage)

-- | The subject line, or title, of the email.
campaignEmailMessage_title :: Lens.Lens' CampaignEmailMessage (Prelude.Maybe Prelude.Text)
campaignEmailMessage_title :: (Maybe Text -> f (Maybe Text))
-> CampaignEmailMessage -> f CampaignEmailMessage
campaignEmailMessage_title = (CampaignEmailMessage -> Maybe Text)
-> (CampaignEmailMessage -> Maybe Text -> CampaignEmailMessage)
-> Lens
     CampaignEmailMessage CampaignEmailMessage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CampaignEmailMessage' {Maybe Text
title :: Maybe Text
$sel:title:CampaignEmailMessage' :: CampaignEmailMessage -> Maybe Text
title} -> Maybe Text
title) (\s :: CampaignEmailMessage
s@CampaignEmailMessage' {} Maybe Text
a -> CampaignEmailMessage
s {$sel:title:CampaignEmailMessage' :: Maybe Text
title = Maybe Text
a} :: CampaignEmailMessage)

instance Core.FromJSON CampaignEmailMessage where
  parseJSON :: Value -> Parser CampaignEmailMessage
parseJSON =
    String
-> (Object -> Parser CampaignEmailMessage)
-> Value
-> Parser CampaignEmailMessage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CampaignEmailMessage"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> CampaignEmailMessage
CampaignEmailMessage'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> CampaignEmailMessage)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> CampaignEmailMessage)
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 Text -> CampaignEmailMessage)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> CampaignEmailMessage)
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
"FromAddress")
            Parser (Maybe Text -> Maybe Text -> CampaignEmailMessage)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> CampaignEmailMessage)
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
"HtmlBody")
            Parser (Maybe Text -> CampaignEmailMessage)
-> Parser (Maybe Text) -> Parser CampaignEmailMessage
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 CampaignEmailMessage

instance Prelude.NFData CampaignEmailMessage

instance Core.ToJSON CampaignEmailMessage where
  toJSON :: CampaignEmailMessage -> Value
toJSON CampaignEmailMessage' {Maybe Text
title :: Maybe Text
htmlBody :: Maybe Text
fromAddress :: Maybe Text
body :: Maybe Text
$sel:title:CampaignEmailMessage' :: CampaignEmailMessage -> Maybe Text
$sel:htmlBody:CampaignEmailMessage' :: CampaignEmailMessage -> Maybe Text
$sel:fromAddress:CampaignEmailMessage' :: CampaignEmailMessage -> Maybe Text
$sel:body:CampaignEmailMessage' :: CampaignEmailMessage -> 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
"FromAddress" 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
fromAddress,
            (Text
"HtmlBody" 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
htmlBody,
            (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
          ]
      )