{-# 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.GetEmailTemplate
(
GetEmailTemplate (..),
newGetEmailTemplate,
getEmailTemplate_version,
getEmailTemplate_templateName,
GetEmailTemplateResponse (..),
newGetEmailTemplateResponse,
getEmailTemplateResponse_httpStatus,
getEmailTemplateResponse_emailTemplateResponse,
)
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 GetEmailTemplate = GetEmailTemplate'
{
GetEmailTemplate -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
GetEmailTemplate -> Text
templateName :: Prelude.Text
}
deriving (GetEmailTemplate -> GetEmailTemplate -> Bool
(GetEmailTemplate -> GetEmailTemplate -> Bool)
-> (GetEmailTemplate -> GetEmailTemplate -> Bool)
-> Eq GetEmailTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEmailTemplate -> GetEmailTemplate -> Bool
$c/= :: GetEmailTemplate -> GetEmailTemplate -> Bool
== :: GetEmailTemplate -> GetEmailTemplate -> Bool
$c== :: GetEmailTemplate -> GetEmailTemplate -> Bool
Prelude.Eq, ReadPrec [GetEmailTemplate]
ReadPrec GetEmailTemplate
Int -> ReadS GetEmailTemplate
ReadS [GetEmailTemplate]
(Int -> ReadS GetEmailTemplate)
-> ReadS [GetEmailTemplate]
-> ReadPrec GetEmailTemplate
-> ReadPrec [GetEmailTemplate]
-> Read GetEmailTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEmailTemplate]
$creadListPrec :: ReadPrec [GetEmailTemplate]
readPrec :: ReadPrec GetEmailTemplate
$creadPrec :: ReadPrec GetEmailTemplate
readList :: ReadS [GetEmailTemplate]
$creadList :: ReadS [GetEmailTemplate]
readsPrec :: Int -> ReadS GetEmailTemplate
$creadsPrec :: Int -> ReadS GetEmailTemplate
Prelude.Read, Int -> GetEmailTemplate -> ShowS
[GetEmailTemplate] -> ShowS
GetEmailTemplate -> String
(Int -> GetEmailTemplate -> ShowS)
-> (GetEmailTemplate -> String)
-> ([GetEmailTemplate] -> ShowS)
-> Show GetEmailTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEmailTemplate] -> ShowS
$cshowList :: [GetEmailTemplate] -> ShowS
show :: GetEmailTemplate -> String
$cshow :: GetEmailTemplate -> String
showsPrec :: Int -> GetEmailTemplate -> ShowS
$cshowsPrec :: Int -> GetEmailTemplate -> ShowS
Prelude.Show, (forall x. GetEmailTemplate -> Rep GetEmailTemplate x)
-> (forall x. Rep GetEmailTemplate x -> GetEmailTemplate)
-> Generic GetEmailTemplate
forall x. Rep GetEmailTemplate x -> GetEmailTemplate
forall x. GetEmailTemplate -> Rep GetEmailTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetEmailTemplate x -> GetEmailTemplate
$cfrom :: forall x. GetEmailTemplate -> Rep GetEmailTemplate x
Prelude.Generic)
newGetEmailTemplate ::
Prelude.Text ->
GetEmailTemplate
newGetEmailTemplate :: Text -> GetEmailTemplate
newGetEmailTemplate Text
pTemplateName_ =
GetEmailTemplate' :: Maybe Text -> Text -> GetEmailTemplate
GetEmailTemplate'
{ $sel:version:GetEmailTemplate' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:templateName:GetEmailTemplate' :: Text
templateName = Text
pTemplateName_
}
getEmailTemplate_version :: Lens.Lens' GetEmailTemplate (Prelude.Maybe Prelude.Text)
getEmailTemplate_version :: (Maybe Text -> f (Maybe Text))
-> GetEmailTemplate -> f GetEmailTemplate
getEmailTemplate_version = (GetEmailTemplate -> Maybe Text)
-> (GetEmailTemplate -> Maybe Text -> GetEmailTemplate)
-> Lens GetEmailTemplate GetEmailTemplate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEmailTemplate' {Maybe Text
version :: Maybe Text
$sel:version:GetEmailTemplate' :: GetEmailTemplate -> Maybe Text
version} -> Maybe Text
version) (\s :: GetEmailTemplate
s@GetEmailTemplate' {} Maybe Text
a -> GetEmailTemplate
s {$sel:version:GetEmailTemplate' :: Maybe Text
version = Maybe Text
a} :: GetEmailTemplate)
getEmailTemplate_templateName :: Lens.Lens' GetEmailTemplate Prelude.Text
getEmailTemplate_templateName :: (Text -> f Text) -> GetEmailTemplate -> f GetEmailTemplate
getEmailTemplate_templateName = (GetEmailTemplate -> Text)
-> (GetEmailTemplate -> Text -> GetEmailTemplate)
-> Lens GetEmailTemplate GetEmailTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEmailTemplate' {Text
templateName :: Text
$sel:templateName:GetEmailTemplate' :: GetEmailTemplate -> Text
templateName} -> Text
templateName) (\s :: GetEmailTemplate
s@GetEmailTemplate' {} Text
a -> GetEmailTemplate
s {$sel:templateName:GetEmailTemplate' :: Text
templateName = Text
a} :: GetEmailTemplate)
instance Core.AWSRequest GetEmailTemplate where
type
AWSResponse GetEmailTemplate =
GetEmailTemplateResponse
request :: GetEmailTemplate -> Request GetEmailTemplate
request = Service -> GetEmailTemplate -> Request GetEmailTemplate
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy GetEmailTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetEmailTemplate)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetEmailTemplate))
-> Logger
-> Service
-> Proxy GetEmailTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetEmailTemplate)))
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 -> EmailTemplateResponse -> GetEmailTemplateResponse
GetEmailTemplateResponse'
(Int -> EmailTemplateResponse -> GetEmailTemplateResponse)
-> Either String Int
-> Either
String (EmailTemplateResponse -> GetEmailTemplateResponse)
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 (EmailTemplateResponse -> GetEmailTemplateResponse)
-> Either String EmailTemplateResponse
-> Either String GetEmailTemplateResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String EmailTemplateResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
)
instance Prelude.Hashable GetEmailTemplate
instance Prelude.NFData GetEmailTemplate
instance Core.ToHeaders GetEmailTemplate where
toHeaders :: GetEmailTemplate -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetEmailTemplate -> 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.ToPath GetEmailTemplate where
toPath :: GetEmailTemplate -> ByteString
toPath GetEmailTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:GetEmailTemplate' :: GetEmailTemplate -> Text
$sel:version:GetEmailTemplate' :: GetEmailTemplate -> Maybe 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 GetEmailTemplate where
toQuery :: GetEmailTemplate -> QueryString
toQuery GetEmailTemplate' {Maybe Text
Text
templateName :: Text
version :: Maybe Text
$sel:templateName:GetEmailTemplate' :: GetEmailTemplate -> Text
$sel:version:GetEmailTemplate' :: GetEmailTemplate -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"version" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
version]
data GetEmailTemplateResponse = GetEmailTemplateResponse'
{
GetEmailTemplateResponse -> Int
httpStatus :: Prelude.Int,
GetEmailTemplateResponse -> EmailTemplateResponse
emailTemplateResponse :: EmailTemplateResponse
}
deriving (GetEmailTemplateResponse -> GetEmailTemplateResponse -> Bool
(GetEmailTemplateResponse -> GetEmailTemplateResponse -> Bool)
-> (GetEmailTemplateResponse -> GetEmailTemplateResponse -> Bool)
-> Eq GetEmailTemplateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetEmailTemplateResponse -> GetEmailTemplateResponse -> Bool
$c/= :: GetEmailTemplateResponse -> GetEmailTemplateResponse -> Bool
== :: GetEmailTemplateResponse -> GetEmailTemplateResponse -> Bool
$c== :: GetEmailTemplateResponse -> GetEmailTemplateResponse -> Bool
Prelude.Eq, ReadPrec [GetEmailTemplateResponse]
ReadPrec GetEmailTemplateResponse
Int -> ReadS GetEmailTemplateResponse
ReadS [GetEmailTemplateResponse]
(Int -> ReadS GetEmailTemplateResponse)
-> ReadS [GetEmailTemplateResponse]
-> ReadPrec GetEmailTemplateResponse
-> ReadPrec [GetEmailTemplateResponse]
-> Read GetEmailTemplateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetEmailTemplateResponse]
$creadListPrec :: ReadPrec [GetEmailTemplateResponse]
readPrec :: ReadPrec GetEmailTemplateResponse
$creadPrec :: ReadPrec GetEmailTemplateResponse
readList :: ReadS [GetEmailTemplateResponse]
$creadList :: ReadS [GetEmailTemplateResponse]
readsPrec :: Int -> ReadS GetEmailTemplateResponse
$creadsPrec :: Int -> ReadS GetEmailTemplateResponse
Prelude.Read, Int -> GetEmailTemplateResponse -> ShowS
[GetEmailTemplateResponse] -> ShowS
GetEmailTemplateResponse -> String
(Int -> GetEmailTemplateResponse -> ShowS)
-> (GetEmailTemplateResponse -> String)
-> ([GetEmailTemplateResponse] -> ShowS)
-> Show GetEmailTemplateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetEmailTemplateResponse] -> ShowS
$cshowList :: [GetEmailTemplateResponse] -> ShowS
show :: GetEmailTemplateResponse -> String
$cshow :: GetEmailTemplateResponse -> String
showsPrec :: Int -> GetEmailTemplateResponse -> ShowS
$cshowsPrec :: Int -> GetEmailTemplateResponse -> ShowS
Prelude.Show, (forall x.
GetEmailTemplateResponse -> Rep GetEmailTemplateResponse x)
-> (forall x.
Rep GetEmailTemplateResponse x -> GetEmailTemplateResponse)
-> Generic GetEmailTemplateResponse
forall x.
Rep GetEmailTemplateResponse x -> GetEmailTemplateResponse
forall x.
GetEmailTemplateResponse -> Rep GetEmailTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetEmailTemplateResponse x -> GetEmailTemplateResponse
$cfrom :: forall x.
GetEmailTemplateResponse -> Rep GetEmailTemplateResponse x
Prelude.Generic)
newGetEmailTemplateResponse ::
Prelude.Int ->
EmailTemplateResponse ->
GetEmailTemplateResponse
newGetEmailTemplateResponse :: Int -> EmailTemplateResponse -> GetEmailTemplateResponse
newGetEmailTemplateResponse
Int
pHttpStatus_
EmailTemplateResponse
pEmailTemplateResponse_ =
GetEmailTemplateResponse' :: Int -> EmailTemplateResponse -> GetEmailTemplateResponse
GetEmailTemplateResponse'
{ $sel:httpStatus:GetEmailTemplateResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:emailTemplateResponse:GetEmailTemplateResponse' :: EmailTemplateResponse
emailTemplateResponse = EmailTemplateResponse
pEmailTemplateResponse_
}
getEmailTemplateResponse_httpStatus :: Lens.Lens' GetEmailTemplateResponse Prelude.Int
getEmailTemplateResponse_httpStatus :: (Int -> f Int)
-> GetEmailTemplateResponse -> f GetEmailTemplateResponse
getEmailTemplateResponse_httpStatus = (GetEmailTemplateResponse -> Int)
-> (GetEmailTemplateResponse -> Int -> GetEmailTemplateResponse)
-> Lens GetEmailTemplateResponse GetEmailTemplateResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEmailTemplateResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetEmailTemplateResponse' :: GetEmailTemplateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetEmailTemplateResponse
s@GetEmailTemplateResponse' {} Int
a -> GetEmailTemplateResponse
s {$sel:httpStatus:GetEmailTemplateResponse' :: Int
httpStatus = Int
a} :: GetEmailTemplateResponse)
getEmailTemplateResponse_emailTemplateResponse :: Lens.Lens' GetEmailTemplateResponse EmailTemplateResponse
getEmailTemplateResponse_emailTemplateResponse :: (EmailTemplateResponse -> f EmailTemplateResponse)
-> GetEmailTemplateResponse -> f GetEmailTemplateResponse
getEmailTemplateResponse_emailTemplateResponse = (GetEmailTemplateResponse -> EmailTemplateResponse)
-> (GetEmailTemplateResponse
-> EmailTemplateResponse -> GetEmailTemplateResponse)
-> Lens
GetEmailTemplateResponse
GetEmailTemplateResponse
EmailTemplateResponse
EmailTemplateResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEmailTemplateResponse' {EmailTemplateResponse
emailTemplateResponse :: EmailTemplateResponse
$sel:emailTemplateResponse:GetEmailTemplateResponse' :: GetEmailTemplateResponse -> EmailTemplateResponse
emailTemplateResponse} -> EmailTemplateResponse
emailTemplateResponse) (\s :: GetEmailTemplateResponse
s@GetEmailTemplateResponse' {} EmailTemplateResponse
a -> GetEmailTemplateResponse
s {$sel:emailTemplateResponse:GetEmailTemplateResponse' :: EmailTemplateResponse
emailTemplateResponse = EmailTemplateResponse
a} :: GetEmailTemplateResponse)
instance Prelude.NFData GetEmailTemplateResponse