{-# 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.SendCustomVerificationEmail
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Adds an email address to the list of identities for your Amazon SES
-- account in the current Amazon Web Services Region and attempts to verify
-- it. As a result of executing this operation, a customized verification
-- email is sent to the specified address.
--
-- To use this operation, you must first create a custom verification email
-- template. For more information about creating and using custom
-- verification email templates, see
-- <https://docs.aws.amazon.com/ses/latest/dg/creating-identities.html#send-email-verify-address-custom Using custom verification email templates>
-- in the /Amazon SES Developer Guide/.
--
-- You can execute this operation no more than once per second.
module Amazonka.SESV2.SendCustomVerificationEmail
  ( -- * Creating a Request
    SendCustomVerificationEmail (..),
    newSendCustomVerificationEmail,

    -- * Request Lenses
    sendCustomVerificationEmail_configurationSetName,
    sendCustomVerificationEmail_emailAddress,
    sendCustomVerificationEmail_templateName,

    -- * Destructuring the Response
    SendCustomVerificationEmailResponse (..),
    newSendCustomVerificationEmailResponse,

    -- * Response Lenses
    sendCustomVerificationEmailResponse_messageId,
    sendCustomVerificationEmailResponse_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 custom verification email to a specified
-- recipient.
--
-- /See:/ 'newSendCustomVerificationEmail' smart constructor.
data SendCustomVerificationEmail = SendCustomVerificationEmail'
  { -- | Name of a configuration set to use when sending the verification email.
    SendCustomVerificationEmail -> Maybe Text
configurationSetName :: Prelude.Maybe Prelude.Text,
    -- | The email address to verify.
    SendCustomVerificationEmail -> Text
emailAddress :: Prelude.Text,
    -- | The name of the custom verification email template to use when sending
    -- the verification email.
    SendCustomVerificationEmail -> Text
templateName :: Prelude.Text
  }
  deriving (SendCustomVerificationEmail -> SendCustomVerificationEmail -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendCustomVerificationEmail -> SendCustomVerificationEmail -> Bool
$c/= :: SendCustomVerificationEmail -> SendCustomVerificationEmail -> Bool
== :: SendCustomVerificationEmail -> SendCustomVerificationEmail -> Bool
$c== :: SendCustomVerificationEmail -> SendCustomVerificationEmail -> Bool
Prelude.Eq, ReadPrec [SendCustomVerificationEmail]
ReadPrec SendCustomVerificationEmail
Int -> ReadS SendCustomVerificationEmail
ReadS [SendCustomVerificationEmail]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendCustomVerificationEmail]
$creadListPrec :: ReadPrec [SendCustomVerificationEmail]
readPrec :: ReadPrec SendCustomVerificationEmail
$creadPrec :: ReadPrec SendCustomVerificationEmail
readList :: ReadS [SendCustomVerificationEmail]
$creadList :: ReadS [SendCustomVerificationEmail]
readsPrec :: Int -> ReadS SendCustomVerificationEmail
$creadsPrec :: Int -> ReadS SendCustomVerificationEmail
Prelude.Read, Int -> SendCustomVerificationEmail -> ShowS
[SendCustomVerificationEmail] -> ShowS
SendCustomVerificationEmail -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendCustomVerificationEmail] -> ShowS
$cshowList :: [SendCustomVerificationEmail] -> ShowS
show :: SendCustomVerificationEmail -> String
$cshow :: SendCustomVerificationEmail -> String
showsPrec :: Int -> SendCustomVerificationEmail -> ShowS
$cshowsPrec :: Int -> SendCustomVerificationEmail -> ShowS
Prelude.Show, forall x.
Rep SendCustomVerificationEmail x -> SendCustomVerificationEmail
forall x.
SendCustomVerificationEmail -> Rep SendCustomVerificationEmail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SendCustomVerificationEmail x -> SendCustomVerificationEmail
$cfrom :: forall x.
SendCustomVerificationEmail -> Rep SendCustomVerificationEmail x
Prelude.Generic)

-- |
-- Create a value of 'SendCustomVerificationEmail' 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', 'sendCustomVerificationEmail_configurationSetName' - Name of a configuration set to use when sending the verification email.
--
-- 'emailAddress', 'sendCustomVerificationEmail_emailAddress' - The email address to verify.
--
-- 'templateName', 'sendCustomVerificationEmail_templateName' - The name of the custom verification email template to use when sending
-- the verification email.
newSendCustomVerificationEmail ::
  -- | 'emailAddress'
  Prelude.Text ->
  -- | 'templateName'
  Prelude.Text ->
  SendCustomVerificationEmail
newSendCustomVerificationEmail :: Text -> Text -> SendCustomVerificationEmail
newSendCustomVerificationEmail
  Text
pEmailAddress_
  Text
pTemplateName_ =
    SendCustomVerificationEmail'
      { $sel:configurationSetName:SendCustomVerificationEmail' :: Maybe Text
configurationSetName =
          forall a. Maybe a
Prelude.Nothing,
        $sel:emailAddress:SendCustomVerificationEmail' :: Text
emailAddress = Text
pEmailAddress_,
        $sel:templateName:SendCustomVerificationEmail' :: Text
templateName = Text
pTemplateName_
      }

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

-- | The email address to verify.
sendCustomVerificationEmail_emailAddress :: Lens.Lens' SendCustomVerificationEmail Prelude.Text
sendCustomVerificationEmail_emailAddress :: Lens' SendCustomVerificationEmail Text
sendCustomVerificationEmail_emailAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendCustomVerificationEmail' {Text
emailAddress :: Text
$sel:emailAddress:SendCustomVerificationEmail' :: SendCustomVerificationEmail -> Text
emailAddress} -> Text
emailAddress) (\s :: SendCustomVerificationEmail
s@SendCustomVerificationEmail' {} Text
a -> SendCustomVerificationEmail
s {$sel:emailAddress:SendCustomVerificationEmail' :: Text
emailAddress = Text
a} :: SendCustomVerificationEmail)

-- | The name of the custom verification email template to use when sending
-- the verification email.
sendCustomVerificationEmail_templateName :: Lens.Lens' SendCustomVerificationEmail Prelude.Text
sendCustomVerificationEmail_templateName :: Lens' SendCustomVerificationEmail Text
sendCustomVerificationEmail_templateName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendCustomVerificationEmail' {Text
templateName :: Text
$sel:templateName:SendCustomVerificationEmail' :: SendCustomVerificationEmail -> Text
templateName} -> Text
templateName) (\s :: SendCustomVerificationEmail
s@SendCustomVerificationEmail' {} Text
a -> SendCustomVerificationEmail
s {$sel:templateName:SendCustomVerificationEmail' :: Text
templateName = Text
a} :: SendCustomVerificationEmail)

instance Core.AWSRequest SendCustomVerificationEmail where
  type
    AWSResponse SendCustomVerificationEmail =
      SendCustomVerificationEmailResponse
  request :: (Service -> Service)
-> SendCustomVerificationEmail
-> Request SendCustomVerificationEmail
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 SendCustomVerificationEmail
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SendCustomVerificationEmail)))
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 -> SendCustomVerificationEmailResponse
SendCustomVerificationEmailResponse'
            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 SendCustomVerificationEmail where
  hashWithSalt :: Int -> SendCustomVerificationEmail -> Int
hashWithSalt Int
_salt SendCustomVerificationEmail' {Maybe Text
Text
templateName :: Text
emailAddress :: Text
configurationSetName :: Maybe Text
$sel:templateName:SendCustomVerificationEmail' :: SendCustomVerificationEmail -> Text
$sel:emailAddress:SendCustomVerificationEmail' :: SendCustomVerificationEmail -> Text
$sel:configurationSetName:SendCustomVerificationEmail' :: SendCustomVerificationEmail -> 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` Text
emailAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
templateName

instance Prelude.NFData SendCustomVerificationEmail where
  rnf :: SendCustomVerificationEmail -> ()
rnf SendCustomVerificationEmail' {Maybe Text
Text
templateName :: Text
emailAddress :: Text
configurationSetName :: Maybe Text
$sel:templateName:SendCustomVerificationEmail' :: SendCustomVerificationEmail -> Text
$sel:emailAddress:SendCustomVerificationEmail' :: SendCustomVerificationEmail -> Text
$sel:configurationSetName:SendCustomVerificationEmail' :: SendCustomVerificationEmail -> 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 Text
emailAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
templateName

instance Data.ToHeaders SendCustomVerificationEmail where
  toHeaders :: SendCustomVerificationEmail -> 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 SendCustomVerificationEmail where
  toJSON :: SendCustomVerificationEmail -> Value
toJSON SendCustomVerificationEmail' {Maybe Text
Text
templateName :: Text
emailAddress :: Text
configurationSetName :: Maybe Text
$sel:templateName:SendCustomVerificationEmail' :: SendCustomVerificationEmail -> Text
$sel:emailAddress:SendCustomVerificationEmail' :: SendCustomVerificationEmail -> Text
$sel:configurationSetName:SendCustomVerificationEmail' :: SendCustomVerificationEmail -> 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,
            forall a. a -> Maybe a
Prelude.Just (Key
"EmailAddress" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
emailAddress),
            forall a. a -> Maybe a
Prelude.Just (Key
"TemplateName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
templateName)
          ]
      )

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

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

-- | The following element is returned by the service.
--
-- /See:/ 'newSendCustomVerificationEmailResponse' smart constructor.
data SendCustomVerificationEmailResponse = SendCustomVerificationEmailResponse'
  { -- | The unique message identifier returned from the
    -- @SendCustomVerificationEmail@ operation.
    SendCustomVerificationEmailResponse -> Maybe Text
messageId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    SendCustomVerificationEmailResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SendCustomVerificationEmailResponse
-> SendCustomVerificationEmailResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendCustomVerificationEmailResponse
-> SendCustomVerificationEmailResponse -> Bool
$c/= :: SendCustomVerificationEmailResponse
-> SendCustomVerificationEmailResponse -> Bool
== :: SendCustomVerificationEmailResponse
-> SendCustomVerificationEmailResponse -> Bool
$c== :: SendCustomVerificationEmailResponse
-> SendCustomVerificationEmailResponse -> Bool
Prelude.Eq, ReadPrec [SendCustomVerificationEmailResponse]
ReadPrec SendCustomVerificationEmailResponse
Int -> ReadS SendCustomVerificationEmailResponse
ReadS [SendCustomVerificationEmailResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendCustomVerificationEmailResponse]
$creadListPrec :: ReadPrec [SendCustomVerificationEmailResponse]
readPrec :: ReadPrec SendCustomVerificationEmailResponse
$creadPrec :: ReadPrec SendCustomVerificationEmailResponse
readList :: ReadS [SendCustomVerificationEmailResponse]
$creadList :: ReadS [SendCustomVerificationEmailResponse]
readsPrec :: Int -> ReadS SendCustomVerificationEmailResponse
$creadsPrec :: Int -> ReadS SendCustomVerificationEmailResponse
Prelude.Read, Int -> SendCustomVerificationEmailResponse -> ShowS
[SendCustomVerificationEmailResponse] -> ShowS
SendCustomVerificationEmailResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendCustomVerificationEmailResponse] -> ShowS
$cshowList :: [SendCustomVerificationEmailResponse] -> ShowS
show :: SendCustomVerificationEmailResponse -> String
$cshow :: SendCustomVerificationEmailResponse -> String
showsPrec :: Int -> SendCustomVerificationEmailResponse -> ShowS
$cshowsPrec :: Int -> SendCustomVerificationEmailResponse -> ShowS
Prelude.Show, forall x.
Rep SendCustomVerificationEmailResponse x
-> SendCustomVerificationEmailResponse
forall x.
SendCustomVerificationEmailResponse
-> Rep SendCustomVerificationEmailResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SendCustomVerificationEmailResponse x
-> SendCustomVerificationEmailResponse
$cfrom :: forall x.
SendCustomVerificationEmailResponse
-> Rep SendCustomVerificationEmailResponse x
Prelude.Generic)

-- |
-- Create a value of 'SendCustomVerificationEmailResponse' 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', 'sendCustomVerificationEmailResponse_messageId' - The unique message identifier returned from the
-- @SendCustomVerificationEmail@ operation.
--
-- 'httpStatus', 'sendCustomVerificationEmailResponse_httpStatus' - The response's http status code.
newSendCustomVerificationEmailResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SendCustomVerificationEmailResponse
newSendCustomVerificationEmailResponse :: Int -> SendCustomVerificationEmailResponse
newSendCustomVerificationEmailResponse Int
pHttpStatus_ =
  SendCustomVerificationEmailResponse'
    { $sel:messageId:SendCustomVerificationEmailResponse' :: Maybe Text
messageId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SendCustomVerificationEmailResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The unique message identifier returned from the
-- @SendCustomVerificationEmail@ operation.
sendCustomVerificationEmailResponse_messageId :: Lens.Lens' SendCustomVerificationEmailResponse (Prelude.Maybe Prelude.Text)
sendCustomVerificationEmailResponse_messageId :: Lens' SendCustomVerificationEmailResponse (Maybe Text)
sendCustomVerificationEmailResponse_messageId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendCustomVerificationEmailResponse' {Maybe Text
messageId :: Maybe Text
$sel:messageId:SendCustomVerificationEmailResponse' :: SendCustomVerificationEmailResponse -> Maybe Text
messageId} -> Maybe Text
messageId) (\s :: SendCustomVerificationEmailResponse
s@SendCustomVerificationEmailResponse' {} Maybe Text
a -> SendCustomVerificationEmailResponse
s {$sel:messageId:SendCustomVerificationEmailResponse' :: Maybe Text
messageId = Maybe Text
a} :: SendCustomVerificationEmailResponse)

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

instance
  Prelude.NFData
    SendCustomVerificationEmailResponse
  where
  rnf :: SendCustomVerificationEmailResponse -> ()
rnf SendCustomVerificationEmailResponse' {Int
Maybe Text
httpStatus :: Int
messageId :: Maybe Text
$sel:httpStatus:SendCustomVerificationEmailResponse' :: SendCustomVerificationEmailResponse -> Int
$sel:messageId:SendCustomVerificationEmailResponse' :: SendCustomVerificationEmailResponse -> 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