{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.SendEmail
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Sends an email message. You can use the Amazon SES API v2 to send the
-- following types of messages:
--
-- -   __Simple__ – A standard email message. When you create this type of
--     message, you specify the sender, the recipient, and the message
--     body, and Amazon SES assembles the message for you.
--
-- -   __Raw__ – A raw, MIME-formatted email message. When you send this
--     type of email, you have to specify all of the message headers, as
--     well as the message body. You can use this message type to send
--     messages that contain attachments. The message that you specify has
--     to be a valid MIME message.
--
-- -   __Templated__ – A message that contains personalization tags. When
--     you send this type of email, Amazon SES API v2 automatically
--     replaces the tags with values that you specify.
module Amazonka.SESV2.SendEmail
  ( -- * Creating a Request
    SendEmail (..),
    newSendEmail,

    -- * Request Lenses
    sendEmail_configurationSetName,
    sendEmail_destination,
    sendEmail_emailTags,
    sendEmail_feedbackForwardingEmailAddress,
    sendEmail_feedbackForwardingEmailAddressIdentityArn,
    sendEmail_fromEmailAddress,
    sendEmail_fromEmailAddressIdentityArn,
    sendEmail_listManagementOptions,
    sendEmail_replyToAddresses,
    sendEmail_content,

    -- * Destructuring the Response
    SendEmailResponse (..),
    newSendEmailResponse,

    -- * Response Lenses
    sendEmailResponse_messageId,
    sendEmailResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SESV2.Types

-- | Represents a request to send a single formatted email using Amazon SES.
-- For more information, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-formatted.html Amazon SES Developer Guide>.
--
-- /See:/ 'newSendEmail' smart constructor.
data SendEmail = SendEmail'
  { -- | The name of the configuration set to use when sending the email.
    SendEmail -> Maybe Text
configurationSetName :: Prelude.Maybe Prelude.Text,
    -- | An object that contains the recipients of the email message.
    SendEmail -> Maybe Destination
destination :: Prelude.Maybe Destination,
    -- | A list of tags, in the form of name\/value pairs, to apply to an email
    -- that you send using the @SendEmail@ operation. Tags correspond to
    -- characteristics of the email that you define, so that you can publish
    -- email sending events.
    SendEmail -> Maybe [MessageTag]
emailTags :: Prelude.Maybe [MessageTag],
    -- | The address that you want bounce and complaint notifications to be sent
    -- to.
    SendEmail -> Maybe Text
feedbackForwardingEmailAddress :: Prelude.Maybe Prelude.Text,
    -- | This parameter is used only for sending authorization. It is the ARN of
    -- the identity that is associated with the sending authorization policy
    -- that permits you to use the email address specified in the
    -- @FeedbackForwardingEmailAddress@ parameter.
    --
    -- For example, if the owner of example.com (which has ARN
    -- arn:aws:ses:us-east-1:123456789012:identity\/example.com) attaches a
    -- policy to it that authorizes you to use feedback\@example.com, then you
    -- would specify the @FeedbackForwardingEmailAddressIdentityArn@ to be
    -- arn:aws:ses:us-east-1:123456789012:identity\/example.com, and the
    -- @FeedbackForwardingEmailAddress@ to be feedback\@example.com.
    --
    -- For more information about sending authorization, see the
    -- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
    SendEmail -> Maybe Text
feedbackForwardingEmailAddressIdentityArn :: Prelude.Maybe Prelude.Text,
    -- | The email address to use as the \"From\" address for the email. The
    -- address that you specify has to be verified.
    SendEmail -> Maybe Text
fromEmailAddress :: Prelude.Maybe Prelude.Text,
    -- | This parameter is used only for sending authorization. It is the ARN of
    -- the identity that is associated with the sending authorization policy
    -- that permits you to use the email address specified in the
    -- @FromEmailAddress@ parameter.
    --
    -- For example, if the owner of example.com (which has ARN
    -- arn:aws:ses:us-east-1:123456789012:identity\/example.com) attaches a
    -- policy to it that authorizes you to use sender\@example.com, then you
    -- would specify the @FromEmailAddressIdentityArn@ to be
    -- arn:aws:ses:us-east-1:123456789012:identity\/example.com, and the
    -- @FromEmailAddress@ to be sender\@example.com.
    --
    -- For more information about sending authorization, see the
    -- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
    --
    -- For Raw emails, the @FromEmailAddressIdentityArn@ value overrides the
    -- X-SES-SOURCE-ARN and X-SES-FROM-ARN headers specified in raw email
    -- message content.
    SendEmail -> Maybe Text
fromEmailAddressIdentityArn :: Prelude.Maybe Prelude.Text,
    -- | An object used to specify a list or topic to which an email belongs,
    -- which will be used when a contact chooses to unsubscribe.
    SendEmail -> Maybe ListManagementOptions
listManagementOptions :: Prelude.Maybe ListManagementOptions,
    -- | The \"Reply-to\" email addresses for the message. When the recipient
    -- replies to the message, each Reply-to address receives the reply.
    SendEmail -> Maybe [Text]
replyToAddresses :: Prelude.Maybe [Prelude.Text],
    -- | An object that contains the body of the message. You can send either a
    -- Simple message Raw message or a template Message.
    SendEmail -> EmailContent
content :: EmailContent
  }
  deriving (SendEmail -> SendEmail -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendEmail -> SendEmail -> Bool
$c/= :: SendEmail -> SendEmail -> Bool
== :: SendEmail -> SendEmail -> Bool
$c== :: SendEmail -> SendEmail -> Bool
Prelude.Eq, ReadPrec [SendEmail]
ReadPrec SendEmail
Int -> ReadS SendEmail
ReadS [SendEmail]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendEmail]
$creadListPrec :: ReadPrec [SendEmail]
readPrec :: ReadPrec SendEmail
$creadPrec :: ReadPrec SendEmail
readList :: ReadS [SendEmail]
$creadList :: ReadS [SendEmail]
readsPrec :: Int -> ReadS SendEmail
$creadsPrec :: Int -> ReadS SendEmail
Prelude.Read, Int -> SendEmail -> ShowS
[SendEmail] -> ShowS
SendEmail -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendEmail] -> ShowS
$cshowList :: [SendEmail] -> ShowS
show :: SendEmail -> String
$cshow :: SendEmail -> String
showsPrec :: Int -> SendEmail -> ShowS
$cshowsPrec :: Int -> SendEmail -> ShowS
Prelude.Show, forall x. Rep SendEmail x -> SendEmail
forall x. SendEmail -> Rep SendEmail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendEmail x -> SendEmail
$cfrom :: forall x. SendEmail -> Rep SendEmail x
Prelude.Generic)

-- |
-- Create a value of 'SendEmail' 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:
--
-- 'configurationSetName', 'sendEmail_configurationSetName' - The name of the configuration set to use when sending the email.
--
-- 'destination', 'sendEmail_destination' - An object that contains the recipients of the email message.
--
-- 'emailTags', 'sendEmail_emailTags' - A list of tags, in the form of name\/value pairs, to apply to an email
-- that you send using the @SendEmail@ operation. Tags correspond to
-- characteristics of the email that you define, so that you can publish
-- email sending events.
--
-- 'feedbackForwardingEmailAddress', 'sendEmail_feedbackForwardingEmailAddress' - The address that you want bounce and complaint notifications to be sent
-- to.
--
-- 'feedbackForwardingEmailAddressIdentityArn', 'sendEmail_feedbackForwardingEmailAddressIdentityArn' - This parameter is used only for sending authorization. It is the ARN of
-- the identity that is associated with the sending authorization policy
-- that permits you to use the email address specified in the
-- @FeedbackForwardingEmailAddress@ parameter.
--
-- For example, if the owner of example.com (which has ARN
-- arn:aws:ses:us-east-1:123456789012:identity\/example.com) attaches a
-- policy to it that authorizes you to use feedback\@example.com, then you
-- would specify the @FeedbackForwardingEmailAddressIdentityArn@ to be
-- arn:aws:ses:us-east-1:123456789012:identity\/example.com, and the
-- @FeedbackForwardingEmailAddress@ to be feedback\@example.com.
--
-- For more information about sending authorization, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
--
-- 'fromEmailAddress', 'sendEmail_fromEmailAddress' - The email address to use as the \"From\" address for the email. The
-- address that you specify has to be verified.
--
-- 'fromEmailAddressIdentityArn', 'sendEmail_fromEmailAddressIdentityArn' - This parameter is used only for sending authorization. It is the ARN of
-- the identity that is associated with the sending authorization policy
-- that permits you to use the email address specified in the
-- @FromEmailAddress@ parameter.
--
-- For example, if the owner of example.com (which has ARN
-- arn:aws:ses:us-east-1:123456789012:identity\/example.com) attaches a
-- policy to it that authorizes you to use sender\@example.com, then you
-- would specify the @FromEmailAddressIdentityArn@ to be
-- arn:aws:ses:us-east-1:123456789012:identity\/example.com, and the
-- @FromEmailAddress@ to be sender\@example.com.
--
-- For more information about sending authorization, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
--
-- For Raw emails, the @FromEmailAddressIdentityArn@ value overrides the
-- X-SES-SOURCE-ARN and X-SES-FROM-ARN headers specified in raw email
-- message content.
--
-- 'listManagementOptions', 'sendEmail_listManagementOptions' - An object used to specify a list or topic to which an email belongs,
-- which will be used when a contact chooses to unsubscribe.
--
-- 'replyToAddresses', 'sendEmail_replyToAddresses' - The \"Reply-to\" email addresses for the message. When the recipient
-- replies to the message, each Reply-to address receives the reply.
--
-- 'content', 'sendEmail_content' - An object that contains the body of the message. You can send either a
-- Simple message Raw message or a template Message.
newSendEmail ::
  -- | 'content'
  EmailContent ->
  SendEmail
newSendEmail :: EmailContent -> SendEmail
newSendEmail EmailContent
pContent_ =
  SendEmail'
    { $sel:configurationSetName:SendEmail' :: Maybe Text
configurationSetName = forall a. Maybe a
Prelude.Nothing,
      $sel:destination:SendEmail' :: Maybe Destination
destination = forall a. Maybe a
Prelude.Nothing,
      $sel:emailTags:SendEmail' :: Maybe [MessageTag]
emailTags = forall a. Maybe a
Prelude.Nothing,
      $sel:feedbackForwardingEmailAddress:SendEmail' :: Maybe Text
feedbackForwardingEmailAddress = forall a. Maybe a
Prelude.Nothing,
      $sel:feedbackForwardingEmailAddressIdentityArn:SendEmail' :: Maybe Text
feedbackForwardingEmailAddressIdentityArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:fromEmailAddress:SendEmail' :: Maybe Text
fromEmailAddress = forall a. Maybe a
Prelude.Nothing,
      $sel:fromEmailAddressIdentityArn:SendEmail' :: Maybe Text
fromEmailAddressIdentityArn = forall a. Maybe a
Prelude.Nothing,
      $sel:listManagementOptions:SendEmail' :: Maybe ListManagementOptions
listManagementOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:replyToAddresses:SendEmail' :: Maybe [Text]
replyToAddresses = forall a. Maybe a
Prelude.Nothing,
      $sel:content:SendEmail' :: EmailContent
content = EmailContent
pContent_
    }

-- | The name of the configuration set to use when sending the email.
sendEmail_configurationSetName :: Lens.Lens' SendEmail (Prelude.Maybe Prelude.Text)
sendEmail_configurationSetName :: Lens' SendEmail (Maybe Text)
sendEmail_configurationSetName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe Text
configurationSetName :: Maybe Text
$sel:configurationSetName:SendEmail' :: SendEmail -> Maybe Text
configurationSetName} -> Maybe Text
configurationSetName) (\s :: SendEmail
s@SendEmail' {} Maybe Text
a -> SendEmail
s {$sel:configurationSetName:SendEmail' :: Maybe Text
configurationSetName = Maybe Text
a} :: SendEmail)

-- | An object that contains the recipients of the email message.
sendEmail_destination :: Lens.Lens' SendEmail (Prelude.Maybe Destination)
sendEmail_destination :: Lens' SendEmail (Maybe Destination)
sendEmail_destination = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe Destination
destination :: Maybe Destination
$sel:destination:SendEmail' :: SendEmail -> Maybe Destination
destination} -> Maybe Destination
destination) (\s :: SendEmail
s@SendEmail' {} Maybe Destination
a -> SendEmail
s {$sel:destination:SendEmail' :: Maybe Destination
destination = Maybe Destination
a} :: SendEmail)

-- | A list of tags, in the form of name\/value pairs, to apply to an email
-- that you send using the @SendEmail@ operation. Tags correspond to
-- characteristics of the email that you define, so that you can publish
-- email sending events.
sendEmail_emailTags :: Lens.Lens' SendEmail (Prelude.Maybe [MessageTag])
sendEmail_emailTags :: Lens' SendEmail (Maybe [MessageTag])
sendEmail_emailTags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe [MessageTag]
emailTags :: Maybe [MessageTag]
$sel:emailTags:SendEmail' :: SendEmail -> Maybe [MessageTag]
emailTags} -> Maybe [MessageTag]
emailTags) (\s :: SendEmail
s@SendEmail' {} Maybe [MessageTag]
a -> SendEmail
s {$sel:emailTags:SendEmail' :: Maybe [MessageTag]
emailTags = Maybe [MessageTag]
a} :: SendEmail) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The address that you want bounce and complaint notifications to be sent
-- to.
sendEmail_feedbackForwardingEmailAddress :: Lens.Lens' SendEmail (Prelude.Maybe Prelude.Text)
sendEmail_feedbackForwardingEmailAddress :: Lens' SendEmail (Maybe Text)
sendEmail_feedbackForwardingEmailAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe Text
feedbackForwardingEmailAddress :: Maybe Text
$sel:feedbackForwardingEmailAddress:SendEmail' :: SendEmail -> Maybe Text
feedbackForwardingEmailAddress} -> Maybe Text
feedbackForwardingEmailAddress) (\s :: SendEmail
s@SendEmail' {} Maybe Text
a -> SendEmail
s {$sel:feedbackForwardingEmailAddress:SendEmail' :: Maybe Text
feedbackForwardingEmailAddress = Maybe Text
a} :: SendEmail)

-- | This parameter is used only for sending authorization. It is the ARN of
-- the identity that is associated with the sending authorization policy
-- that permits you to use the email address specified in the
-- @FeedbackForwardingEmailAddress@ parameter.
--
-- For example, if the owner of example.com (which has ARN
-- arn:aws:ses:us-east-1:123456789012:identity\/example.com) attaches a
-- policy to it that authorizes you to use feedback\@example.com, then you
-- would specify the @FeedbackForwardingEmailAddressIdentityArn@ to be
-- arn:aws:ses:us-east-1:123456789012:identity\/example.com, and the
-- @FeedbackForwardingEmailAddress@ to be feedback\@example.com.
--
-- For more information about sending authorization, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
sendEmail_feedbackForwardingEmailAddressIdentityArn :: Lens.Lens' SendEmail (Prelude.Maybe Prelude.Text)
sendEmail_feedbackForwardingEmailAddressIdentityArn :: Lens' SendEmail (Maybe Text)
sendEmail_feedbackForwardingEmailAddressIdentityArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe Text
feedbackForwardingEmailAddressIdentityArn :: Maybe Text
$sel:feedbackForwardingEmailAddressIdentityArn:SendEmail' :: SendEmail -> Maybe Text
feedbackForwardingEmailAddressIdentityArn} -> Maybe Text
feedbackForwardingEmailAddressIdentityArn) (\s :: SendEmail
s@SendEmail' {} Maybe Text
a -> SendEmail
s {$sel:feedbackForwardingEmailAddressIdentityArn:SendEmail' :: Maybe Text
feedbackForwardingEmailAddressIdentityArn = Maybe Text
a} :: SendEmail)

-- | The email address to use as the \"From\" address for the email. The
-- address that you specify has to be verified.
sendEmail_fromEmailAddress :: Lens.Lens' SendEmail (Prelude.Maybe Prelude.Text)
sendEmail_fromEmailAddress :: Lens' SendEmail (Maybe Text)
sendEmail_fromEmailAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe Text
fromEmailAddress :: Maybe Text
$sel:fromEmailAddress:SendEmail' :: SendEmail -> Maybe Text
fromEmailAddress} -> Maybe Text
fromEmailAddress) (\s :: SendEmail
s@SendEmail' {} Maybe Text
a -> SendEmail
s {$sel:fromEmailAddress:SendEmail' :: Maybe Text
fromEmailAddress = Maybe Text
a} :: SendEmail)

-- | This parameter is used only for sending authorization. It is the ARN of
-- the identity that is associated with the sending authorization policy
-- that permits you to use the email address specified in the
-- @FromEmailAddress@ parameter.
--
-- For example, if the owner of example.com (which has ARN
-- arn:aws:ses:us-east-1:123456789012:identity\/example.com) attaches a
-- policy to it that authorizes you to use sender\@example.com, then you
-- would specify the @FromEmailAddressIdentityArn@ to be
-- arn:aws:ses:us-east-1:123456789012:identity\/example.com, and the
-- @FromEmailAddress@ to be sender\@example.com.
--
-- For more information about sending authorization, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
--
-- For Raw emails, the @FromEmailAddressIdentityArn@ value overrides the
-- X-SES-SOURCE-ARN and X-SES-FROM-ARN headers specified in raw email
-- message content.
sendEmail_fromEmailAddressIdentityArn :: Lens.Lens' SendEmail (Prelude.Maybe Prelude.Text)
sendEmail_fromEmailAddressIdentityArn :: Lens' SendEmail (Maybe Text)
sendEmail_fromEmailAddressIdentityArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe Text
fromEmailAddressIdentityArn :: Maybe Text
$sel:fromEmailAddressIdentityArn:SendEmail' :: SendEmail -> Maybe Text
fromEmailAddressIdentityArn} -> Maybe Text
fromEmailAddressIdentityArn) (\s :: SendEmail
s@SendEmail' {} Maybe Text
a -> SendEmail
s {$sel:fromEmailAddressIdentityArn:SendEmail' :: Maybe Text
fromEmailAddressIdentityArn = Maybe Text
a} :: SendEmail)

-- | An object used to specify a list or topic to which an email belongs,
-- which will be used when a contact chooses to unsubscribe.
sendEmail_listManagementOptions :: Lens.Lens' SendEmail (Prelude.Maybe ListManagementOptions)
sendEmail_listManagementOptions :: Lens' SendEmail (Maybe ListManagementOptions)
sendEmail_listManagementOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe ListManagementOptions
listManagementOptions :: Maybe ListManagementOptions
$sel:listManagementOptions:SendEmail' :: SendEmail -> Maybe ListManagementOptions
listManagementOptions} -> Maybe ListManagementOptions
listManagementOptions) (\s :: SendEmail
s@SendEmail' {} Maybe ListManagementOptions
a -> SendEmail
s {$sel:listManagementOptions:SendEmail' :: Maybe ListManagementOptions
listManagementOptions = Maybe ListManagementOptions
a} :: SendEmail)

-- | The \"Reply-to\" email addresses for the message. When the recipient
-- replies to the message, each Reply-to address receives the reply.
sendEmail_replyToAddresses :: Lens.Lens' SendEmail (Prelude.Maybe [Prelude.Text])
sendEmail_replyToAddresses :: Lens' SendEmail (Maybe [Text])
sendEmail_replyToAddresses = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {Maybe [Text]
replyToAddresses :: Maybe [Text]
$sel:replyToAddresses:SendEmail' :: SendEmail -> Maybe [Text]
replyToAddresses} -> Maybe [Text]
replyToAddresses) (\s :: SendEmail
s@SendEmail' {} Maybe [Text]
a -> SendEmail
s {$sel:replyToAddresses:SendEmail' :: Maybe [Text]
replyToAddresses = Maybe [Text]
a} :: SendEmail) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An object that contains the body of the message. You can send either a
-- Simple message Raw message or a template Message.
sendEmail_content :: Lens.Lens' SendEmail EmailContent
sendEmail_content :: Lens' SendEmail EmailContent
sendEmail_content = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmail' {EmailContent
content :: EmailContent
$sel:content:SendEmail' :: SendEmail -> EmailContent
content} -> EmailContent
content) (\s :: SendEmail
s@SendEmail' {} EmailContent
a -> SendEmail
s {$sel:content:SendEmail' :: EmailContent
content = EmailContent
a} :: SendEmail)

instance Core.AWSRequest SendEmail where
  type AWSResponse SendEmail = SendEmailResponse
  request :: (Service -> Service) -> SendEmail -> Request SendEmail
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy SendEmail
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendEmail)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> SendEmailResponse
SendEmailResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"MessageId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable SendEmail where
  hashWithSalt :: Int -> SendEmail -> Int
hashWithSalt Int
_salt SendEmail' {Maybe [Text]
Maybe [MessageTag]
Maybe Text
Maybe Destination
Maybe ListManagementOptions
EmailContent
content :: EmailContent
replyToAddresses :: Maybe [Text]
listManagementOptions :: Maybe ListManagementOptions
fromEmailAddressIdentityArn :: Maybe Text
fromEmailAddress :: Maybe Text
feedbackForwardingEmailAddressIdentityArn :: Maybe Text
feedbackForwardingEmailAddress :: Maybe Text
emailTags :: Maybe [MessageTag]
destination :: Maybe Destination
configurationSetName :: Maybe Text
$sel:content:SendEmail' :: SendEmail -> EmailContent
$sel:replyToAddresses:SendEmail' :: SendEmail -> Maybe [Text]
$sel:listManagementOptions:SendEmail' :: SendEmail -> Maybe ListManagementOptions
$sel:fromEmailAddressIdentityArn:SendEmail' :: SendEmail -> Maybe Text
$sel:fromEmailAddress:SendEmail' :: SendEmail -> Maybe Text
$sel:feedbackForwardingEmailAddressIdentityArn:SendEmail' :: SendEmail -> Maybe Text
$sel:feedbackForwardingEmailAddress:SendEmail' :: SendEmail -> Maybe Text
$sel:emailTags:SendEmail' :: SendEmail -> Maybe [MessageTag]
$sel:destination:SendEmail' :: SendEmail -> Maybe Destination
$sel:configurationSetName:SendEmail' :: SendEmail -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
configurationSetName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Destination
destination
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [MessageTag]
emailTags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
feedbackForwardingEmailAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
feedbackForwardingEmailAddressIdentityArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
fromEmailAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
fromEmailAddressIdentityArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ListManagementOptions
listManagementOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
replyToAddresses
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EmailContent
content

instance Prelude.NFData SendEmail where
  rnf :: SendEmail -> ()
rnf SendEmail' {Maybe [Text]
Maybe [MessageTag]
Maybe Text
Maybe Destination
Maybe ListManagementOptions
EmailContent
content :: EmailContent
replyToAddresses :: Maybe [Text]
listManagementOptions :: Maybe ListManagementOptions
fromEmailAddressIdentityArn :: Maybe Text
fromEmailAddress :: Maybe Text
feedbackForwardingEmailAddressIdentityArn :: Maybe Text
feedbackForwardingEmailAddress :: Maybe Text
emailTags :: Maybe [MessageTag]
destination :: Maybe Destination
configurationSetName :: Maybe Text
$sel:content:SendEmail' :: SendEmail -> EmailContent
$sel:replyToAddresses:SendEmail' :: SendEmail -> Maybe [Text]
$sel:listManagementOptions:SendEmail' :: SendEmail -> Maybe ListManagementOptions
$sel:fromEmailAddressIdentityArn:SendEmail' :: SendEmail -> Maybe Text
$sel:fromEmailAddress:SendEmail' :: SendEmail -> Maybe Text
$sel:feedbackForwardingEmailAddressIdentityArn:SendEmail' :: SendEmail -> Maybe Text
$sel:feedbackForwardingEmailAddress:SendEmail' :: SendEmail -> Maybe Text
$sel:emailTags:SendEmail' :: SendEmail -> Maybe [MessageTag]
$sel:destination:SendEmail' :: SendEmail -> Maybe Destination
$sel:configurationSetName:SendEmail' :: SendEmail -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
configurationSetName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Destination
destination
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [MessageTag]
emailTags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
feedbackForwardingEmailAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
feedbackForwardingEmailAddressIdentityArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fromEmailAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fromEmailAddressIdentityArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ListManagementOptions
listManagementOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
replyToAddresses
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EmailContent
content

instance Data.ToHeaders SendEmail where
  toHeaders :: SendEmail -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON SendEmail where
  toJSON :: SendEmail -> Value
toJSON SendEmail' {Maybe [Text]
Maybe [MessageTag]
Maybe Text
Maybe Destination
Maybe ListManagementOptions
EmailContent
content :: EmailContent
replyToAddresses :: Maybe [Text]
listManagementOptions :: Maybe ListManagementOptions
fromEmailAddressIdentityArn :: Maybe Text
fromEmailAddress :: Maybe Text
feedbackForwardingEmailAddressIdentityArn :: Maybe Text
feedbackForwardingEmailAddress :: Maybe Text
emailTags :: Maybe [MessageTag]
destination :: Maybe Destination
configurationSetName :: Maybe Text
$sel:content:SendEmail' :: SendEmail -> EmailContent
$sel:replyToAddresses:SendEmail' :: SendEmail -> Maybe [Text]
$sel:listManagementOptions:SendEmail' :: SendEmail -> Maybe ListManagementOptions
$sel:fromEmailAddressIdentityArn:SendEmail' :: SendEmail -> Maybe Text
$sel:fromEmailAddress:SendEmail' :: SendEmail -> Maybe Text
$sel:feedbackForwardingEmailAddressIdentityArn:SendEmail' :: SendEmail -> Maybe Text
$sel:feedbackForwardingEmailAddress:SendEmail' :: SendEmail -> Maybe Text
$sel:emailTags:SendEmail' :: SendEmail -> Maybe [MessageTag]
$sel:destination:SendEmail' :: SendEmail -> Maybe Destination
$sel:configurationSetName:SendEmail' :: SendEmail -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ConfigurationSetName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
configurationSetName,
            (Key
"Destination" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Destination
destination,
            (Key
"EmailTags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [MessageTag]
emailTags,
            (Key
"FeedbackForwardingEmailAddress" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
feedbackForwardingEmailAddress,
            (Key
"FeedbackForwardingEmailAddressIdentityArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
feedbackForwardingEmailAddressIdentityArn,
            (Key
"FromEmailAddress" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
fromEmailAddress,
            (Key
"FromEmailAddressIdentityArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
fromEmailAddressIdentityArn,
            (Key
"ListManagementOptions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ListManagementOptions
listManagementOptions,
            (Key
"ReplyToAddresses" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
replyToAddresses,
            forall a. a -> Maybe a
Prelude.Just (Key
"Content" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= EmailContent
content)
          ]
      )

instance Data.ToPath SendEmail where
  toPath :: SendEmail -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v2/email/outbound-emails"

instance Data.ToQuery SendEmail where
  toQuery :: SendEmail -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | A unique message ID that you receive when an email is accepted for
-- sending.
--
-- /See:/ 'newSendEmailResponse' smart constructor.
data SendEmailResponse = SendEmailResponse'
  { -- | A unique identifier for the message that is generated when the message
    -- is accepted.
    --
    -- It\'s possible for Amazon SES to accept a message without sending it.
    -- This can happen when the message that you\'re trying to send has an
    -- attachment contains a virus, or when you send a templated email that
    -- contains invalid personalization content, for example.
    SendEmailResponse -> Maybe Text
messageId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    SendEmailResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SendEmailResponse -> SendEmailResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendEmailResponse -> SendEmailResponse -> Bool
$c/= :: SendEmailResponse -> SendEmailResponse -> Bool
== :: SendEmailResponse -> SendEmailResponse -> Bool
$c== :: SendEmailResponse -> SendEmailResponse -> Bool
Prelude.Eq, ReadPrec [SendEmailResponse]
ReadPrec SendEmailResponse
Int -> ReadS SendEmailResponse
ReadS [SendEmailResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendEmailResponse]
$creadListPrec :: ReadPrec [SendEmailResponse]
readPrec :: ReadPrec SendEmailResponse
$creadPrec :: ReadPrec SendEmailResponse
readList :: ReadS [SendEmailResponse]
$creadList :: ReadS [SendEmailResponse]
readsPrec :: Int -> ReadS SendEmailResponse
$creadsPrec :: Int -> ReadS SendEmailResponse
Prelude.Read, Int -> SendEmailResponse -> ShowS
[SendEmailResponse] -> ShowS
SendEmailResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendEmailResponse] -> ShowS
$cshowList :: [SendEmailResponse] -> ShowS
show :: SendEmailResponse -> String
$cshow :: SendEmailResponse -> String
showsPrec :: Int -> SendEmailResponse -> ShowS
$cshowsPrec :: Int -> SendEmailResponse -> ShowS
Prelude.Show, forall x. Rep SendEmailResponse x -> SendEmailResponse
forall x. SendEmailResponse -> Rep SendEmailResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendEmailResponse x -> SendEmailResponse
$cfrom :: forall x. SendEmailResponse -> Rep SendEmailResponse x
Prelude.Generic)

-- |
-- Create a value of 'SendEmailResponse' 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:
--
-- 'messageId', 'sendEmailResponse_messageId' - A unique identifier for the message that is generated when the message
-- is accepted.
--
-- It\'s possible for Amazon SES to accept a message without sending it.
-- This can happen when the message that you\'re trying to send has an
-- attachment contains a virus, or when you send a templated email that
-- contains invalid personalization content, for example.
--
-- 'httpStatus', 'sendEmailResponse_httpStatus' - The response's http status code.
newSendEmailResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SendEmailResponse
newSendEmailResponse :: Int -> SendEmailResponse
newSendEmailResponse Int
pHttpStatus_ =
  SendEmailResponse'
    { $sel:messageId:SendEmailResponse' :: Maybe Text
messageId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SendEmailResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A unique identifier for the message that is generated when the message
-- is accepted.
--
-- It\'s possible for Amazon SES to accept a message without sending it.
-- This can happen when the message that you\'re trying to send has an
-- attachment contains a virus, or when you send a templated email that
-- contains invalid personalization content, for example.
sendEmailResponse_messageId :: Lens.Lens' SendEmailResponse (Prelude.Maybe Prelude.Text)
sendEmailResponse_messageId :: Lens' SendEmailResponse (Maybe Text)
sendEmailResponse_messageId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmailResponse' {Maybe Text
messageId :: Maybe Text
$sel:messageId:SendEmailResponse' :: SendEmailResponse -> Maybe Text
messageId} -> Maybe Text
messageId) (\s :: SendEmailResponse
s@SendEmailResponse' {} Maybe Text
a -> SendEmailResponse
s {$sel:messageId:SendEmailResponse' :: Maybe Text
messageId = Maybe Text
a} :: SendEmailResponse)

-- | The response's http status code.
sendEmailResponse_httpStatus :: Lens.Lens' SendEmailResponse Prelude.Int
sendEmailResponse_httpStatus :: Lens' SendEmailResponse Int
sendEmailResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendEmailResponse' {Int
httpStatus :: Int
$sel:httpStatus:SendEmailResponse' :: SendEmailResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SendEmailResponse
s@SendEmailResponse' {} Int
a -> SendEmailResponse
s {$sel:httpStatus:SendEmailResponse' :: Int
httpStatus = Int
a} :: SendEmailResponse)

instance Prelude.NFData SendEmailResponse where
  rnf :: SendEmailResponse -> ()
rnf SendEmailResponse' {Int
Maybe Text
httpStatus :: Int
messageId :: Maybe Text
$sel:httpStatus:SendEmailResponse' :: SendEmailResponse -> Int
$sel:messageId:SendEmailResponse' :: SendEmailResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
messageId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus