{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Pinpoint.UpdateJourney
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the configuration and other settings for a journey.
module Amazonka.Pinpoint.UpdateJourney
  ( -- * Creating a Request
    UpdateJourney (..),
    newUpdateJourney,

    -- * Request Lenses
    updateJourney_journeyId,
    updateJourney_applicationId,
    updateJourney_writeJourneyRequest,

    -- * Destructuring the Response
    UpdateJourneyResponse (..),
    newUpdateJourneyResponse,

    -- * Response Lenses
    updateJourneyResponse_httpStatus,
    updateJourneyResponse_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

-- | /See:/ 'newUpdateJourney' smart constructor.
data UpdateJourney = UpdateJourney'
  { -- | The unique identifier for the journey.
    UpdateJourney -> Text
journeyId :: Prelude.Text,
    -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    UpdateJourney -> Text
applicationId :: Prelude.Text,
    UpdateJourney -> WriteJourneyRequest
writeJourneyRequest :: WriteJourneyRequest
  }
  deriving (UpdateJourney -> UpdateJourney -> Bool
(UpdateJourney -> UpdateJourney -> Bool)
-> (UpdateJourney -> UpdateJourney -> Bool) -> Eq UpdateJourney
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateJourney -> UpdateJourney -> Bool
$c/= :: UpdateJourney -> UpdateJourney -> Bool
== :: UpdateJourney -> UpdateJourney -> Bool
$c== :: UpdateJourney -> UpdateJourney -> Bool
Prelude.Eq, ReadPrec [UpdateJourney]
ReadPrec UpdateJourney
Int -> ReadS UpdateJourney
ReadS [UpdateJourney]
(Int -> ReadS UpdateJourney)
-> ReadS [UpdateJourney]
-> ReadPrec UpdateJourney
-> ReadPrec [UpdateJourney]
-> Read UpdateJourney
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateJourney]
$creadListPrec :: ReadPrec [UpdateJourney]
readPrec :: ReadPrec UpdateJourney
$creadPrec :: ReadPrec UpdateJourney
readList :: ReadS [UpdateJourney]
$creadList :: ReadS [UpdateJourney]
readsPrec :: Int -> ReadS UpdateJourney
$creadsPrec :: Int -> ReadS UpdateJourney
Prelude.Read, Int -> UpdateJourney -> ShowS
[UpdateJourney] -> ShowS
UpdateJourney -> String
(Int -> UpdateJourney -> ShowS)
-> (UpdateJourney -> String)
-> ([UpdateJourney] -> ShowS)
-> Show UpdateJourney
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateJourney] -> ShowS
$cshowList :: [UpdateJourney] -> ShowS
show :: UpdateJourney -> String
$cshow :: UpdateJourney -> String
showsPrec :: Int -> UpdateJourney -> ShowS
$cshowsPrec :: Int -> UpdateJourney -> ShowS
Prelude.Show, (forall x. UpdateJourney -> Rep UpdateJourney x)
-> (forall x. Rep UpdateJourney x -> UpdateJourney)
-> Generic UpdateJourney
forall x. Rep UpdateJourney x -> UpdateJourney
forall x. UpdateJourney -> Rep UpdateJourney x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateJourney x -> UpdateJourney
$cfrom :: forall x. UpdateJourney -> Rep UpdateJourney x
Prelude.Generic)

-- |
-- Create a value of 'UpdateJourney' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'journeyId', 'updateJourney_journeyId' - The unique identifier for the journey.
--
-- 'applicationId', 'updateJourney_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
--
-- 'writeJourneyRequest', 'updateJourney_writeJourneyRequest' - Undocumented member.
newUpdateJourney ::
  -- | 'journeyId'
  Prelude.Text ->
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'writeJourneyRequest'
  WriteJourneyRequest ->
  UpdateJourney
newUpdateJourney :: Text -> Text -> WriteJourneyRequest -> UpdateJourney
newUpdateJourney
  Text
pJourneyId_
  Text
pApplicationId_
  WriteJourneyRequest
pWriteJourneyRequest_ =
    UpdateJourney' :: Text -> Text -> WriteJourneyRequest -> UpdateJourney
UpdateJourney'
      { $sel:journeyId:UpdateJourney' :: Text
journeyId = Text
pJourneyId_,
        $sel:applicationId:UpdateJourney' :: Text
applicationId = Text
pApplicationId_,
        $sel:writeJourneyRequest:UpdateJourney' :: WriteJourneyRequest
writeJourneyRequest = WriteJourneyRequest
pWriteJourneyRequest_
      }

-- | The unique identifier for the journey.
updateJourney_journeyId :: Lens.Lens' UpdateJourney Prelude.Text
updateJourney_journeyId :: (Text -> f Text) -> UpdateJourney -> f UpdateJourney
updateJourney_journeyId = (UpdateJourney -> Text)
-> (UpdateJourney -> Text -> UpdateJourney)
-> Lens UpdateJourney UpdateJourney Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJourney' {Text
journeyId :: Text
$sel:journeyId:UpdateJourney' :: UpdateJourney -> Text
journeyId} -> Text
journeyId) (\s :: UpdateJourney
s@UpdateJourney' {} Text
a -> UpdateJourney
s {$sel:journeyId:UpdateJourney' :: Text
journeyId = Text
a} :: UpdateJourney)

-- | The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
updateJourney_applicationId :: Lens.Lens' UpdateJourney Prelude.Text
updateJourney_applicationId :: (Text -> f Text) -> UpdateJourney -> f UpdateJourney
updateJourney_applicationId = (UpdateJourney -> Text)
-> (UpdateJourney -> Text -> UpdateJourney)
-> Lens UpdateJourney UpdateJourney Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJourney' {Text
applicationId :: Text
$sel:applicationId:UpdateJourney' :: UpdateJourney -> Text
applicationId} -> Text
applicationId) (\s :: UpdateJourney
s@UpdateJourney' {} Text
a -> UpdateJourney
s {$sel:applicationId:UpdateJourney' :: Text
applicationId = Text
a} :: UpdateJourney)

-- | Undocumented member.
updateJourney_writeJourneyRequest :: Lens.Lens' UpdateJourney WriteJourneyRequest
updateJourney_writeJourneyRequest :: (WriteJourneyRequest -> f WriteJourneyRequest)
-> UpdateJourney -> f UpdateJourney
updateJourney_writeJourneyRequest = (UpdateJourney -> WriteJourneyRequest)
-> (UpdateJourney -> WriteJourneyRequest -> UpdateJourney)
-> Lens
     UpdateJourney UpdateJourney WriteJourneyRequest WriteJourneyRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJourney' {WriteJourneyRequest
writeJourneyRequest :: WriteJourneyRequest
$sel:writeJourneyRequest:UpdateJourney' :: UpdateJourney -> WriteJourneyRequest
writeJourneyRequest} -> WriteJourneyRequest
writeJourneyRequest) (\s :: UpdateJourney
s@UpdateJourney' {} WriteJourneyRequest
a -> UpdateJourney
s {$sel:writeJourneyRequest:UpdateJourney' :: WriteJourneyRequest
writeJourneyRequest = WriteJourneyRequest
a} :: UpdateJourney)

instance Core.AWSRequest UpdateJourney where
  type
    AWSResponse UpdateJourney =
      UpdateJourneyResponse
  request :: UpdateJourney -> Request UpdateJourney
request = Service -> UpdateJourney -> Request UpdateJourney
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateJourney
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateJourney)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateJourney))
-> Logger
-> Service
-> Proxy UpdateJourney
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateJourney)))
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 -> UpdateJourneyResponse
UpdateJourneyResponse'
            (Int -> JourneyResponse -> UpdateJourneyResponse)
-> Either String Int
-> Either String (JourneyResponse -> UpdateJourneyResponse)
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 -> UpdateJourneyResponse)
-> Either String JourneyResponse
-> Either String UpdateJourneyResponse
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 UpdateJourney

instance Prelude.NFData UpdateJourney

instance Core.ToHeaders UpdateJourney where
  toHeaders :: UpdateJourney -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateJourney -> 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 UpdateJourney where
  toJSON :: UpdateJourney -> Value
toJSON UpdateJourney' {Text
WriteJourneyRequest
writeJourneyRequest :: WriteJourneyRequest
applicationId :: Text
journeyId :: Text
$sel:writeJourneyRequest:UpdateJourney' :: UpdateJourney -> WriteJourneyRequest
$sel:applicationId:UpdateJourney' :: UpdateJourney -> Text
$sel:journeyId:UpdateJourney' :: UpdateJourney -> 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 UpdateJourney where
  toPath :: UpdateJourney -> ByteString
toPath UpdateJourney' {Text
WriteJourneyRequest
writeJourneyRequest :: WriteJourneyRequest
applicationId :: Text
journeyId :: Text
$sel:writeJourneyRequest:UpdateJourney' :: UpdateJourney -> WriteJourneyRequest
$sel:applicationId:UpdateJourney' :: UpdateJourney -> Text
$sel:journeyId:UpdateJourney' :: UpdateJourney -> 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/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
journeyId
      ]

instance Core.ToQuery UpdateJourney where
  toQuery :: UpdateJourney -> QueryString
toQuery = QueryString -> UpdateJourney -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateJourneyResponse' smart constructor.
data UpdateJourneyResponse = UpdateJourneyResponse'
  { -- | The response's http status code.
    UpdateJourneyResponse -> Int
httpStatus :: Prelude.Int,
    UpdateJourneyResponse -> JourneyResponse
journeyResponse :: JourneyResponse
  }
  deriving (UpdateJourneyResponse -> UpdateJourneyResponse -> Bool
(UpdateJourneyResponse -> UpdateJourneyResponse -> Bool)
-> (UpdateJourneyResponse -> UpdateJourneyResponse -> Bool)
-> Eq UpdateJourneyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateJourneyResponse -> UpdateJourneyResponse -> Bool
$c/= :: UpdateJourneyResponse -> UpdateJourneyResponse -> Bool
== :: UpdateJourneyResponse -> UpdateJourneyResponse -> Bool
$c== :: UpdateJourneyResponse -> UpdateJourneyResponse -> Bool
Prelude.Eq, ReadPrec [UpdateJourneyResponse]
ReadPrec UpdateJourneyResponse
Int -> ReadS UpdateJourneyResponse
ReadS [UpdateJourneyResponse]
(Int -> ReadS UpdateJourneyResponse)
-> ReadS [UpdateJourneyResponse]
-> ReadPrec UpdateJourneyResponse
-> ReadPrec [UpdateJourneyResponse]
-> Read UpdateJourneyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateJourneyResponse]
$creadListPrec :: ReadPrec [UpdateJourneyResponse]
readPrec :: ReadPrec UpdateJourneyResponse
$creadPrec :: ReadPrec UpdateJourneyResponse
readList :: ReadS [UpdateJourneyResponse]
$creadList :: ReadS [UpdateJourneyResponse]
readsPrec :: Int -> ReadS UpdateJourneyResponse
$creadsPrec :: Int -> ReadS UpdateJourneyResponse
Prelude.Read, Int -> UpdateJourneyResponse -> ShowS
[UpdateJourneyResponse] -> ShowS
UpdateJourneyResponse -> String
(Int -> UpdateJourneyResponse -> ShowS)
-> (UpdateJourneyResponse -> String)
-> ([UpdateJourneyResponse] -> ShowS)
-> Show UpdateJourneyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateJourneyResponse] -> ShowS
$cshowList :: [UpdateJourneyResponse] -> ShowS
show :: UpdateJourneyResponse -> String
$cshow :: UpdateJourneyResponse -> String
showsPrec :: Int -> UpdateJourneyResponse -> ShowS
$cshowsPrec :: Int -> UpdateJourneyResponse -> ShowS
Prelude.Show, (forall x. UpdateJourneyResponse -> Rep UpdateJourneyResponse x)
-> (forall x. Rep UpdateJourneyResponse x -> UpdateJourneyResponse)
-> Generic UpdateJourneyResponse
forall x. Rep UpdateJourneyResponse x -> UpdateJourneyResponse
forall x. UpdateJourneyResponse -> Rep UpdateJourneyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateJourneyResponse x -> UpdateJourneyResponse
$cfrom :: forall x. UpdateJourneyResponse -> Rep UpdateJourneyResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateJourneyResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'httpStatus', 'updateJourneyResponse_httpStatus' - The response's http status code.
--
-- 'journeyResponse', 'updateJourneyResponse_journeyResponse' - Undocumented member.
newUpdateJourneyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'journeyResponse'
  JourneyResponse ->
  UpdateJourneyResponse
newUpdateJourneyResponse :: Int -> JourneyResponse -> UpdateJourneyResponse
newUpdateJourneyResponse
  Int
pHttpStatus_
  JourneyResponse
pJourneyResponse_ =
    UpdateJourneyResponse' :: Int -> JourneyResponse -> UpdateJourneyResponse
UpdateJourneyResponse'
      { $sel:httpStatus:UpdateJourneyResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:journeyResponse:UpdateJourneyResponse' :: JourneyResponse
journeyResponse = JourneyResponse
pJourneyResponse_
      }

-- | The response's http status code.
updateJourneyResponse_httpStatus :: Lens.Lens' UpdateJourneyResponse Prelude.Int
updateJourneyResponse_httpStatus :: (Int -> f Int) -> UpdateJourneyResponse -> f UpdateJourneyResponse
updateJourneyResponse_httpStatus = (UpdateJourneyResponse -> Int)
-> (UpdateJourneyResponse -> Int -> UpdateJourneyResponse)
-> Lens UpdateJourneyResponse UpdateJourneyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJourneyResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateJourneyResponse' :: UpdateJourneyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateJourneyResponse
s@UpdateJourneyResponse' {} Int
a -> UpdateJourneyResponse
s {$sel:httpStatus:UpdateJourneyResponse' :: Int
httpStatus = Int
a} :: UpdateJourneyResponse)

-- | Undocumented member.
updateJourneyResponse_journeyResponse :: Lens.Lens' UpdateJourneyResponse JourneyResponse
updateJourneyResponse_journeyResponse :: (JourneyResponse -> f JourneyResponse)
-> UpdateJourneyResponse -> f UpdateJourneyResponse
updateJourneyResponse_journeyResponse = (UpdateJourneyResponse -> JourneyResponse)
-> (UpdateJourneyResponse
    -> JourneyResponse -> UpdateJourneyResponse)
-> Lens
     UpdateJourneyResponse
     UpdateJourneyResponse
     JourneyResponse
     JourneyResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJourneyResponse' {JourneyResponse
journeyResponse :: JourneyResponse
$sel:journeyResponse:UpdateJourneyResponse' :: UpdateJourneyResponse -> JourneyResponse
journeyResponse} -> JourneyResponse
journeyResponse) (\s :: UpdateJourneyResponse
s@UpdateJourneyResponse' {} JourneyResponse
a -> UpdateJourneyResponse
s {$sel:journeyResponse:UpdateJourneyResponse' :: JourneyResponse
journeyResponse = JourneyResponse
a} :: UpdateJourneyResponse)

instance Prelude.NFData UpdateJourneyResponse