{-# 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.SESV2.Types.BulkEmailEntry
-- 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.SESV2.Types.BulkEmailEntry where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SESV2.Types.Destination
import Amazonka.SESV2.Types.MessageTag
import Amazonka.SESV2.Types.ReplacementEmailContent

-- | /See:/ 'newBulkEmailEntry' smart constructor.
data BulkEmailEntry = BulkEmailEntry'
  { -- | The @ReplacementEmailContent@ associated with a @BulkEmailEntry@.
    BulkEmailEntry -> Maybe ReplacementEmailContent
replacementEmailContent :: Prelude.Maybe ReplacementEmailContent,
    -- | A list of tags, in the form of name\/value pairs, to apply to an email
    -- that you send using the @SendBulkTemplatedEmail@ operation. Tags
    -- correspond to characteristics of the email that you define, so that you
    -- can publish email sending events.
    BulkEmailEntry -> Maybe [MessageTag]
replacementTags :: Prelude.Maybe [MessageTag],
    -- | Represents the destination of the message, consisting of To:, CC:, and
    -- BCC: fields.
    --
    -- Amazon SES does not support the SMTPUTF8 extension, as described in
    -- <https://tools.ietf.org/html/rfc6531 RFC6531>. For this reason, the
    -- local part of a destination email address (the part of the email address
    -- that precedes the \@ sign) may only contain
    -- <https://en.wikipedia.org/wiki/Email_address#Local-part 7-bit ASCII characters>.
    -- If the domain part of an address (the part after the \@ sign) contains
    -- non-ASCII characters, they must be encoded using Punycode, as described
    -- in <https://tools.ietf.org/html/rfc3492.html RFC3492>.
    BulkEmailEntry -> Destination
destination :: Destination
  }
  deriving (BulkEmailEntry -> BulkEmailEntry -> Bool
(BulkEmailEntry -> BulkEmailEntry -> Bool)
-> (BulkEmailEntry -> BulkEmailEntry -> Bool) -> Eq BulkEmailEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BulkEmailEntry -> BulkEmailEntry -> Bool
$c/= :: BulkEmailEntry -> BulkEmailEntry -> Bool
== :: BulkEmailEntry -> BulkEmailEntry -> Bool
$c== :: BulkEmailEntry -> BulkEmailEntry -> Bool
Prelude.Eq, ReadPrec [BulkEmailEntry]
ReadPrec BulkEmailEntry
Int -> ReadS BulkEmailEntry
ReadS [BulkEmailEntry]
(Int -> ReadS BulkEmailEntry)
-> ReadS [BulkEmailEntry]
-> ReadPrec BulkEmailEntry
-> ReadPrec [BulkEmailEntry]
-> Read BulkEmailEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BulkEmailEntry]
$creadListPrec :: ReadPrec [BulkEmailEntry]
readPrec :: ReadPrec BulkEmailEntry
$creadPrec :: ReadPrec BulkEmailEntry
readList :: ReadS [BulkEmailEntry]
$creadList :: ReadS [BulkEmailEntry]
readsPrec :: Int -> ReadS BulkEmailEntry
$creadsPrec :: Int -> ReadS BulkEmailEntry
Prelude.Read, Int -> BulkEmailEntry -> ShowS
[BulkEmailEntry] -> ShowS
BulkEmailEntry -> String
(Int -> BulkEmailEntry -> ShowS)
-> (BulkEmailEntry -> String)
-> ([BulkEmailEntry] -> ShowS)
-> Show BulkEmailEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BulkEmailEntry] -> ShowS
$cshowList :: [BulkEmailEntry] -> ShowS
show :: BulkEmailEntry -> String
$cshow :: BulkEmailEntry -> String
showsPrec :: Int -> BulkEmailEntry -> ShowS
$cshowsPrec :: Int -> BulkEmailEntry -> ShowS
Prelude.Show, (forall x. BulkEmailEntry -> Rep BulkEmailEntry x)
-> (forall x. Rep BulkEmailEntry x -> BulkEmailEntry)
-> Generic BulkEmailEntry
forall x. Rep BulkEmailEntry x -> BulkEmailEntry
forall x. BulkEmailEntry -> Rep BulkEmailEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BulkEmailEntry x -> BulkEmailEntry
$cfrom :: forall x. BulkEmailEntry -> Rep BulkEmailEntry x
Prelude.Generic)

-- |
-- Create a value of 'BulkEmailEntry' 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:
--
-- 'replacementEmailContent', 'bulkEmailEntry_replacementEmailContent' - The @ReplacementEmailContent@ associated with a @BulkEmailEntry@.
--
-- 'replacementTags', 'bulkEmailEntry_replacementTags' - A list of tags, in the form of name\/value pairs, to apply to an email
-- that you send using the @SendBulkTemplatedEmail@ operation. Tags
-- correspond to characteristics of the email that you define, so that you
-- can publish email sending events.
--
-- 'destination', 'bulkEmailEntry_destination' - Represents the destination of the message, consisting of To:, CC:, and
-- BCC: fields.
--
-- Amazon SES does not support the SMTPUTF8 extension, as described in
-- <https://tools.ietf.org/html/rfc6531 RFC6531>. For this reason, the
-- local part of a destination email address (the part of the email address
-- that precedes the \@ sign) may only contain
-- <https://en.wikipedia.org/wiki/Email_address#Local-part 7-bit ASCII characters>.
-- If the domain part of an address (the part after the \@ sign) contains
-- non-ASCII characters, they must be encoded using Punycode, as described
-- in <https://tools.ietf.org/html/rfc3492.html RFC3492>.
newBulkEmailEntry ::
  -- | 'destination'
  Destination ->
  BulkEmailEntry
newBulkEmailEntry :: Destination -> BulkEmailEntry
newBulkEmailEntry Destination
pDestination_ =
  BulkEmailEntry' :: Maybe ReplacementEmailContent
-> Maybe [MessageTag] -> Destination -> BulkEmailEntry
BulkEmailEntry'
    { $sel:replacementEmailContent:BulkEmailEntry' :: Maybe ReplacementEmailContent
replacementEmailContent =
        Maybe ReplacementEmailContent
forall a. Maybe a
Prelude.Nothing,
      $sel:replacementTags:BulkEmailEntry' :: Maybe [MessageTag]
replacementTags = Maybe [MessageTag]
forall a. Maybe a
Prelude.Nothing,
      $sel:destination:BulkEmailEntry' :: Destination
destination = Destination
pDestination_
    }

-- | The @ReplacementEmailContent@ associated with a @BulkEmailEntry@.
bulkEmailEntry_replacementEmailContent :: Lens.Lens' BulkEmailEntry (Prelude.Maybe ReplacementEmailContent)
bulkEmailEntry_replacementEmailContent :: (Maybe ReplacementEmailContent
 -> f (Maybe ReplacementEmailContent))
-> BulkEmailEntry -> f BulkEmailEntry
bulkEmailEntry_replacementEmailContent = (BulkEmailEntry -> Maybe ReplacementEmailContent)
-> (BulkEmailEntry
    -> Maybe ReplacementEmailContent -> BulkEmailEntry)
-> Lens
     BulkEmailEntry
     BulkEmailEntry
     (Maybe ReplacementEmailContent)
     (Maybe ReplacementEmailContent)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BulkEmailEntry' {Maybe ReplacementEmailContent
replacementEmailContent :: Maybe ReplacementEmailContent
$sel:replacementEmailContent:BulkEmailEntry' :: BulkEmailEntry -> Maybe ReplacementEmailContent
replacementEmailContent} -> Maybe ReplacementEmailContent
replacementEmailContent) (\s :: BulkEmailEntry
s@BulkEmailEntry' {} Maybe ReplacementEmailContent
a -> BulkEmailEntry
s {$sel:replacementEmailContent:BulkEmailEntry' :: Maybe ReplacementEmailContent
replacementEmailContent = Maybe ReplacementEmailContent
a} :: BulkEmailEntry)

-- | A list of tags, in the form of name\/value pairs, to apply to an email
-- that you send using the @SendBulkTemplatedEmail@ operation. Tags
-- correspond to characteristics of the email that you define, so that you
-- can publish email sending events.
bulkEmailEntry_replacementTags :: Lens.Lens' BulkEmailEntry (Prelude.Maybe [MessageTag])
bulkEmailEntry_replacementTags :: (Maybe [MessageTag] -> f (Maybe [MessageTag]))
-> BulkEmailEntry -> f BulkEmailEntry
bulkEmailEntry_replacementTags = (BulkEmailEntry -> Maybe [MessageTag])
-> (BulkEmailEntry -> Maybe [MessageTag] -> BulkEmailEntry)
-> Lens
     BulkEmailEntry
     BulkEmailEntry
     (Maybe [MessageTag])
     (Maybe [MessageTag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BulkEmailEntry' {Maybe [MessageTag]
replacementTags :: Maybe [MessageTag]
$sel:replacementTags:BulkEmailEntry' :: BulkEmailEntry -> Maybe [MessageTag]
replacementTags} -> Maybe [MessageTag]
replacementTags) (\s :: BulkEmailEntry
s@BulkEmailEntry' {} Maybe [MessageTag]
a -> BulkEmailEntry
s {$sel:replacementTags:BulkEmailEntry' :: Maybe [MessageTag]
replacementTags = Maybe [MessageTag]
a} :: BulkEmailEntry) ((Maybe [MessageTag] -> f (Maybe [MessageTag]))
 -> BulkEmailEntry -> f BulkEmailEntry)
-> ((Maybe [MessageTag] -> f (Maybe [MessageTag]))
    -> Maybe [MessageTag] -> f (Maybe [MessageTag]))
-> (Maybe [MessageTag] -> f (Maybe [MessageTag]))
-> BulkEmailEntry
-> f BulkEmailEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [MessageTag] [MessageTag] [MessageTag] [MessageTag]
-> Iso
     (Maybe [MessageTag])
     (Maybe [MessageTag])
     (Maybe [MessageTag])
     (Maybe [MessageTag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [MessageTag] [MessageTag] [MessageTag] [MessageTag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Represents the destination of the message, consisting of To:, CC:, and
-- BCC: fields.
--
-- Amazon SES does not support the SMTPUTF8 extension, as described in
-- <https://tools.ietf.org/html/rfc6531 RFC6531>. For this reason, the
-- local part of a destination email address (the part of the email address
-- that precedes the \@ sign) may only contain
-- <https://en.wikipedia.org/wiki/Email_address#Local-part 7-bit ASCII characters>.
-- If the domain part of an address (the part after the \@ sign) contains
-- non-ASCII characters, they must be encoded using Punycode, as described
-- in <https://tools.ietf.org/html/rfc3492.html RFC3492>.
bulkEmailEntry_destination :: Lens.Lens' BulkEmailEntry Destination
bulkEmailEntry_destination :: (Destination -> f Destination)
-> BulkEmailEntry -> f BulkEmailEntry
bulkEmailEntry_destination = (BulkEmailEntry -> Destination)
-> (BulkEmailEntry -> Destination -> BulkEmailEntry)
-> Lens BulkEmailEntry BulkEmailEntry Destination Destination
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BulkEmailEntry' {Destination
destination :: Destination
$sel:destination:BulkEmailEntry' :: BulkEmailEntry -> Destination
destination} -> Destination
destination) (\s :: BulkEmailEntry
s@BulkEmailEntry' {} Destination
a -> BulkEmailEntry
s {$sel:destination:BulkEmailEntry' :: Destination
destination = Destination
a} :: BulkEmailEntry)

instance Prelude.Hashable BulkEmailEntry

instance Prelude.NFData BulkEmailEntry

instance Core.ToJSON BulkEmailEntry where
  toJSON :: BulkEmailEntry -> Value
toJSON BulkEmailEntry' {Maybe [MessageTag]
Maybe ReplacementEmailContent
Destination
destination :: Destination
replacementTags :: Maybe [MessageTag]
replacementEmailContent :: Maybe ReplacementEmailContent
$sel:destination:BulkEmailEntry' :: BulkEmailEntry -> Destination
$sel:replacementTags:BulkEmailEntry' :: BulkEmailEntry -> Maybe [MessageTag]
$sel:replacementEmailContent:BulkEmailEntry' :: BulkEmailEntry -> Maybe ReplacementEmailContent
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ReplacementEmailContent" Text -> ReplacementEmailContent -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ReplacementEmailContent -> Pair)
-> Maybe ReplacementEmailContent -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ReplacementEmailContent
replacementEmailContent,
            (Text
"ReplacementTags" Text -> [MessageTag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([MessageTag] -> Pair) -> Maybe [MessageTag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [MessageTag]
replacementTags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Destination" Text -> Destination -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Destination
destination)
          ]
      )