{-# 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.AssociatePhoneNumberContactFlow
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associates a flow with a phone number claimed to your Amazon Connect
-- instance.
--
-- If the number is claimed to a traffic distribution group, and you are
-- calling this API using an instance in the Amazon Web Services Region
-- where the traffic distribution group was created, you can use either a
-- full phone number ARN or UUID value for the @PhoneNumberId@ URI request
-- parameter. However, if the number is claimed to a traffic distribution
-- group and you are calling this API using an instance in the alternate
-- Amazon Web Services Region associated with the traffic distribution
-- group, you must provide a full phone number ARN. If a UUID is provided
-- in this scenario, you will receive a @ResourceNotFoundException@.
module Amazonka.Connect.AssociatePhoneNumberContactFlow
  ( -- * Creating a Request
    AssociatePhoneNumberContactFlow (..),
    newAssociatePhoneNumberContactFlow,

    -- * Request Lenses
    associatePhoneNumberContactFlow_phoneNumberId,
    associatePhoneNumberContactFlow_instanceId,
    associatePhoneNumberContactFlow_contactFlowId,

    -- * Destructuring the Response
    AssociatePhoneNumberContactFlowResponse (..),
    newAssociatePhoneNumberContactFlowResponse,
  )
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:/ 'newAssociatePhoneNumberContactFlow' smart constructor.
data AssociatePhoneNumberContactFlow = AssociatePhoneNumberContactFlow'
  { -- | A unique identifier for the phone number.
    AssociatePhoneNumberContactFlow -> Text
phoneNumberId :: Prelude.Text,
    -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    AssociatePhoneNumberContactFlow -> Text
instanceId :: Prelude.Text,
    -- | The identifier of the flow.
    AssociatePhoneNumberContactFlow -> Text
contactFlowId :: Prelude.Text
  }
  deriving (AssociatePhoneNumberContactFlow
-> AssociatePhoneNumberContactFlow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociatePhoneNumberContactFlow
-> AssociatePhoneNumberContactFlow -> Bool
$c/= :: AssociatePhoneNumberContactFlow
-> AssociatePhoneNumberContactFlow -> Bool
== :: AssociatePhoneNumberContactFlow
-> AssociatePhoneNumberContactFlow -> Bool
$c== :: AssociatePhoneNumberContactFlow
-> AssociatePhoneNumberContactFlow -> Bool
Prelude.Eq, ReadPrec [AssociatePhoneNumberContactFlow]
ReadPrec AssociatePhoneNumberContactFlow
Int -> ReadS AssociatePhoneNumberContactFlow
ReadS [AssociatePhoneNumberContactFlow]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociatePhoneNumberContactFlow]
$creadListPrec :: ReadPrec [AssociatePhoneNumberContactFlow]
readPrec :: ReadPrec AssociatePhoneNumberContactFlow
$creadPrec :: ReadPrec AssociatePhoneNumberContactFlow
readList :: ReadS [AssociatePhoneNumberContactFlow]
$creadList :: ReadS [AssociatePhoneNumberContactFlow]
readsPrec :: Int -> ReadS AssociatePhoneNumberContactFlow
$creadsPrec :: Int -> ReadS AssociatePhoneNumberContactFlow
Prelude.Read, Int -> AssociatePhoneNumberContactFlow -> ShowS
[AssociatePhoneNumberContactFlow] -> ShowS
AssociatePhoneNumberContactFlow -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociatePhoneNumberContactFlow] -> ShowS
$cshowList :: [AssociatePhoneNumberContactFlow] -> ShowS
show :: AssociatePhoneNumberContactFlow -> String
$cshow :: AssociatePhoneNumberContactFlow -> String
showsPrec :: Int -> AssociatePhoneNumberContactFlow -> ShowS
$cshowsPrec :: Int -> AssociatePhoneNumberContactFlow -> ShowS
Prelude.Show, forall x.
Rep AssociatePhoneNumberContactFlow x
-> AssociatePhoneNumberContactFlow
forall x.
AssociatePhoneNumberContactFlow
-> Rep AssociatePhoneNumberContactFlow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociatePhoneNumberContactFlow x
-> AssociatePhoneNumberContactFlow
$cfrom :: forall x.
AssociatePhoneNumberContactFlow
-> Rep AssociatePhoneNumberContactFlow x
Prelude.Generic)

-- |
-- Create a value of 'AssociatePhoneNumberContactFlow' 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:
--
-- 'phoneNumberId', 'associatePhoneNumberContactFlow_phoneNumberId' - A unique identifier for the phone number.
--
-- 'instanceId', 'associatePhoneNumberContactFlow_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
--
-- 'contactFlowId', 'associatePhoneNumberContactFlow_contactFlowId' - The identifier of the flow.
newAssociatePhoneNumberContactFlow ::
  -- | 'phoneNumberId'
  Prelude.Text ->
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'contactFlowId'
  Prelude.Text ->
  AssociatePhoneNumberContactFlow
newAssociatePhoneNumberContactFlow :: Text -> Text -> Text -> AssociatePhoneNumberContactFlow
newAssociatePhoneNumberContactFlow
  Text
pPhoneNumberId_
  Text
pInstanceId_
  Text
pContactFlowId_ =
    AssociatePhoneNumberContactFlow'
      { $sel:phoneNumberId:AssociatePhoneNumberContactFlow' :: Text
phoneNumberId =
          Text
pPhoneNumberId_,
        $sel:instanceId:AssociatePhoneNumberContactFlow' :: Text
instanceId = Text
pInstanceId_,
        $sel:contactFlowId:AssociatePhoneNumberContactFlow' :: Text
contactFlowId = Text
pContactFlowId_
      }

-- | A unique identifier for the phone number.
associatePhoneNumberContactFlow_phoneNumberId :: Lens.Lens' AssociatePhoneNumberContactFlow Prelude.Text
associatePhoneNumberContactFlow_phoneNumberId :: Lens' AssociatePhoneNumberContactFlow Text
associatePhoneNumberContactFlow_phoneNumberId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatePhoneNumberContactFlow' {Text
phoneNumberId :: Text
$sel:phoneNumberId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
phoneNumberId} -> Text
phoneNumberId) (\s :: AssociatePhoneNumberContactFlow
s@AssociatePhoneNumberContactFlow' {} Text
a -> AssociatePhoneNumberContactFlow
s {$sel:phoneNumberId:AssociatePhoneNumberContactFlow' :: Text
phoneNumberId = Text
a} :: AssociatePhoneNumberContactFlow)

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

-- | The identifier of the flow.
associatePhoneNumberContactFlow_contactFlowId :: Lens.Lens' AssociatePhoneNumberContactFlow Prelude.Text
associatePhoneNumberContactFlow_contactFlowId :: Lens' AssociatePhoneNumberContactFlow Text
associatePhoneNumberContactFlow_contactFlowId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatePhoneNumberContactFlow' {Text
contactFlowId :: Text
$sel:contactFlowId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
contactFlowId} -> Text
contactFlowId) (\s :: AssociatePhoneNumberContactFlow
s@AssociatePhoneNumberContactFlow' {} Text
a -> AssociatePhoneNumberContactFlow
s {$sel:contactFlowId:AssociatePhoneNumberContactFlow' :: Text
contactFlowId = Text
a} :: AssociatePhoneNumberContactFlow)

instance
  Core.AWSRequest
    AssociatePhoneNumberContactFlow
  where
  type
    AWSResponse AssociatePhoneNumberContactFlow =
      AssociatePhoneNumberContactFlowResponse
  request :: (Service -> Service)
-> AssociatePhoneNumberContactFlow
-> Request AssociatePhoneNumberContactFlow
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 AssociatePhoneNumberContactFlow
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AssociatePhoneNumberContactFlow)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AssociatePhoneNumberContactFlowResponse
AssociatePhoneNumberContactFlowResponse'

instance
  Prelude.Hashable
    AssociatePhoneNumberContactFlow
  where
  hashWithSalt :: Int -> AssociatePhoneNumberContactFlow -> Int
hashWithSalt
    Int
_salt
    AssociatePhoneNumberContactFlow' {Text
contactFlowId :: Text
instanceId :: Text
phoneNumberId :: Text
$sel:contactFlowId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
$sel:instanceId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
$sel:phoneNumberId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
phoneNumberId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
contactFlowId

instance
  Prelude.NFData
    AssociatePhoneNumberContactFlow
  where
  rnf :: AssociatePhoneNumberContactFlow -> ()
rnf AssociatePhoneNumberContactFlow' {Text
contactFlowId :: Text
instanceId :: Text
phoneNumberId :: Text
$sel:contactFlowId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
$sel:instanceId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
$sel:phoneNumberId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
phoneNumberId
      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

instance
  Data.ToHeaders
    AssociatePhoneNumberContactFlow
  where
  toHeaders :: AssociatePhoneNumberContactFlow -> [Header]
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 -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON AssociatePhoneNumberContactFlow where
  toJSON :: AssociatePhoneNumberContactFlow -> Value
toJSON AssociatePhoneNumberContactFlow' {Text
contactFlowId :: Text
instanceId :: Text
phoneNumberId :: Text
$sel:contactFlowId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
$sel:instanceId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
$sel:phoneNumberId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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)
          ]
      )

instance Data.ToPath AssociatePhoneNumberContactFlow where
  toPath :: AssociatePhoneNumberContactFlow -> ByteString
toPath AssociatePhoneNumberContactFlow' {Text
contactFlowId :: Text
instanceId :: Text
phoneNumberId :: Text
$sel:contactFlowId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
$sel:instanceId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
$sel:phoneNumberId:AssociatePhoneNumberContactFlow' :: AssociatePhoneNumberContactFlow -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/phone-number/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
phoneNumberId,
        ByteString
"/contact-flow"
      ]

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

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

-- |
-- Create a value of 'AssociatePhoneNumberContactFlowResponse' 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.
newAssociatePhoneNumberContactFlowResponse ::
  AssociatePhoneNumberContactFlowResponse
newAssociatePhoneNumberContactFlowResponse :: AssociatePhoneNumberContactFlowResponse
newAssociatePhoneNumberContactFlowResponse =
  AssociatePhoneNumberContactFlowResponse
AssociatePhoneNumberContactFlowResponse'

instance
  Prelude.NFData
    AssociatePhoneNumberContactFlowResponse
  where
  rnf :: AssociatePhoneNumberContactFlowResponse -> ()
rnf AssociatePhoneNumberContactFlowResponse
_ = ()