{-# 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.Connect.Types.UserPhoneConfig
-- 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)
module Amazonka.Connect.Types.UserPhoneConfig where

import Amazonka.Connect.Types.PhoneType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the phone configuration settings for a user.
--
-- /See:/ 'newUserPhoneConfig' smart constructor.
data UserPhoneConfig = UserPhoneConfig'
  { -- | The Auto accept setting.
    UserPhoneConfig -> Maybe Bool
autoAccept :: Prelude.Maybe Prelude.Bool,
    -- | The After Call Work (ACW) timeout setting, in seconds.
    UserPhoneConfig -> Maybe Natural
afterContactWorkTimeLimit :: Prelude.Maybe Prelude.Natural,
    -- | The phone number for the user\'s desk phone.
    UserPhoneConfig -> Maybe Text
deskPhoneNumber :: Prelude.Maybe Prelude.Text,
    -- | The phone type.
    UserPhoneConfig -> PhoneType
phoneType :: PhoneType
  }
  deriving (UserPhoneConfig -> UserPhoneConfig -> Bool
(UserPhoneConfig -> UserPhoneConfig -> Bool)
-> (UserPhoneConfig -> UserPhoneConfig -> Bool)
-> Eq UserPhoneConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserPhoneConfig -> UserPhoneConfig -> Bool
$c/= :: UserPhoneConfig -> UserPhoneConfig -> Bool
== :: UserPhoneConfig -> UserPhoneConfig -> Bool
$c== :: UserPhoneConfig -> UserPhoneConfig -> Bool
Prelude.Eq, ReadPrec [UserPhoneConfig]
ReadPrec UserPhoneConfig
Int -> ReadS UserPhoneConfig
ReadS [UserPhoneConfig]
(Int -> ReadS UserPhoneConfig)
-> ReadS [UserPhoneConfig]
-> ReadPrec UserPhoneConfig
-> ReadPrec [UserPhoneConfig]
-> Read UserPhoneConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserPhoneConfig]
$creadListPrec :: ReadPrec [UserPhoneConfig]
readPrec :: ReadPrec UserPhoneConfig
$creadPrec :: ReadPrec UserPhoneConfig
readList :: ReadS [UserPhoneConfig]
$creadList :: ReadS [UserPhoneConfig]
readsPrec :: Int -> ReadS UserPhoneConfig
$creadsPrec :: Int -> ReadS UserPhoneConfig
Prelude.Read, Int -> UserPhoneConfig -> ShowS
[UserPhoneConfig] -> ShowS
UserPhoneConfig -> String
(Int -> UserPhoneConfig -> ShowS)
-> (UserPhoneConfig -> String)
-> ([UserPhoneConfig] -> ShowS)
-> Show UserPhoneConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserPhoneConfig] -> ShowS
$cshowList :: [UserPhoneConfig] -> ShowS
show :: UserPhoneConfig -> String
$cshow :: UserPhoneConfig -> String
showsPrec :: Int -> UserPhoneConfig -> ShowS
$cshowsPrec :: Int -> UserPhoneConfig -> ShowS
Prelude.Show, (forall x. UserPhoneConfig -> Rep UserPhoneConfig x)
-> (forall x. Rep UserPhoneConfig x -> UserPhoneConfig)
-> Generic UserPhoneConfig
forall x. Rep UserPhoneConfig x -> UserPhoneConfig
forall x. UserPhoneConfig -> Rep UserPhoneConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserPhoneConfig x -> UserPhoneConfig
$cfrom :: forall x. UserPhoneConfig -> Rep UserPhoneConfig x
Prelude.Generic)

-- |
-- Create a value of 'UserPhoneConfig' 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:
--
-- 'autoAccept', 'userPhoneConfig_autoAccept' - The Auto accept setting.
--
-- 'afterContactWorkTimeLimit', 'userPhoneConfig_afterContactWorkTimeLimit' - The After Call Work (ACW) timeout setting, in seconds.
--
-- 'deskPhoneNumber', 'userPhoneConfig_deskPhoneNumber' - The phone number for the user\'s desk phone.
--
-- 'phoneType', 'userPhoneConfig_phoneType' - The phone type.
newUserPhoneConfig ::
  -- | 'phoneType'
  PhoneType ->
  UserPhoneConfig
newUserPhoneConfig :: PhoneType -> UserPhoneConfig
newUserPhoneConfig PhoneType
pPhoneType_ =
  UserPhoneConfig' :: Maybe Bool
-> Maybe Natural -> Maybe Text -> PhoneType -> UserPhoneConfig
UserPhoneConfig'
    { $sel:autoAccept:UserPhoneConfig' :: Maybe Bool
autoAccept = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:afterContactWorkTimeLimit:UserPhoneConfig' :: Maybe Natural
afterContactWorkTimeLimit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:deskPhoneNumber:UserPhoneConfig' :: Maybe Text
deskPhoneNumber = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:phoneType:UserPhoneConfig' :: PhoneType
phoneType = PhoneType
pPhoneType_
    }

-- | The Auto accept setting.
userPhoneConfig_autoAccept :: Lens.Lens' UserPhoneConfig (Prelude.Maybe Prelude.Bool)
userPhoneConfig_autoAccept :: (Maybe Bool -> f (Maybe Bool))
-> UserPhoneConfig -> f UserPhoneConfig
userPhoneConfig_autoAccept = (UserPhoneConfig -> Maybe Bool)
-> (UserPhoneConfig -> Maybe Bool -> UserPhoneConfig)
-> Lens UserPhoneConfig UserPhoneConfig (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserPhoneConfig' {Maybe Bool
autoAccept :: Maybe Bool
$sel:autoAccept:UserPhoneConfig' :: UserPhoneConfig -> Maybe Bool
autoAccept} -> Maybe Bool
autoAccept) (\s :: UserPhoneConfig
s@UserPhoneConfig' {} Maybe Bool
a -> UserPhoneConfig
s {$sel:autoAccept:UserPhoneConfig' :: Maybe Bool
autoAccept = Maybe Bool
a} :: UserPhoneConfig)

-- | The After Call Work (ACW) timeout setting, in seconds.
userPhoneConfig_afterContactWorkTimeLimit :: Lens.Lens' UserPhoneConfig (Prelude.Maybe Prelude.Natural)
userPhoneConfig_afterContactWorkTimeLimit :: (Maybe Natural -> f (Maybe Natural))
-> UserPhoneConfig -> f UserPhoneConfig
userPhoneConfig_afterContactWorkTimeLimit = (UserPhoneConfig -> Maybe Natural)
-> (UserPhoneConfig -> Maybe Natural -> UserPhoneConfig)
-> Lens
     UserPhoneConfig UserPhoneConfig (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserPhoneConfig' {Maybe Natural
afterContactWorkTimeLimit :: Maybe Natural
$sel:afterContactWorkTimeLimit:UserPhoneConfig' :: UserPhoneConfig -> Maybe Natural
afterContactWorkTimeLimit} -> Maybe Natural
afterContactWorkTimeLimit) (\s :: UserPhoneConfig
s@UserPhoneConfig' {} Maybe Natural
a -> UserPhoneConfig
s {$sel:afterContactWorkTimeLimit:UserPhoneConfig' :: Maybe Natural
afterContactWorkTimeLimit = Maybe Natural
a} :: UserPhoneConfig)

-- | The phone number for the user\'s desk phone.
userPhoneConfig_deskPhoneNumber :: Lens.Lens' UserPhoneConfig (Prelude.Maybe Prelude.Text)
userPhoneConfig_deskPhoneNumber :: (Maybe Text -> f (Maybe Text))
-> UserPhoneConfig -> f UserPhoneConfig
userPhoneConfig_deskPhoneNumber = (UserPhoneConfig -> Maybe Text)
-> (UserPhoneConfig -> Maybe Text -> UserPhoneConfig)
-> Lens UserPhoneConfig UserPhoneConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserPhoneConfig' {Maybe Text
deskPhoneNumber :: Maybe Text
$sel:deskPhoneNumber:UserPhoneConfig' :: UserPhoneConfig -> Maybe Text
deskPhoneNumber} -> Maybe Text
deskPhoneNumber) (\s :: UserPhoneConfig
s@UserPhoneConfig' {} Maybe Text
a -> UserPhoneConfig
s {$sel:deskPhoneNumber:UserPhoneConfig' :: Maybe Text
deskPhoneNumber = Maybe Text
a} :: UserPhoneConfig)

-- | The phone type.
userPhoneConfig_phoneType :: Lens.Lens' UserPhoneConfig PhoneType
userPhoneConfig_phoneType :: (PhoneType -> f PhoneType) -> UserPhoneConfig -> f UserPhoneConfig
userPhoneConfig_phoneType = (UserPhoneConfig -> PhoneType)
-> (UserPhoneConfig -> PhoneType -> UserPhoneConfig)
-> Lens UserPhoneConfig UserPhoneConfig PhoneType PhoneType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserPhoneConfig' {PhoneType
phoneType :: PhoneType
$sel:phoneType:UserPhoneConfig' :: UserPhoneConfig -> PhoneType
phoneType} -> PhoneType
phoneType) (\s :: UserPhoneConfig
s@UserPhoneConfig' {} PhoneType
a -> UserPhoneConfig
s {$sel:phoneType:UserPhoneConfig' :: PhoneType
phoneType = PhoneType
a} :: UserPhoneConfig)

instance Core.FromJSON UserPhoneConfig where
  parseJSON :: Value -> Parser UserPhoneConfig
parseJSON =
    String
-> (Object -> Parser UserPhoneConfig)
-> Value
-> Parser UserPhoneConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UserPhoneConfig"
      ( \Object
x ->
          Maybe Bool
-> Maybe Natural -> Maybe Text -> PhoneType -> UserPhoneConfig
UserPhoneConfig'
            (Maybe Bool
 -> Maybe Natural -> Maybe Text -> PhoneType -> UserPhoneConfig)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Natural -> Maybe Text -> PhoneType -> UserPhoneConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AutoAccept")
            Parser
  (Maybe Natural -> Maybe Text -> PhoneType -> UserPhoneConfig)
-> Parser (Maybe Natural)
-> Parser (Maybe Text -> PhoneType -> UserPhoneConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AfterContactWorkTimeLimit")
            Parser (Maybe Text -> PhoneType -> UserPhoneConfig)
-> Parser (Maybe Text) -> Parser (PhoneType -> UserPhoneConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeskPhoneNumber")
            Parser (PhoneType -> UserPhoneConfig)
-> Parser PhoneType -> Parser UserPhoneConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PhoneType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"PhoneType")
      )

instance Prelude.Hashable UserPhoneConfig

instance Prelude.NFData UserPhoneConfig

instance Core.ToJSON UserPhoneConfig where
  toJSON :: UserPhoneConfig -> Value
toJSON UserPhoneConfig' {Maybe Bool
Maybe Natural
Maybe Text
PhoneType
phoneType :: PhoneType
deskPhoneNumber :: Maybe Text
afterContactWorkTimeLimit :: Maybe Natural
autoAccept :: Maybe Bool
$sel:phoneType:UserPhoneConfig' :: UserPhoneConfig -> PhoneType
$sel:deskPhoneNumber:UserPhoneConfig' :: UserPhoneConfig -> Maybe Text
$sel:afterContactWorkTimeLimit:UserPhoneConfig' :: UserPhoneConfig -> Maybe Natural
$sel:autoAccept:UserPhoneConfig' :: UserPhoneConfig -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AutoAccept" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
autoAccept,
            (Text
"AfterContactWorkTimeLimit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
afterContactWorkTimeLimit,
            (Text
"DeskPhoneNumber" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
deskPhoneNumber,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PhoneType" Text -> PhoneType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PhoneType
phoneType)
          ]
      )