{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Initiates a 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 the following 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@.
--
-- If you use the @ChatDurationInMinutes@ parameter and receive a 400
-- error, your account may not support the ability to configure custom chat
-- durations. For more information, contact Amazon Web Services Support.
--
-- 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_attributes,
    startChatContact_chatDurationInMinutes,
    startChatContact_clientToken,
    startChatContact_initialMessage,
    startChatContact_supportedMessagingContentTypes,
    startChatContact_instanceId,
    startChatContact_contactFlowId,
    startChatContact_participantDetails,

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

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

import Amazonka.Connect.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 custom key-value pair using an attribute map. The attributes are
    -- standard Amazon Connect attributes. They can be accessed in 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 total duration of the newly started chat session. If not specified,
    -- the chat session duration defaults to 25 hour. The minumum configurable
    -- time is 60 minutes. The maximum configurable time is 10,080 minutes (7
    -- days).
    StartChatContact -> Maybe Natural
chatDurationInMinutes :: Prelude.Maybe Prelude.Natural,
    -- | A unique, case-sensitive identifier that you provide to ensure the
    -- idempotency of the request. If not provided, the Amazon Web Services SDK
    -- populates this field. For more information about idempotency, see
    -- <https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/ Making retries safe with idempotent APIs>.
    StartChatContact -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The initial message to be sent to the newly created chat.
    StartChatContact -> Maybe ChatMessage
initialMessage :: Prelude.Maybe ChatMessage,
    -- | The supported chat message content types. Content types must always
    -- contain @text\/plain@. You can then put any other supported type in the
    -- list. For example, all the following lists are valid because they
    -- contain @text\/plain@:
    -- @[text\/plain, text\/markdown, application\/json]@,
    -- @[text\/markdown, text\/plain]@, @[text\/plain, application\/json]@.
    StartChatContact -> Maybe [Text]
supportedMessagingContentTypes :: Prelude.Maybe [Prelude.Text],
    -- | 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 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 flow.
    -- On the flow page, under the name of the 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
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]
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
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. 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:
--
-- 'attributes', 'startChatContact_attributes' - A custom key-value pair using an attribute map. The attributes are
-- standard Amazon Connect attributes. They can be accessed in 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.
--
-- 'chatDurationInMinutes', 'startChatContact_chatDurationInMinutes' - The total duration of the newly started chat session. If not specified,
-- the chat session duration defaults to 25 hour. The minumum configurable
-- time is 60 minutes. The maximum configurable time is 10,080 minutes (7
-- days).
--
-- 'clientToken', 'startChatContact_clientToken' - A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. If not provided, the Amazon Web Services SDK
-- populates this field. For more information about idempotency, see
-- <https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/ Making retries safe with idempotent APIs>.
--
-- 'initialMessage', 'startChatContact_initialMessage' - The initial message to be sent to the newly created chat.
--
-- 'supportedMessagingContentTypes', 'startChatContact_supportedMessagingContentTypes' - The supported chat message content types. Content types must always
-- contain @text\/plain@. You can then put any other supported type in the
-- list. For example, all the following lists are valid because they
-- contain @text\/plain@:
-- @[text\/plain, text\/markdown, application\/json]@,
-- @[text\/markdown, text\/plain]@, @[text\/plain, application\/json]@.
--
-- '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 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 flow.
-- On the flow page, under the name of the 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'
      { $sel:attributes:StartChatContact' :: Maybe (HashMap Text Text)
attributes = forall a. Maybe a
Prelude.Nothing,
        $sel:chatDurationInMinutes:StartChatContact' :: Maybe Natural
chatDurationInMinutes = forall a. Maybe a
Prelude.Nothing,
        $sel:clientToken:StartChatContact' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
        $sel:initialMessage:StartChatContact' :: Maybe ChatMessage
initialMessage = forall a. Maybe a
Prelude.Nothing,
        $sel:supportedMessagingContentTypes:StartChatContact' :: Maybe [Text]
supportedMessagingContentTypes = 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 custom key-value pair using an attribute map. The attributes are
-- standard Amazon Connect attributes. They can be accessed in 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 :: Lens' StartChatContact (Maybe (HashMap Text Text))
startChatContact_attributes = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The total duration of the newly started chat session. If not specified,
-- the chat session duration defaults to 25 hour. The minumum configurable
-- time is 60 minutes. The maximum configurable time is 10,080 minutes (7
-- days).
startChatContact_chatDurationInMinutes :: Lens.Lens' StartChatContact (Prelude.Maybe Prelude.Natural)
startChatContact_chatDurationInMinutes :: Lens' StartChatContact (Maybe Natural)
startChatContact_chatDurationInMinutes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartChatContact' {Maybe Natural
chatDurationInMinutes :: Maybe Natural
$sel:chatDurationInMinutes:StartChatContact' :: StartChatContact -> Maybe Natural
chatDurationInMinutes} -> Maybe Natural
chatDurationInMinutes) (\s :: StartChatContact
s@StartChatContact' {} Maybe Natural
a -> StartChatContact
s {$sel:chatDurationInMinutes:StartChatContact' :: Maybe Natural
chatDurationInMinutes = Maybe Natural
a} :: StartChatContact)

-- | A unique, case-sensitive identifier that you provide to ensure the
-- idempotency of the request. If not provided, the Amazon Web Services SDK
-- populates this field. For more information about idempotency, see
-- <https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/ Making retries safe with idempotent APIs>.
startChatContact_clientToken :: Lens.Lens' StartChatContact (Prelude.Maybe Prelude.Text)
startChatContact_clientToken :: Lens' StartChatContact (Maybe Text)
startChatContact_clientToken = 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)

-- | The initial message to be sent to the newly created chat.
startChatContact_initialMessage :: Lens.Lens' StartChatContact (Prelude.Maybe ChatMessage)
startChatContact_initialMessage :: Lens' StartChatContact (Maybe ChatMessage)
startChatContact_initialMessage = 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 supported chat message content types. Content types must always
-- contain @text\/plain@. You can then put any other supported type in the
-- list. For example, all the following lists are valid because they
-- contain @text\/plain@:
-- @[text\/plain, text\/markdown, application\/json]@,
-- @[text\/markdown, text\/plain]@, @[text\/plain, application\/json]@.
startChatContact_supportedMessagingContentTypes :: Lens.Lens' StartChatContact (Prelude.Maybe [Prelude.Text])
startChatContact_supportedMessagingContentTypes :: Lens' StartChatContact (Maybe [Text])
startChatContact_supportedMessagingContentTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartChatContact' {Maybe [Text]
supportedMessagingContentTypes :: Maybe [Text]
$sel:supportedMessagingContentTypes:StartChatContact' :: StartChatContact -> Maybe [Text]
supportedMessagingContentTypes} -> Maybe [Text]
supportedMessagingContentTypes) (\s :: StartChatContact
s@StartChatContact' {} Maybe [Text]
a -> StartChatContact
s {$sel:supportedMessagingContentTypes:StartChatContact' :: Maybe [Text]
supportedMessagingContentTypes = Maybe [Text]
a} :: StartChatContact) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: Lens' StartChatContact Text
startChatContact_instanceId = 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 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 flow.
-- On the flow page, under the name of the 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 :: Lens' StartChatContact Text
startChatContact_contactFlowId = 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 :: Lens' StartChatContact ParticipantDetails
startChatContact_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 :: (Service -> Service)
-> StartChatContact -> Request StartChatContact
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StartChatContact
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartChatContact)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ContactId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ParticipantId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ParticipantToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable StartChatContact where
  hashWithSalt :: Int -> StartChatContact -> Int
hashWithSalt Int
_salt StartChatContact' {Maybe Natural
Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe ChatMessage
Text
ParticipantDetails
participantDetails :: ParticipantDetails
contactFlowId :: Text
instanceId :: Text
supportedMessagingContentTypes :: Maybe [Text]
initialMessage :: Maybe ChatMessage
clientToken :: Maybe Text
chatDurationInMinutes :: Maybe Natural
attributes :: Maybe (HashMap Text Text)
$sel:participantDetails:StartChatContact' :: StartChatContact -> ParticipantDetails
$sel:contactFlowId:StartChatContact' :: StartChatContact -> Text
$sel:instanceId:StartChatContact' :: StartChatContact -> Text
$sel:supportedMessagingContentTypes:StartChatContact' :: StartChatContact -> Maybe [Text]
$sel:initialMessage:StartChatContact' :: StartChatContact -> Maybe ChatMessage
$sel:clientToken:StartChatContact' :: StartChatContact -> Maybe Text
$sel:chatDurationInMinutes:StartChatContact' :: StartChatContact -> Maybe Natural
$sel:attributes:StartChatContact' :: StartChatContact -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
chatDurationInMinutes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ChatMessage
initialMessage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
supportedMessagingContentTypes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
contactFlowId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ParticipantDetails
participantDetails

instance Prelude.NFData StartChatContact where
  rnf :: StartChatContact -> ()
rnf StartChatContact' {Maybe Natural
Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe ChatMessage
Text
ParticipantDetails
participantDetails :: ParticipantDetails
contactFlowId :: Text
instanceId :: Text
supportedMessagingContentTypes :: Maybe [Text]
initialMessage :: Maybe ChatMessage
clientToken :: Maybe Text
chatDurationInMinutes :: Maybe Natural
attributes :: Maybe (HashMap Text Text)
$sel:participantDetails:StartChatContact' :: StartChatContact -> ParticipantDetails
$sel:contactFlowId:StartChatContact' :: StartChatContact -> Text
$sel:instanceId:StartChatContact' :: StartChatContact -> Text
$sel:supportedMessagingContentTypes:StartChatContact' :: StartChatContact -> Maybe [Text]
$sel:initialMessage:StartChatContact' :: StartChatContact -> Maybe ChatMessage
$sel:clientToken:StartChatContact' :: StartChatContact -> Maybe Text
$sel:chatDurationInMinutes:StartChatContact' :: StartChatContact -> Maybe Natural
$sel:attributes:StartChatContact' :: StartChatContact -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
chatDurationInMinutes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ChatMessage
initialMessage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
supportedMessagingContentTypes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
contactFlowId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ParticipantDetails
participantDetails

instance Data.ToHeaders StartChatContact where
  toHeaders :: StartChatContact -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StartChatContact where
  toJSON :: StartChatContact -> Value
toJSON StartChatContact' {Maybe Natural
Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe ChatMessage
Text
ParticipantDetails
participantDetails :: ParticipantDetails
contactFlowId :: Text
instanceId :: Text
supportedMessagingContentTypes :: Maybe [Text]
initialMessage :: Maybe ChatMessage
clientToken :: Maybe Text
chatDurationInMinutes :: Maybe Natural
attributes :: Maybe (HashMap Text Text)
$sel:participantDetails:StartChatContact' :: StartChatContact -> ParticipantDetails
$sel:contactFlowId:StartChatContact' :: StartChatContact -> Text
$sel:instanceId:StartChatContact' :: StartChatContact -> Text
$sel:supportedMessagingContentTypes:StartChatContact' :: StartChatContact -> Maybe [Text]
$sel:initialMessage:StartChatContact' :: StartChatContact -> Maybe ChatMessage
$sel:clientToken:StartChatContact' :: StartChatContact -> Maybe Text
$sel:chatDurationInMinutes:StartChatContact' :: StartChatContact -> Maybe Natural
$sel:attributes:StartChatContact' :: StartChatContact -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Attributes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
attributes,
            (Key
"ChatDurationInMinutes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
chatDurationInMinutes,
            (Key
"ClientToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken,
            (Key
"InitialMessage" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ChatMessage
initialMessage,
            (Key
"SupportedMessagingContentTypes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
supportedMessagingContentTypes,
            forall a. a -> Maybe a
Prelude.Just (Key
"InstanceId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
instanceId),
            forall a. a -> Maybe a
Prelude.Just (Key
"ContactFlowId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
contactFlowId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ParticipantDetails" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ParticipantDetails
participantDetails)
          ]
      )

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

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

-- | /See:/ 'newStartChatContactResponse' smart constructor.
data StartChatContactResponse = StartChatContactResponse'
  { -- | The identifier of this contact within the Amazon Connect instance.
    StartChatContactResponse -> Maybe Text
contactId :: 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 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 response's http status code.
    StartChatContactResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartChatContactResponse -> StartChatContactResponse -> Bool
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]
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
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.
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:
--
-- 'contactId', 'startChatContactResponse_contactId' - The identifier of this contact within the Amazon Connect instance.
--
-- 'participantId', 'startChatContactResponse_participantId' - The identifier for a chat participant. The participantId for a chat
-- participant is the same throughout the chat lifecycle.
--
-- '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.
--
-- 'httpStatus', 'startChatContactResponse_httpStatus' - The response's http status code.
newStartChatContactResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartChatContactResponse
newStartChatContactResponse :: Int -> StartChatContactResponse
newStartChatContactResponse Int
pHttpStatus_ =
  StartChatContactResponse'
    { $sel:contactId:StartChatContactResponse' :: Maybe Text
contactId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:participantId:StartChatContactResponse' :: Maybe Text
participantId = forall a. Maybe a
Prelude.Nothing,
      $sel:participantToken:StartChatContactResponse' :: Maybe Text
participantToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartChatContactResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The identifier of this contact within the Amazon Connect instance.
startChatContactResponse_contactId :: Lens.Lens' StartChatContactResponse (Prelude.Maybe Prelude.Text)
startChatContactResponse_contactId :: Lens' StartChatContactResponse (Maybe Text)
startChatContactResponse_contactId = 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 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 :: Lens' StartChatContactResponse (Maybe Text)
startChatContactResponse_participantId = 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 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 :: Lens' StartChatContactResponse (Maybe Text)
startChatContactResponse_participantToken = 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 response's http status code.
startChatContactResponse_httpStatus :: Lens.Lens' StartChatContactResponse Prelude.Int
startChatContactResponse_httpStatus :: Lens' StartChatContactResponse Int
startChatContactResponse_httpStatus = 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 where
  rnf :: StartChatContactResponse -> ()
rnf StartChatContactResponse' {Int
Maybe Text
httpStatus :: Int
participantToken :: Maybe Text
participantId :: Maybe Text
contactId :: Maybe Text
$sel:httpStatus:StartChatContactResponse' :: StartChatContactResponse -> Int
$sel:participantToken:StartChatContactResponse' :: StartChatContactResponse -> Maybe Text
$sel:participantId:StartChatContactResponse' :: StartChatContactResponse -> Maybe Text
$sel:contactId:StartChatContactResponse' :: StartChatContactResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contactId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
participantId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
participantToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus