{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.UserSettings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Chime.Types.UserSettings where

import Amazonka.Chime.Types.TelephonySettings
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

-- | Settings associated with an Amazon Chime user, including inbound and
-- outbound calling and text messaging.
--
-- /See:/ 'newUserSettings' smart constructor.
data UserSettings = UserSettings'
  { -- | The telephony settings associated with the user.
    UserSettings -> TelephonySettings
telephony :: TelephonySettings
  }
  deriving (UserSettings -> UserSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserSettings -> UserSettings -> Bool
$c/= :: UserSettings -> UserSettings -> Bool
== :: UserSettings -> UserSettings -> Bool
$c== :: UserSettings -> UserSettings -> Bool
Prelude.Eq, ReadPrec [UserSettings]
ReadPrec UserSettings
Int -> ReadS UserSettings
ReadS [UserSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserSettings]
$creadListPrec :: ReadPrec [UserSettings]
readPrec :: ReadPrec UserSettings
$creadPrec :: ReadPrec UserSettings
readList :: ReadS [UserSettings]
$creadList :: ReadS [UserSettings]
readsPrec :: Int -> ReadS UserSettings
$creadsPrec :: Int -> ReadS UserSettings
Prelude.Read, Int -> UserSettings -> ShowS
[UserSettings] -> ShowS
UserSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserSettings] -> ShowS
$cshowList :: [UserSettings] -> ShowS
show :: UserSettings -> String
$cshow :: UserSettings -> String
showsPrec :: Int -> UserSettings -> ShowS
$cshowsPrec :: Int -> UserSettings -> ShowS
Prelude.Show, forall x. Rep UserSettings x -> UserSettings
forall x. UserSettings -> Rep UserSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserSettings x -> UserSettings
$cfrom :: forall x. UserSettings -> Rep UserSettings x
Prelude.Generic)

-- |
-- Create a value of 'UserSettings' 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:
--
-- 'telephony', 'userSettings_telephony' - The telephony settings associated with the user.
newUserSettings ::
  -- | 'telephony'
  TelephonySettings ->
  UserSettings
newUserSettings :: TelephonySettings -> UserSettings
newUserSettings TelephonySettings
pTelephony_ =
  UserSettings' {$sel:telephony:UserSettings' :: TelephonySettings
telephony = TelephonySettings
pTelephony_}

-- | The telephony settings associated with the user.
userSettings_telephony :: Lens.Lens' UserSettings TelephonySettings
userSettings_telephony :: Lens' UserSettings TelephonySettings
userSettings_telephony = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserSettings' {TelephonySettings
telephony :: TelephonySettings
$sel:telephony:UserSettings' :: UserSettings -> TelephonySettings
telephony} -> TelephonySettings
telephony) (\s :: UserSettings
s@UserSettings' {} TelephonySettings
a -> UserSettings
s {$sel:telephony:UserSettings' :: TelephonySettings
telephony = TelephonySettings
a} :: UserSettings)

instance Data.FromJSON UserSettings where
  parseJSON :: Value -> Parser UserSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UserSettings"
      ( \Object
x ->
          TelephonySettings -> UserSettings
UserSettings' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Telephony")
      )

instance Prelude.Hashable UserSettings where
  hashWithSalt :: Int -> UserSettings -> Int
hashWithSalt Int
_salt UserSettings' {TelephonySettings
telephony :: TelephonySettings
$sel:telephony:UserSettings' :: UserSettings -> TelephonySettings
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TelephonySettings
telephony

instance Prelude.NFData UserSettings where
  rnf :: UserSettings -> ()
rnf UserSettings' {TelephonySettings
telephony :: TelephonySettings
$sel:telephony:UserSettings' :: UserSettings -> TelephonySettings
..} = forall a. NFData a => a -> ()
Prelude.rnf TelephonySettings
telephony

instance Data.ToJSON UserSettings where
  toJSON :: UserSettings -> Value
toJSON UserSettings' {TelephonySettings
telephony :: TelephonySettings
$sel:telephony:UserSettings' :: UserSettings -> TelephonySettings
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Telephony" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TelephonySettings
telephony)]
      )