{-# 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.SendMessages
(
SendMessages (..),
newSendMessages,
sendMessages_applicationId,
sendMessages_messageRequest,
SendMessagesResponse (..),
newSendMessagesResponse,
sendMessagesResponse_httpStatus,
sendMessagesResponse_messageResponse,
)
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 SendMessages = SendMessages'
{
SendMessages -> Text
applicationId :: Prelude.Text,
SendMessages -> MessageRequest
messageRequest :: MessageRequest
}
deriving (SendMessages -> SendMessages -> Bool
(SendMessages -> SendMessages -> Bool)
-> (SendMessages -> SendMessages -> Bool) -> Eq SendMessages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendMessages -> SendMessages -> Bool
$c/= :: SendMessages -> SendMessages -> Bool
== :: SendMessages -> SendMessages -> Bool
$c== :: SendMessages -> SendMessages -> Bool
Prelude.Eq, ReadPrec [SendMessages]
ReadPrec SendMessages
Int -> ReadS SendMessages
ReadS [SendMessages]
(Int -> ReadS SendMessages)
-> ReadS [SendMessages]
-> ReadPrec SendMessages
-> ReadPrec [SendMessages]
-> Read SendMessages
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendMessages]
$creadListPrec :: ReadPrec [SendMessages]
readPrec :: ReadPrec SendMessages
$creadPrec :: ReadPrec SendMessages
readList :: ReadS [SendMessages]
$creadList :: ReadS [SendMessages]
readsPrec :: Int -> ReadS SendMessages
$creadsPrec :: Int -> ReadS SendMessages
Prelude.Read, Int -> SendMessages -> ShowS
[SendMessages] -> ShowS
SendMessages -> String
(Int -> SendMessages -> ShowS)
-> (SendMessages -> String)
-> ([SendMessages] -> ShowS)
-> Show SendMessages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendMessages] -> ShowS
$cshowList :: [SendMessages] -> ShowS
show :: SendMessages -> String
$cshow :: SendMessages -> String
showsPrec :: Int -> SendMessages -> ShowS
$cshowsPrec :: Int -> SendMessages -> ShowS
Prelude.Show, (forall x. SendMessages -> Rep SendMessages x)
-> (forall x. Rep SendMessages x -> SendMessages)
-> Generic SendMessages
forall x. Rep SendMessages x -> SendMessages
forall x. SendMessages -> Rep SendMessages x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendMessages x -> SendMessages
$cfrom :: forall x. SendMessages -> Rep SendMessages x
Prelude.Generic)
newSendMessages ::
Prelude.Text ->
MessageRequest ->
SendMessages
newSendMessages :: Text -> MessageRequest -> SendMessages
newSendMessages Text
pApplicationId_ MessageRequest
pMessageRequest_ =
SendMessages' :: Text -> MessageRequest -> SendMessages
SendMessages'
{ $sel:applicationId:SendMessages' :: Text
applicationId = Text
pApplicationId_,
$sel:messageRequest:SendMessages' :: MessageRequest
messageRequest = MessageRequest
pMessageRequest_
}
sendMessages_applicationId :: Lens.Lens' SendMessages Prelude.Text
sendMessages_applicationId :: (Text -> f Text) -> SendMessages -> f SendMessages
sendMessages_applicationId = (SendMessages -> Text)
-> (SendMessages -> Text -> SendMessages)
-> Lens SendMessages SendMessages Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendMessages' {Text
applicationId :: Text
$sel:applicationId:SendMessages' :: SendMessages -> Text
applicationId} -> Text
applicationId) (\s :: SendMessages
s@SendMessages' {} Text
a -> SendMessages
s {$sel:applicationId:SendMessages' :: Text
applicationId = Text
a} :: SendMessages)
sendMessages_messageRequest :: Lens.Lens' SendMessages MessageRequest
sendMessages_messageRequest :: (MessageRequest -> f MessageRequest)
-> SendMessages -> f SendMessages
sendMessages_messageRequest = (SendMessages -> MessageRequest)
-> (SendMessages -> MessageRequest -> SendMessages)
-> Lens SendMessages SendMessages MessageRequest MessageRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendMessages' {MessageRequest
messageRequest :: MessageRequest
$sel:messageRequest:SendMessages' :: SendMessages -> MessageRequest
messageRequest} -> MessageRequest
messageRequest) (\s :: SendMessages
s@SendMessages' {} MessageRequest
a -> SendMessages
s {$sel:messageRequest:SendMessages' :: MessageRequest
messageRequest = MessageRequest
a} :: SendMessages)
instance Core.AWSRequest SendMessages where
type AWSResponse SendMessages = SendMessagesResponse
request :: SendMessages -> Request SendMessages
request = Service -> SendMessages -> Request SendMessages
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy SendMessages
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendMessages)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse SendMessages))
-> Logger
-> Service
-> Proxy SendMessages
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendMessages)))
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 -> MessageResponse -> SendMessagesResponse
SendMessagesResponse'
(Int -> MessageResponse -> SendMessagesResponse)
-> Either String Int
-> Either String (MessageResponse -> SendMessagesResponse)
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 (MessageResponse -> SendMessagesResponse)
-> Either String MessageResponse
-> Either String SendMessagesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String MessageResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
)
instance Prelude.Hashable SendMessages
instance Prelude.NFData SendMessages
instance Core.ToHeaders SendMessages where
toHeaders :: SendMessages -> ResponseHeaders
toHeaders =
ResponseHeaders -> SendMessages -> 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 SendMessages where
toJSON :: SendMessages -> Value
toJSON SendMessages' {Text
MessageRequest
messageRequest :: MessageRequest
applicationId :: Text
$sel:messageRequest:SendMessages' :: SendMessages -> MessageRequest
$sel:applicationId:SendMessages' :: SendMessages -> 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
"MessageRequest" Text -> MessageRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= MessageRequest
messageRequest)
]
)
instance Core.ToPath SendMessages where
toPath :: SendMessages -> ByteString
toPath SendMessages' {Text
MessageRequest
messageRequest :: MessageRequest
applicationId :: Text
$sel:messageRequest:SendMessages' :: SendMessages -> MessageRequest
$sel:applicationId:SendMessages' :: SendMessages -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/v1/apps/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId, ByteString
"/messages"]
instance Core.ToQuery SendMessages where
toQuery :: SendMessages -> QueryString
toQuery = QueryString -> SendMessages -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data SendMessagesResponse = SendMessagesResponse'
{
SendMessagesResponse -> Int
httpStatus :: Prelude.Int,
SendMessagesResponse -> MessageResponse
messageResponse :: MessageResponse
}
deriving (SendMessagesResponse -> SendMessagesResponse -> Bool
(SendMessagesResponse -> SendMessagesResponse -> Bool)
-> (SendMessagesResponse -> SendMessagesResponse -> Bool)
-> Eq SendMessagesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendMessagesResponse -> SendMessagesResponse -> Bool
$c/= :: SendMessagesResponse -> SendMessagesResponse -> Bool
== :: SendMessagesResponse -> SendMessagesResponse -> Bool
$c== :: SendMessagesResponse -> SendMessagesResponse -> Bool
Prelude.Eq, ReadPrec [SendMessagesResponse]
ReadPrec SendMessagesResponse
Int -> ReadS SendMessagesResponse
ReadS [SendMessagesResponse]
(Int -> ReadS SendMessagesResponse)
-> ReadS [SendMessagesResponse]
-> ReadPrec SendMessagesResponse
-> ReadPrec [SendMessagesResponse]
-> Read SendMessagesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendMessagesResponse]
$creadListPrec :: ReadPrec [SendMessagesResponse]
readPrec :: ReadPrec SendMessagesResponse
$creadPrec :: ReadPrec SendMessagesResponse
readList :: ReadS [SendMessagesResponse]
$creadList :: ReadS [SendMessagesResponse]
readsPrec :: Int -> ReadS SendMessagesResponse
$creadsPrec :: Int -> ReadS SendMessagesResponse
Prelude.Read, Int -> SendMessagesResponse -> ShowS
[SendMessagesResponse] -> ShowS
SendMessagesResponse -> String
(Int -> SendMessagesResponse -> ShowS)
-> (SendMessagesResponse -> String)
-> ([SendMessagesResponse] -> ShowS)
-> Show SendMessagesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendMessagesResponse] -> ShowS
$cshowList :: [SendMessagesResponse] -> ShowS
show :: SendMessagesResponse -> String
$cshow :: SendMessagesResponse -> String
showsPrec :: Int -> SendMessagesResponse -> ShowS
$cshowsPrec :: Int -> SendMessagesResponse -> ShowS
Prelude.Show, (forall x. SendMessagesResponse -> Rep SendMessagesResponse x)
-> (forall x. Rep SendMessagesResponse x -> SendMessagesResponse)
-> Generic SendMessagesResponse
forall x. Rep SendMessagesResponse x -> SendMessagesResponse
forall x. SendMessagesResponse -> Rep SendMessagesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendMessagesResponse x -> SendMessagesResponse
$cfrom :: forall x. SendMessagesResponse -> Rep SendMessagesResponse x
Prelude.Generic)
newSendMessagesResponse ::
Prelude.Int ->
MessageResponse ->
SendMessagesResponse
newSendMessagesResponse :: Int -> MessageResponse -> SendMessagesResponse
newSendMessagesResponse
Int
pHttpStatus_
MessageResponse
pMessageResponse_ =
SendMessagesResponse' :: Int -> MessageResponse -> SendMessagesResponse
SendMessagesResponse'
{ $sel:httpStatus:SendMessagesResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:messageResponse:SendMessagesResponse' :: MessageResponse
messageResponse = MessageResponse
pMessageResponse_
}
sendMessagesResponse_httpStatus :: Lens.Lens' SendMessagesResponse Prelude.Int
sendMessagesResponse_httpStatus :: (Int -> f Int) -> SendMessagesResponse -> f SendMessagesResponse
sendMessagesResponse_httpStatus = (SendMessagesResponse -> Int)
-> (SendMessagesResponse -> Int -> SendMessagesResponse)
-> Lens SendMessagesResponse SendMessagesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendMessagesResponse' {Int
httpStatus :: Int
$sel:httpStatus:SendMessagesResponse' :: SendMessagesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SendMessagesResponse
s@SendMessagesResponse' {} Int
a -> SendMessagesResponse
s {$sel:httpStatus:SendMessagesResponse' :: Int
httpStatus = Int
a} :: SendMessagesResponse)
sendMessagesResponse_messageResponse :: Lens.Lens' SendMessagesResponse MessageResponse
sendMessagesResponse_messageResponse :: (MessageResponse -> f MessageResponse)
-> SendMessagesResponse -> f SendMessagesResponse
sendMessagesResponse_messageResponse = (SendMessagesResponse -> MessageResponse)
-> (SendMessagesResponse
-> MessageResponse -> SendMessagesResponse)
-> Lens
SendMessagesResponse
SendMessagesResponse
MessageResponse
MessageResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendMessagesResponse' {MessageResponse
messageResponse :: MessageResponse
$sel:messageResponse:SendMessagesResponse' :: SendMessagesResponse -> MessageResponse
messageResponse} -> MessageResponse
messageResponse) (\s :: SendMessagesResponse
s@SendMessagesResponse' {} MessageResponse
a -> SendMessagesResponse
s {$sel:messageResponse:SendMessagesResponse' :: MessageResponse
messageResponse = MessageResponse
a} :: SendMessagesResponse)
instance Prelude.NFData SendMessagesResponse