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

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

-- | A link that an agent selects to complete a given task. You can have up
-- to 4,096 UTF-8 bytes across all references for a contact.
--
-- /See:/ 'newReference' smart constructor.
data Reference = Reference'
  { -- | A formatted URL that displays to an agent in the Contact Control Panel
    -- (CCP)
    Reference -> Text
value :: Prelude.Text,
    -- | A valid URL.
    Reference -> ReferenceType
type' :: ReferenceType
  }
  deriving (Reference -> Reference -> Bool
(Reference -> Reference -> Bool)
-> (Reference -> Reference -> Bool) -> Eq Reference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Reference -> Reference -> Bool
$c/= :: Reference -> Reference -> Bool
== :: Reference -> Reference -> Bool
$c== :: Reference -> Reference -> Bool
Prelude.Eq, ReadPrec [Reference]
ReadPrec Reference
Int -> ReadS Reference
ReadS [Reference]
(Int -> ReadS Reference)
-> ReadS [Reference]
-> ReadPrec Reference
-> ReadPrec [Reference]
-> Read Reference
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Reference]
$creadListPrec :: ReadPrec [Reference]
readPrec :: ReadPrec Reference
$creadPrec :: ReadPrec Reference
readList :: ReadS [Reference]
$creadList :: ReadS [Reference]
readsPrec :: Int -> ReadS Reference
$creadsPrec :: Int -> ReadS Reference
Prelude.Read, Int -> Reference -> ShowS
[Reference] -> ShowS
Reference -> String
(Int -> Reference -> ShowS)
-> (Reference -> String)
-> ([Reference] -> ShowS)
-> Show Reference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Reference] -> ShowS
$cshowList :: [Reference] -> ShowS
show :: Reference -> String
$cshow :: Reference -> String
showsPrec :: Int -> Reference -> ShowS
$cshowsPrec :: Int -> Reference -> ShowS
Prelude.Show, (forall x. Reference -> Rep Reference x)
-> (forall x. Rep Reference x -> Reference) -> Generic Reference
forall x. Rep Reference x -> Reference
forall x. Reference -> Rep Reference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Reference x -> Reference
$cfrom :: forall x. Reference -> Rep Reference x
Prelude.Generic)

-- |
-- Create a value of 'Reference' 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:
--
-- 'value', 'reference_value' - A formatted URL that displays to an agent in the Contact Control Panel
-- (CCP)
--
-- 'type'', 'reference_type' - A valid URL.
newReference ::
  -- | 'value'
  Prelude.Text ->
  -- | 'type''
  ReferenceType ->
  Reference
newReference :: Text -> ReferenceType -> Reference
newReference Text
pValue_ ReferenceType
pType_ =
  Reference' :: Text -> ReferenceType -> Reference
Reference' {$sel:value:Reference' :: Text
value = Text
pValue_, $sel:type':Reference' :: ReferenceType
type' = ReferenceType
pType_}

-- | A formatted URL that displays to an agent in the Contact Control Panel
-- (CCP)
reference_value :: Lens.Lens' Reference Prelude.Text
reference_value :: (Text -> f Text) -> Reference -> f Reference
reference_value = (Reference -> Text)
-> (Reference -> Text -> Reference)
-> Lens Reference Reference Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Reference' {Text
value :: Text
$sel:value:Reference' :: Reference -> Text
value} -> Text
value) (\s :: Reference
s@Reference' {} Text
a -> Reference
s {$sel:value:Reference' :: Text
value = Text
a} :: Reference)

-- | A valid URL.
reference_type :: Lens.Lens' Reference ReferenceType
reference_type :: (ReferenceType -> f ReferenceType) -> Reference -> f Reference
reference_type = (Reference -> ReferenceType)
-> (Reference -> ReferenceType -> Reference)
-> Lens Reference Reference ReferenceType ReferenceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Reference' {ReferenceType
type' :: ReferenceType
$sel:type':Reference' :: Reference -> ReferenceType
type'} -> ReferenceType
type') (\s :: Reference
s@Reference' {} ReferenceType
a -> Reference
s {$sel:type':Reference' :: ReferenceType
type' = ReferenceType
a} :: Reference)

instance Prelude.Hashable Reference

instance Prelude.NFData Reference

instance Core.ToJSON Reference where
  toJSON :: Reference -> Value
toJSON Reference' {Text
ReferenceType
type' :: ReferenceType
value :: Text
$sel:type':Reference' :: Reference -> ReferenceType
$sel:value:Reference' :: Reference -> 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
"Value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
value),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> ReferenceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ReferenceType
type')
          ]
      )