{-# 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.CreateCampaign
(
CreateCampaign (..),
newCreateCampaign,
createCampaign_applicationId,
createCampaign_writeCampaignRequest,
CreateCampaignResponse (..),
newCreateCampaignResponse,
createCampaignResponse_httpStatus,
createCampaignResponse_campaignResponse,
)
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 CreateCampaign = CreateCampaign'
{
CreateCampaign -> Text
applicationId :: Prelude.Text,
CreateCampaign -> WriteCampaignRequest
writeCampaignRequest :: WriteCampaignRequest
}
deriving (CreateCampaign -> CreateCampaign -> Bool
(CreateCampaign -> CreateCampaign -> Bool)
-> (CreateCampaign -> CreateCampaign -> Bool) -> Eq CreateCampaign
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCampaign -> CreateCampaign -> Bool
$c/= :: CreateCampaign -> CreateCampaign -> Bool
== :: CreateCampaign -> CreateCampaign -> Bool
$c== :: CreateCampaign -> CreateCampaign -> Bool
Prelude.Eq, ReadPrec [CreateCampaign]
ReadPrec CreateCampaign
Int -> ReadS CreateCampaign
ReadS [CreateCampaign]
(Int -> ReadS CreateCampaign)
-> ReadS [CreateCampaign]
-> ReadPrec CreateCampaign
-> ReadPrec [CreateCampaign]
-> Read CreateCampaign
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCampaign]
$creadListPrec :: ReadPrec [CreateCampaign]
readPrec :: ReadPrec CreateCampaign
$creadPrec :: ReadPrec CreateCampaign
readList :: ReadS [CreateCampaign]
$creadList :: ReadS [CreateCampaign]
readsPrec :: Int -> ReadS CreateCampaign
$creadsPrec :: Int -> ReadS CreateCampaign
Prelude.Read, Int -> CreateCampaign -> ShowS
[CreateCampaign] -> ShowS
CreateCampaign -> String
(Int -> CreateCampaign -> ShowS)
-> (CreateCampaign -> String)
-> ([CreateCampaign] -> ShowS)
-> Show CreateCampaign
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCampaign] -> ShowS
$cshowList :: [CreateCampaign] -> ShowS
show :: CreateCampaign -> String
$cshow :: CreateCampaign -> String
showsPrec :: Int -> CreateCampaign -> ShowS
$cshowsPrec :: Int -> CreateCampaign -> ShowS
Prelude.Show, (forall x. CreateCampaign -> Rep CreateCampaign x)
-> (forall x. Rep CreateCampaign x -> CreateCampaign)
-> Generic CreateCampaign
forall x. Rep CreateCampaign x -> CreateCampaign
forall x. CreateCampaign -> Rep CreateCampaign x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCampaign x -> CreateCampaign
$cfrom :: forall x. CreateCampaign -> Rep CreateCampaign x
Prelude.Generic)
newCreateCampaign ::
Prelude.Text ->
WriteCampaignRequest ->
CreateCampaign
newCreateCampaign :: Text -> WriteCampaignRequest -> CreateCampaign
newCreateCampaign
Text
pApplicationId_
WriteCampaignRequest
pWriteCampaignRequest_ =
CreateCampaign' :: Text -> WriteCampaignRequest -> CreateCampaign
CreateCampaign'
{ $sel:applicationId:CreateCampaign' :: Text
applicationId = Text
pApplicationId_,
$sel:writeCampaignRequest:CreateCampaign' :: WriteCampaignRequest
writeCampaignRequest = WriteCampaignRequest
pWriteCampaignRequest_
}
createCampaign_applicationId :: Lens.Lens' CreateCampaign Prelude.Text
createCampaign_applicationId :: (Text -> f Text) -> CreateCampaign -> f CreateCampaign
createCampaign_applicationId = (CreateCampaign -> Text)
-> (CreateCampaign -> Text -> CreateCampaign)
-> Lens CreateCampaign CreateCampaign Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCampaign' {Text
applicationId :: Text
$sel:applicationId:CreateCampaign' :: CreateCampaign -> Text
applicationId} -> Text
applicationId) (\s :: CreateCampaign
s@CreateCampaign' {} Text
a -> CreateCampaign
s {$sel:applicationId:CreateCampaign' :: Text
applicationId = Text
a} :: CreateCampaign)
createCampaign_writeCampaignRequest :: Lens.Lens' CreateCampaign WriteCampaignRequest
createCampaign_writeCampaignRequest :: (WriteCampaignRequest -> f WriteCampaignRequest)
-> CreateCampaign -> f CreateCampaign
createCampaign_writeCampaignRequest = (CreateCampaign -> WriteCampaignRequest)
-> (CreateCampaign -> WriteCampaignRequest -> CreateCampaign)
-> Lens
CreateCampaign
CreateCampaign
WriteCampaignRequest
WriteCampaignRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCampaign' {WriteCampaignRequest
writeCampaignRequest :: WriteCampaignRequest
$sel:writeCampaignRequest:CreateCampaign' :: CreateCampaign -> WriteCampaignRequest
writeCampaignRequest} -> WriteCampaignRequest
writeCampaignRequest) (\s :: CreateCampaign
s@CreateCampaign' {} WriteCampaignRequest
a -> CreateCampaign
s {$sel:writeCampaignRequest:CreateCampaign' :: WriteCampaignRequest
writeCampaignRequest = WriteCampaignRequest
a} :: CreateCampaign)
instance Core.AWSRequest CreateCampaign where
type
AWSResponse CreateCampaign =
CreateCampaignResponse
request :: CreateCampaign -> Request CreateCampaign
request = Service -> CreateCampaign -> Request CreateCampaign
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateCampaign
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCampaign)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateCampaign))
-> Logger
-> Service
-> Proxy CreateCampaign
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCampaign)))
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 -> CampaignResponse -> CreateCampaignResponse
CreateCampaignResponse'
(Int -> CampaignResponse -> CreateCampaignResponse)
-> Either String Int
-> Either String (CampaignResponse -> CreateCampaignResponse)
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 (CampaignResponse -> CreateCampaignResponse)
-> Either String CampaignResponse
-> Either String CreateCampaignResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String CampaignResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
)
instance Prelude.Hashable CreateCampaign
instance Prelude.NFData CreateCampaign
instance Core.ToHeaders CreateCampaign where
toHeaders :: CreateCampaign -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateCampaign -> 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 CreateCampaign where
toJSON :: CreateCampaign -> Value
toJSON CreateCampaign' {Text
WriteCampaignRequest
writeCampaignRequest :: WriteCampaignRequest
applicationId :: Text
$sel:writeCampaignRequest:CreateCampaign' :: CreateCampaign -> WriteCampaignRequest
$sel:applicationId:CreateCampaign' :: CreateCampaign -> 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
"WriteCampaignRequest"
Text -> WriteCampaignRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= WriteCampaignRequest
writeCampaignRequest
)
]
)
instance Core.ToPath CreateCampaign where
toPath :: CreateCampaign -> ByteString
toPath CreateCampaign' {Text
WriteCampaignRequest
writeCampaignRequest :: WriteCampaignRequest
applicationId :: Text
$sel:writeCampaignRequest:CreateCampaign' :: CreateCampaign -> WriteCampaignRequest
$sel:applicationId:CreateCampaign' :: CreateCampaign -> 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
"/campaigns"]
instance Core.ToQuery CreateCampaign where
toQuery :: CreateCampaign -> QueryString
toQuery = QueryString -> CreateCampaign -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateCampaignResponse = CreateCampaignResponse'
{
CreateCampaignResponse -> Int
httpStatus :: Prelude.Int,
CreateCampaignResponse -> CampaignResponse
campaignResponse :: CampaignResponse
}
deriving (CreateCampaignResponse -> CreateCampaignResponse -> Bool
(CreateCampaignResponse -> CreateCampaignResponse -> Bool)
-> (CreateCampaignResponse -> CreateCampaignResponse -> Bool)
-> Eq CreateCampaignResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCampaignResponse -> CreateCampaignResponse -> Bool
$c/= :: CreateCampaignResponse -> CreateCampaignResponse -> Bool
== :: CreateCampaignResponse -> CreateCampaignResponse -> Bool
$c== :: CreateCampaignResponse -> CreateCampaignResponse -> Bool
Prelude.Eq, ReadPrec [CreateCampaignResponse]
ReadPrec CreateCampaignResponse
Int -> ReadS CreateCampaignResponse
ReadS [CreateCampaignResponse]
(Int -> ReadS CreateCampaignResponse)
-> ReadS [CreateCampaignResponse]
-> ReadPrec CreateCampaignResponse
-> ReadPrec [CreateCampaignResponse]
-> Read CreateCampaignResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCampaignResponse]
$creadListPrec :: ReadPrec [CreateCampaignResponse]
readPrec :: ReadPrec CreateCampaignResponse
$creadPrec :: ReadPrec CreateCampaignResponse
readList :: ReadS [CreateCampaignResponse]
$creadList :: ReadS [CreateCampaignResponse]
readsPrec :: Int -> ReadS CreateCampaignResponse
$creadsPrec :: Int -> ReadS CreateCampaignResponse
Prelude.Read, Int -> CreateCampaignResponse -> ShowS
[CreateCampaignResponse] -> ShowS
CreateCampaignResponse -> String
(Int -> CreateCampaignResponse -> ShowS)
-> (CreateCampaignResponse -> String)
-> ([CreateCampaignResponse] -> ShowS)
-> Show CreateCampaignResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCampaignResponse] -> ShowS
$cshowList :: [CreateCampaignResponse] -> ShowS
show :: CreateCampaignResponse -> String
$cshow :: CreateCampaignResponse -> String
showsPrec :: Int -> CreateCampaignResponse -> ShowS
$cshowsPrec :: Int -> CreateCampaignResponse -> ShowS
Prelude.Show, (forall x. CreateCampaignResponse -> Rep CreateCampaignResponse x)
-> (forall x.
Rep CreateCampaignResponse x -> CreateCampaignResponse)
-> Generic CreateCampaignResponse
forall x. Rep CreateCampaignResponse x -> CreateCampaignResponse
forall x. CreateCampaignResponse -> Rep CreateCampaignResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCampaignResponse x -> CreateCampaignResponse
$cfrom :: forall x. CreateCampaignResponse -> Rep CreateCampaignResponse x
Prelude.Generic)
newCreateCampaignResponse ::
Prelude.Int ->
CampaignResponse ->
CreateCampaignResponse
newCreateCampaignResponse :: Int -> CampaignResponse -> CreateCampaignResponse
newCreateCampaignResponse
Int
pHttpStatus_
CampaignResponse
pCampaignResponse_ =
CreateCampaignResponse' :: Int -> CampaignResponse -> CreateCampaignResponse
CreateCampaignResponse'
{ $sel:httpStatus:CreateCampaignResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:campaignResponse:CreateCampaignResponse' :: CampaignResponse
campaignResponse = CampaignResponse
pCampaignResponse_
}
createCampaignResponse_httpStatus :: Lens.Lens' CreateCampaignResponse Prelude.Int
createCampaignResponse_httpStatus :: (Int -> f Int)
-> CreateCampaignResponse -> f CreateCampaignResponse
createCampaignResponse_httpStatus = (CreateCampaignResponse -> Int)
-> (CreateCampaignResponse -> Int -> CreateCampaignResponse)
-> Lens CreateCampaignResponse CreateCampaignResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCampaignResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateCampaignResponse' :: CreateCampaignResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateCampaignResponse
s@CreateCampaignResponse' {} Int
a -> CreateCampaignResponse
s {$sel:httpStatus:CreateCampaignResponse' :: Int
httpStatus = Int
a} :: CreateCampaignResponse)
createCampaignResponse_campaignResponse :: Lens.Lens' CreateCampaignResponse CampaignResponse
createCampaignResponse_campaignResponse :: (CampaignResponse -> f CampaignResponse)
-> CreateCampaignResponse -> f CreateCampaignResponse
createCampaignResponse_campaignResponse = (CreateCampaignResponse -> CampaignResponse)
-> (CreateCampaignResponse
-> CampaignResponse -> CreateCampaignResponse)
-> Lens
CreateCampaignResponse
CreateCampaignResponse
CampaignResponse
CampaignResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCampaignResponse' {CampaignResponse
campaignResponse :: CampaignResponse
$sel:campaignResponse:CreateCampaignResponse' :: CreateCampaignResponse -> CampaignResponse
campaignResponse} -> CampaignResponse
campaignResponse) (\s :: CreateCampaignResponse
s@CreateCampaignResponse' {} CampaignResponse
a -> CreateCampaignResponse
s {$sel:campaignResponse:CreateCampaignResponse' :: CampaignResponse
campaignResponse = CampaignResponse
a} :: CreateCampaignResponse)
instance Prelude.NFData CreateCampaignResponse