{-# 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.GetUserSettings
-- 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 settings for the specified user ID, such as any associated
-- phone number settings.
module Amazonka.Chime.GetUserSettings
  ( -- * Creating a Request
    GetUserSettings (..),
    newGetUserSettings,

    -- * Request Lenses
    getUserSettings_accountId,
    getUserSettings_userId,

    -- * Destructuring the Response
    GetUserSettingsResponse (..),
    newGetUserSettingsResponse,

    -- * Response Lenses
    getUserSettingsResponse_userSettings,
    getUserSettingsResponse_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:/ 'newGetUserSettings' smart constructor.
data GetUserSettings = GetUserSettings'
  { -- | The Amazon Chime account ID.
    GetUserSettings -> Text
accountId :: Prelude.Text,
    -- | The user ID.
    GetUserSettings -> Text
userId :: Prelude.Text
  }
  deriving (GetUserSettings -> GetUserSettings -> Bool
(GetUserSettings -> GetUserSettings -> Bool)
-> (GetUserSettings -> GetUserSettings -> Bool)
-> Eq GetUserSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUserSettings -> GetUserSettings -> Bool
$c/= :: GetUserSettings -> GetUserSettings -> Bool
== :: GetUserSettings -> GetUserSettings -> Bool
$c== :: GetUserSettings -> GetUserSettings -> Bool
Prelude.Eq, ReadPrec [GetUserSettings]
ReadPrec GetUserSettings
Int -> ReadS GetUserSettings
ReadS [GetUserSettings]
(Int -> ReadS GetUserSettings)
-> ReadS [GetUserSettings]
-> ReadPrec GetUserSettings
-> ReadPrec [GetUserSettings]
-> Read GetUserSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetUserSettings]
$creadListPrec :: ReadPrec [GetUserSettings]
readPrec :: ReadPrec GetUserSettings
$creadPrec :: ReadPrec GetUserSettings
readList :: ReadS [GetUserSettings]
$creadList :: ReadS [GetUserSettings]
readsPrec :: Int -> ReadS GetUserSettings
$creadsPrec :: Int -> ReadS GetUserSettings
Prelude.Read, Int -> GetUserSettings -> ShowS
[GetUserSettings] -> ShowS
GetUserSettings -> String
(Int -> GetUserSettings -> ShowS)
-> (GetUserSettings -> String)
-> ([GetUserSettings] -> ShowS)
-> Show GetUserSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUserSettings] -> ShowS
$cshowList :: [GetUserSettings] -> ShowS
show :: GetUserSettings -> String
$cshow :: GetUserSettings -> String
showsPrec :: Int -> GetUserSettings -> ShowS
$cshowsPrec :: Int -> GetUserSettings -> ShowS
Prelude.Show, (forall x. GetUserSettings -> Rep GetUserSettings x)
-> (forall x. Rep GetUserSettings x -> GetUserSettings)
-> Generic GetUserSettings
forall x. Rep GetUserSettings x -> GetUserSettings
forall x. GetUserSettings -> Rep GetUserSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetUserSettings x -> GetUserSettings
$cfrom :: forall x. GetUserSettings -> Rep GetUserSettings x
Prelude.Generic)

-- |
-- Create a value of 'GetUserSettings' 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', 'getUserSettings_accountId' - The Amazon Chime account ID.
--
-- 'userId', 'getUserSettings_userId' - The user ID.
newGetUserSettings ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'userId'
  Prelude.Text ->
  GetUserSettings
newGetUserSettings :: Text -> Text -> GetUserSettings
newGetUserSettings Text
pAccountId_ Text
pUserId_ =
  GetUserSettings' :: Text -> Text -> GetUserSettings
GetUserSettings'
    { $sel:accountId:GetUserSettings' :: Text
accountId = Text
pAccountId_,
      $sel:userId:GetUserSettings' :: Text
userId = Text
pUserId_
    }

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

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

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

instance Prelude.NFData GetUserSettings

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

instance Core.ToPath GetUserSettings where
  toPath :: GetUserSettings -> ByteString
toPath GetUserSettings' {Text
userId :: Text
accountId :: Text
$sel:userId:GetUserSettings' :: GetUserSettings -> Text
$sel:accountId:GetUserSettings' :: GetUserSettings -> 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,
        ByteString
"/settings"
      ]

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

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

-- |
-- Create a value of 'GetUserSettingsResponse' 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:
--
-- 'userSettings', 'getUserSettingsResponse_userSettings' - The user settings.
--
-- 'httpStatus', 'getUserSettingsResponse_httpStatus' - The response's http status code.
newGetUserSettingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetUserSettingsResponse
newGetUserSettingsResponse :: Int -> GetUserSettingsResponse
newGetUserSettingsResponse Int
pHttpStatus_ =
  GetUserSettingsResponse' :: Maybe UserSettings -> Int -> GetUserSettingsResponse
GetUserSettingsResponse'
    { $sel:userSettings:GetUserSettingsResponse' :: Maybe UserSettings
userSettings =
        Maybe UserSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetUserSettingsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The user settings.
getUserSettingsResponse_userSettings :: Lens.Lens' GetUserSettingsResponse (Prelude.Maybe UserSettings)
getUserSettingsResponse_userSettings :: (Maybe UserSettings -> f (Maybe UserSettings))
-> GetUserSettingsResponse -> f GetUserSettingsResponse
getUserSettingsResponse_userSettings = (GetUserSettingsResponse -> Maybe UserSettings)
-> (GetUserSettingsResponse
    -> Maybe UserSettings -> GetUserSettingsResponse)
-> Lens
     GetUserSettingsResponse
     GetUserSettingsResponse
     (Maybe UserSettings)
     (Maybe UserSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUserSettingsResponse' {Maybe UserSettings
userSettings :: Maybe UserSettings
$sel:userSettings:GetUserSettingsResponse' :: GetUserSettingsResponse -> Maybe UserSettings
userSettings} -> Maybe UserSettings
userSettings) (\s :: GetUserSettingsResponse
s@GetUserSettingsResponse' {} Maybe UserSettings
a -> GetUserSettingsResponse
s {$sel:userSettings:GetUserSettingsResponse' :: Maybe UserSettings
userSettings = Maybe UserSettings
a} :: GetUserSettingsResponse)

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

instance Prelude.NFData GetUserSettingsResponse