{-# 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.Shield.Types.EmergencyContact
-- 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.Shield.Types.EmergencyContact where

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

-- | Contact information that the SRT can use to contact you if you have
-- proactive engagement enabled, for escalations to the SRT and to initiate
-- proactive customer support.
--
-- /See:/ 'newEmergencyContact' smart constructor.
data EmergencyContact = EmergencyContact'
  { -- | Additional notes regarding the contact.
    EmergencyContact -> Maybe Text
contactNotes :: Prelude.Maybe Prelude.Text,
    -- | The phone number for the contact.
    EmergencyContact -> Maybe Text
phoneNumber :: Prelude.Maybe Prelude.Text,
    -- | The email address for the contact.
    EmergencyContact -> Text
emailAddress :: Prelude.Text
  }
  deriving (EmergencyContact -> EmergencyContact -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EmergencyContact -> EmergencyContact -> Bool
$c/= :: EmergencyContact -> EmergencyContact -> Bool
== :: EmergencyContact -> EmergencyContact -> Bool
$c== :: EmergencyContact -> EmergencyContact -> Bool
Prelude.Eq, ReadPrec [EmergencyContact]
ReadPrec EmergencyContact
Int -> ReadS EmergencyContact
ReadS [EmergencyContact]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EmergencyContact]
$creadListPrec :: ReadPrec [EmergencyContact]
readPrec :: ReadPrec EmergencyContact
$creadPrec :: ReadPrec EmergencyContact
readList :: ReadS [EmergencyContact]
$creadList :: ReadS [EmergencyContact]
readsPrec :: Int -> ReadS EmergencyContact
$creadsPrec :: Int -> ReadS EmergencyContact
Prelude.Read, Int -> EmergencyContact -> ShowS
[EmergencyContact] -> ShowS
EmergencyContact -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EmergencyContact] -> ShowS
$cshowList :: [EmergencyContact] -> ShowS
show :: EmergencyContact -> String
$cshow :: EmergencyContact -> String
showsPrec :: Int -> EmergencyContact -> ShowS
$cshowsPrec :: Int -> EmergencyContact -> ShowS
Prelude.Show, forall x. Rep EmergencyContact x -> EmergencyContact
forall x. EmergencyContact -> Rep EmergencyContact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EmergencyContact x -> EmergencyContact
$cfrom :: forall x. EmergencyContact -> Rep EmergencyContact x
Prelude.Generic)

-- |
-- Create a value of 'EmergencyContact' 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:
--
-- 'contactNotes', 'emergencyContact_contactNotes' - Additional notes regarding the contact.
--
-- 'phoneNumber', 'emergencyContact_phoneNumber' - The phone number for the contact.
--
-- 'emailAddress', 'emergencyContact_emailAddress' - The email address for the contact.
newEmergencyContact ::
  -- | 'emailAddress'
  Prelude.Text ->
  EmergencyContact
newEmergencyContact :: Text -> EmergencyContact
newEmergencyContact Text
pEmailAddress_ =
  EmergencyContact'
    { $sel:contactNotes:EmergencyContact' :: Maybe Text
contactNotes = forall a. Maybe a
Prelude.Nothing,
      $sel:phoneNumber:EmergencyContact' :: Maybe Text
phoneNumber = forall a. Maybe a
Prelude.Nothing,
      $sel:emailAddress:EmergencyContact' :: Text
emailAddress = Text
pEmailAddress_
    }

-- | Additional notes regarding the contact.
emergencyContact_contactNotes :: Lens.Lens' EmergencyContact (Prelude.Maybe Prelude.Text)
emergencyContact_contactNotes :: Lens' EmergencyContact (Maybe Text)
emergencyContact_contactNotes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmergencyContact' {Maybe Text
contactNotes :: Maybe Text
$sel:contactNotes:EmergencyContact' :: EmergencyContact -> Maybe Text
contactNotes} -> Maybe Text
contactNotes) (\s :: EmergencyContact
s@EmergencyContact' {} Maybe Text
a -> EmergencyContact
s {$sel:contactNotes:EmergencyContact' :: Maybe Text
contactNotes = Maybe Text
a} :: EmergencyContact)

-- | The phone number for the contact.
emergencyContact_phoneNumber :: Lens.Lens' EmergencyContact (Prelude.Maybe Prelude.Text)
emergencyContact_phoneNumber :: Lens' EmergencyContact (Maybe Text)
emergencyContact_phoneNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmergencyContact' {Maybe Text
phoneNumber :: Maybe Text
$sel:phoneNumber:EmergencyContact' :: EmergencyContact -> Maybe Text
phoneNumber} -> Maybe Text
phoneNumber) (\s :: EmergencyContact
s@EmergencyContact' {} Maybe Text
a -> EmergencyContact
s {$sel:phoneNumber:EmergencyContact' :: Maybe Text
phoneNumber = Maybe Text
a} :: EmergencyContact)

-- | The email address for the contact.
emergencyContact_emailAddress :: Lens.Lens' EmergencyContact Prelude.Text
emergencyContact_emailAddress :: Lens' EmergencyContact Text
emergencyContact_emailAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EmergencyContact' {Text
emailAddress :: Text
$sel:emailAddress:EmergencyContact' :: EmergencyContact -> Text
emailAddress} -> Text
emailAddress) (\s :: EmergencyContact
s@EmergencyContact' {} Text
a -> EmergencyContact
s {$sel:emailAddress:EmergencyContact' :: Text
emailAddress = Text
a} :: EmergencyContact)

instance Data.FromJSON EmergencyContact where
  parseJSON :: Value -> Parser EmergencyContact
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EmergencyContact"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> EmergencyContact
EmergencyContact'
            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
"ContactNotes")
            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
"PhoneNumber")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"EmailAddress")
      )

instance Prelude.Hashable EmergencyContact where
  hashWithSalt :: Int -> EmergencyContact -> Int
hashWithSalt Int
_salt EmergencyContact' {Maybe Text
Text
emailAddress :: Text
phoneNumber :: Maybe Text
contactNotes :: Maybe Text
$sel:emailAddress:EmergencyContact' :: EmergencyContact -> Text
$sel:phoneNumber:EmergencyContact' :: EmergencyContact -> Maybe Text
$sel:contactNotes:EmergencyContact' :: EmergencyContact -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
contactNotes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
phoneNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
emailAddress

instance Prelude.NFData EmergencyContact where
  rnf :: EmergencyContact -> ()
rnf EmergencyContact' {Maybe Text
Text
emailAddress :: Text
phoneNumber :: Maybe Text
contactNotes :: Maybe Text
$sel:emailAddress:EmergencyContact' :: EmergencyContact -> Text
$sel:phoneNumber:EmergencyContact' :: EmergencyContact -> Maybe Text
$sel:contactNotes:EmergencyContact' :: EmergencyContact -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contactNotes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
phoneNumber
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
emailAddress

instance Data.ToJSON EmergencyContact where
  toJSON :: EmergencyContact -> Value
toJSON EmergencyContact' {Maybe Text
Text
emailAddress :: Text
phoneNumber :: Maybe Text
contactNotes :: Maybe Text
$sel:emailAddress:EmergencyContact' :: EmergencyContact -> Text
$sel:phoneNumber:EmergencyContact' :: EmergencyContact -> Maybe Text
$sel:contactNotes:EmergencyContact' :: EmergencyContact -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ContactNotes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
contactNotes,
            (Key
"PhoneNumber" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
phoneNumber,
            forall a. a -> Maybe a
Prelude.Just (Key
"EmailAddress" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
emailAddress)
          ]
      )