{-# 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.Connect.StartChatContact
-- 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)
--
-- Initiates a contact flow to start a new chat for the customer. Response
-- of this API provides a token required to obtain credentials from the
-- <https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_CreateParticipantConnection.html CreateParticipantConnection>
-- API in the Amazon Connect Participant Service.
--
-- When a new chat contact is successfully created, clients must subscribe
-- to the participant’s connection for the created chat within 5 minutes.
-- This is achieved by invoking
-- <https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_CreateParticipantConnection.html CreateParticipantConnection>
-- with WEBSOCKET and CONNECTION_CREDENTIALS.
--
-- A 429 error occurs in two situations:
--
-- -   API rate limit is exceeded. API TPS throttling returns a
--     @TooManyRequests@ exception.
--
-- -   The
--     <https://docs.aws.amazon.com/connect/latest/adminguide/amazon-connect-service-limits.html quota for concurrent active chats>
--     is exceeded. Active chat throttling returns a
--     @LimitExceededException@.
--
-- For more information about chat, see
-- <https://docs.aws.amazon.com/connect/latest/adminguide/chat.html Chat>
-- in the /Amazon Connect Administrator Guide/.
module Amazonka.Connect.StartChatContact
  ( -- * Creating a Request
    StartChatContact (..),
    newStartChatContact,

    -- * Request Lenses
    startChatContact_clientToken,
    startChatContact_attributes,
    startChatContact_initialMessage,
    startChatContact_instanceId,
    startChatContact_contactFlowId,
    startChatContact_participantDetails,

    -- * Destructuring the Response
    StartChatContactResponse (..),
    newStartChatContactResponse,

    -- * Response Lenses
    startChatContactResponse_participantToken,
    startChatContactResponse_participantId,
    startChatContactResponse_contactId,
    startChatContactResponse_httpStatus,
  )
where

import Amazonka.Connect.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newStartChatContact' smart constructor.
data StartChatContact = StartChatContact'
  { -- | A unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request.
    StartChatContact -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | A custom key-value pair using an attribute map. The attributes are
    -- standard Amazon Connect attributes. They can be accessed in contact
    -- flows just like any other contact attributes.
    --
    -- There can be up to 32,768 UTF-8 bytes across all key-value pairs per
    -- contact. Attribute keys can include only alphanumeric, dash, and
    -- underscore characters.
    StartChatContact -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The initial message to be sent to the newly created chat.
    StartChatContact -> Maybe ChatMessage
initialMessage :: Prelude.Maybe ChatMessage,
    -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    StartChatContact -> Text
instanceId :: Prelude.Text,
    -- | The identifier of the contact flow for initiating the chat. To see the
    -- ContactFlowId in the Amazon Connect console user interface, on the
    -- navigation menu go to __Routing__, __Contact Flows__. Choose the contact
    -- flow. On the contact flow page, under the name of the contact flow,
    -- choose __Show additional flow information__. The ContactFlowId is the
    -- last part of the ARN, shown here in bold:
    --
    -- arn:aws:connect:us-west-2:xxxxxxxxxxxx:instance\/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\/contact-flow\/__846ec553-a005-41c0-8341-xxxxxxxxxxxx__
    StartChatContact -> Text
contactFlowId :: Prelude.Text,
    -- | Information identifying the participant.
    StartChatContact -> ParticipantDetails
participantDetails :: ParticipantDetails
  }
  deriving (StartChatContact -> StartChatContact -> Bool
(StartChatContact -> StartChatContact -> Bool)
-> (StartChatContact -> StartChatContact -> Bool)
-> Eq StartChatContact
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartChatContact -> StartChatContact -> Bool
$c/= :: StartChatContact -> StartChatContact -> Bool
== :: StartChatContact -> StartChatContact -> Bool
$c== :: StartChatContact -> StartChatContact -> Bool
Prelude.Eq, ReadPrec [StartChatContact]
ReadPrec StartChatContact
Int -> ReadS StartChatContact
ReadS [StartChatContact]
(Int -> ReadS StartChatContact)
-> ReadS [StartChatContact]
-> ReadPrec StartChatContact
-> ReadPrec [StartChatContact]
-> Read StartChatContact
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartChatContact]
$creadListPrec :: ReadPrec [StartChatContact]
readPrec :: ReadPrec StartChatContact
$creadPrec :: ReadPrec StartChatContact
readList :: ReadS [StartChatContact]
$creadList :: ReadS [StartChatContact]
readsPrec :: Int -> ReadS StartChatContact
$creadsPrec :: Int -> ReadS StartChatContact
Prelude.Read, Int -> StartChatContact -> ShowS
[StartChatContact] -> ShowS
StartChatContact -> String
(Int -> StartChatContact -> ShowS)
-> (StartChatContact -> String)
-> ([StartChatContact] -> ShowS)
-> Show StartChatContact
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartChatContact] -> ShowS
$cshowList :: [StartChatContact] -> ShowS
show :: StartChatContact -> String
$cshow :: StartChatContact -> String
showsPrec :: Int -> StartChatContact -> ShowS
$cshowsPrec :: Int -> StartChatContact -> ShowS
Prelude.Show, (forall x. StartChatContact -> Rep StartChatContact x)
-> (forall x. Rep StartChatContact x -> StartChatContact)
-> Generic StartChatContact
forall x. Rep StartChatContact x -> StartChatContact
forall x. StartChatContact -> Rep StartChatContact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartChatContact x -> StartChatContact
$cfrom :: forall x. StartChatContact -> Rep StartChatContact x
Prelude.Generic)

-- |
-- Create a value of 'StartChatContact' 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:
--
-- 'clientToken', 'startChatContact_clientToken' - A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
--
-- 'attributes', 'startChatContact_attributes' - A custom key-value pair using an attribute map. The attributes are
-- standard Amazon Connect attributes. They can be accessed in contact
-- flows just like any other contact attributes.
--
-- There can be up to 32,768 UTF-8 bytes across all key-value pairs per
-- contact. Attribute keys can include only alphanumeric, dash, and
-- underscore characters.
--
-- 'initialMessage', 'startChatContact_initialMessage' - The initial message to be sent to the newly created chat.
--
-- 'instanceId', 'startChatContact_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
--
-- 'contactFlowId', 'startChatContact_contactFlowId' - The identifier of the contact flow for initiating the chat. To see the
-- ContactFlowId in the Amazon Connect console user interface, on the
-- navigation menu go to __Routing__, __Contact Flows__. Choose the contact
-- flow. On the contact flow page, under the name of the contact flow,
-- choose __Show additional flow information__. The ContactFlowId is the
-- last part of the ARN, shown here in bold:
--
-- arn:aws:connect:us-west-2:xxxxxxxxxxxx:instance\/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\/contact-flow\/__846ec553-a005-41c0-8341-xxxxxxxxxxxx__
--
-- 'participantDetails', 'startChatContact_participantDetails' - Information identifying the participant.
newStartChatContact ::
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'contactFlowId'
  Prelude.Text ->
  -- | 'participantDetails'
  ParticipantDetails ->
  StartChatContact
newStartChatContact :: Text -> Text -> ParticipantDetails -> StartChatContact
newStartChatContact
  Text
pInstanceId_
  Text
pContactFlowId_
  ParticipantDetails
pParticipantDetails_ =
    StartChatContact' :: Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe ChatMessage
-> Text
-> Text
-> ParticipantDetails
-> StartChatContact
StartChatContact'
      { $sel:clientToken:StartChatContact' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:attributes:StartChatContact' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:initialMessage:StartChatContact' :: Maybe ChatMessage
initialMessage = Maybe ChatMessage
forall a. Maybe a
Prelude.Nothing,
        $sel:instanceId:StartChatContact' :: Text
instanceId = Text
pInstanceId_,
        $sel:contactFlowId:StartChatContact' :: Text
contactFlowId = Text
pContactFlowId_,
        $sel:participantDetails:StartChatContact' :: ParticipantDetails
participantDetails = ParticipantDetails
pParticipantDetails_
      }

-- | A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request.
startChatContact_clientToken :: Lens.Lens' StartChatContact (Prelude.Maybe Prelude.Text)
startChatContact_clientToken :: (Maybe Text -> f (Maybe Text))
-> StartChatContact -> f StartChatContact
startChatContact_clientToken = (StartChatContact -> Maybe Text)
-> (StartChatContact -> Maybe Text -> StartChatContact)
-> Lens StartChatContact StartChatContact (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartChatContact' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:StartChatContact' :: StartChatContact -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: StartChatContact
s@StartChatContact' {} Maybe Text
a -> StartChatContact
s {$sel:clientToken:StartChatContact' :: Maybe Text
clientToken = Maybe Text
a} :: StartChatContact)

-- | A custom key-value pair using an attribute map. The attributes are
-- standard Amazon Connect attributes. They can be accessed in contact
-- flows just like any other contact attributes.
--
-- There can be up to 32,768 UTF-8 bytes across all key-value pairs per
-- contact. Attribute keys can include only alphanumeric, dash, and
-- underscore characters.
startChatContact_attributes :: Lens.Lens' StartChatContact (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
startChatContact_attributes :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> StartChatContact -> f StartChatContact
startChatContact_attributes = (StartChatContact -> Maybe (HashMap Text Text))
-> (StartChatContact
    -> Maybe (HashMap Text Text) -> StartChatContact)
-> Lens
     StartChatContact
     StartChatContact
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartChatContact' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:StartChatContact' :: StartChatContact -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: StartChatContact
s@StartChatContact' {} Maybe (HashMap Text Text)
a -> StartChatContact
s {$sel:attributes:StartChatContact' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: StartChatContact) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> StartChatContact -> f StartChatContact)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> StartChatContact
-> f StartChatContact
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The initial message to be sent to the newly created chat.
startChatContact_initialMessage :: Lens.Lens' StartChatContact (Prelude.Maybe ChatMessage)
startChatContact_initialMessage :: (Maybe ChatMessage -> f (Maybe ChatMessage))
-> StartChatContact -> f StartChatContact
startChatContact_initialMessage = (StartChatContact -> Maybe ChatMessage)
-> (StartChatContact -> Maybe ChatMessage -> StartChatContact)
-> Lens
     StartChatContact
     StartChatContact
     (Maybe ChatMessage)
     (Maybe ChatMessage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartChatContact' {Maybe ChatMessage
initialMessage :: Maybe ChatMessage
$sel:initialMessage:StartChatContact' :: StartChatContact -> Maybe ChatMessage
initialMessage} -> Maybe ChatMessage
initialMessage) (\s :: StartChatContact
s@StartChatContact' {} Maybe ChatMessage
a -> StartChatContact
s {$sel:initialMessage:StartChatContact' :: Maybe ChatMessage
initialMessage = Maybe ChatMessage
a} :: StartChatContact)

-- | The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
startChatContact_instanceId :: Lens.Lens' StartChatContact Prelude.Text
startChatContact_instanceId :: (Text -> f Text) -> StartChatContact -> f StartChatContact
startChatContact_instanceId = (StartChatContact -> Text)
-> (StartChatContact -> Text -> StartChatContact)
-> Lens StartChatContact StartChatContact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartChatContact' {Text
instanceId :: Text
$sel:instanceId:StartChatContact' :: StartChatContact -> Text
instanceId} -> Text
instanceId) (\s :: StartChatContact
s@StartChatContact' {} Text
a -> StartChatContact
s {$sel:instanceId:StartChatContact' :: Text
instanceId = Text
a} :: StartChatContact)

-- | The identifier of the contact flow for initiating the chat. To see the
-- ContactFlowId in the Amazon Connect console user interface, on the
-- navigation menu go to __Routing__, __Contact Flows__. Choose the contact
-- flow. On the contact flow page, under the name of the contact flow,
-- choose __Show additional flow information__. The ContactFlowId is the
-- last part of the ARN, shown here in bold:
--
-- arn:aws:connect:us-west-2:xxxxxxxxxxxx:instance\/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\/contact-flow\/__846ec553-a005-41c0-8341-xxxxxxxxxxxx__
startChatContact_contactFlowId :: Lens.Lens' StartChatContact Prelude.Text
startChatContact_contactFlowId :: (Text -> f Text) -> StartChatContact -> f StartChatContact
startChatContact_contactFlowId = (StartChatContact -> Text)
-> (StartChatContact -> Text -> StartChatContact)
-> Lens StartChatContact StartChatContact Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartChatContact' {Text
contactFlowId :: Text
$sel:contactFlowId:StartChatContact' :: StartChatContact -> Text
contactFlowId} -> Text
contactFlowId) (\s :: StartChatContact
s@StartChatContact' {} Text
a -> StartChatContact
s {$sel:contactFlowId:StartChatContact' :: Text
contactFlowId = Text
a} :: StartChatContact)

-- | Information identifying the participant.
startChatContact_participantDetails :: Lens.Lens' StartChatContact ParticipantDetails
startChatContact_participantDetails :: (ParticipantDetails -> f ParticipantDetails)
-> StartChatContact -> f StartChatContact
startChatContact_participantDetails = (StartChatContact -> ParticipantDetails)
-> (StartChatContact -> ParticipantDetails -> StartChatContact)
-> Lens
     StartChatContact
     StartChatContact
     ParticipantDetails
     ParticipantDetails
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartChatContact' {ParticipantDetails
participantDetails :: ParticipantDetails
$sel:participantDetails:StartChatContact' :: StartChatContact -> ParticipantDetails
participantDetails} -> ParticipantDetails
participantDetails) (\s :: StartChatContact
s@StartChatContact' {} ParticipantDetails
a -> StartChatContact
s {$sel:participantDetails:StartChatContact' :: ParticipantDetails
participantDetails = ParticipantDetails
a} :: StartChatContact)

instance Core.AWSRequest StartChatContact where
  type
    AWSResponse StartChatContact =
      StartChatContactResponse
  request :: StartChatContact -> Request StartChatContact
request = Service -> StartChatContact -> Request StartChatContact
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartChatContact
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartChatContact)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StartChatContact))
-> Logger
-> Service
-> Proxy StartChatContact
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartChatContact)))
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 ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Int -> StartChatContactResponse
StartChatContactResponse'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Int -> StartChatContactResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text -> Maybe Text -> Int -> StartChatContactResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ParticipantToken")
            Either
  String
  (Maybe Text -> Maybe Text -> Int -> StartChatContactResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> StartChatContactResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ParticipantId")
            Either String (Maybe Text -> Int -> StartChatContactResponse)
-> Either String (Maybe Text)
-> Either String (Int -> StartChatContactResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ContactId")
            Either String (Int -> StartChatContactResponse)
-> Either String Int -> Either String StartChatContactResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable StartChatContact

instance Prelude.NFData StartChatContact

instance Core.ToHeaders StartChatContact where
  toHeaders :: StartChatContact -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartChatContact -> 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 StartChatContact where
  toJSON :: StartChatContact -> Value
toJSON StartChatContact' {Maybe Text
Maybe (HashMap Text Text)
Maybe ChatMessage
Text
ParticipantDetails
participantDetails :: ParticipantDetails
contactFlowId :: Text
instanceId :: Text
initialMessage :: Maybe ChatMessage
attributes :: Maybe (HashMap Text Text)
clientToken :: Maybe Text
$sel:participantDetails:StartChatContact' :: StartChatContact -> ParticipantDetails
$sel:contactFlowId:StartChatContact' :: StartChatContact -> Text
$sel:instanceId:StartChatContact' :: StartChatContact -> Text
$sel:initialMessage:StartChatContact' :: StartChatContact -> Maybe ChatMessage
$sel:attributes:StartChatContact' :: StartChatContact -> Maybe (HashMap Text Text)
$sel:clientToken:StartChatContact' :: StartChatContact -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ClientToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            (Text
"Attributes" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
attributes,
            (Text
"InitialMessage" Text -> ChatMessage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ChatMessage -> Pair) -> Maybe ChatMessage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ChatMessage
initialMessage,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InstanceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ContactFlowId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contactFlowId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ParticipantDetails" Text -> ParticipantDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ParticipantDetails
participantDetails)
          ]
      )

instance Core.ToPath StartChatContact where
  toPath :: StartChatContact -> ByteString
toPath = ByteString -> StartChatContact -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/contact/chat"

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

-- | /See:/ 'newStartChatContactResponse' smart constructor.
data StartChatContactResponse = StartChatContactResponse'
  { -- | The token used by the chat participant to call
    -- <https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_CreateParticipantConnection.html CreateParticipantConnection>.
    -- The participant token is valid for the lifetime of a chat participant.
    StartChatContactResponse -> Maybe Text
participantToken :: Prelude.Maybe Prelude.Text,
    -- | The identifier for a chat participant. The participantId for a chat
    -- participant is the same throughout the chat lifecycle.
    StartChatContactResponse -> Maybe Text
participantId :: Prelude.Maybe Prelude.Text,
    -- | The identifier of this contact within the Amazon Connect instance.
    StartChatContactResponse -> Maybe Text
contactId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    StartChatContactResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartChatContactResponse -> StartChatContactResponse -> Bool
(StartChatContactResponse -> StartChatContactResponse -> Bool)
-> (StartChatContactResponse -> StartChatContactResponse -> Bool)
-> Eq StartChatContactResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartChatContactResponse -> StartChatContactResponse -> Bool
$c/= :: StartChatContactResponse -> StartChatContactResponse -> Bool
== :: StartChatContactResponse -> StartChatContactResponse -> Bool
$c== :: StartChatContactResponse -> StartChatContactResponse -> Bool
Prelude.Eq, ReadPrec [StartChatContactResponse]
ReadPrec StartChatContactResponse
Int -> ReadS StartChatContactResponse
ReadS [StartChatContactResponse]
(Int -> ReadS StartChatContactResponse)
-> ReadS [StartChatContactResponse]
-> ReadPrec StartChatContactResponse
-> ReadPrec [StartChatContactResponse]
-> Read StartChatContactResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartChatContactResponse]
$creadListPrec :: ReadPrec [StartChatContactResponse]
readPrec :: ReadPrec StartChatContactResponse
$creadPrec :: ReadPrec StartChatContactResponse
readList :: ReadS [StartChatContactResponse]
$creadList :: ReadS [StartChatContactResponse]
readsPrec :: Int -> ReadS StartChatContactResponse
$creadsPrec :: Int -> ReadS StartChatContactResponse
Prelude.Read, Int -> StartChatContactResponse -> ShowS
[StartChatContactResponse] -> ShowS
StartChatContactResponse -> String
(Int -> StartChatContactResponse -> ShowS)
-> (StartChatContactResponse -> String)
-> ([StartChatContactResponse] -> ShowS)
-> Show StartChatContactResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartChatContactResponse] -> ShowS
$cshowList :: [StartChatContactResponse] -> ShowS
show :: StartChatContactResponse -> String
$cshow :: StartChatContactResponse -> String
showsPrec :: Int -> StartChatContactResponse -> ShowS
$cshowsPrec :: Int -> StartChatContactResponse -> ShowS
Prelude.Show, (forall x.
 StartChatContactResponse -> Rep StartChatContactResponse x)
-> (forall x.
    Rep StartChatContactResponse x -> StartChatContactResponse)
-> Generic StartChatContactResponse
forall x.
Rep StartChatContactResponse x -> StartChatContactResponse
forall x.
StartChatContactResponse -> Rep StartChatContactResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartChatContactResponse x -> StartChatContactResponse
$cfrom :: forall x.
StartChatContactResponse -> Rep StartChatContactResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartChatContactResponse' 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:
--
-- 'participantToken', 'startChatContactResponse_participantToken' - The token used by the chat participant to call
-- <https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_CreateParticipantConnection.html CreateParticipantConnection>.
-- The participant token is valid for the lifetime of a chat participant.
--
-- 'participantId', 'startChatContactResponse_participantId' - The identifier for a chat participant. The participantId for a chat
-- participant is the same throughout the chat lifecycle.
--
-- 'contactId', 'startChatContactResponse_contactId' - The identifier of this contact within the Amazon Connect instance.
--
-- 'httpStatus', 'startChatContactResponse_httpStatus' - The response's http status code.
newStartChatContactResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartChatContactResponse
newStartChatContactResponse :: Int -> StartChatContactResponse
newStartChatContactResponse Int
pHttpStatus_ =
  StartChatContactResponse' :: Maybe Text
-> Maybe Text -> Maybe Text -> Int -> StartChatContactResponse
StartChatContactResponse'
    { $sel:participantToken:StartChatContactResponse' :: Maybe Text
participantToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:participantId:StartChatContactResponse' :: Maybe Text
participantId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contactId:StartChatContactResponse' :: Maybe Text
contactId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartChatContactResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token used by the chat participant to call
-- <https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_CreateParticipantConnection.html CreateParticipantConnection>.
-- The participant token is valid for the lifetime of a chat participant.
startChatContactResponse_participantToken :: Lens.Lens' StartChatContactResponse (Prelude.Maybe Prelude.Text)
startChatContactResponse_participantToken :: (Maybe Text -> f (Maybe Text))
-> StartChatContactResponse -> f StartChatContactResponse
startChatContactResponse_participantToken = (StartChatContactResponse -> Maybe Text)
-> (StartChatContactResponse
    -> Maybe Text -> StartChatContactResponse)
-> Lens
     StartChatContactResponse
     StartChatContactResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartChatContactResponse' {Maybe Text
participantToken :: Maybe Text
$sel:participantToken:StartChatContactResponse' :: StartChatContactResponse -> Maybe Text
participantToken} -> Maybe Text
participantToken) (\s :: StartChatContactResponse
s@StartChatContactResponse' {} Maybe Text
a -> StartChatContactResponse
s {$sel:participantToken:StartChatContactResponse' :: Maybe Text
participantToken = Maybe Text
a} :: StartChatContactResponse)

-- | The identifier for a chat participant. The participantId for a chat
-- participant is the same throughout the chat lifecycle.
startChatContactResponse_participantId :: Lens.Lens' StartChatContactResponse (Prelude.Maybe Prelude.Text)
startChatContactResponse_participantId :: (Maybe Text -> f (Maybe Text))
-> StartChatContactResponse -> f StartChatContactResponse
startChatContactResponse_participantId = (StartChatContactResponse -> Maybe Text)
-> (StartChatContactResponse
    -> Maybe Text -> StartChatContactResponse)
-> Lens
     StartChatContactResponse
     StartChatContactResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartChatContactResponse' {Maybe Text
participantId :: Maybe Text
$sel:participantId:StartChatContactResponse' :: StartChatContactResponse -> Maybe Text
participantId} -> Maybe Text
participantId) (\s :: StartChatContactResponse
s@StartChatContactResponse' {} Maybe Text
a -> StartChatContactResponse
s {$sel:participantId:StartChatContactResponse' :: Maybe Text
participantId = Maybe Text
a} :: StartChatContactResponse)

-- | The identifier of this contact within the Amazon Connect instance.
startChatContactResponse_contactId :: Lens.Lens' StartChatContactResponse (Prelude.Maybe Prelude.Text)
startChatContactResponse_contactId :: (Maybe Text -> f (Maybe Text))
-> StartChatContactResponse -> f StartChatContactResponse
startChatContactResponse_contactId = (StartChatContactResponse -> Maybe Text)
-> (StartChatContactResponse
    -> Maybe Text -> StartChatContactResponse)
-> Lens
     StartChatContactResponse
     StartChatContactResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartChatContactResponse' {Maybe Text
contactId :: Maybe Text
$sel:contactId:StartChatContactResponse' :: StartChatContactResponse -> Maybe Text
contactId} -> Maybe Text
contactId) (\s :: StartChatContactResponse
s@StartChatContactResponse' {} Maybe Text
a -> StartChatContactResponse
s {$sel:contactId:StartChatContactResponse' :: Maybe Text
contactId = Maybe Text
a} :: StartChatContactResponse)

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

instance Prelude.NFData StartChatContactResponse