{-# 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.UserIdentityInfo
-- 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.UserIdentityInfo 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

-- | Contains information about the identity of a user.
--
-- /See:/ 'newUserIdentityInfo' smart constructor.
data UserIdentityInfo = UserIdentityInfo'
  { -- | The email address. If you are using SAML for identity management and
    -- include this parameter, an error is returned.
    UserIdentityInfo -> Maybe Text
email :: Prelude.Maybe Prelude.Text,
    -- | The first name. This is required if you are using Amazon Connect or SAML
    -- for identity management.
    UserIdentityInfo -> Maybe Text
firstName :: Prelude.Maybe Prelude.Text,
    -- | The last name. This is required if you are using Amazon Connect or SAML
    -- for identity management.
    UserIdentityInfo -> Maybe Text
lastName :: Prelude.Maybe Prelude.Text,
    -- | The user\'s mobile number.
    UserIdentityInfo -> Maybe Text
mobile :: Prelude.Maybe Prelude.Text,
    -- | The user\'s secondary email address. If you provide a secondary email,
    -- the user receives email notifications - other than password reset
    -- notifications - to this email address instead of to their primary email
    -- address.
    --
    -- Pattern:
    -- @(?=^.{0,265}$)[a-zA-Z0-9._%+-]+\@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,63}@
    UserIdentityInfo -> Maybe Text
secondaryEmail :: Prelude.Maybe Prelude.Text
  }
  deriving (UserIdentityInfo -> UserIdentityInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserIdentityInfo -> UserIdentityInfo -> Bool
$c/= :: UserIdentityInfo -> UserIdentityInfo -> Bool
== :: UserIdentityInfo -> UserIdentityInfo -> Bool
$c== :: UserIdentityInfo -> UserIdentityInfo -> Bool
Prelude.Eq, ReadPrec [UserIdentityInfo]
ReadPrec UserIdentityInfo
Int -> ReadS UserIdentityInfo
ReadS [UserIdentityInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserIdentityInfo]
$creadListPrec :: ReadPrec [UserIdentityInfo]
readPrec :: ReadPrec UserIdentityInfo
$creadPrec :: ReadPrec UserIdentityInfo
readList :: ReadS [UserIdentityInfo]
$creadList :: ReadS [UserIdentityInfo]
readsPrec :: Int -> ReadS UserIdentityInfo
$creadsPrec :: Int -> ReadS UserIdentityInfo
Prelude.Read, Int -> UserIdentityInfo -> ShowS
[UserIdentityInfo] -> ShowS
UserIdentityInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserIdentityInfo] -> ShowS
$cshowList :: [UserIdentityInfo] -> ShowS
show :: UserIdentityInfo -> String
$cshow :: UserIdentityInfo -> String
showsPrec :: Int -> UserIdentityInfo -> ShowS
$cshowsPrec :: Int -> UserIdentityInfo -> ShowS
Prelude.Show, forall x. Rep UserIdentityInfo x -> UserIdentityInfo
forall x. UserIdentityInfo -> Rep UserIdentityInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UserIdentityInfo x -> UserIdentityInfo
$cfrom :: forall x. UserIdentityInfo -> Rep UserIdentityInfo x
Prelude.Generic)

-- |
-- Create a value of 'UserIdentityInfo' 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:
--
-- 'email', 'userIdentityInfo_email' - The email address. If you are using SAML for identity management and
-- include this parameter, an error is returned.
--
-- 'firstName', 'userIdentityInfo_firstName' - The first name. This is required if you are using Amazon Connect or SAML
-- for identity management.
--
-- 'lastName', 'userIdentityInfo_lastName' - The last name. This is required if you are using Amazon Connect or SAML
-- for identity management.
--
-- 'mobile', 'userIdentityInfo_mobile' - The user\'s mobile number.
--
-- 'secondaryEmail', 'userIdentityInfo_secondaryEmail' - The user\'s secondary email address. If you provide a secondary email,
-- the user receives email notifications - other than password reset
-- notifications - to this email address instead of to their primary email
-- address.
--
-- Pattern:
-- @(?=^.{0,265}$)[a-zA-Z0-9._%+-]+\@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,63}@
newUserIdentityInfo ::
  UserIdentityInfo
newUserIdentityInfo :: UserIdentityInfo
newUserIdentityInfo =
  UserIdentityInfo'
    { $sel:email:UserIdentityInfo' :: Maybe Text
email = forall a. Maybe a
Prelude.Nothing,
      $sel:firstName:UserIdentityInfo' :: Maybe Text
firstName = forall a. Maybe a
Prelude.Nothing,
      $sel:lastName:UserIdentityInfo' :: Maybe Text
lastName = forall a. Maybe a
Prelude.Nothing,
      $sel:mobile:UserIdentityInfo' :: Maybe Text
mobile = forall a. Maybe a
Prelude.Nothing,
      $sel:secondaryEmail:UserIdentityInfo' :: Maybe Text
secondaryEmail = forall a. Maybe a
Prelude.Nothing
    }

-- | The email address. If you are using SAML for identity management and
-- include this parameter, an error is returned.
userIdentityInfo_email :: Lens.Lens' UserIdentityInfo (Prelude.Maybe Prelude.Text)
userIdentityInfo_email :: Lens' UserIdentityInfo (Maybe Text)
userIdentityInfo_email = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentityInfo' {Maybe Text
email :: Maybe Text
$sel:email:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
email} -> Maybe Text
email) (\s :: UserIdentityInfo
s@UserIdentityInfo' {} Maybe Text
a -> UserIdentityInfo
s {$sel:email:UserIdentityInfo' :: Maybe Text
email = Maybe Text
a} :: UserIdentityInfo)

-- | The first name. This is required if you are using Amazon Connect or SAML
-- for identity management.
userIdentityInfo_firstName :: Lens.Lens' UserIdentityInfo (Prelude.Maybe Prelude.Text)
userIdentityInfo_firstName :: Lens' UserIdentityInfo (Maybe Text)
userIdentityInfo_firstName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentityInfo' {Maybe Text
firstName :: Maybe Text
$sel:firstName:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
firstName} -> Maybe Text
firstName) (\s :: UserIdentityInfo
s@UserIdentityInfo' {} Maybe Text
a -> UserIdentityInfo
s {$sel:firstName:UserIdentityInfo' :: Maybe Text
firstName = Maybe Text
a} :: UserIdentityInfo)

-- | The last name. This is required if you are using Amazon Connect or SAML
-- for identity management.
userIdentityInfo_lastName :: Lens.Lens' UserIdentityInfo (Prelude.Maybe Prelude.Text)
userIdentityInfo_lastName :: Lens' UserIdentityInfo (Maybe Text)
userIdentityInfo_lastName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentityInfo' {Maybe Text
lastName :: Maybe Text
$sel:lastName:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
lastName} -> Maybe Text
lastName) (\s :: UserIdentityInfo
s@UserIdentityInfo' {} Maybe Text
a -> UserIdentityInfo
s {$sel:lastName:UserIdentityInfo' :: Maybe Text
lastName = Maybe Text
a} :: UserIdentityInfo)

-- | The user\'s mobile number.
userIdentityInfo_mobile :: Lens.Lens' UserIdentityInfo (Prelude.Maybe Prelude.Text)
userIdentityInfo_mobile :: Lens' UserIdentityInfo (Maybe Text)
userIdentityInfo_mobile = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentityInfo' {Maybe Text
mobile :: Maybe Text
$sel:mobile:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
mobile} -> Maybe Text
mobile) (\s :: UserIdentityInfo
s@UserIdentityInfo' {} Maybe Text
a -> UserIdentityInfo
s {$sel:mobile:UserIdentityInfo' :: Maybe Text
mobile = Maybe Text
a} :: UserIdentityInfo)

-- | The user\'s secondary email address. If you provide a secondary email,
-- the user receives email notifications - other than password reset
-- notifications - to this email address instead of to their primary email
-- address.
--
-- Pattern:
-- @(?=^.{0,265}$)[a-zA-Z0-9._%+-]+\@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,63}@
userIdentityInfo_secondaryEmail :: Lens.Lens' UserIdentityInfo (Prelude.Maybe Prelude.Text)
userIdentityInfo_secondaryEmail :: Lens' UserIdentityInfo (Maybe Text)
userIdentityInfo_secondaryEmail = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UserIdentityInfo' {Maybe Text
secondaryEmail :: Maybe Text
$sel:secondaryEmail:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
secondaryEmail} -> Maybe Text
secondaryEmail) (\s :: UserIdentityInfo
s@UserIdentityInfo' {} Maybe Text
a -> UserIdentityInfo
s {$sel:secondaryEmail:UserIdentityInfo' :: Maybe Text
secondaryEmail = Maybe Text
a} :: UserIdentityInfo)

instance Data.FromJSON UserIdentityInfo where
  parseJSON :: Value -> Parser UserIdentityInfo
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UserIdentityInfo"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> UserIdentityInfo
UserIdentityInfo'
            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
"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
"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
"Mobile")
            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
"SecondaryEmail")
      )

instance Prelude.Hashable UserIdentityInfo where
  hashWithSalt :: Int -> UserIdentityInfo -> Int
hashWithSalt Int
_salt UserIdentityInfo' {Maybe Text
secondaryEmail :: Maybe Text
mobile :: Maybe Text
lastName :: Maybe Text
firstName :: Maybe Text
email :: Maybe Text
$sel:secondaryEmail:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:mobile:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:lastName:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:firstName:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:email:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
email
      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 Text
mobile
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
secondaryEmail

instance Prelude.NFData UserIdentityInfo where
  rnf :: UserIdentityInfo -> ()
rnf UserIdentityInfo' {Maybe Text
secondaryEmail :: Maybe Text
mobile :: Maybe Text
lastName :: Maybe Text
firstName :: Maybe Text
email :: Maybe Text
$sel:secondaryEmail:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:mobile:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:lastName:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:firstName:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:email:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
email
      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 Text
mobile
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
secondaryEmail

instance Data.ToJSON UserIdentityInfo where
  toJSON :: UserIdentityInfo -> Value
toJSON UserIdentityInfo' {Maybe Text
secondaryEmail :: Maybe Text
mobile :: Maybe Text
lastName :: Maybe Text
firstName :: Maybe Text
email :: Maybe Text
$sel:secondaryEmail:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:mobile:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:lastName:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:firstName:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:email:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Email" 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
email,
            (Key
"FirstName" 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
firstName,
            (Key
"LastName" 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
lastName,
            (Key
"Mobile" 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
mobile,
            (Key
"SecondaryEmail" 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
secondaryEmail
          ]
      )