{-# 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 #-}
module Amazonka.SESV2.UpdateContact
(
UpdateContact (..),
newUpdateContact,
updateContact_unsubscribeAll,
updateContact_attributesData,
updateContact_topicPreferences,
updateContact_contactListName,
updateContact_emailAddress,
UpdateContactResponse (..),
newUpdateContactResponse,
updateContactResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SESV2.Types
data UpdateContact = UpdateContact'
{
UpdateContact -> Maybe Bool
unsubscribeAll :: Prelude.Maybe Prelude.Bool,
UpdateContact -> Maybe Text
attributesData :: Prelude.Maybe Prelude.Text,
UpdateContact -> Maybe [TopicPreference]
topicPreferences :: Prelude.Maybe [TopicPreference],
UpdateContact -> Text
contactListName :: Prelude.Text,
UpdateContact -> Text
emailAddress :: Prelude.Text
}
deriving (UpdateContact -> UpdateContact -> Bool
(UpdateContact -> UpdateContact -> Bool)
-> (UpdateContact -> UpdateContact -> Bool) -> Eq UpdateContact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateContact -> UpdateContact -> Bool
$c/= :: UpdateContact -> UpdateContact -> Bool
== :: UpdateContact -> UpdateContact -> Bool
$c== :: UpdateContact -> UpdateContact -> Bool
Prelude.Eq, ReadPrec [UpdateContact]
ReadPrec UpdateContact
Int -> ReadS UpdateContact
ReadS [UpdateContact]
(Int -> ReadS UpdateContact)
-> ReadS [UpdateContact]
-> ReadPrec UpdateContact
-> ReadPrec [UpdateContact]
-> Read UpdateContact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateContact]
$creadListPrec :: ReadPrec [UpdateContact]
readPrec :: ReadPrec UpdateContact
$creadPrec :: ReadPrec UpdateContact
readList :: ReadS [UpdateContact]
$creadList :: ReadS [UpdateContact]
readsPrec :: Int -> ReadS UpdateContact
$creadsPrec :: Int -> ReadS UpdateContact
Prelude.Read, Int -> UpdateContact -> ShowS
[UpdateContact] -> ShowS
UpdateContact -> String
(Int -> UpdateContact -> ShowS)
-> (UpdateContact -> String)
-> ([UpdateContact] -> ShowS)
-> Show UpdateContact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateContact] -> ShowS
$cshowList :: [UpdateContact] -> ShowS
show :: UpdateContact -> String
$cshow :: UpdateContact -> String
showsPrec :: Int -> UpdateContact -> ShowS
$cshowsPrec :: Int -> UpdateContact -> ShowS
Prelude.Show, (forall x. UpdateContact -> Rep UpdateContact x)
-> (forall x. Rep UpdateContact x -> UpdateContact)
-> Generic UpdateContact
forall x. Rep UpdateContact x -> UpdateContact
forall x. UpdateContact -> Rep UpdateContact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateContact x -> UpdateContact
$cfrom :: forall x. UpdateContact -> Rep UpdateContact x
Prelude.Generic)
newUpdateContact ::
Prelude.Text ->
Prelude.Text ->
UpdateContact
newUpdateContact :: Text -> Text -> UpdateContact
newUpdateContact Text
pContactListName_ Text
pEmailAddress_ =
UpdateContact' :: Maybe Bool
-> Maybe Text
-> Maybe [TopicPreference]
-> Text
-> Text
-> UpdateContact
UpdateContact'
{ $sel:unsubscribeAll:UpdateContact' :: Maybe Bool
unsubscribeAll = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:attributesData:UpdateContact' :: Maybe Text
attributesData = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:topicPreferences:UpdateContact' :: Maybe [TopicPreference]
topicPreferences = Maybe [TopicPreference]
forall a. Maybe a
Prelude.Nothing,
$sel:contactListName:UpdateContact' :: Text
contactListName = Text
pContactListName_,
$sel:emailAddress:UpdateContact' :: Text
emailAddress = Text
pEmailAddress_
}
updateContact_unsubscribeAll :: Lens.Lens' UpdateContact (Prelude.Maybe Prelude.Bool)
updateContact_unsubscribeAll :: (Maybe Bool -> f (Maybe Bool)) -> UpdateContact -> f UpdateContact
updateContact_unsubscribeAll = (UpdateContact -> Maybe Bool)
-> (UpdateContact -> Maybe Bool -> UpdateContact)
-> Lens UpdateContact UpdateContact (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContact' {Maybe Bool
unsubscribeAll :: Maybe Bool
$sel:unsubscribeAll:UpdateContact' :: UpdateContact -> Maybe Bool
unsubscribeAll} -> Maybe Bool
unsubscribeAll) (\s :: UpdateContact
s@UpdateContact' {} Maybe Bool
a -> UpdateContact
s {$sel:unsubscribeAll:UpdateContact' :: Maybe Bool
unsubscribeAll = Maybe Bool
a} :: UpdateContact)
updateContact_attributesData :: Lens.Lens' UpdateContact (Prelude.Maybe Prelude.Text)
updateContact_attributesData :: (Maybe Text -> f (Maybe Text)) -> UpdateContact -> f UpdateContact
updateContact_attributesData = (UpdateContact -> Maybe Text)
-> (UpdateContact -> Maybe Text -> UpdateContact)
-> Lens UpdateContact UpdateContact (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContact' {Maybe Text
attributesData :: Maybe Text
$sel:attributesData:UpdateContact' :: UpdateContact -> Maybe Text
attributesData} -> Maybe Text
attributesData) (\s :: UpdateContact
s@UpdateContact' {} Maybe Text
a -> UpdateContact
s {$sel:attributesData:UpdateContact' :: Maybe Text
attributesData = Maybe Text
a} :: UpdateContact)
updateContact_topicPreferences :: Lens.Lens' UpdateContact (Prelude.Maybe [TopicPreference])
updateContact_topicPreferences :: (Maybe [TopicPreference] -> f (Maybe [TopicPreference]))
-> UpdateContact -> f UpdateContact
updateContact_topicPreferences = (UpdateContact -> Maybe [TopicPreference])
-> (UpdateContact -> Maybe [TopicPreference] -> UpdateContact)
-> Lens
UpdateContact
UpdateContact
(Maybe [TopicPreference])
(Maybe [TopicPreference])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContact' {Maybe [TopicPreference]
topicPreferences :: Maybe [TopicPreference]
$sel:topicPreferences:UpdateContact' :: UpdateContact -> Maybe [TopicPreference]
topicPreferences} -> Maybe [TopicPreference]
topicPreferences) (\s :: UpdateContact
s@UpdateContact' {} Maybe [TopicPreference]
a -> UpdateContact
s {$sel:topicPreferences:UpdateContact' :: Maybe [TopicPreference]
topicPreferences = Maybe [TopicPreference]
a} :: UpdateContact) ((Maybe [TopicPreference] -> f (Maybe [TopicPreference]))
-> UpdateContact -> f UpdateContact)
-> ((Maybe [TopicPreference] -> f (Maybe [TopicPreference]))
-> Maybe [TopicPreference] -> f (Maybe [TopicPreference]))
-> (Maybe [TopicPreference] -> f (Maybe [TopicPreference]))
-> UpdateContact
-> f UpdateContact
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[TopicPreference]
[TopicPreference]
[TopicPreference]
[TopicPreference]
-> Iso
(Maybe [TopicPreference])
(Maybe [TopicPreference])
(Maybe [TopicPreference])
(Maybe [TopicPreference])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
[TopicPreference]
[TopicPreference]
[TopicPreference]
[TopicPreference]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
updateContact_contactListName :: Lens.Lens' UpdateContact Prelude.Text
updateContact_contactListName :: (Text -> f Text) -> UpdateContact -> f UpdateContact
updateContact_contactListName = (UpdateContact -> Text)
-> (UpdateContact -> Text -> UpdateContact)
-> Lens UpdateContact UpdateContact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContact' {Text
contactListName :: Text
$sel:contactListName:UpdateContact' :: UpdateContact -> Text
contactListName} -> Text
contactListName) (\s :: UpdateContact
s@UpdateContact' {} Text
a -> UpdateContact
s {$sel:contactListName:UpdateContact' :: Text
contactListName = Text
a} :: UpdateContact)
updateContact_emailAddress :: Lens.Lens' UpdateContact Prelude.Text
updateContact_emailAddress :: (Text -> f Text) -> UpdateContact -> f UpdateContact
updateContact_emailAddress = (UpdateContact -> Text)
-> (UpdateContact -> Text -> UpdateContact)
-> Lens UpdateContact UpdateContact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContact' {Text
emailAddress :: Text
$sel:emailAddress:UpdateContact' :: UpdateContact -> Text
emailAddress} -> Text
emailAddress) (\s :: UpdateContact
s@UpdateContact' {} Text
a -> UpdateContact
s {$sel:emailAddress:UpdateContact' :: Text
emailAddress = Text
a} :: UpdateContact)
instance Core.AWSRequest UpdateContact where
type
AWSResponse UpdateContact =
UpdateContactResponse
request :: UpdateContact -> Request UpdateContact
request = Service -> UpdateContact -> Request UpdateContact
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
response :: Logger
-> Service
-> Proxy UpdateContact
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateContact)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse UpdateContact))
-> Logger
-> Service
-> Proxy UpdateContact
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateContact)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
( \Int
s ResponseHeaders
h ()
x ->
Int -> UpdateContactResponse
UpdateContactResponse'
(Int -> UpdateContactResponse)
-> Either String Int -> Either String UpdateContactResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable UpdateContact
instance Prelude.NFData UpdateContact
instance Core.ToHeaders UpdateContact where
toHeaders :: UpdateContact -> ResponseHeaders
toHeaders =
ResponseHeaders -> UpdateContact -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON UpdateContact where
toJSON :: UpdateContact -> Value
toJSON UpdateContact' {Maybe Bool
Maybe [TopicPreference]
Maybe Text
Text
emailAddress :: Text
contactListName :: Text
topicPreferences :: Maybe [TopicPreference]
attributesData :: Maybe Text
unsubscribeAll :: Maybe Bool
$sel:emailAddress:UpdateContact' :: UpdateContact -> Text
$sel:contactListName:UpdateContact' :: UpdateContact -> Text
$sel:topicPreferences:UpdateContact' :: UpdateContact -> Maybe [TopicPreference]
$sel:attributesData:UpdateContact' :: UpdateContact -> Maybe Text
$sel:unsubscribeAll:UpdateContact' :: UpdateContact -> Maybe Bool
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"UnsubscribeAll" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
unsubscribeAll,
(Text
"AttributesData" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
attributesData,
(Text
"TopicPreferences" Text -> [TopicPreference] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
([TopicPreference] -> Pair)
-> Maybe [TopicPreference] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TopicPreference]
topicPreferences
]
)
instance Core.ToPath UpdateContact where
toPath :: UpdateContact -> ByteString
toPath UpdateContact' {Maybe Bool
Maybe [TopicPreference]
Maybe Text
Text
emailAddress :: Text
contactListName :: Text
topicPreferences :: Maybe [TopicPreference]
attributesData :: Maybe Text
unsubscribeAll :: Maybe Bool
$sel:emailAddress:UpdateContact' :: UpdateContact -> Text
$sel:contactListName:UpdateContact' :: UpdateContact -> Text
$sel:topicPreferences:UpdateContact' :: UpdateContact -> Maybe [TopicPreference]
$sel:attributesData:UpdateContact' :: UpdateContact -> Maybe Text
$sel:unsubscribeAll:UpdateContact' :: UpdateContact -> Maybe Bool
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/v2/email/contact-lists/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
contactListName,
ByteString
"/contacts/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
emailAddress
]
instance Core.ToQuery UpdateContact where
toQuery :: UpdateContact -> QueryString
toQuery = QueryString -> UpdateContact -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data UpdateContactResponse = UpdateContactResponse'
{
UpdateContactResponse -> Int
httpStatus :: Prelude.Int
}
deriving (UpdateContactResponse -> UpdateContactResponse -> Bool
(UpdateContactResponse -> UpdateContactResponse -> Bool)
-> (UpdateContactResponse -> UpdateContactResponse -> Bool)
-> Eq UpdateContactResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateContactResponse -> UpdateContactResponse -> Bool
$c/= :: UpdateContactResponse -> UpdateContactResponse -> Bool
== :: UpdateContactResponse -> UpdateContactResponse -> Bool
$c== :: UpdateContactResponse -> UpdateContactResponse -> Bool
Prelude.Eq, ReadPrec [UpdateContactResponse]
ReadPrec UpdateContactResponse
Int -> ReadS UpdateContactResponse
ReadS [UpdateContactResponse]
(Int -> ReadS UpdateContactResponse)
-> ReadS [UpdateContactResponse]
-> ReadPrec UpdateContactResponse
-> ReadPrec [UpdateContactResponse]
-> Read UpdateContactResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateContactResponse]
$creadListPrec :: ReadPrec [UpdateContactResponse]
readPrec :: ReadPrec UpdateContactResponse
$creadPrec :: ReadPrec UpdateContactResponse
readList :: ReadS [UpdateContactResponse]
$creadList :: ReadS [UpdateContactResponse]
readsPrec :: Int -> ReadS UpdateContactResponse
$creadsPrec :: Int -> ReadS UpdateContactResponse
Prelude.Read, Int -> UpdateContactResponse -> ShowS
[UpdateContactResponse] -> ShowS
UpdateContactResponse -> String
(Int -> UpdateContactResponse -> ShowS)
-> (UpdateContactResponse -> String)
-> ([UpdateContactResponse] -> ShowS)
-> Show UpdateContactResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateContactResponse] -> ShowS
$cshowList :: [UpdateContactResponse] -> ShowS
show :: UpdateContactResponse -> String
$cshow :: UpdateContactResponse -> String
showsPrec :: Int -> UpdateContactResponse -> ShowS
$cshowsPrec :: Int -> UpdateContactResponse -> ShowS
Prelude.Show, (forall x. UpdateContactResponse -> Rep UpdateContactResponse x)
-> (forall x. Rep UpdateContactResponse x -> UpdateContactResponse)
-> Generic UpdateContactResponse
forall x. Rep UpdateContactResponse x -> UpdateContactResponse
forall x. UpdateContactResponse -> Rep UpdateContactResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateContactResponse x -> UpdateContactResponse
$cfrom :: forall x. UpdateContactResponse -> Rep UpdateContactResponse x
Prelude.Generic)
newUpdateContactResponse ::
Prelude.Int ->
UpdateContactResponse
newUpdateContactResponse :: Int -> UpdateContactResponse
newUpdateContactResponse Int
pHttpStatus_ =
UpdateContactResponse' :: Int -> UpdateContactResponse
UpdateContactResponse' {$sel:httpStatus:UpdateContactResponse' :: Int
httpStatus = Int
pHttpStatus_}
updateContactResponse_httpStatus :: Lens.Lens' UpdateContactResponse Prelude.Int
updateContactResponse_httpStatus :: (Int -> f Int) -> UpdateContactResponse -> f UpdateContactResponse
updateContactResponse_httpStatus = (UpdateContactResponse -> Int)
-> (UpdateContactResponse -> Int -> UpdateContactResponse)
-> Lens UpdateContactResponse UpdateContactResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateContactResponse' :: UpdateContactResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateContactResponse
s@UpdateContactResponse' {} Int
a -> UpdateContactResponse
s {$sel:httpStatus:UpdateContactResponse' :: Int
httpStatus = Int
a} :: UpdateContactResponse)
instance Prelude.NFData UpdateContactResponse