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

import Amazonka.Chime.Types.Member
import Amazonka.Chime.Types.RoomMembershipRole
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The room membership details.
--
-- /See:/ 'newRoomMembership' smart constructor.
data RoomMembership = RoomMembership'
  { -- | The room membership update timestamp, in ISO 8601 format.
    RoomMembership -> Maybe POSIX
updatedTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The membership role.
    RoomMembership -> Maybe RoomMembershipRole
role' :: Prelude.Maybe RoomMembershipRole,
    -- | The room ID.
    RoomMembership -> Maybe Text
roomId :: Prelude.Maybe Prelude.Text,
    RoomMembership -> Maybe Member
member :: Prelude.Maybe Member,
    -- | The identifier of the user that invited the room member.
    RoomMembership -> Maybe Text
invitedBy :: Prelude.Maybe Prelude.Text
  }
  deriving (RoomMembership -> RoomMembership -> Bool
(RoomMembership -> RoomMembership -> Bool)
-> (RoomMembership -> RoomMembership -> Bool) -> Eq RoomMembership
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RoomMembership -> RoomMembership -> Bool
$c/= :: RoomMembership -> RoomMembership -> Bool
== :: RoomMembership -> RoomMembership -> Bool
$c== :: RoomMembership -> RoomMembership -> Bool
Prelude.Eq, Int -> RoomMembership -> ShowS
[RoomMembership] -> ShowS
RoomMembership -> String
(Int -> RoomMembership -> ShowS)
-> (RoomMembership -> String)
-> ([RoomMembership] -> ShowS)
-> Show RoomMembership
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RoomMembership] -> ShowS
$cshowList :: [RoomMembership] -> ShowS
show :: RoomMembership -> String
$cshow :: RoomMembership -> String
showsPrec :: Int -> RoomMembership -> ShowS
$cshowsPrec :: Int -> RoomMembership -> ShowS
Prelude.Show, (forall x. RoomMembership -> Rep RoomMembership x)
-> (forall x. Rep RoomMembership x -> RoomMembership)
-> Generic RoomMembership
forall x. Rep RoomMembership x -> RoomMembership
forall x. RoomMembership -> Rep RoomMembership x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RoomMembership x -> RoomMembership
$cfrom :: forall x. RoomMembership -> Rep RoomMembership x
Prelude.Generic)

-- |
-- Create a value of 'RoomMembership' 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:
--
-- 'updatedTimestamp', 'roomMembership_updatedTimestamp' - The room membership update timestamp, in ISO 8601 format.
--
-- 'role'', 'roomMembership_role' - The membership role.
--
-- 'roomId', 'roomMembership_roomId' - The room ID.
--
-- 'member', 'roomMembership_member' - Undocumented member.
--
-- 'invitedBy', 'roomMembership_invitedBy' - The identifier of the user that invited the room member.
newRoomMembership ::
  RoomMembership
newRoomMembership :: RoomMembership
newRoomMembership =
  RoomMembership' :: Maybe POSIX
-> Maybe RoomMembershipRole
-> Maybe Text
-> Maybe Member
-> Maybe Text
-> RoomMembership
RoomMembership'
    { $sel:updatedTimestamp:RoomMembership' :: Maybe POSIX
updatedTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:role':RoomMembership' :: Maybe RoomMembershipRole
role' = Maybe RoomMembershipRole
forall a. Maybe a
Prelude.Nothing,
      $sel:roomId:RoomMembership' :: Maybe Text
roomId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:member:RoomMembership' :: Maybe Member
member = Maybe Member
forall a. Maybe a
Prelude.Nothing,
      $sel:invitedBy:RoomMembership' :: Maybe Text
invitedBy = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The room membership update timestamp, in ISO 8601 format.
roomMembership_updatedTimestamp :: Lens.Lens' RoomMembership (Prelude.Maybe Prelude.UTCTime)
roomMembership_updatedTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> RoomMembership -> f RoomMembership
roomMembership_updatedTimestamp = (RoomMembership -> Maybe POSIX)
-> (RoomMembership -> Maybe POSIX -> RoomMembership)
-> Lens RoomMembership RoomMembership (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoomMembership' {Maybe POSIX
updatedTimestamp :: Maybe POSIX
$sel:updatedTimestamp:RoomMembership' :: RoomMembership -> Maybe POSIX
updatedTimestamp} -> Maybe POSIX
updatedTimestamp) (\s :: RoomMembership
s@RoomMembership' {} Maybe POSIX
a -> RoomMembership
s {$sel:updatedTimestamp:RoomMembership' :: Maybe POSIX
updatedTimestamp = Maybe POSIX
a} :: RoomMembership) ((Maybe POSIX -> f (Maybe POSIX))
 -> RoomMembership -> f RoomMembership)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> RoomMembership
-> f RoomMembership
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The membership role.
roomMembership_role :: Lens.Lens' RoomMembership (Prelude.Maybe RoomMembershipRole)
roomMembership_role :: (Maybe RoomMembershipRole -> f (Maybe RoomMembershipRole))
-> RoomMembership -> f RoomMembership
roomMembership_role = (RoomMembership -> Maybe RoomMembershipRole)
-> (RoomMembership -> Maybe RoomMembershipRole -> RoomMembership)
-> Lens
     RoomMembership
     RoomMembership
     (Maybe RoomMembershipRole)
     (Maybe RoomMembershipRole)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoomMembership' {Maybe RoomMembershipRole
role' :: Maybe RoomMembershipRole
$sel:role':RoomMembership' :: RoomMembership -> Maybe RoomMembershipRole
role'} -> Maybe RoomMembershipRole
role') (\s :: RoomMembership
s@RoomMembership' {} Maybe RoomMembershipRole
a -> RoomMembership
s {$sel:role':RoomMembership' :: Maybe RoomMembershipRole
role' = Maybe RoomMembershipRole
a} :: RoomMembership)

-- | The room ID.
roomMembership_roomId :: Lens.Lens' RoomMembership (Prelude.Maybe Prelude.Text)
roomMembership_roomId :: (Maybe Text -> f (Maybe Text))
-> RoomMembership -> f RoomMembership
roomMembership_roomId = (RoomMembership -> Maybe Text)
-> (RoomMembership -> Maybe Text -> RoomMembership)
-> Lens RoomMembership RoomMembership (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoomMembership' {Maybe Text
roomId :: Maybe Text
$sel:roomId:RoomMembership' :: RoomMembership -> Maybe Text
roomId} -> Maybe Text
roomId) (\s :: RoomMembership
s@RoomMembership' {} Maybe Text
a -> RoomMembership
s {$sel:roomId:RoomMembership' :: Maybe Text
roomId = Maybe Text
a} :: RoomMembership)

-- | Undocumented member.
roomMembership_member :: Lens.Lens' RoomMembership (Prelude.Maybe Member)
roomMembership_member :: (Maybe Member -> f (Maybe Member))
-> RoomMembership -> f RoomMembership
roomMembership_member = (RoomMembership -> Maybe Member)
-> (RoomMembership -> Maybe Member -> RoomMembership)
-> Lens RoomMembership RoomMembership (Maybe Member) (Maybe Member)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoomMembership' {Maybe Member
member :: Maybe Member
$sel:member:RoomMembership' :: RoomMembership -> Maybe Member
member} -> Maybe Member
member) (\s :: RoomMembership
s@RoomMembership' {} Maybe Member
a -> RoomMembership
s {$sel:member:RoomMembership' :: Maybe Member
member = Maybe Member
a} :: RoomMembership)

-- | The identifier of the user that invited the room member.
roomMembership_invitedBy :: Lens.Lens' RoomMembership (Prelude.Maybe Prelude.Text)
roomMembership_invitedBy :: (Maybe Text -> f (Maybe Text))
-> RoomMembership -> f RoomMembership
roomMembership_invitedBy = (RoomMembership -> Maybe Text)
-> (RoomMembership -> Maybe Text -> RoomMembership)
-> Lens RoomMembership RoomMembership (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoomMembership' {Maybe Text
invitedBy :: Maybe Text
$sel:invitedBy:RoomMembership' :: RoomMembership -> Maybe Text
invitedBy} -> Maybe Text
invitedBy) (\s :: RoomMembership
s@RoomMembership' {} Maybe Text
a -> RoomMembership
s {$sel:invitedBy:RoomMembership' :: Maybe Text
invitedBy = Maybe Text
a} :: RoomMembership)

instance Core.FromJSON RoomMembership where
  parseJSON :: Value -> Parser RoomMembership
parseJSON =
    String
-> (Object -> Parser RoomMembership)
-> Value
-> Parser RoomMembership
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RoomMembership"
      ( \Object
x ->
          Maybe POSIX
-> Maybe RoomMembershipRole
-> Maybe Text
-> Maybe Member
-> Maybe Text
-> RoomMembership
RoomMembership'
            (Maybe POSIX
 -> Maybe RoomMembershipRole
 -> Maybe Text
 -> Maybe Member
 -> Maybe Text
 -> RoomMembership)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe RoomMembershipRole
      -> Maybe Text -> Maybe Member -> Maybe Text -> RoomMembership)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UpdatedTimestamp")
            Parser
  (Maybe RoomMembershipRole
   -> Maybe Text -> Maybe Member -> Maybe Text -> RoomMembership)
-> Parser (Maybe RoomMembershipRole)
-> Parser
     (Maybe Text -> Maybe Member -> Maybe Text -> RoomMembership)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RoomMembershipRole)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Role")
            Parser (Maybe Text -> Maybe Member -> Maybe Text -> RoomMembership)
-> Parser (Maybe Text)
-> Parser (Maybe Member -> Maybe Text -> RoomMembership)
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
"RoomId")
            Parser (Maybe Member -> Maybe Text -> RoomMembership)
-> Parser (Maybe Member) -> Parser (Maybe Text -> RoomMembership)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Member)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Member")
            Parser (Maybe Text -> RoomMembership)
-> Parser (Maybe Text) -> Parser RoomMembership
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
"InvitedBy")
      )

instance Prelude.Hashable RoomMembership

instance Prelude.NFData RoomMembership