{-# 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.UpdateContactAttributes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates or updates user-defined contact attributes associated with the
-- specified contact.
--
-- You can create or update user-defined attributes for both ongoing and
-- completed contacts. For example, while the call is active, you can
-- update the customer\'s name or the reason the customer called. You can
-- add notes about steps that the agent took during the call that display
-- to the next agent that takes the call. You can also update attributes
-- for a contact using data from your CRM application and save the data
-- with the contact in Amazon Connect. You could also flag calls for
-- additional analysis, such as legal review or to identify abusive
-- callers.
--
-- Contact attributes are available in Amazon Connect for 24 months, and
-- are then deleted. For information about contact record retention and the
-- maximum size of the contact record attributes section, see
-- <https://docs.aws.amazon.com/connect/latest/adminguide/amazon-connect-service-limits.html#feature-limits Feature specifications>
-- in the /Amazon Connect Administrator Guide/.
module Amazonka.Connect.UpdateContactAttributes
  ( -- * Creating a Request
    UpdateContactAttributes (..),
    newUpdateContactAttributes,

    -- * Request Lenses
    updateContactAttributes_initialContactId,
    updateContactAttributes_instanceId,
    updateContactAttributes_attributes,

    -- * Destructuring the Response
    UpdateContactAttributesResponse (..),
    newUpdateContactAttributesResponse,

    -- * Response Lenses
    updateContactAttributesResponse_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:/ 'newUpdateContactAttributes' smart constructor.
data UpdateContactAttributes = UpdateContactAttributes'
  { -- | The identifier of the contact. This is the identifier of the contact
    -- associated with the first interaction with the contact center.
    UpdateContactAttributes -> Text
initialContactId :: Prelude.Text,
    -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    UpdateContactAttributes -> Text
instanceId :: Prelude.Text,
    -- | The Amazon Connect attributes. These attributes can be accessed in flows
    -- just like any other contact attributes.
    --
    -- You can have up to 32,768 UTF-8 bytes across all attributes for a
    -- contact. Attribute keys can include only alphanumeric, dash, and
    -- underscore characters.
    UpdateContactAttributes -> HashMap Text Text
attributes :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (UpdateContactAttributes -> UpdateContactAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateContactAttributes -> UpdateContactAttributes -> Bool
$c/= :: UpdateContactAttributes -> UpdateContactAttributes -> Bool
== :: UpdateContactAttributes -> UpdateContactAttributes -> Bool
$c== :: UpdateContactAttributes -> UpdateContactAttributes -> Bool
Prelude.Eq, ReadPrec [UpdateContactAttributes]
ReadPrec UpdateContactAttributes
Int -> ReadS UpdateContactAttributes
ReadS [UpdateContactAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateContactAttributes]
$creadListPrec :: ReadPrec [UpdateContactAttributes]
readPrec :: ReadPrec UpdateContactAttributes
$creadPrec :: ReadPrec UpdateContactAttributes
readList :: ReadS [UpdateContactAttributes]
$creadList :: ReadS [UpdateContactAttributes]
readsPrec :: Int -> ReadS UpdateContactAttributes
$creadsPrec :: Int -> ReadS UpdateContactAttributes
Prelude.Read, Int -> UpdateContactAttributes -> ShowS
[UpdateContactAttributes] -> ShowS
UpdateContactAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateContactAttributes] -> ShowS
$cshowList :: [UpdateContactAttributes] -> ShowS
show :: UpdateContactAttributes -> String
$cshow :: UpdateContactAttributes -> String
showsPrec :: Int -> UpdateContactAttributes -> ShowS
$cshowsPrec :: Int -> UpdateContactAttributes -> ShowS
Prelude.Show, forall x. Rep UpdateContactAttributes x -> UpdateContactAttributes
forall x. UpdateContactAttributes -> Rep UpdateContactAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateContactAttributes x -> UpdateContactAttributes
$cfrom :: forall x. UpdateContactAttributes -> Rep UpdateContactAttributes x
Prelude.Generic)

-- |
-- Create a value of 'UpdateContactAttributes' 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:
--
-- 'initialContactId', 'updateContactAttributes_initialContactId' - The identifier of the contact. This is the identifier of the contact
-- associated with the first interaction with the contact center.
--
-- 'instanceId', 'updateContactAttributes_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
--
-- 'attributes', 'updateContactAttributes_attributes' - The Amazon Connect attributes. These attributes can be accessed in flows
-- just like any other contact attributes.
--
-- You can have up to 32,768 UTF-8 bytes across all attributes for a
-- contact. Attribute keys can include only alphanumeric, dash, and
-- underscore characters.
newUpdateContactAttributes ::
  -- | 'initialContactId'
  Prelude.Text ->
  -- | 'instanceId'
  Prelude.Text ->
  UpdateContactAttributes
newUpdateContactAttributes :: Text -> Text -> UpdateContactAttributes
newUpdateContactAttributes
  Text
pInitialContactId_
  Text
pInstanceId_ =
    UpdateContactAttributes'
      { $sel:initialContactId:UpdateContactAttributes' :: Text
initialContactId =
          Text
pInitialContactId_,
        $sel:instanceId:UpdateContactAttributes' :: Text
instanceId = Text
pInstanceId_,
        $sel:attributes:UpdateContactAttributes' :: HashMap Text Text
attributes = forall a. Monoid a => a
Prelude.mempty
      }

-- | The identifier of the contact. This is the identifier of the contact
-- associated with the first interaction with the contact center.
updateContactAttributes_initialContactId :: Lens.Lens' UpdateContactAttributes Prelude.Text
updateContactAttributes_initialContactId :: Lens' UpdateContactAttributes Text
updateContactAttributes_initialContactId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactAttributes' {Text
initialContactId :: Text
$sel:initialContactId:UpdateContactAttributes' :: UpdateContactAttributes -> Text
initialContactId} -> Text
initialContactId) (\s :: UpdateContactAttributes
s@UpdateContactAttributes' {} Text
a -> UpdateContactAttributes
s {$sel:initialContactId:UpdateContactAttributes' :: Text
initialContactId = Text
a} :: UpdateContactAttributes)

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

-- | The Amazon Connect attributes. These attributes can be accessed in flows
-- just like any other contact attributes.
--
-- You can have up to 32,768 UTF-8 bytes across all attributes for a
-- contact. Attribute keys can include only alphanumeric, dash, and
-- underscore characters.
updateContactAttributes_attributes :: Lens.Lens' UpdateContactAttributes (Prelude.HashMap Prelude.Text Prelude.Text)
updateContactAttributes_attributes :: Lens' UpdateContactAttributes (HashMap Text Text)
updateContactAttributes_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactAttributes' {HashMap Text Text
attributes :: HashMap Text Text
$sel:attributes:UpdateContactAttributes' :: UpdateContactAttributes -> HashMap Text Text
attributes} -> HashMap Text Text
attributes) (\s :: UpdateContactAttributes
s@UpdateContactAttributes' {} HashMap Text Text
a -> UpdateContactAttributes
s {$sel:attributes:UpdateContactAttributes' :: HashMap Text Text
attributes = HashMap Text Text
a} :: UpdateContactAttributes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest UpdateContactAttributes where
  type
    AWSResponse UpdateContactAttributes =
      UpdateContactAttributesResponse
  request :: (Service -> Service)
-> UpdateContactAttributes -> Request UpdateContactAttributes
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateContactAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateContactAttributes)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateContactAttributesResponse
UpdateContactAttributesResponse'
            forall (f :: * -> *) a b. Functor 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 UpdateContactAttributes where
  hashWithSalt :: Int -> UpdateContactAttributes -> Int
hashWithSalt Int
_salt UpdateContactAttributes' {Text
HashMap Text Text
attributes :: HashMap Text Text
instanceId :: Text
initialContactId :: Text
$sel:attributes:UpdateContactAttributes' :: UpdateContactAttributes -> HashMap Text Text
$sel:instanceId:UpdateContactAttributes' :: UpdateContactAttributes -> Text
$sel:initialContactId:UpdateContactAttributes' :: UpdateContactAttributes -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
initialContactId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text Text
attributes

instance Prelude.NFData UpdateContactAttributes where
  rnf :: UpdateContactAttributes -> ()
rnf UpdateContactAttributes' {Text
HashMap Text Text
attributes :: HashMap Text Text
instanceId :: Text
initialContactId :: Text
$sel:attributes:UpdateContactAttributes' :: UpdateContactAttributes -> HashMap Text Text
$sel:instanceId:UpdateContactAttributes' :: UpdateContactAttributes -> Text
$sel:initialContactId:UpdateContactAttributes' :: UpdateContactAttributes -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
initialContactId
      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 HashMap Text Text
attributes

instance Data.ToHeaders UpdateContactAttributes where
  toHeaders :: UpdateContactAttributes -> 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 UpdateContactAttributes where
  toJSON :: UpdateContactAttributes -> Value
toJSON UpdateContactAttributes' {Text
HashMap Text Text
attributes :: HashMap Text Text
instanceId :: Text
initialContactId :: Text
$sel:attributes:UpdateContactAttributes' :: UpdateContactAttributes -> HashMap Text Text
$sel:instanceId:UpdateContactAttributes' :: UpdateContactAttributes -> Text
$sel:initialContactId:UpdateContactAttributes' :: UpdateContactAttributes -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"InitialContactId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
initialContactId),
            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
"Attributes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= HashMap Text Text
attributes)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateContactAttributesResponse' 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', 'updateContactAttributesResponse_httpStatus' - The response's http status code.
newUpdateContactAttributesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateContactAttributesResponse
newUpdateContactAttributesResponse :: Int -> UpdateContactAttributesResponse
newUpdateContactAttributesResponse Int
pHttpStatus_ =
  UpdateContactAttributesResponse'
    { $sel:httpStatus:UpdateContactAttributesResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    UpdateContactAttributesResponse
  where
  rnf :: UpdateContactAttributesResponse -> ()
rnf UpdateContactAttributesResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateContactAttributesResponse' :: UpdateContactAttributesResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus