{-# 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.Chime.Types.MemberError
-- 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.Chime.Types.MemberError where

import Amazonka.Chime.Types.ErrorCode
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The list of errors returned when a member action results in an error.
--
-- /See:/ 'newMemberError' smart constructor.
data MemberError = MemberError'
  { -- | The member ID.
    MemberError -> Maybe Text
memberId :: Prelude.Maybe Prelude.Text,
    -- | The error code.
    MemberError -> Maybe ErrorCode
errorCode :: Prelude.Maybe ErrorCode,
    -- | The error message.
    MemberError -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (MemberError -> MemberError -> Bool
(MemberError -> MemberError -> Bool)
-> (MemberError -> MemberError -> Bool) -> Eq MemberError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MemberError -> MemberError -> Bool
$c/= :: MemberError -> MemberError -> Bool
== :: MemberError -> MemberError -> Bool
$c== :: MemberError -> MemberError -> Bool
Prelude.Eq, ReadPrec [MemberError]
ReadPrec MemberError
Int -> ReadS MemberError
ReadS [MemberError]
(Int -> ReadS MemberError)
-> ReadS [MemberError]
-> ReadPrec MemberError
-> ReadPrec [MemberError]
-> Read MemberError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MemberError]
$creadListPrec :: ReadPrec [MemberError]
readPrec :: ReadPrec MemberError
$creadPrec :: ReadPrec MemberError
readList :: ReadS [MemberError]
$creadList :: ReadS [MemberError]
readsPrec :: Int -> ReadS MemberError
$creadsPrec :: Int -> ReadS MemberError
Prelude.Read, Int -> MemberError -> ShowS
[MemberError] -> ShowS
MemberError -> String
(Int -> MemberError -> ShowS)
-> (MemberError -> String)
-> ([MemberError] -> ShowS)
-> Show MemberError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MemberError] -> ShowS
$cshowList :: [MemberError] -> ShowS
show :: MemberError -> String
$cshow :: MemberError -> String
showsPrec :: Int -> MemberError -> ShowS
$cshowsPrec :: Int -> MemberError -> ShowS
Prelude.Show, (forall x. MemberError -> Rep MemberError x)
-> (forall x. Rep MemberError x -> MemberError)
-> Generic MemberError
forall x. Rep MemberError x -> MemberError
forall x. MemberError -> Rep MemberError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MemberError x -> MemberError
$cfrom :: forall x. MemberError -> Rep MemberError x
Prelude.Generic)

-- |
-- Create a value of 'MemberError' 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:
--
-- 'memberId', 'memberError_memberId' - The member ID.
--
-- 'errorCode', 'memberError_errorCode' - The error code.
--
-- 'errorMessage', 'memberError_errorMessage' - The error message.
newMemberError ::
  MemberError
newMemberError :: MemberError
newMemberError =
  MemberError' :: Maybe Text -> Maybe ErrorCode -> Maybe Text -> MemberError
MemberError'
    { $sel:memberId:MemberError' :: Maybe Text
memberId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorCode:MemberError' :: Maybe ErrorCode
errorCode = Maybe ErrorCode
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:MemberError' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The member ID.
memberError_memberId :: Lens.Lens' MemberError (Prelude.Maybe Prelude.Text)
memberError_memberId :: (Maybe Text -> f (Maybe Text)) -> MemberError -> f MemberError
memberError_memberId = (MemberError -> Maybe Text)
-> (MemberError -> Maybe Text -> MemberError)
-> Lens MemberError MemberError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberError' {Maybe Text
memberId :: Maybe Text
$sel:memberId:MemberError' :: MemberError -> Maybe Text
memberId} -> Maybe Text
memberId) (\s :: MemberError
s@MemberError' {} Maybe Text
a -> MemberError
s {$sel:memberId:MemberError' :: Maybe Text
memberId = Maybe Text
a} :: MemberError)

-- | The error code.
memberError_errorCode :: Lens.Lens' MemberError (Prelude.Maybe ErrorCode)
memberError_errorCode :: (Maybe ErrorCode -> f (Maybe ErrorCode))
-> MemberError -> f MemberError
memberError_errorCode = (MemberError -> Maybe ErrorCode)
-> (MemberError -> Maybe ErrorCode -> MemberError)
-> Lens MemberError MemberError (Maybe ErrorCode) (Maybe ErrorCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberError' {Maybe ErrorCode
errorCode :: Maybe ErrorCode
$sel:errorCode:MemberError' :: MemberError -> Maybe ErrorCode
errorCode} -> Maybe ErrorCode
errorCode) (\s :: MemberError
s@MemberError' {} Maybe ErrorCode
a -> MemberError
s {$sel:errorCode:MemberError' :: Maybe ErrorCode
errorCode = Maybe ErrorCode
a} :: MemberError)

-- | The error message.
memberError_errorMessage :: Lens.Lens' MemberError (Prelude.Maybe Prelude.Text)
memberError_errorMessage :: (Maybe Text -> f (Maybe Text)) -> MemberError -> f MemberError
memberError_errorMessage = (MemberError -> Maybe Text)
-> (MemberError -> Maybe Text -> MemberError)
-> Lens MemberError MemberError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MemberError' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:MemberError' :: MemberError -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: MemberError
s@MemberError' {} Maybe Text
a -> MemberError
s {$sel:errorMessage:MemberError' :: Maybe Text
errorMessage = Maybe Text
a} :: MemberError)

instance Core.FromJSON MemberError where
  parseJSON :: Value -> Parser MemberError
parseJSON =
    String
-> (Object -> Parser MemberError) -> Value -> Parser MemberError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MemberError"
      ( \Object
x ->
          Maybe Text -> Maybe ErrorCode -> Maybe Text -> MemberError
MemberError'
            (Maybe Text -> Maybe ErrorCode -> Maybe Text -> MemberError)
-> Parser (Maybe Text)
-> Parser (Maybe ErrorCode -> Maybe Text -> MemberError)
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
"MemberId")
            Parser (Maybe ErrorCode -> Maybe Text -> MemberError)
-> Parser (Maybe ErrorCode) -> Parser (Maybe Text -> MemberError)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ErrorCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ErrorCode")
            Parser (Maybe Text -> MemberError)
-> Parser (Maybe Text) -> Parser MemberError
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
"ErrorMessage")
      )

instance Prelude.Hashable MemberError

instance Prelude.NFData MemberError