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