{-# 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.CreateContact
(
CreateContact (..),
newCreateContact,
createContact_attributesData,
createContact_topicPreferences,
createContact_unsubscribeAll,
createContact_contactListName,
createContact_emailAddress,
CreateContactResponse (..),
newCreateContactResponse,
createContactResponse_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
data CreateContact = CreateContact'
{
CreateContact -> Maybe Text
attributesData :: Prelude.Maybe Prelude.Text,
CreateContact -> Maybe [TopicPreference]
topicPreferences :: Prelude.Maybe [TopicPreference],
CreateContact -> Maybe Bool
unsubscribeAll :: Prelude.Maybe Prelude.Bool,
CreateContact -> Text
contactListName :: Prelude.Text,
CreateContact -> Text
emailAddress :: Prelude.Text
}
deriving (CreateContact -> CreateContact -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateContact -> CreateContact -> Bool
$c/= :: CreateContact -> CreateContact -> Bool
== :: CreateContact -> CreateContact -> Bool
$c== :: CreateContact -> CreateContact -> Bool
Prelude.Eq, ReadPrec [CreateContact]
ReadPrec CreateContact
Int -> ReadS CreateContact
ReadS [CreateContact]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateContact]
$creadListPrec :: ReadPrec [CreateContact]
readPrec :: ReadPrec CreateContact
$creadPrec :: ReadPrec CreateContact
readList :: ReadS [CreateContact]
$creadList :: ReadS [CreateContact]
readsPrec :: Int -> ReadS CreateContact
$creadsPrec :: Int -> ReadS CreateContact
Prelude.Read, Int -> CreateContact -> ShowS
[CreateContact] -> ShowS
CreateContact -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateContact] -> ShowS
$cshowList :: [CreateContact] -> ShowS
show :: CreateContact -> String
$cshow :: CreateContact -> String
showsPrec :: Int -> CreateContact -> ShowS
$cshowsPrec :: Int -> CreateContact -> ShowS
Prelude.Show, forall x. Rep CreateContact x -> CreateContact
forall x. CreateContact -> Rep CreateContact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateContact x -> CreateContact
$cfrom :: forall x. CreateContact -> Rep CreateContact x
Prelude.Generic)
newCreateContact ::
Prelude.Text ->
Prelude.Text ->
CreateContact
newCreateContact :: Text -> Text -> CreateContact
newCreateContact Text
pContactListName_ Text
pEmailAddress_ =
CreateContact'
{ $sel:attributesData:CreateContact' :: Maybe Text
attributesData = forall a. Maybe a
Prelude.Nothing,
$sel:topicPreferences:CreateContact' :: Maybe [TopicPreference]
topicPreferences = forall a. Maybe a
Prelude.Nothing,
$sel:unsubscribeAll:CreateContact' :: Maybe Bool
unsubscribeAll = forall a. Maybe a
Prelude.Nothing,
$sel:contactListName:CreateContact' :: Text
contactListName = Text
pContactListName_,
$sel:emailAddress:CreateContact' :: Text
emailAddress = Text
pEmailAddress_
}
createContact_attributesData :: Lens.Lens' CreateContact (Prelude.Maybe Prelude.Text)
createContact_attributesData :: Lens' CreateContact (Maybe Text)
createContact_attributesData = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContact' {Maybe Text
attributesData :: Maybe Text
$sel:attributesData:CreateContact' :: CreateContact -> Maybe Text
attributesData} -> Maybe Text
attributesData) (\s :: CreateContact
s@CreateContact' {} Maybe Text
a -> CreateContact
s {$sel:attributesData:CreateContact' :: Maybe Text
attributesData = Maybe Text
a} :: CreateContact)
createContact_topicPreferences :: Lens.Lens' CreateContact (Prelude.Maybe [TopicPreference])
createContact_topicPreferences :: Lens' CreateContact (Maybe [TopicPreference])
createContact_topicPreferences = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContact' {Maybe [TopicPreference]
topicPreferences :: Maybe [TopicPreference]
$sel:topicPreferences:CreateContact' :: CreateContact -> Maybe [TopicPreference]
topicPreferences} -> Maybe [TopicPreference]
topicPreferences) (\s :: CreateContact
s@CreateContact' {} Maybe [TopicPreference]
a -> CreateContact
s {$sel:topicPreferences:CreateContact' :: Maybe [TopicPreference]
topicPreferences = Maybe [TopicPreference]
a} :: CreateContact) 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
createContact_unsubscribeAll :: Lens.Lens' CreateContact (Prelude.Maybe Prelude.Bool)
createContact_unsubscribeAll :: Lens' CreateContact (Maybe Bool)
createContact_unsubscribeAll = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContact' {Maybe Bool
unsubscribeAll :: Maybe Bool
$sel:unsubscribeAll:CreateContact' :: CreateContact -> Maybe Bool
unsubscribeAll} -> Maybe Bool
unsubscribeAll) (\s :: CreateContact
s@CreateContact' {} Maybe Bool
a -> CreateContact
s {$sel:unsubscribeAll:CreateContact' :: Maybe Bool
unsubscribeAll = Maybe Bool
a} :: CreateContact)
createContact_contactListName :: Lens.Lens' CreateContact Prelude.Text
createContact_contactListName :: Lens' CreateContact Text
createContact_contactListName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContact' {Text
contactListName :: Text
$sel:contactListName:CreateContact' :: CreateContact -> Text
contactListName} -> Text
contactListName) (\s :: CreateContact
s@CreateContact' {} Text
a -> CreateContact
s {$sel:contactListName:CreateContact' :: Text
contactListName = Text
a} :: CreateContact)
createContact_emailAddress :: Lens.Lens' CreateContact Prelude.Text
createContact_emailAddress :: Lens' CreateContact Text
createContact_emailAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContact' {Text
emailAddress :: Text
$sel:emailAddress:CreateContact' :: CreateContact -> Text
emailAddress} -> Text
emailAddress) (\s :: CreateContact
s@CreateContact' {} Text
a -> CreateContact
s {$sel:emailAddress:CreateContact' :: Text
emailAddress = Text
a} :: CreateContact)
instance Core.AWSRequest CreateContact where
type
AWSResponse CreateContact =
CreateContactResponse
request :: (Service -> Service) -> CreateContact -> Request CreateContact
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 CreateContact
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateContact)))
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 -> CreateContactResponse
CreateContactResponse'
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 CreateContact where
hashWithSalt :: Int -> CreateContact -> Int
hashWithSalt Int
_salt CreateContact' {Maybe Bool
Maybe [TopicPreference]
Maybe Text
Text
emailAddress :: Text
contactListName :: Text
unsubscribeAll :: Maybe Bool
topicPreferences :: Maybe [TopicPreference]
attributesData :: Maybe Text
$sel:emailAddress:CreateContact' :: CreateContact -> Text
$sel:contactListName:CreateContact' :: CreateContact -> Text
$sel:unsubscribeAll:CreateContact' :: CreateContact -> Maybe Bool
$sel:topicPreferences:CreateContact' :: CreateContact -> Maybe [TopicPreference]
$sel:attributesData:CreateContact' :: CreateContact -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
attributesData
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [TopicPreference]
topicPreferences
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
unsubscribeAll
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
contactListName
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
emailAddress
instance Prelude.NFData CreateContact where
rnf :: CreateContact -> ()
rnf CreateContact' {Maybe Bool
Maybe [TopicPreference]
Maybe Text
Text
emailAddress :: Text
contactListName :: Text
unsubscribeAll :: Maybe Bool
topicPreferences :: Maybe [TopicPreference]
attributesData :: Maybe Text
$sel:emailAddress:CreateContact' :: CreateContact -> Text
$sel:contactListName:CreateContact' :: CreateContact -> Text
$sel:unsubscribeAll:CreateContact' :: CreateContact -> Maybe Bool
$sel:topicPreferences:CreateContact' :: CreateContact -> Maybe [TopicPreference]
$sel:attributesData:CreateContact' :: CreateContact -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
attributesData
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [TopicPreference]
topicPreferences
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
unsubscribeAll
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
contactListName
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
emailAddress
instance Data.ToHeaders CreateContact where
toHeaders :: CreateContact -> 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 CreateContact where
toJSON :: CreateContact -> Value
toJSON CreateContact' {Maybe Bool
Maybe [TopicPreference]
Maybe Text
Text
emailAddress :: Text
contactListName :: Text
unsubscribeAll :: Maybe Bool
topicPreferences :: Maybe [TopicPreference]
attributesData :: Maybe Text
$sel:emailAddress:CreateContact' :: CreateContact -> Text
$sel:contactListName:CreateContact' :: CreateContact -> Text
$sel:unsubscribeAll:CreateContact' :: CreateContact -> Maybe Bool
$sel:topicPreferences:CreateContact' :: CreateContact -> Maybe [TopicPreference]
$sel:attributesData:CreateContact' :: CreateContact -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"AttributesData" 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
attributesData,
(Key
"TopicPreferences" 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 [TopicPreference]
topicPreferences,
(Key
"UnsubscribeAll" 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
unsubscribeAll,
forall a. a -> Maybe a
Prelude.Just (Key
"EmailAddress" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
emailAddress)
]
)
instance Data.ToPath CreateContact where
toPath :: CreateContact -> ByteString
toPath CreateContact' {Maybe Bool
Maybe [TopicPreference]
Maybe Text
Text
emailAddress :: Text
contactListName :: Text
unsubscribeAll :: Maybe Bool
topicPreferences :: Maybe [TopicPreference]
attributesData :: Maybe Text
$sel:emailAddress:CreateContact' :: CreateContact -> Text
$sel:contactListName:CreateContact' :: CreateContact -> Text
$sel:unsubscribeAll:CreateContact' :: CreateContact -> Maybe Bool
$sel:topicPreferences:CreateContact' :: CreateContact -> Maybe [TopicPreference]
$sel:attributesData:CreateContact' :: CreateContact -> Maybe Text
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/v2/email/contact-lists/",
forall a. ToByteString a => a -> ByteString
Data.toBS Text
contactListName,
ByteString
"/contacts"
]
instance Data.ToQuery CreateContact where
toQuery :: CreateContact -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data CreateContactResponse = CreateContactResponse'
{
CreateContactResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateContactResponse -> CreateContactResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateContactResponse -> CreateContactResponse -> Bool
$c/= :: CreateContactResponse -> CreateContactResponse -> Bool
== :: CreateContactResponse -> CreateContactResponse -> Bool
$c== :: CreateContactResponse -> CreateContactResponse -> Bool
Prelude.Eq, ReadPrec [CreateContactResponse]
ReadPrec CreateContactResponse
Int -> ReadS CreateContactResponse
ReadS [CreateContactResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateContactResponse]
$creadListPrec :: ReadPrec [CreateContactResponse]
readPrec :: ReadPrec CreateContactResponse
$creadPrec :: ReadPrec CreateContactResponse
readList :: ReadS [CreateContactResponse]
$creadList :: ReadS [CreateContactResponse]
readsPrec :: Int -> ReadS CreateContactResponse
$creadsPrec :: Int -> ReadS CreateContactResponse
Prelude.Read, Int -> CreateContactResponse -> ShowS
[CreateContactResponse] -> ShowS
CreateContactResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateContactResponse] -> ShowS
$cshowList :: [CreateContactResponse] -> ShowS
show :: CreateContactResponse -> String
$cshow :: CreateContactResponse -> String
showsPrec :: Int -> CreateContactResponse -> ShowS
$cshowsPrec :: Int -> CreateContactResponse -> ShowS
Prelude.Show, forall x. Rep CreateContactResponse x -> CreateContactResponse
forall x. CreateContactResponse -> Rep CreateContactResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateContactResponse x -> CreateContactResponse
$cfrom :: forall x. CreateContactResponse -> Rep CreateContactResponse x
Prelude.Generic)
newCreateContactResponse ::
Prelude.Int ->
CreateContactResponse
newCreateContactResponse :: Int -> CreateContactResponse
newCreateContactResponse Int
pHttpStatus_ =
CreateContactResponse' {$sel:httpStatus:CreateContactResponse' :: Int
httpStatus = Int
pHttpStatus_}
createContactResponse_httpStatus :: Lens.Lens' CreateContactResponse Prelude.Int
createContactResponse_httpStatus :: Lens' CreateContactResponse Int
createContactResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContactResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateContactResponse' :: CreateContactResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateContactResponse
s@CreateContactResponse' {} Int
a -> CreateContactResponse
s {$sel:httpStatus:CreateContactResponse' :: Int
httpStatus = Int
a} :: CreateContactResponse)
instance Prelude.NFData CreateContactResponse where
rnf :: CreateContactResponse -> ()
rnf CreateContactResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateContactResponse' :: CreateContactResponse -> Int
..} =
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus