{-# 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.UpdateCampaign
(
UpdateCampaign (..),
newUpdateCampaign,
updateCampaign_campaignId,
updateCampaign_applicationId,
updateCampaign_writeCampaignRequest,
UpdateCampaignResponse (..),
newUpdateCampaignResponse,
updateCampaignResponse_httpStatus,
updateCampaignResponse_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 UpdateCampaign = UpdateCampaign'
{
UpdateCampaign -> Text
campaignId :: Prelude.Text,
UpdateCampaign -> Text
applicationId :: Prelude.Text,
UpdateCampaign -> WriteCampaignRequest
writeCampaignRequest :: WriteCampaignRequest
}
deriving (UpdateCampaign -> UpdateCampaign -> Bool
(UpdateCampaign -> UpdateCampaign -> Bool)
-> (UpdateCampaign -> UpdateCampaign -> Bool) -> Eq UpdateCampaign
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateCampaign -> UpdateCampaign -> Bool
$c/= :: UpdateCampaign -> UpdateCampaign -> Bool
== :: UpdateCampaign -> UpdateCampaign -> Bool
$c== :: UpdateCampaign -> UpdateCampaign -> Bool
Prelude.Eq, ReadPrec [UpdateCampaign]
ReadPrec UpdateCampaign
Int -> ReadS UpdateCampaign
ReadS [UpdateCampaign]
(Int -> ReadS UpdateCampaign)
-> ReadS [UpdateCampaign]
-> ReadPrec UpdateCampaign
-> ReadPrec [UpdateCampaign]
-> Read UpdateCampaign
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateCampaign]
$creadListPrec :: ReadPrec [UpdateCampaign]
readPrec :: ReadPrec UpdateCampaign
$creadPrec :: ReadPrec UpdateCampaign
readList :: ReadS [UpdateCampaign]
$creadList :: ReadS [UpdateCampaign]
readsPrec :: Int -> ReadS UpdateCampaign
$creadsPrec :: Int -> ReadS UpdateCampaign
Prelude.Read, Int -> UpdateCampaign -> ShowS
[UpdateCampaign] -> ShowS
UpdateCampaign -> String
(Int -> UpdateCampaign -> ShowS)
-> (UpdateCampaign -> String)
-> ([UpdateCampaign] -> ShowS)
-> Show UpdateCampaign
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateCampaign] -> ShowS
$cshowList :: [UpdateCampaign] -> ShowS
show :: UpdateCampaign -> String
$cshow :: UpdateCampaign -> String
showsPrec :: Int -> UpdateCampaign -> ShowS
$cshowsPrec :: Int -> UpdateCampaign -> ShowS
Prelude.Show, (forall x. UpdateCampaign -> Rep UpdateCampaign x)
-> (forall x. Rep UpdateCampaign x -> UpdateCampaign)
-> Generic UpdateCampaign
forall x. Rep UpdateCampaign x -> UpdateCampaign
forall x. UpdateCampaign -> Rep UpdateCampaign x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateCampaign x -> UpdateCampaign
$cfrom :: forall x. UpdateCampaign -> Rep UpdateCampaign x
Prelude.Generic)
newUpdateCampaign ::
Prelude.Text ->
Prelude.Text ->
WriteCampaignRequest ->
UpdateCampaign
newUpdateCampaign :: Text -> Text -> WriteCampaignRequest -> UpdateCampaign
newUpdateCampaign
Text
pCampaignId_
Text
pApplicationId_
WriteCampaignRequest
pWriteCampaignRequest_ =
UpdateCampaign' :: Text -> Text -> WriteCampaignRequest -> UpdateCampaign
UpdateCampaign'
{ $sel:campaignId:UpdateCampaign' :: Text
campaignId = Text
pCampaignId_,
$sel:applicationId:UpdateCampaign' :: Text
applicationId = Text
pApplicationId_,
$sel:writeCampaignRequest:UpdateCampaign' :: WriteCampaignRequest
writeCampaignRequest = WriteCampaignRequest
pWriteCampaignRequest_
}
updateCampaign_campaignId :: Lens.Lens' UpdateCampaign Prelude.Text
updateCampaign_campaignId :: (Text -> f Text) -> UpdateCampaign -> f UpdateCampaign
updateCampaign_campaignId = (UpdateCampaign -> Text)
-> (UpdateCampaign -> Text -> UpdateCampaign)
-> Lens UpdateCampaign UpdateCampaign Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCampaign' {Text
campaignId :: Text
$sel:campaignId:UpdateCampaign' :: UpdateCampaign -> Text
campaignId} -> Text
campaignId) (\s :: UpdateCampaign
s@UpdateCampaign' {} Text
a -> UpdateCampaign
s {$sel:campaignId:UpdateCampaign' :: Text
campaignId = Text
a} :: UpdateCampaign)
updateCampaign_applicationId :: Lens.Lens' UpdateCampaign Prelude.Text
updateCampaign_applicationId :: (Text -> f Text) -> UpdateCampaign -> f UpdateCampaign
updateCampaign_applicationId = (UpdateCampaign -> Text)
-> (UpdateCampaign -> Text -> UpdateCampaign)
-> Lens UpdateCampaign UpdateCampaign Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCampaign' {Text
applicationId :: Text
$sel:applicationId:UpdateCampaign' :: UpdateCampaign -> Text
applicationId} -> Text
applicationId) (\s :: UpdateCampaign
s@UpdateCampaign' {} Text
a -> UpdateCampaign
s {$sel:applicationId:UpdateCampaign' :: Text
applicationId = Text
a} :: UpdateCampaign)
updateCampaign_writeCampaignRequest :: Lens.Lens' UpdateCampaign WriteCampaignRequest
updateCampaign_writeCampaignRequest :: (WriteCampaignRequest -> f WriteCampaignRequest)
-> UpdateCampaign -> f UpdateCampaign
updateCampaign_writeCampaignRequest = (UpdateCampaign -> WriteCampaignRequest)
-> (UpdateCampaign -> WriteCampaignRequest -> UpdateCampaign)
-> Lens
UpdateCampaign
UpdateCampaign
WriteCampaignRequest
WriteCampaignRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCampaign' {WriteCampaignRequest
writeCampaignRequest :: WriteCampaignRequest
$sel:writeCampaignRequest:UpdateCampaign' :: UpdateCampaign -> WriteCampaignRequest
writeCampaignRequest} -> WriteCampaignRequest
writeCampaignRequest) (\s :: UpdateCampaign
s@UpdateCampaign' {} WriteCampaignRequest
a -> UpdateCampaign
s {$sel:writeCampaignRequest:UpdateCampaign' :: WriteCampaignRequest
writeCampaignRequest = WriteCampaignRequest
a} :: UpdateCampaign)
instance Core.AWSRequest UpdateCampaign where
type
AWSResponse UpdateCampaign =
UpdateCampaignResponse
request :: UpdateCampaign -> Request UpdateCampaign
request = Service -> UpdateCampaign -> Request UpdateCampaign
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
response :: Logger
-> Service
-> Proxy UpdateCampaign
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateCampaign)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse UpdateCampaign))
-> Logger
-> Service
-> Proxy UpdateCampaign
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateCampaign)))
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 -> UpdateCampaignResponse
UpdateCampaignResponse'
(Int -> CampaignResponse -> UpdateCampaignResponse)
-> Either String Int
-> Either String (CampaignResponse -> UpdateCampaignResponse)
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 -> UpdateCampaignResponse)
-> Either String CampaignResponse
-> Either String UpdateCampaignResponse
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 UpdateCampaign
instance Prelude.NFData UpdateCampaign
instance Core.ToHeaders UpdateCampaign where
toHeaders :: UpdateCampaign -> ResponseHeaders
toHeaders =
ResponseHeaders -> UpdateCampaign -> 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 UpdateCampaign where
toJSON :: UpdateCampaign -> Value
toJSON UpdateCampaign' {Text
WriteCampaignRequest
writeCampaignRequest :: WriteCampaignRequest
applicationId :: Text
campaignId :: Text
$sel:writeCampaignRequest:UpdateCampaign' :: UpdateCampaign -> WriteCampaignRequest
$sel:applicationId:UpdateCampaign' :: UpdateCampaign -> Text
$sel:campaignId:UpdateCampaign' :: UpdateCampaign -> 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 UpdateCampaign where
toPath :: UpdateCampaign -> ByteString
toPath UpdateCampaign' {Text
WriteCampaignRequest
writeCampaignRequest :: WriteCampaignRequest
applicationId :: Text
campaignId :: Text
$sel:writeCampaignRequest:UpdateCampaign' :: UpdateCampaign -> WriteCampaignRequest
$sel:applicationId:UpdateCampaign' :: UpdateCampaign -> Text
$sel:campaignId:UpdateCampaign' :: UpdateCampaign -> 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/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
campaignId
]
instance Core.ToQuery UpdateCampaign where
toQuery :: UpdateCampaign -> QueryString
toQuery = QueryString -> UpdateCampaign -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data UpdateCampaignResponse = UpdateCampaignResponse'
{
UpdateCampaignResponse -> Int
httpStatus :: Prelude.Int,
UpdateCampaignResponse -> CampaignResponse
campaignResponse :: CampaignResponse
}
deriving (UpdateCampaignResponse -> UpdateCampaignResponse -> Bool
(UpdateCampaignResponse -> UpdateCampaignResponse -> Bool)
-> (UpdateCampaignResponse -> UpdateCampaignResponse -> Bool)
-> Eq UpdateCampaignResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateCampaignResponse -> UpdateCampaignResponse -> Bool
$c/= :: UpdateCampaignResponse -> UpdateCampaignResponse -> Bool
== :: UpdateCampaignResponse -> UpdateCampaignResponse -> Bool
$c== :: UpdateCampaignResponse -> UpdateCampaignResponse -> Bool
Prelude.Eq, ReadPrec [UpdateCampaignResponse]
ReadPrec UpdateCampaignResponse
Int -> ReadS UpdateCampaignResponse
ReadS [UpdateCampaignResponse]
(Int -> ReadS UpdateCampaignResponse)
-> ReadS [UpdateCampaignResponse]
-> ReadPrec UpdateCampaignResponse
-> ReadPrec [UpdateCampaignResponse]
-> Read UpdateCampaignResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateCampaignResponse]
$creadListPrec :: ReadPrec [UpdateCampaignResponse]
readPrec :: ReadPrec UpdateCampaignResponse
$creadPrec :: ReadPrec UpdateCampaignResponse
readList :: ReadS [UpdateCampaignResponse]
$creadList :: ReadS [UpdateCampaignResponse]
readsPrec :: Int -> ReadS UpdateCampaignResponse
$creadsPrec :: Int -> ReadS UpdateCampaignResponse
Prelude.Read, Int -> UpdateCampaignResponse -> ShowS
[UpdateCampaignResponse] -> ShowS
UpdateCampaignResponse -> String
(Int -> UpdateCampaignResponse -> ShowS)
-> (UpdateCampaignResponse -> String)
-> ([UpdateCampaignResponse] -> ShowS)
-> Show UpdateCampaignResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateCampaignResponse] -> ShowS
$cshowList :: [UpdateCampaignResponse] -> ShowS
show :: UpdateCampaignResponse -> String
$cshow :: UpdateCampaignResponse -> String
showsPrec :: Int -> UpdateCampaignResponse -> ShowS
$cshowsPrec :: Int -> UpdateCampaignResponse -> ShowS
Prelude.Show, (forall x. UpdateCampaignResponse -> Rep UpdateCampaignResponse x)
-> (forall x.
Rep UpdateCampaignResponse x -> UpdateCampaignResponse)
-> Generic UpdateCampaignResponse
forall x. Rep UpdateCampaignResponse x -> UpdateCampaignResponse
forall x. UpdateCampaignResponse -> Rep UpdateCampaignResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateCampaignResponse x -> UpdateCampaignResponse
$cfrom :: forall x. UpdateCampaignResponse -> Rep UpdateCampaignResponse x
Prelude.Generic)
newUpdateCampaignResponse ::
Prelude.Int ->
CampaignResponse ->
UpdateCampaignResponse
newUpdateCampaignResponse :: Int -> CampaignResponse -> UpdateCampaignResponse
newUpdateCampaignResponse
Int
pHttpStatus_
CampaignResponse
pCampaignResponse_ =
UpdateCampaignResponse' :: Int -> CampaignResponse -> UpdateCampaignResponse
UpdateCampaignResponse'
{ $sel:httpStatus:UpdateCampaignResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:campaignResponse:UpdateCampaignResponse' :: CampaignResponse
campaignResponse = CampaignResponse
pCampaignResponse_
}
updateCampaignResponse_httpStatus :: Lens.Lens' UpdateCampaignResponse Prelude.Int
updateCampaignResponse_httpStatus :: (Int -> f Int)
-> UpdateCampaignResponse -> f UpdateCampaignResponse
updateCampaignResponse_httpStatus = (UpdateCampaignResponse -> Int)
-> (UpdateCampaignResponse -> Int -> UpdateCampaignResponse)
-> Lens UpdateCampaignResponse UpdateCampaignResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCampaignResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateCampaignResponse' :: UpdateCampaignResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateCampaignResponse
s@UpdateCampaignResponse' {} Int
a -> UpdateCampaignResponse
s {$sel:httpStatus:UpdateCampaignResponse' :: Int
httpStatus = Int
a} :: UpdateCampaignResponse)
updateCampaignResponse_campaignResponse :: Lens.Lens' UpdateCampaignResponse CampaignResponse
updateCampaignResponse_campaignResponse :: (CampaignResponse -> f CampaignResponse)
-> UpdateCampaignResponse -> f UpdateCampaignResponse
updateCampaignResponse_campaignResponse = (UpdateCampaignResponse -> CampaignResponse)
-> (UpdateCampaignResponse
-> CampaignResponse -> UpdateCampaignResponse)
-> Lens
UpdateCampaignResponse
UpdateCampaignResponse
CampaignResponse
CampaignResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCampaignResponse' {CampaignResponse
campaignResponse :: CampaignResponse
$sel:campaignResponse:UpdateCampaignResponse' :: UpdateCampaignResponse -> CampaignResponse
campaignResponse} -> CampaignResponse
campaignResponse) (\s :: UpdateCampaignResponse
s@UpdateCampaignResponse' {} CampaignResponse
a -> UpdateCampaignResponse
s {$sel:campaignResponse:UpdateCampaignResponse' :: CampaignResponse
campaignResponse = CampaignResponse
a} :: UpdateCampaignResponse)
instance Prelude.NFData UpdateCampaignResponse