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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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 first name. This is required if you are using Amazon Connect or SAML
    -- for identity management.
    UserIdentityInfo -> Maybe Text
firstName :: Prelude.Maybe Prelude.Text
  }
  deriving (UserIdentityInfo -> UserIdentityInfo -> Bool
(UserIdentityInfo -> UserIdentityInfo -> Bool)
-> (UserIdentityInfo -> UserIdentityInfo -> Bool)
-> Eq UserIdentityInfo
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]
(Int -> ReadS UserIdentityInfo)
-> ReadS [UserIdentityInfo]
-> ReadPrec UserIdentityInfo
-> ReadPrec [UserIdentityInfo]
-> Read 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
(Int -> UserIdentityInfo -> ShowS)
-> (UserIdentityInfo -> String)
-> ([UserIdentityInfo] -> ShowS)
-> Show UserIdentityInfo
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. UserIdentityInfo -> Rep UserIdentityInfo x)
-> (forall x. Rep UserIdentityInfo x -> UserIdentityInfo)
-> Generic UserIdentityInfo
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.
--
-- 'lastName', 'userIdentityInfo_lastName' - The last name. This is required if you are using Amazon Connect or SAML
-- for identity management.
--
-- 'firstName', 'userIdentityInfo_firstName' - The first name. This is required if you are using Amazon Connect or SAML
-- for identity management.
newUserIdentityInfo ::
  UserIdentityInfo
newUserIdentityInfo :: UserIdentityInfo
newUserIdentityInfo =
  UserIdentityInfo' :: Maybe Text -> Maybe Text -> Maybe Text -> UserIdentityInfo
UserIdentityInfo'
    { $sel:email:UserIdentityInfo' :: Maybe Text
email = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastName:UserIdentityInfo' :: Maybe Text
lastName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:firstName:UserIdentityInfo' :: Maybe Text
firstName = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> UserIdentityInfo -> f UserIdentityInfo
userIdentityInfo_email = (UserIdentityInfo -> Maybe Text)
-> (UserIdentityInfo -> Maybe Text -> UserIdentityInfo)
-> Lens UserIdentityInfo UserIdentityInfo (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text))
-> UserIdentityInfo -> f UserIdentityInfo
userIdentityInfo_lastName = (UserIdentityInfo -> Maybe Text)
-> (UserIdentityInfo -> Maybe Text -> UserIdentityInfo)
-> Lens UserIdentityInfo UserIdentityInfo (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text))
-> UserIdentityInfo -> f UserIdentityInfo
userIdentityInfo_firstName = (UserIdentityInfo -> Maybe Text)
-> (UserIdentityInfo -> Maybe Text -> UserIdentityInfo)
-> Lens UserIdentityInfo UserIdentityInfo (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON UserIdentityInfo where
  parseJSON :: Value -> Parser UserIdentityInfo
parseJSON =
    String
-> (Object -> Parser UserIdentityInfo)
-> Value
-> Parser UserIdentityInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UserIdentityInfo"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> UserIdentityInfo
UserIdentityInfo'
            (Maybe Text -> Maybe Text -> Maybe Text -> UserIdentityInfo)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> UserIdentityInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Email")
            Parser (Maybe Text -> Maybe Text -> UserIdentityInfo)
-> Parser (Maybe Text) -> Parser (Maybe Text -> UserIdentityInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastName")
            Parser (Maybe Text -> UserIdentityInfo)
-> Parser (Maybe Text) -> Parser UserIdentityInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FirstName")
      )

instance Prelude.Hashable UserIdentityInfo

instance Prelude.NFData UserIdentityInfo

instance Core.ToJSON UserIdentityInfo where
  toJSON :: UserIdentityInfo -> Value
toJSON UserIdentityInfo' {Maybe Text
firstName :: Maybe Text
lastName :: Maybe Text
email :: Maybe Text
$sel:firstName:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:lastName:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
$sel:email:UserIdentityInfo' :: UserIdentityInfo -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Email" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
email,
            (Text
"LastName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
lastName,
            (Text
"FirstName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
firstName
          ]
      )