{-# 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.QuickConnectConfig
-- 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.QuickConnectConfig where

import Amazonka.Connect.Types.PhoneNumberQuickConnectConfig
import Amazonka.Connect.Types.QueueQuickConnectConfig
import Amazonka.Connect.Types.QuickConnectType
import Amazonka.Connect.Types.UserQuickConnectConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains configuration settings for a quick connect.
--
-- /See:/ 'newQuickConnectConfig' smart constructor.
data QuickConnectConfig = QuickConnectConfig'
  { -- | The queue configuration. This is required only if QuickConnectType is
    -- QUEUE.
    QuickConnectConfig -> Maybe QueueQuickConnectConfig
queueConfig :: Prelude.Maybe QueueQuickConnectConfig,
    -- | The user configuration. This is required only if QuickConnectType is
    -- USER.
    QuickConnectConfig -> Maybe UserQuickConnectConfig
userConfig :: Prelude.Maybe UserQuickConnectConfig,
    -- | The phone configuration. This is required only if QuickConnectType is
    -- PHONE_NUMBER.
    QuickConnectConfig -> Maybe PhoneNumberQuickConnectConfig
phoneConfig :: Prelude.Maybe PhoneNumberQuickConnectConfig,
    -- | The type of quick connect. In the Amazon Connect console, when you
    -- create a quick connect, you are prompted to assign one of the following
    -- types: Agent (USER), External (PHONE_NUMBER), or Queue (QUEUE).
    QuickConnectConfig -> QuickConnectType
quickConnectType :: QuickConnectType
  }
  deriving (QuickConnectConfig -> QuickConnectConfig -> Bool
(QuickConnectConfig -> QuickConnectConfig -> Bool)
-> (QuickConnectConfig -> QuickConnectConfig -> Bool)
-> Eq QuickConnectConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QuickConnectConfig -> QuickConnectConfig -> Bool
$c/= :: QuickConnectConfig -> QuickConnectConfig -> Bool
== :: QuickConnectConfig -> QuickConnectConfig -> Bool
$c== :: QuickConnectConfig -> QuickConnectConfig -> Bool
Prelude.Eq, ReadPrec [QuickConnectConfig]
ReadPrec QuickConnectConfig
Int -> ReadS QuickConnectConfig
ReadS [QuickConnectConfig]
(Int -> ReadS QuickConnectConfig)
-> ReadS [QuickConnectConfig]
-> ReadPrec QuickConnectConfig
-> ReadPrec [QuickConnectConfig]
-> Read QuickConnectConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QuickConnectConfig]
$creadListPrec :: ReadPrec [QuickConnectConfig]
readPrec :: ReadPrec QuickConnectConfig
$creadPrec :: ReadPrec QuickConnectConfig
readList :: ReadS [QuickConnectConfig]
$creadList :: ReadS [QuickConnectConfig]
readsPrec :: Int -> ReadS QuickConnectConfig
$creadsPrec :: Int -> ReadS QuickConnectConfig
Prelude.Read, Int -> QuickConnectConfig -> ShowS
[QuickConnectConfig] -> ShowS
QuickConnectConfig -> String
(Int -> QuickConnectConfig -> ShowS)
-> (QuickConnectConfig -> String)
-> ([QuickConnectConfig] -> ShowS)
-> Show QuickConnectConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QuickConnectConfig] -> ShowS
$cshowList :: [QuickConnectConfig] -> ShowS
show :: QuickConnectConfig -> String
$cshow :: QuickConnectConfig -> String
showsPrec :: Int -> QuickConnectConfig -> ShowS
$cshowsPrec :: Int -> QuickConnectConfig -> ShowS
Prelude.Show, (forall x. QuickConnectConfig -> Rep QuickConnectConfig x)
-> (forall x. Rep QuickConnectConfig x -> QuickConnectConfig)
-> Generic QuickConnectConfig
forall x. Rep QuickConnectConfig x -> QuickConnectConfig
forall x. QuickConnectConfig -> Rep QuickConnectConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QuickConnectConfig x -> QuickConnectConfig
$cfrom :: forall x. QuickConnectConfig -> Rep QuickConnectConfig x
Prelude.Generic)

-- |
-- Create a value of 'QuickConnectConfig' 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:
--
-- 'queueConfig', 'quickConnectConfig_queueConfig' - The queue configuration. This is required only if QuickConnectType is
-- QUEUE.
--
-- 'userConfig', 'quickConnectConfig_userConfig' - The user configuration. This is required only if QuickConnectType is
-- USER.
--
-- 'phoneConfig', 'quickConnectConfig_phoneConfig' - The phone configuration. This is required only if QuickConnectType is
-- PHONE_NUMBER.
--
-- 'quickConnectType', 'quickConnectConfig_quickConnectType' - The type of quick connect. In the Amazon Connect console, when you
-- create a quick connect, you are prompted to assign one of the following
-- types: Agent (USER), External (PHONE_NUMBER), or Queue (QUEUE).
newQuickConnectConfig ::
  -- | 'quickConnectType'
  QuickConnectType ->
  QuickConnectConfig
newQuickConnectConfig :: QuickConnectType -> QuickConnectConfig
newQuickConnectConfig QuickConnectType
pQuickConnectType_ =
  QuickConnectConfig' :: Maybe QueueQuickConnectConfig
-> Maybe UserQuickConnectConfig
-> Maybe PhoneNumberQuickConnectConfig
-> QuickConnectType
-> QuickConnectConfig
QuickConnectConfig'
    { $sel:queueConfig:QuickConnectConfig' :: Maybe QueueQuickConnectConfig
queueConfig = Maybe QueueQuickConnectConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:userConfig:QuickConnectConfig' :: Maybe UserQuickConnectConfig
userConfig = Maybe UserQuickConnectConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:phoneConfig:QuickConnectConfig' :: Maybe PhoneNumberQuickConnectConfig
phoneConfig = Maybe PhoneNumberQuickConnectConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:quickConnectType:QuickConnectConfig' :: QuickConnectType
quickConnectType = QuickConnectType
pQuickConnectType_
    }

-- | The queue configuration. This is required only if QuickConnectType is
-- QUEUE.
quickConnectConfig_queueConfig :: Lens.Lens' QuickConnectConfig (Prelude.Maybe QueueQuickConnectConfig)
quickConnectConfig_queueConfig :: (Maybe QueueQuickConnectConfig
 -> f (Maybe QueueQuickConnectConfig))
-> QuickConnectConfig -> f QuickConnectConfig
quickConnectConfig_queueConfig = (QuickConnectConfig -> Maybe QueueQuickConnectConfig)
-> (QuickConnectConfig
    -> Maybe QueueQuickConnectConfig -> QuickConnectConfig)
-> Lens
     QuickConnectConfig
     QuickConnectConfig
     (Maybe QueueQuickConnectConfig)
     (Maybe QueueQuickConnectConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QuickConnectConfig' {Maybe QueueQuickConnectConfig
queueConfig :: Maybe QueueQuickConnectConfig
$sel:queueConfig:QuickConnectConfig' :: QuickConnectConfig -> Maybe QueueQuickConnectConfig
queueConfig} -> Maybe QueueQuickConnectConfig
queueConfig) (\s :: QuickConnectConfig
s@QuickConnectConfig' {} Maybe QueueQuickConnectConfig
a -> QuickConnectConfig
s {$sel:queueConfig:QuickConnectConfig' :: Maybe QueueQuickConnectConfig
queueConfig = Maybe QueueQuickConnectConfig
a} :: QuickConnectConfig)

-- | The user configuration. This is required only if QuickConnectType is
-- USER.
quickConnectConfig_userConfig :: Lens.Lens' QuickConnectConfig (Prelude.Maybe UserQuickConnectConfig)
quickConnectConfig_userConfig :: (Maybe UserQuickConnectConfig -> f (Maybe UserQuickConnectConfig))
-> QuickConnectConfig -> f QuickConnectConfig
quickConnectConfig_userConfig = (QuickConnectConfig -> Maybe UserQuickConnectConfig)
-> (QuickConnectConfig
    -> Maybe UserQuickConnectConfig -> QuickConnectConfig)
-> Lens
     QuickConnectConfig
     QuickConnectConfig
     (Maybe UserQuickConnectConfig)
     (Maybe UserQuickConnectConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QuickConnectConfig' {Maybe UserQuickConnectConfig
userConfig :: Maybe UserQuickConnectConfig
$sel:userConfig:QuickConnectConfig' :: QuickConnectConfig -> Maybe UserQuickConnectConfig
userConfig} -> Maybe UserQuickConnectConfig
userConfig) (\s :: QuickConnectConfig
s@QuickConnectConfig' {} Maybe UserQuickConnectConfig
a -> QuickConnectConfig
s {$sel:userConfig:QuickConnectConfig' :: Maybe UserQuickConnectConfig
userConfig = Maybe UserQuickConnectConfig
a} :: QuickConnectConfig)

-- | The phone configuration. This is required only if QuickConnectType is
-- PHONE_NUMBER.
quickConnectConfig_phoneConfig :: Lens.Lens' QuickConnectConfig (Prelude.Maybe PhoneNumberQuickConnectConfig)
quickConnectConfig_phoneConfig :: (Maybe PhoneNumberQuickConnectConfig
 -> f (Maybe PhoneNumberQuickConnectConfig))
-> QuickConnectConfig -> f QuickConnectConfig
quickConnectConfig_phoneConfig = (QuickConnectConfig -> Maybe PhoneNumberQuickConnectConfig)
-> (QuickConnectConfig
    -> Maybe PhoneNumberQuickConnectConfig -> QuickConnectConfig)
-> Lens
     QuickConnectConfig
     QuickConnectConfig
     (Maybe PhoneNumberQuickConnectConfig)
     (Maybe PhoneNumberQuickConnectConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QuickConnectConfig' {Maybe PhoneNumberQuickConnectConfig
phoneConfig :: Maybe PhoneNumberQuickConnectConfig
$sel:phoneConfig:QuickConnectConfig' :: QuickConnectConfig -> Maybe PhoneNumberQuickConnectConfig
phoneConfig} -> Maybe PhoneNumberQuickConnectConfig
phoneConfig) (\s :: QuickConnectConfig
s@QuickConnectConfig' {} Maybe PhoneNumberQuickConnectConfig
a -> QuickConnectConfig
s {$sel:phoneConfig:QuickConnectConfig' :: Maybe PhoneNumberQuickConnectConfig
phoneConfig = Maybe PhoneNumberQuickConnectConfig
a} :: QuickConnectConfig)

-- | The type of quick connect. In the Amazon Connect console, when you
-- create a quick connect, you are prompted to assign one of the following
-- types: Agent (USER), External (PHONE_NUMBER), or Queue (QUEUE).
quickConnectConfig_quickConnectType :: Lens.Lens' QuickConnectConfig QuickConnectType
quickConnectConfig_quickConnectType :: (QuickConnectType -> f QuickConnectType)
-> QuickConnectConfig -> f QuickConnectConfig
quickConnectConfig_quickConnectType = (QuickConnectConfig -> QuickConnectType)
-> (QuickConnectConfig -> QuickConnectType -> QuickConnectConfig)
-> Lens
     QuickConnectConfig
     QuickConnectConfig
     QuickConnectType
     QuickConnectType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QuickConnectConfig' {QuickConnectType
quickConnectType :: QuickConnectType
$sel:quickConnectType:QuickConnectConfig' :: QuickConnectConfig -> QuickConnectType
quickConnectType} -> QuickConnectType
quickConnectType) (\s :: QuickConnectConfig
s@QuickConnectConfig' {} QuickConnectType
a -> QuickConnectConfig
s {$sel:quickConnectType:QuickConnectConfig' :: QuickConnectType
quickConnectType = QuickConnectType
a} :: QuickConnectConfig)

instance Core.FromJSON QuickConnectConfig where
  parseJSON :: Value -> Parser QuickConnectConfig
parseJSON =
    String
-> (Object -> Parser QuickConnectConfig)
-> Value
-> Parser QuickConnectConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"QuickConnectConfig"
      ( \Object
x ->
          Maybe QueueQuickConnectConfig
-> Maybe UserQuickConnectConfig
-> Maybe PhoneNumberQuickConnectConfig
-> QuickConnectType
-> QuickConnectConfig
QuickConnectConfig'
            (Maybe QueueQuickConnectConfig
 -> Maybe UserQuickConnectConfig
 -> Maybe PhoneNumberQuickConnectConfig
 -> QuickConnectType
 -> QuickConnectConfig)
-> Parser (Maybe QueueQuickConnectConfig)
-> Parser
     (Maybe UserQuickConnectConfig
      -> Maybe PhoneNumberQuickConnectConfig
      -> QuickConnectType
      -> QuickConnectConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe QueueQuickConnectConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"QueueConfig")
            Parser
  (Maybe UserQuickConnectConfig
   -> Maybe PhoneNumberQuickConnectConfig
   -> QuickConnectType
   -> QuickConnectConfig)
-> Parser (Maybe UserQuickConnectConfig)
-> Parser
     (Maybe PhoneNumberQuickConnectConfig
      -> QuickConnectType -> QuickConnectConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe UserQuickConnectConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UserConfig")
            Parser
  (Maybe PhoneNumberQuickConnectConfig
   -> QuickConnectType -> QuickConnectConfig)
-> Parser (Maybe PhoneNumberQuickConnectConfig)
-> Parser (QuickConnectType -> QuickConnectConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe PhoneNumberQuickConnectConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PhoneConfig")
            Parser (QuickConnectType -> QuickConnectConfig)
-> Parser QuickConnectType -> Parser QuickConnectConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser QuickConnectType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"QuickConnectType")
      )

instance Prelude.Hashable QuickConnectConfig

instance Prelude.NFData QuickConnectConfig

instance Core.ToJSON QuickConnectConfig where
  toJSON :: QuickConnectConfig -> Value
toJSON QuickConnectConfig' {Maybe PhoneNumberQuickConnectConfig
Maybe QueueQuickConnectConfig
Maybe UserQuickConnectConfig
QuickConnectType
quickConnectType :: QuickConnectType
phoneConfig :: Maybe PhoneNumberQuickConnectConfig
userConfig :: Maybe UserQuickConnectConfig
queueConfig :: Maybe QueueQuickConnectConfig
$sel:quickConnectType:QuickConnectConfig' :: QuickConnectConfig -> QuickConnectType
$sel:phoneConfig:QuickConnectConfig' :: QuickConnectConfig -> Maybe PhoneNumberQuickConnectConfig
$sel:userConfig:QuickConnectConfig' :: QuickConnectConfig -> Maybe UserQuickConnectConfig
$sel:queueConfig:QuickConnectConfig' :: QuickConnectConfig -> Maybe QueueQuickConnectConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"QueueConfig" Text -> QueueQuickConnectConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (QueueQuickConnectConfig -> Pair)
-> Maybe QueueQuickConnectConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe QueueQuickConnectConfig
queueConfig,
            (Text
"UserConfig" Text -> UserQuickConnectConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (UserQuickConnectConfig -> Pair)
-> Maybe UserQuickConnectConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UserQuickConnectConfig
userConfig,
            (Text
"PhoneConfig" Text -> PhoneNumberQuickConnectConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (PhoneNumberQuickConnectConfig -> Pair)
-> Maybe PhoneNumberQuickConnectConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PhoneNumberQuickConnectConfig
phoneConfig,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"QuickConnectType" Text -> QuickConnectType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= QuickConnectType
quickConnectType)
          ]
      )