{-# 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.GetContactAttributes
-- 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)
--
-- Retrieves the contact attributes for the specified contact.
module Amazonka.Connect.GetContactAttributes
  ( -- * Creating a Request
    GetContactAttributes (..),
    newGetContactAttributes,

    -- * Request Lenses
    getContactAttributes_instanceId,
    getContactAttributes_initialContactId,

    -- * Destructuring the Response
    GetContactAttributesResponse (..),
    newGetContactAttributesResponse,

    -- * Response Lenses
    getContactAttributesResponse_attributes,
    getContactAttributesResponse_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:/ 'newGetContactAttributes' smart constructor.
data GetContactAttributes = GetContactAttributes'
  { -- | The identifier of the Amazon Connect instance.
    GetContactAttributes -> Text
instanceId :: Prelude.Text,
    -- | The identifier of the initial contact.
    GetContactAttributes -> Text
initialContactId :: Prelude.Text
  }
  deriving (GetContactAttributes -> GetContactAttributes -> Bool
(GetContactAttributes -> GetContactAttributes -> Bool)
-> (GetContactAttributes -> GetContactAttributes -> Bool)
-> Eq GetContactAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContactAttributes -> GetContactAttributes -> Bool
$c/= :: GetContactAttributes -> GetContactAttributes -> Bool
== :: GetContactAttributes -> GetContactAttributes -> Bool
$c== :: GetContactAttributes -> GetContactAttributes -> Bool
Prelude.Eq, ReadPrec [GetContactAttributes]
ReadPrec GetContactAttributes
Int -> ReadS GetContactAttributes
ReadS [GetContactAttributes]
(Int -> ReadS GetContactAttributes)
-> ReadS [GetContactAttributes]
-> ReadPrec GetContactAttributes
-> ReadPrec [GetContactAttributes]
-> Read GetContactAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContactAttributes]
$creadListPrec :: ReadPrec [GetContactAttributes]
readPrec :: ReadPrec GetContactAttributes
$creadPrec :: ReadPrec GetContactAttributes
readList :: ReadS [GetContactAttributes]
$creadList :: ReadS [GetContactAttributes]
readsPrec :: Int -> ReadS GetContactAttributes
$creadsPrec :: Int -> ReadS GetContactAttributes
Prelude.Read, Int -> GetContactAttributes -> ShowS
[GetContactAttributes] -> ShowS
GetContactAttributes -> String
(Int -> GetContactAttributes -> ShowS)
-> (GetContactAttributes -> String)
-> ([GetContactAttributes] -> ShowS)
-> Show GetContactAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContactAttributes] -> ShowS
$cshowList :: [GetContactAttributes] -> ShowS
show :: GetContactAttributes -> String
$cshow :: GetContactAttributes -> String
showsPrec :: Int -> GetContactAttributes -> ShowS
$cshowsPrec :: Int -> GetContactAttributes -> ShowS
Prelude.Show, (forall x. GetContactAttributes -> Rep GetContactAttributes x)
-> (forall x. Rep GetContactAttributes x -> GetContactAttributes)
-> Generic GetContactAttributes
forall x. Rep GetContactAttributes x -> GetContactAttributes
forall x. GetContactAttributes -> Rep GetContactAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetContactAttributes x -> GetContactAttributes
$cfrom :: forall x. GetContactAttributes -> Rep GetContactAttributes x
Prelude.Generic)

-- |
-- Create a value of 'GetContactAttributes' 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:
--
-- 'instanceId', 'getContactAttributes_instanceId' - The identifier of the Amazon Connect instance.
--
-- 'initialContactId', 'getContactAttributes_initialContactId' - The identifier of the initial contact.
newGetContactAttributes ::
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'initialContactId'
  Prelude.Text ->
  GetContactAttributes
newGetContactAttributes :: Text -> Text -> GetContactAttributes
newGetContactAttributes
  Text
pInstanceId_
  Text
pInitialContactId_ =
    GetContactAttributes' :: Text -> Text -> GetContactAttributes
GetContactAttributes'
      { $sel:instanceId:GetContactAttributes' :: Text
instanceId = Text
pInstanceId_,
        $sel:initialContactId:GetContactAttributes' :: Text
initialContactId = Text
pInitialContactId_
      }

-- | The identifier of the Amazon Connect instance.
getContactAttributes_instanceId :: Lens.Lens' GetContactAttributes Prelude.Text
getContactAttributes_instanceId :: (Text -> f Text) -> GetContactAttributes -> f GetContactAttributes
getContactAttributes_instanceId = (GetContactAttributes -> Text)
-> (GetContactAttributes -> Text -> GetContactAttributes)
-> Lens GetContactAttributes GetContactAttributes Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContactAttributes' {Text
instanceId :: Text
$sel:instanceId:GetContactAttributes' :: GetContactAttributes -> Text
instanceId} -> Text
instanceId) (\s :: GetContactAttributes
s@GetContactAttributes' {} Text
a -> GetContactAttributes
s {$sel:instanceId:GetContactAttributes' :: Text
instanceId = Text
a} :: GetContactAttributes)

-- | The identifier of the initial contact.
getContactAttributes_initialContactId :: Lens.Lens' GetContactAttributes Prelude.Text
getContactAttributes_initialContactId :: (Text -> f Text) -> GetContactAttributes -> f GetContactAttributes
getContactAttributes_initialContactId = (GetContactAttributes -> Text)
-> (GetContactAttributes -> Text -> GetContactAttributes)
-> Lens GetContactAttributes GetContactAttributes Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContactAttributes' {Text
initialContactId :: Text
$sel:initialContactId:GetContactAttributes' :: GetContactAttributes -> Text
initialContactId} -> Text
initialContactId) (\s :: GetContactAttributes
s@GetContactAttributes' {} Text
a -> GetContactAttributes
s {$sel:initialContactId:GetContactAttributes' :: Text
initialContactId = Text
a} :: GetContactAttributes)

instance Core.AWSRequest GetContactAttributes where
  type
    AWSResponse GetContactAttributes =
      GetContactAttributesResponse
  request :: GetContactAttributes -> Request GetContactAttributes
request = Service -> GetContactAttributes -> Request GetContactAttributes
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetContactAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetContactAttributes)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetContactAttributes))
-> Logger
-> Service
-> Proxy GetContactAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetContactAttributes)))
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 (HashMap Text Text) -> Int -> GetContactAttributesResponse
GetContactAttributesResponse'
            (Maybe (HashMap Text Text) -> Int -> GetContactAttributesResponse)
-> Either String (Maybe (HashMap Text Text))
-> Either String (Int -> GetContactAttributesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Attributes" Either String (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text)
-> Either String (Maybe (HashMap Text Text))
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> GetContactAttributesResponse)
-> Either String Int -> Either String GetContactAttributesResponse
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 GetContactAttributes

instance Prelude.NFData GetContactAttributes

instance Core.ToHeaders GetContactAttributes where
  toHeaders :: GetContactAttributes -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetContactAttributes -> 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.ToPath GetContactAttributes where
  toPath :: GetContactAttributes -> ByteString
toPath GetContactAttributes' {Text
initialContactId :: Text
instanceId :: Text
$sel:initialContactId:GetContactAttributes' :: GetContactAttributes -> Text
$sel:instanceId:GetContactAttributes' :: GetContactAttributes -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/contact/attributes/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
instanceId,
        ByteString
"/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
initialContactId
      ]

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

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

-- |
-- Create a value of 'GetContactAttributesResponse' 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', 'getContactAttributesResponse_attributes' - Information about the attributes.
--
-- 'httpStatus', 'getContactAttributesResponse_httpStatus' - The response's http status code.
newGetContactAttributesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetContactAttributesResponse
newGetContactAttributesResponse :: Int -> GetContactAttributesResponse
newGetContactAttributesResponse Int
pHttpStatus_ =
  GetContactAttributesResponse' :: Maybe (HashMap Text Text) -> Int -> GetContactAttributesResponse
GetContactAttributesResponse'
    { $sel:attributes:GetContactAttributesResponse' :: Maybe (HashMap Text Text)
attributes =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetContactAttributesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the attributes.
getContactAttributesResponse_attributes :: Lens.Lens' GetContactAttributesResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
getContactAttributesResponse_attributes :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> GetContactAttributesResponse -> f GetContactAttributesResponse
getContactAttributesResponse_attributes = (GetContactAttributesResponse -> Maybe (HashMap Text Text))
-> (GetContactAttributesResponse
    -> Maybe (HashMap Text Text) -> GetContactAttributesResponse)
-> Lens
     GetContactAttributesResponse
     GetContactAttributesResponse
     (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 (\GetContactAttributesResponse' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:GetContactAttributesResponse' :: GetContactAttributesResponse -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: GetContactAttributesResponse
s@GetContactAttributesResponse' {} Maybe (HashMap Text Text)
a -> GetContactAttributesResponse
s {$sel:attributes:GetContactAttributesResponse' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: GetContactAttributesResponse) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> GetContactAttributesResponse -> f GetContactAttributesResponse)
-> ((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)))
-> GetContactAttributesResponse
-> f GetContactAttributesResponse
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 response's http status code.
getContactAttributesResponse_httpStatus :: Lens.Lens' GetContactAttributesResponse Prelude.Int
getContactAttributesResponse_httpStatus :: (Int -> f Int)
-> GetContactAttributesResponse -> f GetContactAttributesResponse
getContactAttributesResponse_httpStatus = (GetContactAttributesResponse -> Int)
-> (GetContactAttributesResponse
    -> Int -> GetContactAttributesResponse)
-> Lens
     GetContactAttributesResponse GetContactAttributesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContactAttributesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetContactAttributesResponse' :: GetContactAttributesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetContactAttributesResponse
s@GetContactAttributesResponse' {} Int
a -> GetContactAttributesResponse
s {$sel:httpStatus:GetContactAttributesResponse' :: Int
httpStatus = Int
a} :: GetContactAttributesResponse)

instance Prelude.NFData GetContactAttributesResponse