{-# 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-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)
--
-- 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.Lens as Lens
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 :: Core.Sensitive Prelude.Text
  }
  deriving (AssociatePhoneNumberWithUser
-> AssociatePhoneNumberWithUser -> Bool
(AssociatePhoneNumberWithUser
 -> AssociatePhoneNumberWithUser -> Bool)
-> (AssociatePhoneNumberWithUser
    -> AssociatePhoneNumberWithUser -> Bool)
-> Eq AssociatePhoneNumberWithUser
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
(Int -> AssociatePhoneNumberWithUser -> ShowS)
-> (AssociatePhoneNumberWithUser -> String)
-> ([AssociatePhoneNumberWithUser] -> ShowS)
-> Show AssociatePhoneNumberWithUser
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.
 AssociatePhoneNumberWithUser -> Rep AssociatePhoneNumberWithUser x)
-> (forall x.
    Rep AssociatePhoneNumberWithUser x -> AssociatePhoneNumberWithUser)
-> Generic AssociatePhoneNumberWithUser
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' :: Text -> Text -> Sensitive Text -> AssociatePhoneNumberWithUser
AssociatePhoneNumberWithUser'
      { $sel:accountId:AssociatePhoneNumberWithUser' :: Text
accountId =
          Text
pAccountId_,
        $sel:userId:AssociatePhoneNumberWithUser' :: Text
userId = Text
pUserId_,
        $sel:e164PhoneNumber:AssociatePhoneNumberWithUser' :: Sensitive Text
e164PhoneNumber =
          Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
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 :: (Text -> f Text)
-> AssociatePhoneNumberWithUser -> f AssociatePhoneNumberWithUser
associatePhoneNumberWithUser_accountId = (AssociatePhoneNumberWithUser -> Text)
-> (AssociatePhoneNumberWithUser
    -> Text -> AssociatePhoneNumberWithUser)
-> Lens
     AssociatePhoneNumberWithUser AssociatePhoneNumberWithUser Text Text
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 :: (Text -> f Text)
-> AssociatePhoneNumberWithUser -> f AssociatePhoneNumberWithUser
associatePhoneNumberWithUser_userId = (AssociatePhoneNumberWithUser -> Text)
-> (AssociatePhoneNumberWithUser
    -> Text -> AssociatePhoneNumberWithUser)
-> Lens
     AssociatePhoneNumberWithUser AssociatePhoneNumberWithUser Text Text
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 :: (Text -> f Text)
-> AssociatePhoneNumberWithUser -> f AssociatePhoneNumberWithUser
associatePhoneNumberWithUser_e164PhoneNumber = (AssociatePhoneNumberWithUser -> Sensitive Text)
-> (AssociatePhoneNumberWithUser
    -> Sensitive Text -> AssociatePhoneNumberWithUser)
-> Lens
     AssociatePhoneNumberWithUser
     AssociatePhoneNumberWithUser
     (Sensitive Text)
     (Sensitive Text)
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) ((Sensitive Text -> f (Sensitive Text))
 -> AssociatePhoneNumberWithUser -> f AssociatePhoneNumberWithUser)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> AssociatePhoneNumberWithUser
-> f AssociatePhoneNumberWithUser
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Core.AWSRequest AssociatePhoneNumberWithUser where
  type
    AWSResponse AssociatePhoneNumberWithUser =
      AssociatePhoneNumberWithUserResponse
  request :: AssociatePhoneNumberWithUser
-> Request AssociatePhoneNumberWithUser
request = Service
-> AssociatePhoneNumberWithUser
-> Request AssociatePhoneNumberWithUser
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociatePhoneNumberWithUser
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociatePhoneNumberWithUser)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AssociatePhoneNumberWithUser))
-> Logger
-> Service
-> Proxy AssociatePhoneNumberWithUser
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociatePhoneNumberWithUser)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AssociatePhoneNumberWithUserResponse
AssociatePhoneNumberWithUserResponse'
            (Int -> AssociatePhoneNumberWithUserResponse)
-> Either String Int
-> Either String AssociatePhoneNumberWithUserResponse
forall (f :: * -> *) a b. Functor 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
    AssociatePhoneNumberWithUser

instance Prelude.NFData AssociatePhoneNumberWithUser

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"E164PhoneNumber" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
e164PhoneNumber)
          ]
      )

instance Core.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
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
accountId,
        ByteString
"/users/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
userId
      ]

instance Core.ToQuery AssociatePhoneNumberWithUser where
  toQuery :: AssociatePhoneNumberWithUser -> QueryString
toQuery =
    QueryString -> AssociatePhoneNumberWithUser -> QueryString
forall a b. a -> b -> a
Prelude.const
      ( [QueryString] -> QueryString
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
(AssociatePhoneNumberWithUserResponse
 -> AssociatePhoneNumberWithUserResponse -> Bool)
-> (AssociatePhoneNumberWithUserResponse
    -> AssociatePhoneNumberWithUserResponse -> Bool)
-> Eq AssociatePhoneNumberWithUserResponse
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]
(Int -> ReadS AssociatePhoneNumberWithUserResponse)
-> ReadS [AssociatePhoneNumberWithUserResponse]
-> ReadPrec AssociatePhoneNumberWithUserResponse
-> ReadPrec [AssociatePhoneNumberWithUserResponse]
-> Read 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
(Int -> AssociatePhoneNumberWithUserResponse -> ShowS)
-> (AssociatePhoneNumberWithUserResponse -> String)
-> ([AssociatePhoneNumberWithUserResponse] -> ShowS)
-> Show AssociatePhoneNumberWithUserResponse
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.
 AssociatePhoneNumberWithUserResponse
 -> Rep AssociatePhoneNumberWithUserResponse x)
-> (forall x.
    Rep AssociatePhoneNumberWithUserResponse x
    -> AssociatePhoneNumberWithUserResponse)
-> Generic AssociatePhoneNumberWithUserResponse
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' :: Int -> AssociatePhoneNumberWithUserResponse
AssociatePhoneNumberWithUserResponse'
    { $sel:httpStatus:AssociatePhoneNumberWithUserResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
associatePhoneNumberWithUserResponse_httpStatus :: Lens.Lens' AssociatePhoneNumberWithUserResponse Prelude.Int
associatePhoneNumberWithUserResponse_httpStatus :: (Int -> f Int)
-> AssociatePhoneNumberWithUserResponse
-> f AssociatePhoneNumberWithUserResponse
associatePhoneNumberWithUserResponse_httpStatus = (AssociatePhoneNumberWithUserResponse -> Int)
-> (AssociatePhoneNumberWithUserResponse
    -> Int -> AssociatePhoneNumberWithUserResponse)
-> Lens
     AssociatePhoneNumberWithUserResponse
     AssociatePhoneNumberWithUserResponse
     Int
     Int
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