{-# 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.AlexaBusiness.Types.Contact
-- 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.AlexaBusiness.Types.Contact where

import Amazonka.AlexaBusiness.Types.PhoneNumber
import Amazonka.AlexaBusiness.Types.SipAddress
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

-- | A contact with attributes.
--
-- /See:/ 'newContact' smart constructor.
data Contact = Contact'
  { -- | The ARN of the contact.
    Contact -> Maybe Text
contactArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the contact to display on the console.
    Contact -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | The first name of the contact, used to call the contact on the device.
    Contact -> Maybe Text
firstName :: Prelude.Maybe Prelude.Text,
    -- | The last name of the contact, used to call the contact on the device.
    Contact -> Maybe Text
lastName :: Prelude.Maybe Prelude.Text,
    -- | The phone number of the contact. The phone number type defaults to WORK.
    -- You can either specify PhoneNumber or PhoneNumbers. We recommend that
    -- you use PhoneNumbers, which lets you specify the phone number type and
    -- multiple numbers.
    Contact -> Maybe (Sensitive Text)
phoneNumber :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The list of phone numbers for the contact.
    Contact -> Maybe [PhoneNumber]
phoneNumbers :: Prelude.Maybe [PhoneNumber],
    -- | The list of SIP addresses for the contact.
    Contact -> Maybe [SipAddress]
sipAddresses :: Prelude.Maybe [SipAddress]
  }
  deriving (Contact -> Contact -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Contact -> Contact -> Bool
$c/= :: Contact -> Contact -> Bool
== :: Contact -> Contact -> Bool
$c== :: Contact -> Contact -> Bool
Prelude.Eq, Int -> Contact -> ShowS
[Contact] -> ShowS
Contact -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Contact] -> ShowS
$cshowList :: [Contact] -> ShowS
show :: Contact -> String
$cshow :: Contact -> String
showsPrec :: Int -> Contact -> ShowS
$cshowsPrec :: Int -> Contact -> ShowS
Prelude.Show, forall x. Rep Contact x -> Contact
forall x. Contact -> Rep Contact x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Contact x -> Contact
$cfrom :: forall x. Contact -> Rep Contact x
Prelude.Generic)

-- |
-- Create a value of 'Contact' 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:
--
-- 'contactArn', 'contact_contactArn' - The ARN of the contact.
--
-- 'displayName', 'contact_displayName' - The name of the contact to display on the console.
--
-- 'firstName', 'contact_firstName' - The first name of the contact, used to call the contact on the device.
--
-- 'lastName', 'contact_lastName' - The last name of the contact, used to call the contact on the device.
--
-- 'phoneNumber', 'contact_phoneNumber' - The phone number of the contact. The phone number type defaults to WORK.
-- You can either specify PhoneNumber or PhoneNumbers. We recommend that
-- you use PhoneNumbers, which lets you specify the phone number type and
-- multiple numbers.
--
-- 'phoneNumbers', 'contact_phoneNumbers' - The list of phone numbers for the contact.
--
-- 'sipAddresses', 'contact_sipAddresses' - The list of SIP addresses for the contact.
newContact ::
  Contact
newContact :: Contact
newContact =
  Contact'
    { $sel:contactArn:Contact' :: Maybe Text
contactArn = forall a. Maybe a
Prelude.Nothing,
      $sel:displayName:Contact' :: Maybe Text
displayName = forall a. Maybe a
Prelude.Nothing,
      $sel:firstName:Contact' :: Maybe Text
firstName = forall a. Maybe a
Prelude.Nothing,
      $sel:lastName:Contact' :: Maybe Text
lastName = forall a. Maybe a
Prelude.Nothing,
      $sel:phoneNumber:Contact' :: Maybe (Sensitive Text)
phoneNumber = forall a. Maybe a
Prelude.Nothing,
      $sel:phoneNumbers:Contact' :: Maybe [PhoneNumber]
phoneNumbers = forall a. Maybe a
Prelude.Nothing,
      $sel:sipAddresses:Contact' :: Maybe [SipAddress]
sipAddresses = forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the contact.
contact_contactArn :: Lens.Lens' Contact (Prelude.Maybe Prelude.Text)
contact_contactArn :: Lens' Contact (Maybe Text)
contact_contactArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contact' {Maybe Text
contactArn :: Maybe Text
$sel:contactArn:Contact' :: Contact -> Maybe Text
contactArn} -> Maybe Text
contactArn) (\s :: Contact
s@Contact' {} Maybe Text
a -> Contact
s {$sel:contactArn:Contact' :: Maybe Text
contactArn = Maybe Text
a} :: Contact)

-- | The name of the contact to display on the console.
contact_displayName :: Lens.Lens' Contact (Prelude.Maybe Prelude.Text)
contact_displayName :: Lens' Contact (Maybe Text)
contact_displayName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contact' {Maybe Text
displayName :: Maybe Text
$sel:displayName:Contact' :: Contact -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: Contact
s@Contact' {} Maybe Text
a -> Contact
s {$sel:displayName:Contact' :: Maybe Text
displayName = Maybe Text
a} :: Contact)

-- | The first name of the contact, used to call the contact on the device.
contact_firstName :: Lens.Lens' Contact (Prelude.Maybe Prelude.Text)
contact_firstName :: Lens' Contact (Maybe Text)
contact_firstName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contact' {Maybe Text
firstName :: Maybe Text
$sel:firstName:Contact' :: Contact -> Maybe Text
firstName} -> Maybe Text
firstName) (\s :: Contact
s@Contact' {} Maybe Text
a -> Contact
s {$sel:firstName:Contact' :: Maybe Text
firstName = Maybe Text
a} :: Contact)

-- | The last name of the contact, used to call the contact on the device.
contact_lastName :: Lens.Lens' Contact (Prelude.Maybe Prelude.Text)
contact_lastName :: Lens' Contact (Maybe Text)
contact_lastName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contact' {Maybe Text
lastName :: Maybe Text
$sel:lastName:Contact' :: Contact -> Maybe Text
lastName} -> Maybe Text
lastName) (\s :: Contact
s@Contact' {} Maybe Text
a -> Contact
s {$sel:lastName:Contact' :: Maybe Text
lastName = Maybe Text
a} :: Contact)

-- | The phone number of the contact. The phone number type defaults to WORK.
-- You can either specify PhoneNumber or PhoneNumbers. We recommend that
-- you use PhoneNumbers, which lets you specify the phone number type and
-- multiple numbers.
contact_phoneNumber :: Lens.Lens' Contact (Prelude.Maybe Prelude.Text)
contact_phoneNumber :: Lens' Contact (Maybe Text)
contact_phoneNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contact' {Maybe (Sensitive Text)
phoneNumber :: Maybe (Sensitive Text)
$sel:phoneNumber:Contact' :: Contact -> Maybe (Sensitive Text)
phoneNumber} -> Maybe (Sensitive Text)
phoneNumber) (\s :: Contact
s@Contact' {} Maybe (Sensitive Text)
a -> Contact
s {$sel:phoneNumber:Contact' :: Maybe (Sensitive Text)
phoneNumber = Maybe (Sensitive Text)
a} :: Contact) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The list of phone numbers for the contact.
contact_phoneNumbers :: Lens.Lens' Contact (Prelude.Maybe [PhoneNumber])
contact_phoneNumbers :: Lens' Contact (Maybe [PhoneNumber])
contact_phoneNumbers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contact' {Maybe [PhoneNumber]
phoneNumbers :: Maybe [PhoneNumber]
$sel:phoneNumbers:Contact' :: Contact -> Maybe [PhoneNumber]
phoneNumbers} -> Maybe [PhoneNumber]
phoneNumbers) (\s :: Contact
s@Contact' {} Maybe [PhoneNumber]
a -> Contact
s {$sel:phoneNumbers:Contact' :: Maybe [PhoneNumber]
phoneNumbers = Maybe [PhoneNumber]
a} :: Contact) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The list of SIP addresses for the contact.
contact_sipAddresses :: Lens.Lens' Contact (Prelude.Maybe [SipAddress])
contact_sipAddresses :: Lens' Contact (Maybe [SipAddress])
contact_sipAddresses = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contact' {Maybe [SipAddress]
sipAddresses :: Maybe [SipAddress]
$sel:sipAddresses:Contact' :: Contact -> Maybe [SipAddress]
sipAddresses} -> Maybe [SipAddress]
sipAddresses) (\s :: Contact
s@Contact' {} Maybe [SipAddress]
a -> Contact
s {$sel:sipAddresses:Contact' :: Maybe [SipAddress]
sipAddresses = Maybe [SipAddress]
a} :: Contact) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON Contact where
  parseJSON :: Value -> Parser Contact
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Contact"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe (Sensitive Text)
-> Maybe [PhoneNumber]
-> Maybe [SipAddress]
-> Contact
Contact'
            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
"ContactArn")
            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
"DisplayName")
            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
"FirstName")
            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
"LastName")
            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 (Maybe a)
Data..:? Key
"PhoneNumbers" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"SipAddresses" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Contact where
  hashWithSalt :: Int -> Contact -> Int
hashWithSalt Int
_salt Contact' {Maybe [PhoneNumber]
Maybe [SipAddress]
Maybe Text
Maybe (Sensitive Text)
sipAddresses :: Maybe [SipAddress]
phoneNumbers :: Maybe [PhoneNumber]
phoneNumber :: Maybe (Sensitive Text)
lastName :: Maybe Text
firstName :: Maybe Text
displayName :: Maybe Text
contactArn :: Maybe Text
$sel:sipAddresses:Contact' :: Contact -> Maybe [SipAddress]
$sel:phoneNumbers:Contact' :: Contact -> Maybe [PhoneNumber]
$sel:phoneNumber:Contact' :: Contact -> Maybe (Sensitive Text)
$sel:lastName:Contact' :: Contact -> Maybe Text
$sel:firstName:Contact' :: Contact -> Maybe Text
$sel:displayName:Contact' :: Contact -> Maybe Text
$sel:contactArn:Contact' :: Contact -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
contactArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
displayName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
firstName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
lastName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
phoneNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PhoneNumber]
phoneNumbers
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [SipAddress]
sipAddresses

instance Prelude.NFData Contact where
  rnf :: Contact -> ()
rnf Contact' {Maybe [PhoneNumber]
Maybe [SipAddress]
Maybe Text
Maybe (Sensitive Text)
sipAddresses :: Maybe [SipAddress]
phoneNumbers :: Maybe [PhoneNumber]
phoneNumber :: Maybe (Sensitive Text)
lastName :: Maybe Text
firstName :: Maybe Text
displayName :: Maybe Text
contactArn :: Maybe Text
$sel:sipAddresses:Contact' :: Contact -> Maybe [SipAddress]
$sel:phoneNumbers:Contact' :: Contact -> Maybe [PhoneNumber]
$sel:phoneNumber:Contact' :: Contact -> Maybe (Sensitive Text)
$sel:lastName:Contact' :: Contact -> Maybe Text
$sel:firstName:Contact' :: Contact -> Maybe Text
$sel:displayName:Contact' :: Contact -> Maybe Text
$sel:contactArn:Contact' :: Contact -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contactArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
displayName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
firstName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
lastName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
phoneNumber
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [PhoneNumber]
phoneNumbers
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [SipAddress]
sipAddresses