{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $sel:applicationId:CreateCampaign' :: Text
applicationId = Text
pApplicationId_,
$sel:writeCampaignRequest:CreateCampaign' :: WriteCampaignRequest
writeCampaignRequest = WriteCampaignRequest
pWriteCampaignRequest_
}
createCampaign_applicationId :: Lens.Lens' CreateCampaign Prelude.Text
createCampaign_applicationId :: Lens' CreateCampaign Text
createCampaign_applicationId = 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 :: Lens' CreateCampaign WriteCampaignRequest
createCampaign_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 :: (Service -> Service) -> CreateCampaign -> Request CreateCampaign
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateCampaign
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateCampaign)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Int -> CampaignResponse -> CreateCampaignResponse
CreateCampaignResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)
)
instance Prelude.Hashable CreateCampaign where
hashWithSalt :: Int -> CreateCampaign -> Int
hashWithSalt Int
_salt CreateCampaign' {Text
WriteCampaignRequest
writeCampaignRequest :: WriteCampaignRequest
applicationId :: Text
$sel:writeCampaignRequest:CreateCampaign' :: CreateCampaign -> WriteCampaignRequest
$sel:applicationId:CreateCampaign' :: CreateCampaign -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` WriteCampaignRequest
writeCampaignRequest
instance Prelude.NFData CreateCampaign where
rnf :: CreateCampaign -> ()
rnf CreateCampaign' {Text
WriteCampaignRequest
writeCampaignRequest :: WriteCampaignRequest
applicationId :: Text
$sel:writeCampaignRequest:CreateCampaign' :: CreateCampaign -> WriteCampaignRequest
$sel:applicationId:CreateCampaign' :: CreateCampaign -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
applicationId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf WriteCampaignRequest
writeCampaignRequest
instance Data.ToHeaders CreateCampaign where
toHeaders :: CreateCampaign -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON CreateCampaign where
toJSON :: CreateCampaign -> Value
toJSON CreateCampaign' {Text
WriteCampaignRequest
writeCampaignRequest :: WriteCampaignRequest
applicationId :: Text
$sel:writeCampaignRequest:CreateCampaign' :: CreateCampaign -> WriteCampaignRequest
$sel:applicationId:CreateCampaign' :: CreateCampaign -> Text
..} =
forall a. ToJSON a => a -> Value
Data.toJSON WriteCampaignRequest
writeCampaignRequest
instance Data.ToPath CreateCampaign where
toPath :: CreateCampaign -> ByteString
toPath CreateCampaign' {Text
WriteCampaignRequest
writeCampaignRequest :: WriteCampaignRequest
applicationId :: Text
$sel:writeCampaignRequest:CreateCampaign' :: CreateCampaign -> WriteCampaignRequest
$sel:applicationId:CreateCampaign' :: CreateCampaign -> Text
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/v1/apps/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
applicationId, ByteString
"/campaigns"]
instance Data.ToQuery CreateCampaign where
toQuery :: CreateCampaign -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data CreateCampaignResponse = CreateCampaignResponse'
{
CreateCampaignResponse -> Int
httpStatus :: Prelude.Int,
CreateCampaignResponse -> CampaignResponse
campaignResponse :: CampaignResponse
}
deriving (CreateCampaignResponse -> CreateCampaignResponse -> Bool
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]
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
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. 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'
{ $sel:httpStatus:CreateCampaignResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:campaignResponse:CreateCampaignResponse' :: CampaignResponse
campaignResponse = CampaignResponse
pCampaignResponse_
}
createCampaignResponse_httpStatus :: Lens.Lens' CreateCampaignResponse Prelude.Int
createCampaignResponse_httpStatus :: Lens' CreateCampaignResponse Int
createCampaignResponse_httpStatus = 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 :: Lens' CreateCampaignResponse CampaignResponse
createCampaignResponse_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 where
rnf :: CreateCampaignResponse -> ()
rnf CreateCampaignResponse' {Int
CampaignResponse
campaignResponse :: CampaignResponse
httpStatus :: Int
$sel:campaignResponse:CreateCampaignResponse' :: CreateCampaignResponse -> CampaignResponse
$sel:httpStatus:CreateCampaignResponse' :: CreateCampaignResponse -> Int
..} =
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CampaignResponse
campaignResponse