{-# 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.Pinpoint.CreateEmailTemplate
(
CreateEmailTemplate (..),
newCreateEmailTemplate,
createEmailTemplate_templateName,
createEmailTemplate_emailTemplateRequest,
CreateEmailTemplateResponse (..),
newCreateEmailTemplateResponse,
createEmailTemplateResponse_httpStatus,
createEmailTemplateResponse_createTemplateMessageBody,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateEmailTemplate = CreateEmailTemplate'
{
CreateEmailTemplate -> Text
templateName :: Prelude.Text,
CreateEmailTemplate -> EmailTemplateRequest
emailTemplateRequest :: EmailTemplateRequest
}
deriving (CreateEmailTemplate -> CreateEmailTemplate -> Bool
(CreateEmailTemplate -> CreateEmailTemplate -> Bool)
-> (CreateEmailTemplate -> CreateEmailTemplate -> Bool)
-> Eq CreateEmailTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateEmailTemplate -> CreateEmailTemplate -> Bool
$c/= :: CreateEmailTemplate -> CreateEmailTemplate -> Bool
== :: CreateEmailTemplate -> CreateEmailTemplate -> Bool
$c== :: CreateEmailTemplate -> CreateEmailTemplate -> Bool
Prelude.Eq, ReadPrec [CreateEmailTemplate]
ReadPrec CreateEmailTemplate
Int -> ReadS CreateEmailTemplate
ReadS [CreateEmailTemplate]
(Int -> ReadS CreateEmailTemplate)
-> ReadS [CreateEmailTemplate]
-> ReadPrec CreateEmailTemplate
-> ReadPrec [CreateEmailTemplate]
-> Read CreateEmailTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateEmailTemplate]
$creadListPrec :: ReadPrec [CreateEmailTemplate]
readPrec :: ReadPrec CreateEmailTemplate
$creadPrec :: ReadPrec CreateEmailTemplate
readList :: ReadS [CreateEmailTemplate]
$creadList :: ReadS [CreateEmailTemplate]
readsPrec :: Int -> ReadS CreateEmailTemplate
$creadsPrec :: Int -> ReadS CreateEmailTemplate
Prelude.Read, Int -> CreateEmailTemplate -> ShowS
[CreateEmailTemplate] -> ShowS
CreateEmailTemplate -> String
(Int -> CreateEmailTemplate -> ShowS)
-> (CreateEmailTemplate -> String)
-> ([CreateEmailTemplate] -> ShowS)
-> Show CreateEmailTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateEmailTemplate] -> ShowS
$cshowList :: [CreateEmailTemplate] -> ShowS
show :: CreateEmailTemplate -> String
$cshow :: CreateEmailTemplate -> String
showsPrec :: Int -> CreateEmailTemplate -> ShowS
$cshowsPrec :: Int -> CreateEmailTemplate -> ShowS
Prelude.Show, (forall x. CreateEmailTemplate -> Rep CreateEmailTemplate x)
-> (forall x. Rep CreateEmailTemplate x -> CreateEmailTemplate)
-> Generic CreateEmailTemplate
forall x. Rep CreateEmailTemplate x -> CreateEmailTemplate
forall x. CreateEmailTemplate -> Rep CreateEmailTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateEmailTemplate x -> CreateEmailTemplate
$cfrom :: forall x. CreateEmailTemplate -> Rep CreateEmailTemplate x
Prelude.Generic)
newCreateEmailTemplate ::
Prelude.Text ->
EmailTemplateRequest ->
CreateEmailTemplate
newCreateEmailTemplate :: Text -> EmailTemplateRequest -> CreateEmailTemplate
newCreateEmailTemplate
Text
pTemplateName_
EmailTemplateRequest
pEmailTemplateRequest_ =
CreateEmailTemplate' :: Text -> EmailTemplateRequest -> CreateEmailTemplate
CreateEmailTemplate'
{ $sel:templateName:CreateEmailTemplate' :: Text
templateName = Text
pTemplateName_,
$sel:emailTemplateRequest:CreateEmailTemplate' :: EmailTemplateRequest
emailTemplateRequest = EmailTemplateRequest
pEmailTemplateRequest_
}
createEmailTemplate_templateName :: Lens.Lens' CreateEmailTemplate Prelude.Text
createEmailTemplate_templateName :: (Text -> f Text) -> CreateEmailTemplate -> f CreateEmailTemplate
createEmailTemplate_templateName = (CreateEmailTemplate -> Text)
-> (CreateEmailTemplate -> Text -> CreateEmailTemplate)
-> Lens CreateEmailTemplate CreateEmailTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEmailTemplate' {Text
templateName :: Text
$sel:templateName:CreateEmailTemplate' :: CreateEmailTemplate -> Text
templateName} -> Text
templateName) (\s :: CreateEmailTemplate
s@CreateEmailTemplate' {} Text
a -> CreateEmailTemplate
s {$sel:templateName:CreateEmailTemplate' :: Text
templateName = Text
a} :: CreateEmailTemplate)
createEmailTemplate_emailTemplateRequest :: Lens.Lens' CreateEmailTemplate EmailTemplateRequest
createEmailTemplate_emailTemplateRequest :: (EmailTemplateRequest -> f EmailTemplateRequest)
-> CreateEmailTemplate -> f CreateEmailTemplate
createEmailTemplate_emailTemplateRequest = (CreateEmailTemplate -> EmailTemplateRequest)
-> (CreateEmailTemplate
-> EmailTemplateRequest -> CreateEmailTemplate)
-> Lens
CreateEmailTemplate
CreateEmailTemplate
EmailTemplateRequest
EmailTemplateRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEmailTemplate' {EmailTemplateRequest
emailTemplateRequest :: EmailTemplateRequest
$sel:emailTemplateRequest:CreateEmailTemplate' :: CreateEmailTemplate -> EmailTemplateRequest
emailTemplateRequest} -> EmailTemplateRequest
emailTemplateRequest) (\s :: CreateEmailTemplate
s@CreateEmailTemplate' {} EmailTemplateRequest
a -> CreateEmailTemplate
s {$sel:emailTemplateRequest:CreateEmailTemplate' :: EmailTemplateRequest
emailTemplateRequest = EmailTemplateRequest
a} :: CreateEmailTemplate)
instance Core.AWSRequest CreateEmailTemplate where
type
AWSResponse CreateEmailTemplate =
CreateEmailTemplateResponse
request :: CreateEmailTemplate -> Request CreateEmailTemplate
request = Service -> CreateEmailTemplate -> Request CreateEmailTemplate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateEmailTemplate
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateEmailTemplate)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateEmailTemplate))
-> Logger
-> Service
-> Proxy CreateEmailTemplate
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateEmailTemplate)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Int -> CreateTemplateMessageBody -> CreateEmailTemplateResponse
CreateEmailTemplateResponse'
(Int -> CreateTemplateMessageBody -> CreateEmailTemplateResponse)
-> Either String Int
-> Either
String (CreateTemplateMessageBody -> CreateEmailTemplateResponse)
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))
Either
String (CreateTemplateMessageBody -> CreateEmailTemplateResponse)
-> Either String CreateTemplateMessageBody
-> Either String CreateEmailTemplateResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String CreateTemplateMessageBody
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
)
instance Prelude.Hashable CreateEmailTemplate
instance Prelude.NFData CreateEmailTemplate
instance Core.ToHeaders CreateEmailTemplate where
toHeaders :: CreateEmailTemplate -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateEmailTemplate -> 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 CreateEmailTemplate where
toJSON :: CreateEmailTemplate -> Value
toJSON CreateEmailTemplate' {Text
EmailTemplateRequest
emailTemplateRequest :: EmailTemplateRequest
templateName :: Text
$sel:emailTemplateRequest:CreateEmailTemplate' :: CreateEmailTemplate -> EmailTemplateRequest
$sel:templateName:CreateEmailTemplate' :: CreateEmailTemplate -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
( Text
"EmailTemplateRequest"
Text -> EmailTemplateRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= EmailTemplateRequest
emailTemplateRequest
)
]
)
instance Core.ToPath CreateEmailTemplate where
toPath :: CreateEmailTemplate -> ByteString
toPath CreateEmailTemplate' {Text
EmailTemplateRequest
emailTemplateRequest :: EmailTemplateRequest
templateName :: Text
$sel:emailTemplateRequest:CreateEmailTemplate' :: CreateEmailTemplate -> EmailTemplateRequest
$sel:templateName:CreateEmailTemplate' :: CreateEmailTemplate -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/v1/templates/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
templateName, ByteString
"/email"]
instance Core.ToQuery CreateEmailTemplate where
toQuery :: CreateEmailTemplate -> QueryString
toQuery = QueryString -> CreateEmailTemplate -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateEmailTemplateResponse = CreateEmailTemplateResponse'
{
CreateEmailTemplateResponse -> Int
httpStatus :: Prelude.Int,
CreateEmailTemplateResponse -> CreateTemplateMessageBody
createTemplateMessageBody :: CreateTemplateMessageBody
}
deriving (CreateEmailTemplateResponse -> CreateEmailTemplateResponse -> Bool
(CreateEmailTemplateResponse
-> CreateEmailTemplateResponse -> Bool)
-> (CreateEmailTemplateResponse
-> CreateEmailTemplateResponse -> Bool)
-> Eq CreateEmailTemplateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateEmailTemplateResponse -> CreateEmailTemplateResponse -> Bool
$c/= :: CreateEmailTemplateResponse -> CreateEmailTemplateResponse -> Bool
== :: CreateEmailTemplateResponse -> CreateEmailTemplateResponse -> Bool
$c== :: CreateEmailTemplateResponse -> CreateEmailTemplateResponse -> Bool
Prelude.Eq, ReadPrec [CreateEmailTemplateResponse]
ReadPrec CreateEmailTemplateResponse
Int -> ReadS CreateEmailTemplateResponse
ReadS [CreateEmailTemplateResponse]
(Int -> ReadS CreateEmailTemplateResponse)
-> ReadS [CreateEmailTemplateResponse]
-> ReadPrec CreateEmailTemplateResponse
-> ReadPrec [CreateEmailTemplateResponse]
-> Read CreateEmailTemplateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateEmailTemplateResponse]
$creadListPrec :: ReadPrec [CreateEmailTemplateResponse]
readPrec :: ReadPrec CreateEmailTemplateResponse
$creadPrec :: ReadPrec CreateEmailTemplateResponse
readList :: ReadS [CreateEmailTemplateResponse]
$creadList :: ReadS [CreateEmailTemplateResponse]
readsPrec :: Int -> ReadS CreateEmailTemplateResponse
$creadsPrec :: Int -> ReadS CreateEmailTemplateResponse
Prelude.Read, Int -> CreateEmailTemplateResponse -> ShowS
[CreateEmailTemplateResponse] -> ShowS
CreateEmailTemplateResponse -> String
(Int -> CreateEmailTemplateResponse -> ShowS)
-> (CreateEmailTemplateResponse -> String)
-> ([CreateEmailTemplateResponse] -> ShowS)
-> Show CreateEmailTemplateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateEmailTemplateResponse] -> ShowS
$cshowList :: [CreateEmailTemplateResponse] -> ShowS
show :: CreateEmailTemplateResponse -> String
$cshow :: CreateEmailTemplateResponse -> String
showsPrec :: Int -> CreateEmailTemplateResponse -> ShowS
$cshowsPrec :: Int -> CreateEmailTemplateResponse -> ShowS
Prelude.Show, (forall x.
CreateEmailTemplateResponse -> Rep CreateEmailTemplateResponse x)
-> (forall x.
Rep CreateEmailTemplateResponse x -> CreateEmailTemplateResponse)
-> Generic CreateEmailTemplateResponse
forall x.
Rep CreateEmailTemplateResponse x -> CreateEmailTemplateResponse
forall x.
CreateEmailTemplateResponse -> Rep CreateEmailTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateEmailTemplateResponse x -> CreateEmailTemplateResponse
$cfrom :: forall x.
CreateEmailTemplateResponse -> Rep CreateEmailTemplateResponse x
Prelude.Generic)
newCreateEmailTemplateResponse ::
Prelude.Int ->
CreateTemplateMessageBody ->
CreateEmailTemplateResponse
newCreateEmailTemplateResponse :: Int -> CreateTemplateMessageBody -> CreateEmailTemplateResponse
newCreateEmailTemplateResponse
Int
pHttpStatus_
CreateTemplateMessageBody
pCreateTemplateMessageBody_ =
CreateEmailTemplateResponse' :: Int -> CreateTemplateMessageBody -> CreateEmailTemplateResponse
CreateEmailTemplateResponse'
{ $sel:httpStatus:CreateEmailTemplateResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:createTemplateMessageBody:CreateEmailTemplateResponse' :: CreateTemplateMessageBody
createTemplateMessageBody =
CreateTemplateMessageBody
pCreateTemplateMessageBody_
}
createEmailTemplateResponse_httpStatus :: Lens.Lens' CreateEmailTemplateResponse Prelude.Int
createEmailTemplateResponse_httpStatus :: (Int -> f Int)
-> CreateEmailTemplateResponse -> f CreateEmailTemplateResponse
createEmailTemplateResponse_httpStatus = (CreateEmailTemplateResponse -> Int)
-> (CreateEmailTemplateResponse
-> Int -> CreateEmailTemplateResponse)
-> Lens
CreateEmailTemplateResponse CreateEmailTemplateResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEmailTemplateResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateEmailTemplateResponse' :: CreateEmailTemplateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateEmailTemplateResponse
s@CreateEmailTemplateResponse' {} Int
a -> CreateEmailTemplateResponse
s {$sel:httpStatus:CreateEmailTemplateResponse' :: Int
httpStatus = Int
a} :: CreateEmailTemplateResponse)
createEmailTemplateResponse_createTemplateMessageBody :: Lens.Lens' CreateEmailTemplateResponse CreateTemplateMessageBody
createEmailTemplateResponse_createTemplateMessageBody :: (CreateTemplateMessageBody -> f CreateTemplateMessageBody)
-> CreateEmailTemplateResponse -> f CreateEmailTemplateResponse
createEmailTemplateResponse_createTemplateMessageBody = (CreateEmailTemplateResponse -> CreateTemplateMessageBody)
-> (CreateEmailTemplateResponse
-> CreateTemplateMessageBody -> CreateEmailTemplateResponse)
-> Lens
CreateEmailTemplateResponse
CreateEmailTemplateResponse
CreateTemplateMessageBody
CreateTemplateMessageBody
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateEmailTemplateResponse' {CreateTemplateMessageBody
createTemplateMessageBody :: CreateTemplateMessageBody
$sel:createTemplateMessageBody:CreateEmailTemplateResponse' :: CreateEmailTemplateResponse -> CreateTemplateMessageBody
createTemplateMessageBody} -> CreateTemplateMessageBody
createTemplateMessageBody) (\s :: CreateEmailTemplateResponse
s@CreateEmailTemplateResponse' {} CreateTemplateMessageBody
a -> CreateEmailTemplateResponse
s {$sel:createTemplateMessageBody:CreateEmailTemplateResponse' :: CreateTemplateMessageBody
createTemplateMessageBody = CreateTemplateMessageBody
a} :: CreateEmailTemplateResponse)
instance Prelude.NFData CreateEmailTemplateResponse