{-# 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.CreateJourney
(
CreateJourney (..),
newCreateJourney,
createJourney_applicationId,
createJourney_writeJourneyRequest,
CreateJourneyResponse (..),
newCreateJourneyResponse,
createJourneyResponse_httpStatus,
createJourneyResponse_journeyResponse,
)
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 CreateJourney = CreateJourney'
{
CreateJourney -> Text
applicationId :: Prelude.Text,
CreateJourney -> WriteJourneyRequest
writeJourneyRequest :: WriteJourneyRequest
}
deriving (CreateJourney -> CreateJourney -> Bool
(CreateJourney -> CreateJourney -> Bool)
-> (CreateJourney -> CreateJourney -> Bool) -> Eq CreateJourney
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateJourney -> CreateJourney -> Bool
$c/= :: CreateJourney -> CreateJourney -> Bool
== :: CreateJourney -> CreateJourney -> Bool
$c== :: CreateJourney -> CreateJourney -> Bool
Prelude.Eq, ReadPrec [CreateJourney]
ReadPrec CreateJourney
Int -> ReadS CreateJourney
ReadS [CreateJourney]
(Int -> ReadS CreateJourney)
-> ReadS [CreateJourney]
-> ReadPrec CreateJourney
-> ReadPrec [CreateJourney]
-> Read CreateJourney
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateJourney]
$creadListPrec :: ReadPrec [CreateJourney]
readPrec :: ReadPrec CreateJourney
$creadPrec :: ReadPrec CreateJourney
readList :: ReadS [CreateJourney]
$creadList :: ReadS [CreateJourney]
readsPrec :: Int -> ReadS CreateJourney
$creadsPrec :: Int -> ReadS CreateJourney
Prelude.Read, Int -> CreateJourney -> ShowS
[CreateJourney] -> ShowS
CreateJourney -> String
(Int -> CreateJourney -> ShowS)
-> (CreateJourney -> String)
-> ([CreateJourney] -> ShowS)
-> Show CreateJourney
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateJourney] -> ShowS
$cshowList :: [CreateJourney] -> ShowS
show :: CreateJourney -> String
$cshow :: CreateJourney -> String
showsPrec :: Int -> CreateJourney -> ShowS
$cshowsPrec :: Int -> CreateJourney -> ShowS
Prelude.Show, (forall x. CreateJourney -> Rep CreateJourney x)
-> (forall x. Rep CreateJourney x -> CreateJourney)
-> Generic CreateJourney
forall x. Rep CreateJourney x -> CreateJourney
forall x. CreateJourney -> Rep CreateJourney x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateJourney x -> CreateJourney
$cfrom :: forall x. CreateJourney -> Rep CreateJourney x
Prelude.Generic)
newCreateJourney ::
Prelude.Text ->
WriteJourneyRequest ->
CreateJourney
newCreateJourney :: Text -> WriteJourneyRequest -> CreateJourney
newCreateJourney
Text
pApplicationId_
WriteJourneyRequest
pWriteJourneyRequest_ =
CreateJourney' :: Text -> WriteJourneyRequest -> CreateJourney
CreateJourney'
{ $sel:applicationId:CreateJourney' :: Text
applicationId = Text
pApplicationId_,
$sel:writeJourneyRequest:CreateJourney' :: WriteJourneyRequest
writeJourneyRequest = WriteJourneyRequest
pWriteJourneyRequest_
}
createJourney_applicationId :: Lens.Lens' CreateJourney Prelude.Text
createJourney_applicationId :: (Text -> f Text) -> CreateJourney -> f CreateJourney
createJourney_applicationId = (CreateJourney -> Text)
-> (CreateJourney -> Text -> CreateJourney)
-> Lens CreateJourney CreateJourney Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateJourney' {Text
applicationId :: Text
$sel:applicationId:CreateJourney' :: CreateJourney -> Text
applicationId} -> Text
applicationId) (\s :: CreateJourney
s@CreateJourney' {} Text
a -> CreateJourney
s {$sel:applicationId:CreateJourney' :: Text
applicationId = Text
a} :: CreateJourney)
createJourney_writeJourneyRequest :: Lens.Lens' CreateJourney WriteJourneyRequest
createJourney_writeJourneyRequest :: (WriteJourneyRequest -> f WriteJourneyRequest)
-> CreateJourney -> f CreateJourney
createJourney_writeJourneyRequest = (CreateJourney -> WriteJourneyRequest)
-> (CreateJourney -> WriteJourneyRequest -> CreateJourney)
-> Lens
CreateJourney CreateJourney WriteJourneyRequest WriteJourneyRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateJourney' {WriteJourneyRequest
writeJourneyRequest :: WriteJourneyRequest
$sel:writeJourneyRequest:CreateJourney' :: CreateJourney -> WriteJourneyRequest
writeJourneyRequest} -> WriteJourneyRequest
writeJourneyRequest) (\s :: CreateJourney
s@CreateJourney' {} WriteJourneyRequest
a -> CreateJourney
s {$sel:writeJourneyRequest:CreateJourney' :: WriteJourneyRequest
writeJourneyRequest = WriteJourneyRequest
a} :: CreateJourney)
instance Core.AWSRequest CreateJourney where
type
AWSResponse CreateJourney =
CreateJourneyResponse
request :: CreateJourney -> Request CreateJourney
request = Service -> CreateJourney -> Request CreateJourney
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateJourney
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateJourney)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateJourney))
-> Logger
-> Service
-> Proxy CreateJourney
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateJourney)))
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 -> JourneyResponse -> CreateJourneyResponse
CreateJourneyResponse'
(Int -> JourneyResponse -> CreateJourneyResponse)
-> Either String Int
-> Either String (JourneyResponse -> CreateJourneyResponse)
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 (JourneyResponse -> CreateJourneyResponse)
-> Either String JourneyResponse
-> Either String CreateJourneyResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String JourneyResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
)
instance Prelude.Hashable CreateJourney
instance Prelude.NFData CreateJourney
instance Core.ToHeaders CreateJourney where
toHeaders :: CreateJourney -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateJourney -> 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 CreateJourney where
toJSON :: CreateJourney -> Value
toJSON CreateJourney' {Text
WriteJourneyRequest
writeJourneyRequest :: WriteJourneyRequest
applicationId :: Text
$sel:writeJourneyRequest:CreateJourney' :: CreateJourney -> WriteJourneyRequest
$sel:applicationId:CreateJourney' :: CreateJourney -> 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
"WriteJourneyRequest" Text -> WriteJourneyRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= WriteJourneyRequest
writeJourneyRequest)
]
)
instance Core.ToPath CreateJourney where
toPath :: CreateJourney -> ByteString
toPath CreateJourney' {Text
WriteJourneyRequest
writeJourneyRequest :: WriteJourneyRequest
applicationId :: Text
$sel:writeJourneyRequest:CreateJourney' :: CreateJourney -> WriteJourneyRequest
$sel:applicationId:CreateJourney' :: CreateJourney -> 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
"/journeys"]
instance Core.ToQuery CreateJourney where
toQuery :: CreateJourney -> QueryString
toQuery = QueryString -> CreateJourney -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateJourneyResponse = CreateJourneyResponse'
{
CreateJourneyResponse -> Int
httpStatus :: Prelude.Int,
CreateJourneyResponse -> JourneyResponse
journeyResponse :: JourneyResponse
}
deriving (CreateJourneyResponse -> CreateJourneyResponse -> Bool
(CreateJourneyResponse -> CreateJourneyResponse -> Bool)
-> (CreateJourneyResponse -> CreateJourneyResponse -> Bool)
-> Eq CreateJourneyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateJourneyResponse -> CreateJourneyResponse -> Bool
$c/= :: CreateJourneyResponse -> CreateJourneyResponse -> Bool
== :: CreateJourneyResponse -> CreateJourneyResponse -> Bool
$c== :: CreateJourneyResponse -> CreateJourneyResponse -> Bool
Prelude.Eq, ReadPrec [CreateJourneyResponse]
ReadPrec CreateJourneyResponse
Int -> ReadS CreateJourneyResponse
ReadS [CreateJourneyResponse]
(Int -> ReadS CreateJourneyResponse)
-> ReadS [CreateJourneyResponse]
-> ReadPrec CreateJourneyResponse
-> ReadPrec [CreateJourneyResponse]
-> Read CreateJourneyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateJourneyResponse]
$creadListPrec :: ReadPrec [CreateJourneyResponse]
readPrec :: ReadPrec CreateJourneyResponse
$creadPrec :: ReadPrec CreateJourneyResponse
readList :: ReadS [CreateJourneyResponse]
$creadList :: ReadS [CreateJourneyResponse]
readsPrec :: Int -> ReadS CreateJourneyResponse
$creadsPrec :: Int -> ReadS CreateJourneyResponse
Prelude.Read, Int -> CreateJourneyResponse -> ShowS
[CreateJourneyResponse] -> ShowS
CreateJourneyResponse -> String
(Int -> CreateJourneyResponse -> ShowS)
-> (CreateJourneyResponse -> String)
-> ([CreateJourneyResponse] -> ShowS)
-> Show CreateJourneyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateJourneyResponse] -> ShowS
$cshowList :: [CreateJourneyResponse] -> ShowS
show :: CreateJourneyResponse -> String
$cshow :: CreateJourneyResponse -> String
showsPrec :: Int -> CreateJourneyResponse -> ShowS
$cshowsPrec :: Int -> CreateJourneyResponse -> ShowS
Prelude.Show, (forall x. CreateJourneyResponse -> Rep CreateJourneyResponse x)
-> (forall x. Rep CreateJourneyResponse x -> CreateJourneyResponse)
-> Generic CreateJourneyResponse
forall x. Rep CreateJourneyResponse x -> CreateJourneyResponse
forall x. CreateJourneyResponse -> Rep CreateJourneyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateJourneyResponse x -> CreateJourneyResponse
$cfrom :: forall x. CreateJourneyResponse -> Rep CreateJourneyResponse x
Prelude.Generic)
newCreateJourneyResponse ::
Prelude.Int ->
JourneyResponse ->
CreateJourneyResponse
newCreateJourneyResponse :: Int -> JourneyResponse -> CreateJourneyResponse
newCreateJourneyResponse
Int
pHttpStatus_
JourneyResponse
pJourneyResponse_ =
CreateJourneyResponse' :: Int -> JourneyResponse -> CreateJourneyResponse
CreateJourneyResponse'
{ $sel:httpStatus:CreateJourneyResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:journeyResponse:CreateJourneyResponse' :: JourneyResponse
journeyResponse = JourneyResponse
pJourneyResponse_
}
createJourneyResponse_httpStatus :: Lens.Lens' CreateJourneyResponse Prelude.Int
createJourneyResponse_httpStatus :: (Int -> f Int) -> CreateJourneyResponse -> f CreateJourneyResponse
createJourneyResponse_httpStatus = (CreateJourneyResponse -> Int)
-> (CreateJourneyResponse -> Int -> CreateJourneyResponse)
-> Lens CreateJourneyResponse CreateJourneyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateJourneyResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateJourneyResponse' :: CreateJourneyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateJourneyResponse
s@CreateJourneyResponse' {} Int
a -> CreateJourneyResponse
s {$sel:httpStatus:CreateJourneyResponse' :: Int
httpStatus = Int
a} :: CreateJourneyResponse)
createJourneyResponse_journeyResponse :: Lens.Lens' CreateJourneyResponse JourneyResponse
createJourneyResponse_journeyResponse :: (JourneyResponse -> f JourneyResponse)
-> CreateJourneyResponse -> f CreateJourneyResponse
createJourneyResponse_journeyResponse = (CreateJourneyResponse -> JourneyResponse)
-> (CreateJourneyResponse
-> JourneyResponse -> CreateJourneyResponse)
-> Lens
CreateJourneyResponse
CreateJourneyResponse
JourneyResponse
JourneyResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateJourneyResponse' {JourneyResponse
journeyResponse :: JourneyResponse
$sel:journeyResponse:CreateJourneyResponse' :: CreateJourneyResponse -> JourneyResponse
journeyResponse} -> JourneyResponse
journeyResponse) (\s :: CreateJourneyResponse
s@CreateJourneyResponse' {} JourneyResponse
a -> CreateJourneyResponse
s {$sel:journeyResponse:CreateJourneyResponse' :: JourneyResponse
journeyResponse = JourneyResponse
a} :: CreateJourneyResponse)
instance Prelude.NFData CreateJourneyResponse