{-# 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.ReferenceSummary
-- 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.Connect.Types.ReferenceSummary where

import Amazonka.Connect.Types.AttachmentReference
import Amazonka.Connect.Types.DateReference
import Amazonka.Connect.Types.EmailReference
import Amazonka.Connect.Types.NumberReference
import Amazonka.Connect.Types.StringReference
import Amazonka.Connect.Types.UrlReference
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

-- | Contains summary information about a reference. @ReferenceSummary@
-- contains only one non null field between the URL and attachment based on
-- the reference type.
--
-- /See:/ 'newReferenceSummary' smart constructor.
data ReferenceSummary = ReferenceSummary'
  { -- | Information about the reference when the @referenceType@ is
    -- @ATTACHMENT@. Otherwise, null.
    ReferenceSummary -> Maybe AttachmentReference
attachment :: Prelude.Maybe AttachmentReference,
    -- | Information about a reference when the @referenceType@ is @DATE@.
    -- Otherwise, null.
    ReferenceSummary -> Maybe DateReference
date :: Prelude.Maybe DateReference,
    -- | Information about a reference when the @referenceType@ is @EMAIL@.
    -- Otherwise, null.
    ReferenceSummary -> Maybe EmailReference
email :: Prelude.Maybe EmailReference,
    -- | Information about a reference when the @referenceType@ is @NUMBER@.
    -- Otherwise, null.
    ReferenceSummary -> Maybe NumberReference
number :: Prelude.Maybe NumberReference,
    -- | Information about a reference when the @referenceType@ is @STRING@.
    -- Otherwise, null.
    ReferenceSummary -> Maybe StringReference
string :: Prelude.Maybe StringReference,
    -- | Information about the reference when the @referenceType@ is @URL@.
    -- Otherwise, null.
    ReferenceSummary -> Maybe UrlReference
url :: Prelude.Maybe UrlReference
  }
  deriving (ReferenceSummary -> ReferenceSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReferenceSummary -> ReferenceSummary -> Bool
$c/= :: ReferenceSummary -> ReferenceSummary -> Bool
== :: ReferenceSummary -> ReferenceSummary -> Bool
$c== :: ReferenceSummary -> ReferenceSummary -> Bool
Prelude.Eq, ReadPrec [ReferenceSummary]
ReadPrec ReferenceSummary
Int -> ReadS ReferenceSummary
ReadS [ReferenceSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReferenceSummary]
$creadListPrec :: ReadPrec [ReferenceSummary]
readPrec :: ReadPrec ReferenceSummary
$creadPrec :: ReadPrec ReferenceSummary
readList :: ReadS [ReferenceSummary]
$creadList :: ReadS [ReferenceSummary]
readsPrec :: Int -> ReadS ReferenceSummary
$creadsPrec :: Int -> ReadS ReferenceSummary
Prelude.Read, Int -> ReferenceSummary -> ShowS
[ReferenceSummary] -> ShowS
ReferenceSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReferenceSummary] -> ShowS
$cshowList :: [ReferenceSummary] -> ShowS
show :: ReferenceSummary -> String
$cshow :: ReferenceSummary -> String
showsPrec :: Int -> ReferenceSummary -> ShowS
$cshowsPrec :: Int -> ReferenceSummary -> ShowS
Prelude.Show, forall x. Rep ReferenceSummary x -> ReferenceSummary
forall x. ReferenceSummary -> Rep ReferenceSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReferenceSummary x -> ReferenceSummary
$cfrom :: forall x. ReferenceSummary -> Rep ReferenceSummary x
Prelude.Generic)

-- |
-- Create a value of 'ReferenceSummary' 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:
--
-- 'attachment', 'referenceSummary_attachment' - Information about the reference when the @referenceType@ is
-- @ATTACHMENT@. Otherwise, null.
--
-- 'date', 'referenceSummary_date' - Information about a reference when the @referenceType@ is @DATE@.
-- Otherwise, null.
--
-- 'email', 'referenceSummary_email' - Information about a reference when the @referenceType@ is @EMAIL@.
-- Otherwise, null.
--
-- 'number', 'referenceSummary_number' - Information about a reference when the @referenceType@ is @NUMBER@.
-- Otherwise, null.
--
-- 'string', 'referenceSummary_string' - Information about a reference when the @referenceType@ is @STRING@.
-- Otherwise, null.
--
-- 'url', 'referenceSummary_url' - Information about the reference when the @referenceType@ is @URL@.
-- Otherwise, null.
newReferenceSummary ::
  ReferenceSummary
newReferenceSummary :: ReferenceSummary
newReferenceSummary =
  ReferenceSummary'
    { $sel:attachment:ReferenceSummary' :: Maybe AttachmentReference
attachment = forall a. Maybe a
Prelude.Nothing,
      $sel:date:ReferenceSummary' :: Maybe DateReference
date = forall a. Maybe a
Prelude.Nothing,
      $sel:email:ReferenceSummary' :: Maybe EmailReference
email = forall a. Maybe a
Prelude.Nothing,
      $sel:number:ReferenceSummary' :: Maybe NumberReference
number = forall a. Maybe a
Prelude.Nothing,
      $sel:string:ReferenceSummary' :: Maybe StringReference
string = forall a. Maybe a
Prelude.Nothing,
      $sel:url:ReferenceSummary' :: Maybe UrlReference
url = forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the reference when the @referenceType@ is
-- @ATTACHMENT@. Otherwise, null.
referenceSummary_attachment :: Lens.Lens' ReferenceSummary (Prelude.Maybe AttachmentReference)
referenceSummary_attachment :: Lens' ReferenceSummary (Maybe AttachmentReference)
referenceSummary_attachment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceSummary' {Maybe AttachmentReference
attachment :: Maybe AttachmentReference
$sel:attachment:ReferenceSummary' :: ReferenceSummary -> Maybe AttachmentReference
attachment} -> Maybe AttachmentReference
attachment) (\s :: ReferenceSummary
s@ReferenceSummary' {} Maybe AttachmentReference
a -> ReferenceSummary
s {$sel:attachment:ReferenceSummary' :: Maybe AttachmentReference
attachment = Maybe AttachmentReference
a} :: ReferenceSummary)

-- | Information about a reference when the @referenceType@ is @DATE@.
-- Otherwise, null.
referenceSummary_date :: Lens.Lens' ReferenceSummary (Prelude.Maybe DateReference)
referenceSummary_date :: Lens' ReferenceSummary (Maybe DateReference)
referenceSummary_date = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceSummary' {Maybe DateReference
date :: Maybe DateReference
$sel:date:ReferenceSummary' :: ReferenceSummary -> Maybe DateReference
date} -> Maybe DateReference
date) (\s :: ReferenceSummary
s@ReferenceSummary' {} Maybe DateReference
a -> ReferenceSummary
s {$sel:date:ReferenceSummary' :: Maybe DateReference
date = Maybe DateReference
a} :: ReferenceSummary)

-- | Information about a reference when the @referenceType@ is @EMAIL@.
-- Otherwise, null.
referenceSummary_email :: Lens.Lens' ReferenceSummary (Prelude.Maybe EmailReference)
referenceSummary_email :: Lens' ReferenceSummary (Maybe EmailReference)
referenceSummary_email = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceSummary' {Maybe EmailReference
email :: Maybe EmailReference
$sel:email:ReferenceSummary' :: ReferenceSummary -> Maybe EmailReference
email} -> Maybe EmailReference
email) (\s :: ReferenceSummary
s@ReferenceSummary' {} Maybe EmailReference
a -> ReferenceSummary
s {$sel:email:ReferenceSummary' :: Maybe EmailReference
email = Maybe EmailReference
a} :: ReferenceSummary)

-- | Information about a reference when the @referenceType@ is @NUMBER@.
-- Otherwise, null.
referenceSummary_number :: Lens.Lens' ReferenceSummary (Prelude.Maybe NumberReference)
referenceSummary_number :: Lens' ReferenceSummary (Maybe NumberReference)
referenceSummary_number = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceSummary' {Maybe NumberReference
number :: Maybe NumberReference
$sel:number:ReferenceSummary' :: ReferenceSummary -> Maybe NumberReference
number} -> Maybe NumberReference
number) (\s :: ReferenceSummary
s@ReferenceSummary' {} Maybe NumberReference
a -> ReferenceSummary
s {$sel:number:ReferenceSummary' :: Maybe NumberReference
number = Maybe NumberReference
a} :: ReferenceSummary)

-- | Information about a reference when the @referenceType@ is @STRING@.
-- Otherwise, null.
referenceSummary_string :: Lens.Lens' ReferenceSummary (Prelude.Maybe StringReference)
referenceSummary_string :: Lens' ReferenceSummary (Maybe StringReference)
referenceSummary_string = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceSummary' {Maybe StringReference
string :: Maybe StringReference
$sel:string:ReferenceSummary' :: ReferenceSummary -> Maybe StringReference
string} -> Maybe StringReference
string) (\s :: ReferenceSummary
s@ReferenceSummary' {} Maybe StringReference
a -> ReferenceSummary
s {$sel:string:ReferenceSummary' :: Maybe StringReference
string = Maybe StringReference
a} :: ReferenceSummary)

-- | Information about the reference when the @referenceType@ is @URL@.
-- Otherwise, null.
referenceSummary_url :: Lens.Lens' ReferenceSummary (Prelude.Maybe UrlReference)
referenceSummary_url :: Lens' ReferenceSummary (Maybe UrlReference)
referenceSummary_url = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceSummary' {Maybe UrlReference
url :: Maybe UrlReference
$sel:url:ReferenceSummary' :: ReferenceSummary -> Maybe UrlReference
url} -> Maybe UrlReference
url) (\s :: ReferenceSummary
s@ReferenceSummary' {} Maybe UrlReference
a -> ReferenceSummary
s {$sel:url:ReferenceSummary' :: Maybe UrlReference
url = Maybe UrlReference
a} :: ReferenceSummary)

instance Data.FromJSON ReferenceSummary where
  parseJSON :: Value -> Parser ReferenceSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ReferenceSummary"
      ( \Object
x ->
          Maybe AttachmentReference
-> Maybe DateReference
-> Maybe EmailReference
-> Maybe NumberReference
-> Maybe StringReference
-> Maybe UrlReference
-> ReferenceSummary
ReferenceSummary'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Attachment")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Date")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Email")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Number")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"String")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Url")
      )

instance Prelude.Hashable ReferenceSummary where
  hashWithSalt :: Int -> ReferenceSummary -> Int
hashWithSalt Int
_salt ReferenceSummary' {Maybe DateReference
Maybe EmailReference
Maybe NumberReference
Maybe AttachmentReference
Maybe StringReference
Maybe UrlReference
url :: Maybe UrlReference
string :: Maybe StringReference
number :: Maybe NumberReference
email :: Maybe EmailReference
date :: Maybe DateReference
attachment :: Maybe AttachmentReference
$sel:url:ReferenceSummary' :: ReferenceSummary -> Maybe UrlReference
$sel:string:ReferenceSummary' :: ReferenceSummary -> Maybe StringReference
$sel:number:ReferenceSummary' :: ReferenceSummary -> Maybe NumberReference
$sel:email:ReferenceSummary' :: ReferenceSummary -> Maybe EmailReference
$sel:date:ReferenceSummary' :: ReferenceSummary -> Maybe DateReference
$sel:attachment:ReferenceSummary' :: ReferenceSummary -> Maybe AttachmentReference
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttachmentReference
attachment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DateReference
date
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EmailReference
email
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NumberReference
number
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StringReference
string
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UrlReference
url

instance Prelude.NFData ReferenceSummary where
  rnf :: ReferenceSummary -> ()
rnf ReferenceSummary' {Maybe DateReference
Maybe EmailReference
Maybe NumberReference
Maybe AttachmentReference
Maybe StringReference
Maybe UrlReference
url :: Maybe UrlReference
string :: Maybe StringReference
number :: Maybe NumberReference
email :: Maybe EmailReference
date :: Maybe DateReference
attachment :: Maybe AttachmentReference
$sel:url:ReferenceSummary' :: ReferenceSummary -> Maybe UrlReference
$sel:string:ReferenceSummary' :: ReferenceSummary -> Maybe StringReference
$sel:number:ReferenceSummary' :: ReferenceSummary -> Maybe NumberReference
$sel:email:ReferenceSummary' :: ReferenceSummary -> Maybe EmailReference
$sel:date:ReferenceSummary' :: ReferenceSummary -> Maybe DateReference
$sel:attachment:ReferenceSummary' :: ReferenceSummary -> Maybe AttachmentReference
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AttachmentReference
attachment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DateReference
date
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EmailReference
email
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NumberReference
number
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StringReference
string
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UrlReference
url