{-# 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.SES.Types.BouncedRecipientInfo
-- 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.SES.Types.BouncedRecipientInfo where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SES.Types.BounceType
import Amazonka.SES.Types.RecipientDsnFields

-- | Recipient-related information to include in the Delivery Status
-- Notification (DSN) when an email that Amazon SES receives on your behalf
-- bounces.
--
-- For information about receiving email through Amazon SES, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email.html Amazon SES Developer Guide>.
--
-- /See:/ 'newBouncedRecipientInfo' smart constructor.
data BouncedRecipientInfo = BouncedRecipientInfo'
  { -- | The reason for the bounce. You must provide either this parameter or
    -- @RecipientDsnFields@.
    BouncedRecipientInfo -> Maybe BounceType
bounceType :: Prelude.Maybe BounceType,
    -- | Recipient-related DSN fields, most of which would normally be filled in
    -- automatically when provided with a @BounceType@. You must provide either
    -- this parameter or @BounceType@.
    BouncedRecipientInfo -> Maybe RecipientDsnFields
recipientDsnFields :: Prelude.Maybe RecipientDsnFields,
    -- | 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 receive email for the recipient of the bounced
    -- email. For more information about sending authorization, see the
    -- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
    BouncedRecipientInfo -> Maybe Text
recipientArn :: Prelude.Maybe Prelude.Text,
    -- | The email address of the recipient of the bounced email.
    BouncedRecipientInfo -> Text
recipient :: Prelude.Text
  }
  deriving (BouncedRecipientInfo -> BouncedRecipientInfo -> Bool
(BouncedRecipientInfo -> BouncedRecipientInfo -> Bool)
-> (BouncedRecipientInfo -> BouncedRecipientInfo -> Bool)
-> Eq BouncedRecipientInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BouncedRecipientInfo -> BouncedRecipientInfo -> Bool
$c/= :: BouncedRecipientInfo -> BouncedRecipientInfo -> Bool
== :: BouncedRecipientInfo -> BouncedRecipientInfo -> Bool
$c== :: BouncedRecipientInfo -> BouncedRecipientInfo -> Bool
Prelude.Eq, ReadPrec [BouncedRecipientInfo]
ReadPrec BouncedRecipientInfo
Int -> ReadS BouncedRecipientInfo
ReadS [BouncedRecipientInfo]
(Int -> ReadS BouncedRecipientInfo)
-> ReadS [BouncedRecipientInfo]
-> ReadPrec BouncedRecipientInfo
-> ReadPrec [BouncedRecipientInfo]
-> Read BouncedRecipientInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BouncedRecipientInfo]
$creadListPrec :: ReadPrec [BouncedRecipientInfo]
readPrec :: ReadPrec BouncedRecipientInfo
$creadPrec :: ReadPrec BouncedRecipientInfo
readList :: ReadS [BouncedRecipientInfo]
$creadList :: ReadS [BouncedRecipientInfo]
readsPrec :: Int -> ReadS BouncedRecipientInfo
$creadsPrec :: Int -> ReadS BouncedRecipientInfo
Prelude.Read, Int -> BouncedRecipientInfo -> ShowS
[BouncedRecipientInfo] -> ShowS
BouncedRecipientInfo -> String
(Int -> BouncedRecipientInfo -> ShowS)
-> (BouncedRecipientInfo -> String)
-> ([BouncedRecipientInfo] -> ShowS)
-> Show BouncedRecipientInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BouncedRecipientInfo] -> ShowS
$cshowList :: [BouncedRecipientInfo] -> ShowS
show :: BouncedRecipientInfo -> String
$cshow :: BouncedRecipientInfo -> String
showsPrec :: Int -> BouncedRecipientInfo -> ShowS
$cshowsPrec :: Int -> BouncedRecipientInfo -> ShowS
Prelude.Show, (forall x. BouncedRecipientInfo -> Rep BouncedRecipientInfo x)
-> (forall x. Rep BouncedRecipientInfo x -> BouncedRecipientInfo)
-> Generic BouncedRecipientInfo
forall x. Rep BouncedRecipientInfo x -> BouncedRecipientInfo
forall x. BouncedRecipientInfo -> Rep BouncedRecipientInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BouncedRecipientInfo x -> BouncedRecipientInfo
$cfrom :: forall x. BouncedRecipientInfo -> Rep BouncedRecipientInfo x
Prelude.Generic)

-- |
-- Create a value of 'BouncedRecipientInfo' 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:
--
-- 'bounceType', 'bouncedRecipientInfo_bounceType' - The reason for the bounce. You must provide either this parameter or
-- @RecipientDsnFields@.
--
-- 'recipientDsnFields', 'bouncedRecipientInfo_recipientDsnFields' - Recipient-related DSN fields, most of which would normally be filled in
-- automatically when provided with a @BounceType@. You must provide either
-- this parameter or @BounceType@.
--
-- 'recipientArn', 'bouncedRecipientInfo_recipientArn' - 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 receive email for the recipient of the bounced
-- email. For more information about sending authorization, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
--
-- 'recipient', 'bouncedRecipientInfo_recipient' - The email address of the recipient of the bounced email.
newBouncedRecipientInfo ::
  -- | 'recipient'
  Prelude.Text ->
  BouncedRecipientInfo
newBouncedRecipientInfo :: Text -> BouncedRecipientInfo
newBouncedRecipientInfo Text
pRecipient_ =
  BouncedRecipientInfo' :: Maybe BounceType
-> Maybe RecipientDsnFields
-> Maybe Text
-> Text
-> BouncedRecipientInfo
BouncedRecipientInfo'
    { $sel:bounceType:BouncedRecipientInfo' :: Maybe BounceType
bounceType = Maybe BounceType
forall a. Maybe a
Prelude.Nothing,
      $sel:recipientDsnFields:BouncedRecipientInfo' :: Maybe RecipientDsnFields
recipientDsnFields = Maybe RecipientDsnFields
forall a. Maybe a
Prelude.Nothing,
      $sel:recipientArn:BouncedRecipientInfo' :: Maybe Text
recipientArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recipient:BouncedRecipientInfo' :: Text
recipient = Text
pRecipient_
    }

-- | The reason for the bounce. You must provide either this parameter or
-- @RecipientDsnFields@.
bouncedRecipientInfo_bounceType :: Lens.Lens' BouncedRecipientInfo (Prelude.Maybe BounceType)
bouncedRecipientInfo_bounceType :: (Maybe BounceType -> f (Maybe BounceType))
-> BouncedRecipientInfo -> f BouncedRecipientInfo
bouncedRecipientInfo_bounceType = (BouncedRecipientInfo -> Maybe BounceType)
-> (BouncedRecipientInfo
    -> Maybe BounceType -> BouncedRecipientInfo)
-> Lens
     BouncedRecipientInfo
     BouncedRecipientInfo
     (Maybe BounceType)
     (Maybe BounceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BouncedRecipientInfo' {Maybe BounceType
bounceType :: Maybe BounceType
$sel:bounceType:BouncedRecipientInfo' :: BouncedRecipientInfo -> Maybe BounceType
bounceType} -> Maybe BounceType
bounceType) (\s :: BouncedRecipientInfo
s@BouncedRecipientInfo' {} Maybe BounceType
a -> BouncedRecipientInfo
s {$sel:bounceType:BouncedRecipientInfo' :: Maybe BounceType
bounceType = Maybe BounceType
a} :: BouncedRecipientInfo)

-- | Recipient-related DSN fields, most of which would normally be filled in
-- automatically when provided with a @BounceType@. You must provide either
-- this parameter or @BounceType@.
bouncedRecipientInfo_recipientDsnFields :: Lens.Lens' BouncedRecipientInfo (Prelude.Maybe RecipientDsnFields)
bouncedRecipientInfo_recipientDsnFields :: (Maybe RecipientDsnFields -> f (Maybe RecipientDsnFields))
-> BouncedRecipientInfo -> f BouncedRecipientInfo
bouncedRecipientInfo_recipientDsnFields = (BouncedRecipientInfo -> Maybe RecipientDsnFields)
-> (BouncedRecipientInfo
    -> Maybe RecipientDsnFields -> BouncedRecipientInfo)
-> Lens
     BouncedRecipientInfo
     BouncedRecipientInfo
     (Maybe RecipientDsnFields)
     (Maybe RecipientDsnFields)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BouncedRecipientInfo' {Maybe RecipientDsnFields
recipientDsnFields :: Maybe RecipientDsnFields
$sel:recipientDsnFields:BouncedRecipientInfo' :: BouncedRecipientInfo -> Maybe RecipientDsnFields
recipientDsnFields} -> Maybe RecipientDsnFields
recipientDsnFields) (\s :: BouncedRecipientInfo
s@BouncedRecipientInfo' {} Maybe RecipientDsnFields
a -> BouncedRecipientInfo
s {$sel:recipientDsnFields:BouncedRecipientInfo' :: Maybe RecipientDsnFields
recipientDsnFields = Maybe RecipientDsnFields
a} :: BouncedRecipientInfo)

-- | 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 receive email for the recipient of the bounced
-- email. For more information about sending authorization, see the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/sending-authorization.html Amazon SES Developer Guide>.
bouncedRecipientInfo_recipientArn :: Lens.Lens' BouncedRecipientInfo (Prelude.Maybe Prelude.Text)
bouncedRecipientInfo_recipientArn :: (Maybe Text -> f (Maybe Text))
-> BouncedRecipientInfo -> f BouncedRecipientInfo
bouncedRecipientInfo_recipientArn = (BouncedRecipientInfo -> Maybe Text)
-> (BouncedRecipientInfo -> Maybe Text -> BouncedRecipientInfo)
-> Lens
     BouncedRecipientInfo BouncedRecipientInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BouncedRecipientInfo' {Maybe Text
recipientArn :: Maybe Text
$sel:recipientArn:BouncedRecipientInfo' :: BouncedRecipientInfo -> Maybe Text
recipientArn} -> Maybe Text
recipientArn) (\s :: BouncedRecipientInfo
s@BouncedRecipientInfo' {} Maybe Text
a -> BouncedRecipientInfo
s {$sel:recipientArn:BouncedRecipientInfo' :: Maybe Text
recipientArn = Maybe Text
a} :: BouncedRecipientInfo)

-- | The email address of the recipient of the bounced email.
bouncedRecipientInfo_recipient :: Lens.Lens' BouncedRecipientInfo Prelude.Text
bouncedRecipientInfo_recipient :: (Text -> f Text) -> BouncedRecipientInfo -> f BouncedRecipientInfo
bouncedRecipientInfo_recipient = (BouncedRecipientInfo -> Text)
-> (BouncedRecipientInfo -> Text -> BouncedRecipientInfo)
-> Lens BouncedRecipientInfo BouncedRecipientInfo Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BouncedRecipientInfo' {Text
recipient :: Text
$sel:recipient:BouncedRecipientInfo' :: BouncedRecipientInfo -> Text
recipient} -> Text
recipient) (\s :: BouncedRecipientInfo
s@BouncedRecipientInfo' {} Text
a -> BouncedRecipientInfo
s {$sel:recipient:BouncedRecipientInfo' :: Text
recipient = Text
a} :: BouncedRecipientInfo)

instance Prelude.Hashable BouncedRecipientInfo

instance Prelude.NFData BouncedRecipientInfo

instance Core.ToQuery BouncedRecipientInfo where
  toQuery :: BouncedRecipientInfo -> QueryString
toQuery BouncedRecipientInfo' {Maybe Text
Maybe BounceType
Maybe RecipientDsnFields
Text
recipient :: Text
recipientArn :: Maybe Text
recipientDsnFields :: Maybe RecipientDsnFields
bounceType :: Maybe BounceType
$sel:recipient:BouncedRecipientInfo' :: BouncedRecipientInfo -> Text
$sel:recipientArn:BouncedRecipientInfo' :: BouncedRecipientInfo -> Maybe Text
$sel:recipientDsnFields:BouncedRecipientInfo' :: BouncedRecipientInfo -> Maybe RecipientDsnFields
$sel:bounceType:BouncedRecipientInfo' :: BouncedRecipientInfo -> Maybe BounceType
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"BounceType" ByteString -> Maybe BounceType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe BounceType
bounceType,
        ByteString
"RecipientDsnFields" ByteString -> Maybe RecipientDsnFields -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe RecipientDsnFields
recipientDsnFields,
        ByteString
"RecipientArn" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
recipientArn,
        ByteString
"Recipient" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
recipient
      ]