{-# 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.Chime.AssociatePhoneNumberWithUser
-- 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 phone number with the specified Amazon Chime user.
module Amazonka.Chime.AssociatePhoneNumberWithUser
  ( -- * Creating a Request
    AssociatePhoneNumberWithUser (..),
    newAssociatePhoneNumberWithUser,

    -- * Request Lenses
    associatePhoneNumberWithUser_accountId,
    associatePhoneNumberWithUser_userId,
    associatePhoneNumberWithUser_e164PhoneNumber,

    -- * Destructuring the Response
    AssociatePhoneNumberWithUserResponse (..),
    newAssociatePhoneNumberWithUserResponse,

    -- * Response Lenses
    associatePhoneNumberWithUserResponse_httpStatus,
  )
where

import Amazonka.Chime.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:/ 'newAssociatePhoneNumberWithUser' smart constructor.
data AssociatePhoneNumberWithUser = AssociatePhoneNumberWithUser'
  { -- | The Amazon Chime account ID.
    AssociatePhoneNumberWithUser -> Text
accountId :: Prelude.Text,
    -- | The user ID.
    AssociatePhoneNumberWithUser -> Text
userId :: Prelude.Text,
    -- | The phone number, in E.164 format.
    AssociatePhoneNumberWithUser -> Sensitive Text
e164PhoneNumber :: Data.Sensitive Prelude.Text
  }
  deriving (AssociatePhoneNumberWithUser
-> AssociatePhoneNumberWithUser -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociatePhoneNumberWithUser
-> AssociatePhoneNumberWithUser -> Bool
$c/= :: AssociatePhoneNumberWithUser
-> AssociatePhoneNumberWithUser -> Bool
== :: AssociatePhoneNumberWithUser
-> AssociatePhoneNumberWithUser -> Bool
$c== :: AssociatePhoneNumberWithUser
-> AssociatePhoneNumberWithUser -> Bool
Prelude.Eq, Int -> AssociatePhoneNumberWithUser -> ShowS
[AssociatePhoneNumberWithUser] -> ShowS
AssociatePhoneNumberWithUser -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociatePhoneNumberWithUser] -> ShowS
$cshowList :: [AssociatePhoneNumberWithUser] -> ShowS
show :: AssociatePhoneNumberWithUser -> String
$cshow :: AssociatePhoneNumberWithUser -> String
showsPrec :: Int -> AssociatePhoneNumberWithUser -> ShowS
$cshowsPrec :: Int -> AssociatePhoneNumberWithUser -> ShowS
Prelude.Show, forall x.
Rep AssociatePhoneNumberWithUser x -> AssociatePhoneNumberWithUser
forall x.
AssociatePhoneNumberWithUser -> Rep AssociatePhoneNumberWithUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssociatePhoneNumberWithUser x -> AssociatePhoneNumberWithUser
$cfrom :: forall x.
AssociatePhoneNumberWithUser -> Rep AssociatePhoneNumberWithUser x
Prelude.Generic)

-- |
-- Create a value of 'AssociatePhoneNumberWithUser' 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:
--
-- 'accountId', 'associatePhoneNumberWithUser_accountId' - The Amazon Chime account ID.
--
-- 'userId', 'associatePhoneNumberWithUser_userId' - The user ID.
--
-- 'e164PhoneNumber', 'associatePhoneNumberWithUser_e164PhoneNumber' - The phone number, in E.164 format.
newAssociatePhoneNumberWithUser ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'userId'
  Prelude.Text ->
  -- | 'e164PhoneNumber'
  Prelude.Text ->
  AssociatePhoneNumberWithUser
newAssociatePhoneNumberWithUser :: Text -> Text -> Text -> AssociatePhoneNumberWithUser
newAssociatePhoneNumberWithUser
  Text
pAccountId_
  Text
pUserId_
  Text
pE164PhoneNumber_ =
    AssociatePhoneNumberWithUser'
      { $sel:accountId:AssociatePhoneNumberWithUser' :: Text
accountId =
          Text
pAccountId_,
        $sel:userId:AssociatePhoneNumberWithUser' :: Text
userId = Text
pUserId_,
        $sel:e164PhoneNumber:AssociatePhoneNumberWithUser' :: Sensitive Text
e164PhoneNumber =
          forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pE164PhoneNumber_
      }

-- | The Amazon Chime account ID.
associatePhoneNumberWithUser_accountId :: Lens.Lens' AssociatePhoneNumberWithUser Prelude.Text
associatePhoneNumberWithUser_accountId :: Lens' AssociatePhoneNumberWithUser Text
associatePhoneNumberWithUser_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatePhoneNumberWithUser' {Text
accountId :: Text
$sel:accountId:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Text
accountId} -> Text
accountId) (\s :: AssociatePhoneNumberWithUser
s@AssociatePhoneNumberWithUser' {} Text
a -> AssociatePhoneNumberWithUser
s {$sel:accountId:AssociatePhoneNumberWithUser' :: Text
accountId = Text
a} :: AssociatePhoneNumberWithUser)

-- | The user ID.
associatePhoneNumberWithUser_userId :: Lens.Lens' AssociatePhoneNumberWithUser Prelude.Text
associatePhoneNumberWithUser_userId :: Lens' AssociatePhoneNumberWithUser Text
associatePhoneNumberWithUser_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatePhoneNumberWithUser' {Text
userId :: Text
$sel:userId:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Text
userId} -> Text
userId) (\s :: AssociatePhoneNumberWithUser
s@AssociatePhoneNumberWithUser' {} Text
a -> AssociatePhoneNumberWithUser
s {$sel:userId:AssociatePhoneNumberWithUser' :: Text
userId = Text
a} :: AssociatePhoneNumberWithUser)

-- | The phone number, in E.164 format.
associatePhoneNumberWithUser_e164PhoneNumber :: Lens.Lens' AssociatePhoneNumberWithUser Prelude.Text
associatePhoneNumberWithUser_e164PhoneNumber :: Lens' AssociatePhoneNumberWithUser Text
associatePhoneNumberWithUser_e164PhoneNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatePhoneNumberWithUser' {Sensitive Text
e164PhoneNumber :: Sensitive Text
$sel:e164PhoneNumber:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Sensitive Text
e164PhoneNumber} -> Sensitive Text
e164PhoneNumber) (\s :: AssociatePhoneNumberWithUser
s@AssociatePhoneNumberWithUser' {} Sensitive Text
a -> AssociatePhoneNumberWithUser
s {$sel:e164PhoneNumber:AssociatePhoneNumberWithUser' :: Sensitive Text
e164PhoneNumber = Sensitive Text
a} :: AssociatePhoneNumberWithUser) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Core.AWSRequest AssociatePhoneNumberWithUser where
  type
    AWSResponse AssociatePhoneNumberWithUser =
      AssociatePhoneNumberWithUserResponse
  request :: (Service -> Service)
-> AssociatePhoneNumberWithUser
-> Request AssociatePhoneNumberWithUser
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 AssociatePhoneNumberWithUser
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociatePhoneNumberWithUser)))
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 -> AssociatePhoneNumberWithUserResponse
AssociatePhoneNumberWithUserResponse'
            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
    AssociatePhoneNumberWithUser
  where
  hashWithSalt :: Int -> AssociatePhoneNumberWithUser -> Int
hashWithSalt Int
_salt AssociatePhoneNumberWithUser' {Text
Sensitive Text
e164PhoneNumber :: Sensitive Text
userId :: Text
accountId :: Text
$sel:e164PhoneNumber:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Sensitive Text
$sel:userId:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Text
$sel:accountId:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
e164PhoneNumber

instance Prelude.NFData AssociatePhoneNumberWithUser where
  rnf :: AssociatePhoneNumberWithUser -> ()
rnf AssociatePhoneNumberWithUser' {Text
Sensitive Text
e164PhoneNumber :: Sensitive Text
userId :: Text
accountId :: Text
$sel:e164PhoneNumber:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Sensitive Text
$sel:userId:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Text
$sel:accountId:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
e164PhoneNumber

instance Data.ToHeaders AssociatePhoneNumberWithUser where
  toHeaders :: AssociatePhoneNumberWithUser -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToJSON AssociatePhoneNumberWithUser where
  toJSON :: AssociatePhoneNumberWithUser -> Value
toJSON AssociatePhoneNumberWithUser' {Text
Sensitive Text
e164PhoneNumber :: Sensitive Text
userId :: Text
accountId :: Text
$sel:e164PhoneNumber:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Sensitive Text
$sel:userId:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Text
$sel:accountId:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"E164PhoneNumber" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
e164PhoneNumber)
          ]
      )

instance Data.ToPath AssociatePhoneNumberWithUser where
  toPath :: AssociatePhoneNumberWithUser -> ByteString
toPath AssociatePhoneNumberWithUser' {Text
Sensitive Text
e164PhoneNumber :: Sensitive Text
userId :: Text
accountId :: Text
$sel:e164PhoneNumber:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Sensitive Text
$sel:userId:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Text
$sel:accountId:AssociatePhoneNumberWithUser' :: AssociatePhoneNumberWithUser -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
accountId,
        ByteString
"/users/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
userId
      ]

instance Data.ToQuery AssociatePhoneNumberWithUser where
  toQuery :: AssociatePhoneNumberWithUser -> QueryString
toQuery =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [QueryString
"operation=associate-phone-number"]
      )

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

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

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

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