{-# 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.UpdateJourneyState
-- 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)
--
-- Cancels (stops) an active journey.
module Amazonka.Pinpoint.UpdateJourneyState
  ( -- * Creating a Request
    UpdateJourneyState (..),
    newUpdateJourneyState,

    -- * Request Lenses
    updateJourneyState_journeyId,
    updateJourneyState_applicationId,
    updateJourneyState_journeyStateRequest,

    -- * Destructuring the Response
    UpdateJourneyStateResponse (..),
    newUpdateJourneyStateResponse,

    -- * Response Lenses
    updateJourneyStateResponse_httpStatus,
    updateJourneyStateResponse_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:/ 'newUpdateJourneyState' smart constructor.
data UpdateJourneyState = UpdateJourneyState'
  { -- | The unique identifier for the journey.
    UpdateJourneyState -> Text
journeyId :: Prelude.Text,
    -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    UpdateJourneyState -> Text
applicationId :: Prelude.Text,
    UpdateJourneyState -> JourneyStateRequest
journeyStateRequest :: JourneyStateRequest
  }
  deriving (UpdateJourneyState -> UpdateJourneyState -> Bool
(UpdateJourneyState -> UpdateJourneyState -> Bool)
-> (UpdateJourneyState -> UpdateJourneyState -> Bool)
-> Eq UpdateJourneyState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateJourneyState -> UpdateJourneyState -> Bool
$c/= :: UpdateJourneyState -> UpdateJourneyState -> Bool
== :: UpdateJourneyState -> UpdateJourneyState -> Bool
$c== :: UpdateJourneyState -> UpdateJourneyState -> Bool
Prelude.Eq, ReadPrec [UpdateJourneyState]
ReadPrec UpdateJourneyState
Int -> ReadS UpdateJourneyState
ReadS [UpdateJourneyState]
(Int -> ReadS UpdateJourneyState)
-> ReadS [UpdateJourneyState]
-> ReadPrec UpdateJourneyState
-> ReadPrec [UpdateJourneyState]
-> Read UpdateJourneyState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateJourneyState]
$creadListPrec :: ReadPrec [UpdateJourneyState]
readPrec :: ReadPrec UpdateJourneyState
$creadPrec :: ReadPrec UpdateJourneyState
readList :: ReadS [UpdateJourneyState]
$creadList :: ReadS [UpdateJourneyState]
readsPrec :: Int -> ReadS UpdateJourneyState
$creadsPrec :: Int -> ReadS UpdateJourneyState
Prelude.Read, Int -> UpdateJourneyState -> ShowS
[UpdateJourneyState] -> ShowS
UpdateJourneyState -> String
(Int -> UpdateJourneyState -> ShowS)
-> (UpdateJourneyState -> String)
-> ([UpdateJourneyState] -> ShowS)
-> Show UpdateJourneyState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateJourneyState] -> ShowS
$cshowList :: [UpdateJourneyState] -> ShowS
show :: UpdateJourneyState -> String
$cshow :: UpdateJourneyState -> String
showsPrec :: Int -> UpdateJourneyState -> ShowS
$cshowsPrec :: Int -> UpdateJourneyState -> ShowS
Prelude.Show, (forall x. UpdateJourneyState -> Rep UpdateJourneyState x)
-> (forall x. Rep UpdateJourneyState x -> UpdateJourneyState)
-> Generic UpdateJourneyState
forall x. Rep UpdateJourneyState x -> UpdateJourneyState
forall x. UpdateJourneyState -> Rep UpdateJourneyState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateJourneyState x -> UpdateJourneyState
$cfrom :: forall x. UpdateJourneyState -> Rep UpdateJourneyState x
Prelude.Generic)

-- |
-- Create a value of 'UpdateJourneyState' 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', 'updateJourneyState_journeyId' - The unique identifier for the journey.
--
-- 'applicationId', 'updateJourneyState_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
--
-- 'journeyStateRequest', 'updateJourneyState_journeyStateRequest' - Undocumented member.
newUpdateJourneyState ::
  -- | 'journeyId'
  Prelude.Text ->
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'journeyStateRequest'
  JourneyStateRequest ->
  UpdateJourneyState
newUpdateJourneyState :: Text -> Text -> JourneyStateRequest -> UpdateJourneyState
newUpdateJourneyState
  Text
pJourneyId_
  Text
pApplicationId_
  JourneyStateRequest
pJourneyStateRequest_ =
    UpdateJourneyState' :: Text -> Text -> JourneyStateRequest -> UpdateJourneyState
UpdateJourneyState'
      { $sel:journeyId:UpdateJourneyState' :: Text
journeyId = Text
pJourneyId_,
        $sel:applicationId:UpdateJourneyState' :: Text
applicationId = Text
pApplicationId_,
        $sel:journeyStateRequest:UpdateJourneyState' :: JourneyStateRequest
journeyStateRequest = JourneyStateRequest
pJourneyStateRequest_
      }

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

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

-- | Undocumented member.
updateJourneyState_journeyStateRequest :: Lens.Lens' UpdateJourneyState JourneyStateRequest
updateJourneyState_journeyStateRequest :: (JourneyStateRequest -> f JourneyStateRequest)
-> UpdateJourneyState -> f UpdateJourneyState
updateJourneyState_journeyStateRequest = (UpdateJourneyState -> JourneyStateRequest)
-> (UpdateJourneyState
    -> JourneyStateRequest -> UpdateJourneyState)
-> Lens
     UpdateJourneyState
     UpdateJourneyState
     JourneyStateRequest
     JourneyStateRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateJourneyState' {JourneyStateRequest
journeyStateRequest :: JourneyStateRequest
$sel:journeyStateRequest:UpdateJourneyState' :: UpdateJourneyState -> JourneyStateRequest
journeyStateRequest} -> JourneyStateRequest
journeyStateRequest) (\s :: UpdateJourneyState
s@UpdateJourneyState' {} JourneyStateRequest
a -> UpdateJourneyState
s {$sel:journeyStateRequest:UpdateJourneyState' :: JourneyStateRequest
journeyStateRequest = JourneyStateRequest
a} :: UpdateJourneyState)

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

instance Prelude.NFData UpdateJourneyState

instance Core.ToHeaders UpdateJourneyState where
  toHeaders :: UpdateJourneyState -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateJourneyState -> 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 UpdateJourneyState where
  toJSON :: UpdateJourneyState -> Value
toJSON UpdateJourneyState' {Text
JourneyStateRequest
journeyStateRequest :: JourneyStateRequest
applicationId :: Text
journeyId :: Text
$sel:journeyStateRequest:UpdateJourneyState' :: UpdateJourneyState -> JourneyStateRequest
$sel:applicationId:UpdateJourneyState' :: UpdateJourneyState -> Text
$sel:journeyId:UpdateJourneyState' :: UpdateJourneyState -> 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
"JourneyStateRequest" Text -> JourneyStateRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= JourneyStateRequest
journeyStateRequest)
          ]
      )

instance Core.ToPath UpdateJourneyState where
  toPath :: UpdateJourneyState -> ByteString
toPath UpdateJourneyState' {Text
JourneyStateRequest
journeyStateRequest :: JourneyStateRequest
applicationId :: Text
journeyId :: Text
$sel:journeyStateRequest:UpdateJourneyState' :: UpdateJourneyState -> JourneyStateRequest
$sel:applicationId:UpdateJourneyState' :: UpdateJourneyState -> Text
$sel:journeyId:UpdateJourneyState' :: UpdateJourneyState -> 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,
        ByteString
"/state"
      ]

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

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

-- |
-- Create a value of 'UpdateJourneyStateResponse' 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', 'updateJourneyStateResponse_httpStatus' - The response's http status code.
--
-- 'journeyResponse', 'updateJourneyStateResponse_journeyResponse' - Undocumented member.
newUpdateJourneyStateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'journeyResponse'
  JourneyResponse ->
  UpdateJourneyStateResponse
newUpdateJourneyStateResponse :: Int -> JourneyResponse -> UpdateJourneyStateResponse
newUpdateJourneyStateResponse
  Int
pHttpStatus_
  JourneyResponse
pJourneyResponse_ =
    UpdateJourneyStateResponse' :: Int -> JourneyResponse -> UpdateJourneyStateResponse
UpdateJourneyStateResponse'
      { $sel:httpStatus:UpdateJourneyStateResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:journeyResponse:UpdateJourneyStateResponse' :: JourneyResponse
journeyResponse = JourneyResponse
pJourneyResponse_
      }

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

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

instance Prelude.NFData UpdateJourneyStateResponse