{-# 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.PutEmailIdentityFeedbackAttributes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Used to enable or disable feedback forwarding for an identity. This
-- setting determines what happens when an identity is used to send an
-- email that results in a bounce or complaint event.
--
-- If the value is @true@, you receive email notifications when bounce or
-- complaint events occur. These notifications are sent to the address that
-- you specified in the @Return-Path@ header of the original email.
--
-- You\'re required to have a method of tracking bounces and complaints. If
-- you haven\'t set up another mechanism for receiving bounce or complaint
-- notifications (for example, by setting up an event destination), you
-- receive an email notification when these events occur (even if this
-- setting is disabled).
module Amazonka.SESV2.PutEmailIdentityFeedbackAttributes
  ( -- * Creating a Request
    PutEmailIdentityFeedbackAttributes (..),
    newPutEmailIdentityFeedbackAttributes,

    -- * Request Lenses
    putEmailIdentityFeedbackAttributes_emailForwardingEnabled,
    putEmailIdentityFeedbackAttributes_emailIdentity,

    -- * Destructuring the Response
    PutEmailIdentityFeedbackAttributesResponse (..),
    newPutEmailIdentityFeedbackAttributesResponse,

    -- * Response Lenses
    putEmailIdentityFeedbackAttributesResponse_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

-- | A request to set the attributes that control how bounce and complaint
-- events are processed.
--
-- /See:/ 'newPutEmailIdentityFeedbackAttributes' smart constructor.
data PutEmailIdentityFeedbackAttributes = PutEmailIdentityFeedbackAttributes'
  { -- | Sets the feedback forwarding configuration for the identity.
    --
    -- If the value is @true@, you receive email notifications when bounce or
    -- complaint events occur. These notifications are sent to the address that
    -- you specified in the @Return-Path@ header of the original email.
    --
    -- You\'re required to have a method of tracking bounces and complaints. If
    -- you haven\'t set up another mechanism for receiving bounce or complaint
    -- notifications (for example, by setting up an event destination), you
    -- receive an email notification when these events occur (even if this
    -- setting is disabled).
    PutEmailIdentityFeedbackAttributes -> Maybe Bool
emailForwardingEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The email identity.
    PutEmailIdentityFeedbackAttributes -> Text
emailIdentity :: Prelude.Text
  }
  deriving (PutEmailIdentityFeedbackAttributes
-> PutEmailIdentityFeedbackAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEmailIdentityFeedbackAttributes
-> PutEmailIdentityFeedbackAttributes -> Bool
$c/= :: PutEmailIdentityFeedbackAttributes
-> PutEmailIdentityFeedbackAttributes -> Bool
== :: PutEmailIdentityFeedbackAttributes
-> PutEmailIdentityFeedbackAttributes -> Bool
$c== :: PutEmailIdentityFeedbackAttributes
-> PutEmailIdentityFeedbackAttributes -> Bool
Prelude.Eq, ReadPrec [PutEmailIdentityFeedbackAttributes]
ReadPrec PutEmailIdentityFeedbackAttributes
Int -> ReadS PutEmailIdentityFeedbackAttributes
ReadS [PutEmailIdentityFeedbackAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEmailIdentityFeedbackAttributes]
$creadListPrec :: ReadPrec [PutEmailIdentityFeedbackAttributes]
readPrec :: ReadPrec PutEmailIdentityFeedbackAttributes
$creadPrec :: ReadPrec PutEmailIdentityFeedbackAttributes
readList :: ReadS [PutEmailIdentityFeedbackAttributes]
$creadList :: ReadS [PutEmailIdentityFeedbackAttributes]
readsPrec :: Int -> ReadS PutEmailIdentityFeedbackAttributes
$creadsPrec :: Int -> ReadS PutEmailIdentityFeedbackAttributes
Prelude.Read, Int -> PutEmailIdentityFeedbackAttributes -> ShowS
[PutEmailIdentityFeedbackAttributes] -> ShowS
PutEmailIdentityFeedbackAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEmailIdentityFeedbackAttributes] -> ShowS
$cshowList :: [PutEmailIdentityFeedbackAttributes] -> ShowS
show :: PutEmailIdentityFeedbackAttributes -> String
$cshow :: PutEmailIdentityFeedbackAttributes -> String
showsPrec :: Int -> PutEmailIdentityFeedbackAttributes -> ShowS
$cshowsPrec :: Int -> PutEmailIdentityFeedbackAttributes -> ShowS
Prelude.Show, forall x.
Rep PutEmailIdentityFeedbackAttributes x
-> PutEmailIdentityFeedbackAttributes
forall x.
PutEmailIdentityFeedbackAttributes
-> Rep PutEmailIdentityFeedbackAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutEmailIdentityFeedbackAttributes x
-> PutEmailIdentityFeedbackAttributes
$cfrom :: forall x.
PutEmailIdentityFeedbackAttributes
-> Rep PutEmailIdentityFeedbackAttributes x
Prelude.Generic)

-- |
-- Create a value of 'PutEmailIdentityFeedbackAttributes' 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:
--
-- 'emailForwardingEnabled', 'putEmailIdentityFeedbackAttributes_emailForwardingEnabled' - Sets the feedback forwarding configuration for the identity.
--
-- If the value is @true@, you receive email notifications when bounce or
-- complaint events occur. These notifications are sent to the address that
-- you specified in the @Return-Path@ header of the original email.
--
-- You\'re required to have a method of tracking bounces and complaints. If
-- you haven\'t set up another mechanism for receiving bounce or complaint
-- notifications (for example, by setting up an event destination), you
-- receive an email notification when these events occur (even if this
-- setting is disabled).
--
-- 'emailIdentity', 'putEmailIdentityFeedbackAttributes_emailIdentity' - The email identity.
newPutEmailIdentityFeedbackAttributes ::
  -- | 'emailIdentity'
  Prelude.Text ->
  PutEmailIdentityFeedbackAttributes
newPutEmailIdentityFeedbackAttributes :: Text -> PutEmailIdentityFeedbackAttributes
newPutEmailIdentityFeedbackAttributes Text
pEmailIdentity_ =
  PutEmailIdentityFeedbackAttributes'
    { $sel:emailForwardingEnabled:PutEmailIdentityFeedbackAttributes' :: Maybe Bool
emailForwardingEnabled =
        forall a. Maybe a
Prelude.Nothing,
      $sel:emailIdentity:PutEmailIdentityFeedbackAttributes' :: Text
emailIdentity = Text
pEmailIdentity_
    }

-- | Sets the feedback forwarding configuration for the identity.
--
-- If the value is @true@, you receive email notifications when bounce or
-- complaint events occur. These notifications are sent to the address that
-- you specified in the @Return-Path@ header of the original email.
--
-- You\'re required to have a method of tracking bounces and complaints. If
-- you haven\'t set up another mechanism for receiving bounce or complaint
-- notifications (for example, by setting up an event destination), you
-- receive an email notification when these events occur (even if this
-- setting is disabled).
putEmailIdentityFeedbackAttributes_emailForwardingEnabled :: Lens.Lens' PutEmailIdentityFeedbackAttributes (Prelude.Maybe Prelude.Bool)
putEmailIdentityFeedbackAttributes_emailForwardingEnabled :: Lens' PutEmailIdentityFeedbackAttributes (Maybe Bool)
putEmailIdentityFeedbackAttributes_emailForwardingEnabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEmailIdentityFeedbackAttributes' {Maybe Bool
emailForwardingEnabled :: Maybe Bool
$sel:emailForwardingEnabled:PutEmailIdentityFeedbackAttributes' :: PutEmailIdentityFeedbackAttributes -> Maybe Bool
emailForwardingEnabled} -> Maybe Bool
emailForwardingEnabled) (\s :: PutEmailIdentityFeedbackAttributes
s@PutEmailIdentityFeedbackAttributes' {} Maybe Bool
a -> PutEmailIdentityFeedbackAttributes
s {$sel:emailForwardingEnabled:PutEmailIdentityFeedbackAttributes' :: Maybe Bool
emailForwardingEnabled = Maybe Bool
a} :: PutEmailIdentityFeedbackAttributes)

-- | The email identity.
putEmailIdentityFeedbackAttributes_emailIdentity :: Lens.Lens' PutEmailIdentityFeedbackAttributes Prelude.Text
putEmailIdentityFeedbackAttributes_emailIdentity :: Lens' PutEmailIdentityFeedbackAttributes Text
putEmailIdentityFeedbackAttributes_emailIdentity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEmailIdentityFeedbackAttributes' {Text
emailIdentity :: Text
$sel:emailIdentity:PutEmailIdentityFeedbackAttributes' :: PutEmailIdentityFeedbackAttributes -> Text
emailIdentity} -> Text
emailIdentity) (\s :: PutEmailIdentityFeedbackAttributes
s@PutEmailIdentityFeedbackAttributes' {} Text
a -> PutEmailIdentityFeedbackAttributes
s {$sel:emailIdentity:PutEmailIdentityFeedbackAttributes' :: Text
emailIdentity = Text
a} :: PutEmailIdentityFeedbackAttributes)

instance
  Core.AWSRequest
    PutEmailIdentityFeedbackAttributes
  where
  type
    AWSResponse PutEmailIdentityFeedbackAttributes =
      PutEmailIdentityFeedbackAttributesResponse
  request :: (Service -> Service)
-> PutEmailIdentityFeedbackAttributes
-> Request PutEmailIdentityFeedbackAttributes
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutEmailIdentityFeedbackAttributes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse PutEmailIdentityFeedbackAttributes)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutEmailIdentityFeedbackAttributesResponse
PutEmailIdentityFeedbackAttributesResponse'
            forall (f :: * -> *) a b. Functor 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
    PutEmailIdentityFeedbackAttributes
  where
  hashWithSalt :: Int -> PutEmailIdentityFeedbackAttributes -> Int
hashWithSalt
    Int
_salt
    PutEmailIdentityFeedbackAttributes' {Maybe Bool
Text
emailIdentity :: Text
emailForwardingEnabled :: Maybe Bool
$sel:emailIdentity:PutEmailIdentityFeedbackAttributes' :: PutEmailIdentityFeedbackAttributes -> Text
$sel:emailForwardingEnabled:PutEmailIdentityFeedbackAttributes' :: PutEmailIdentityFeedbackAttributes -> Maybe Bool
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
emailForwardingEnabled
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
emailIdentity

instance
  Prelude.NFData
    PutEmailIdentityFeedbackAttributes
  where
  rnf :: PutEmailIdentityFeedbackAttributes -> ()
rnf PutEmailIdentityFeedbackAttributes' {Maybe Bool
Text
emailIdentity :: Text
emailForwardingEnabled :: Maybe Bool
$sel:emailIdentity:PutEmailIdentityFeedbackAttributes' :: PutEmailIdentityFeedbackAttributes -> Text
$sel:emailForwardingEnabled:PutEmailIdentityFeedbackAttributes' :: PutEmailIdentityFeedbackAttributes -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
emailForwardingEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
emailIdentity

instance
  Data.ToHeaders
    PutEmailIdentityFeedbackAttributes
  where
  toHeaders :: PutEmailIdentityFeedbackAttributes -> 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
    PutEmailIdentityFeedbackAttributes
  where
  toJSON :: PutEmailIdentityFeedbackAttributes -> Value
toJSON PutEmailIdentityFeedbackAttributes' {Maybe Bool
Text
emailIdentity :: Text
emailForwardingEnabled :: Maybe Bool
$sel:emailIdentity:PutEmailIdentityFeedbackAttributes' :: PutEmailIdentityFeedbackAttributes -> Text
$sel:emailForwardingEnabled:PutEmailIdentityFeedbackAttributes' :: PutEmailIdentityFeedbackAttributes -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EmailForwardingEnabled" 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 Bool
emailForwardingEnabled
          ]
      )

instance
  Data.ToPath
    PutEmailIdentityFeedbackAttributes
  where
  toPath :: PutEmailIdentityFeedbackAttributes -> ByteString
toPath PutEmailIdentityFeedbackAttributes' {Maybe Bool
Text
emailIdentity :: Text
emailForwardingEnabled :: Maybe Bool
$sel:emailIdentity:PutEmailIdentityFeedbackAttributes' :: PutEmailIdentityFeedbackAttributes -> Text
$sel:emailForwardingEnabled:PutEmailIdentityFeedbackAttributes' :: PutEmailIdentityFeedbackAttributes -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v2/email/identities/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
emailIdentity,
        ByteString
"/feedback"
      ]

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

-- | An HTTP 200 response if the request succeeds, or an error message if the
-- request fails.
--
-- /See:/ 'newPutEmailIdentityFeedbackAttributesResponse' smart constructor.
data PutEmailIdentityFeedbackAttributesResponse = PutEmailIdentityFeedbackAttributesResponse'
  { -- | The response's http status code.
    PutEmailIdentityFeedbackAttributesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutEmailIdentityFeedbackAttributesResponse
-> PutEmailIdentityFeedbackAttributesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEmailIdentityFeedbackAttributesResponse
-> PutEmailIdentityFeedbackAttributesResponse -> Bool
$c/= :: PutEmailIdentityFeedbackAttributesResponse
-> PutEmailIdentityFeedbackAttributesResponse -> Bool
== :: PutEmailIdentityFeedbackAttributesResponse
-> PutEmailIdentityFeedbackAttributesResponse -> Bool
$c== :: PutEmailIdentityFeedbackAttributesResponse
-> PutEmailIdentityFeedbackAttributesResponse -> Bool
Prelude.Eq, ReadPrec [PutEmailIdentityFeedbackAttributesResponse]
ReadPrec PutEmailIdentityFeedbackAttributesResponse
Int -> ReadS PutEmailIdentityFeedbackAttributesResponse
ReadS [PutEmailIdentityFeedbackAttributesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEmailIdentityFeedbackAttributesResponse]
$creadListPrec :: ReadPrec [PutEmailIdentityFeedbackAttributesResponse]
readPrec :: ReadPrec PutEmailIdentityFeedbackAttributesResponse
$creadPrec :: ReadPrec PutEmailIdentityFeedbackAttributesResponse
readList :: ReadS [PutEmailIdentityFeedbackAttributesResponse]
$creadList :: ReadS [PutEmailIdentityFeedbackAttributesResponse]
readsPrec :: Int -> ReadS PutEmailIdentityFeedbackAttributesResponse
$creadsPrec :: Int -> ReadS PutEmailIdentityFeedbackAttributesResponse
Prelude.Read, Int -> PutEmailIdentityFeedbackAttributesResponse -> ShowS
[PutEmailIdentityFeedbackAttributesResponse] -> ShowS
PutEmailIdentityFeedbackAttributesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEmailIdentityFeedbackAttributesResponse] -> ShowS
$cshowList :: [PutEmailIdentityFeedbackAttributesResponse] -> ShowS
show :: PutEmailIdentityFeedbackAttributesResponse -> String
$cshow :: PutEmailIdentityFeedbackAttributesResponse -> String
showsPrec :: Int -> PutEmailIdentityFeedbackAttributesResponse -> ShowS
$cshowsPrec :: Int -> PutEmailIdentityFeedbackAttributesResponse -> ShowS
Prelude.Show, forall x.
Rep PutEmailIdentityFeedbackAttributesResponse x
-> PutEmailIdentityFeedbackAttributesResponse
forall x.
PutEmailIdentityFeedbackAttributesResponse
-> Rep PutEmailIdentityFeedbackAttributesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutEmailIdentityFeedbackAttributesResponse x
-> PutEmailIdentityFeedbackAttributesResponse
$cfrom :: forall x.
PutEmailIdentityFeedbackAttributesResponse
-> Rep PutEmailIdentityFeedbackAttributesResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutEmailIdentityFeedbackAttributesResponse' 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:
--
-- 'httpStatus', 'putEmailIdentityFeedbackAttributesResponse_httpStatus' - The response's http status code.
newPutEmailIdentityFeedbackAttributesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutEmailIdentityFeedbackAttributesResponse
newPutEmailIdentityFeedbackAttributesResponse :: Int -> PutEmailIdentityFeedbackAttributesResponse
newPutEmailIdentityFeedbackAttributesResponse
  Int
pHttpStatus_ =
    PutEmailIdentityFeedbackAttributesResponse'
      { $sel:httpStatus:PutEmailIdentityFeedbackAttributesResponse' :: Int
httpStatus =
          Int
pHttpStatus_
      }

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

instance
  Prelude.NFData
    PutEmailIdentityFeedbackAttributesResponse
  where
  rnf :: PutEmailIdentityFeedbackAttributesResponse -> ()
rnf PutEmailIdentityFeedbackAttributesResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutEmailIdentityFeedbackAttributesResponse' :: PutEmailIdentityFeedbackAttributesResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus