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

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

-- | Summary of the membership details of an @AppInstanceUser@.
--
-- /See:/ 'newAppInstanceUserMembershipSummary' smart constructor.
data AppInstanceUserMembershipSummary = AppInstanceUserMembershipSummary'
  { -- | The time at which a message was last read.
    AppInstanceUserMembershipSummary -> Maybe POSIX
readMarkerTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The type of @ChannelMembership@.
    AppInstanceUserMembershipSummary -> Maybe ChannelMembershipType
type' :: Prelude.Maybe ChannelMembershipType
  }
  deriving (AppInstanceUserMembershipSummary
-> AppInstanceUserMembershipSummary -> Bool
(AppInstanceUserMembershipSummary
 -> AppInstanceUserMembershipSummary -> Bool)
-> (AppInstanceUserMembershipSummary
    -> AppInstanceUserMembershipSummary -> Bool)
-> Eq AppInstanceUserMembershipSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AppInstanceUserMembershipSummary
-> AppInstanceUserMembershipSummary -> Bool
$c/= :: AppInstanceUserMembershipSummary
-> AppInstanceUserMembershipSummary -> Bool
== :: AppInstanceUserMembershipSummary
-> AppInstanceUserMembershipSummary -> Bool
$c== :: AppInstanceUserMembershipSummary
-> AppInstanceUserMembershipSummary -> Bool
Prelude.Eq, ReadPrec [AppInstanceUserMembershipSummary]
ReadPrec AppInstanceUserMembershipSummary
Int -> ReadS AppInstanceUserMembershipSummary
ReadS [AppInstanceUserMembershipSummary]
(Int -> ReadS AppInstanceUserMembershipSummary)
-> ReadS [AppInstanceUserMembershipSummary]
-> ReadPrec AppInstanceUserMembershipSummary
-> ReadPrec [AppInstanceUserMembershipSummary]
-> Read AppInstanceUserMembershipSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AppInstanceUserMembershipSummary]
$creadListPrec :: ReadPrec [AppInstanceUserMembershipSummary]
readPrec :: ReadPrec AppInstanceUserMembershipSummary
$creadPrec :: ReadPrec AppInstanceUserMembershipSummary
readList :: ReadS [AppInstanceUserMembershipSummary]
$creadList :: ReadS [AppInstanceUserMembershipSummary]
readsPrec :: Int -> ReadS AppInstanceUserMembershipSummary
$creadsPrec :: Int -> ReadS AppInstanceUserMembershipSummary
Prelude.Read, Int -> AppInstanceUserMembershipSummary -> ShowS
[AppInstanceUserMembershipSummary] -> ShowS
AppInstanceUserMembershipSummary -> String
(Int -> AppInstanceUserMembershipSummary -> ShowS)
-> (AppInstanceUserMembershipSummary -> String)
-> ([AppInstanceUserMembershipSummary] -> ShowS)
-> Show AppInstanceUserMembershipSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AppInstanceUserMembershipSummary] -> ShowS
$cshowList :: [AppInstanceUserMembershipSummary] -> ShowS
show :: AppInstanceUserMembershipSummary -> String
$cshow :: AppInstanceUserMembershipSummary -> String
showsPrec :: Int -> AppInstanceUserMembershipSummary -> ShowS
$cshowsPrec :: Int -> AppInstanceUserMembershipSummary -> ShowS
Prelude.Show, (forall x.
 AppInstanceUserMembershipSummary
 -> Rep AppInstanceUserMembershipSummary x)
-> (forall x.
    Rep AppInstanceUserMembershipSummary x
    -> AppInstanceUserMembershipSummary)
-> Generic AppInstanceUserMembershipSummary
forall x.
Rep AppInstanceUserMembershipSummary x
-> AppInstanceUserMembershipSummary
forall x.
AppInstanceUserMembershipSummary
-> Rep AppInstanceUserMembershipSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AppInstanceUserMembershipSummary x
-> AppInstanceUserMembershipSummary
$cfrom :: forall x.
AppInstanceUserMembershipSummary
-> Rep AppInstanceUserMembershipSummary x
Prelude.Generic)

-- |
-- Create a value of 'AppInstanceUserMembershipSummary' 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:
--
-- 'readMarkerTimestamp', 'appInstanceUserMembershipSummary_readMarkerTimestamp' - The time at which a message was last read.
--
-- 'type'', 'appInstanceUserMembershipSummary_type' - The type of @ChannelMembership@.
newAppInstanceUserMembershipSummary ::
  AppInstanceUserMembershipSummary
newAppInstanceUserMembershipSummary :: AppInstanceUserMembershipSummary
newAppInstanceUserMembershipSummary =
  AppInstanceUserMembershipSummary' :: Maybe POSIX
-> Maybe ChannelMembershipType -> AppInstanceUserMembershipSummary
AppInstanceUserMembershipSummary'
    { $sel:readMarkerTimestamp:AppInstanceUserMembershipSummary' :: Maybe POSIX
readMarkerTimestamp =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:type':AppInstanceUserMembershipSummary' :: Maybe ChannelMembershipType
type' = Maybe ChannelMembershipType
forall a. Maybe a
Prelude.Nothing
    }

-- | The time at which a message was last read.
appInstanceUserMembershipSummary_readMarkerTimestamp :: Lens.Lens' AppInstanceUserMembershipSummary (Prelude.Maybe Prelude.UTCTime)
appInstanceUserMembershipSummary_readMarkerTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AppInstanceUserMembershipSummary
-> f AppInstanceUserMembershipSummary
appInstanceUserMembershipSummary_readMarkerTimestamp = (AppInstanceUserMembershipSummary -> Maybe POSIX)
-> (AppInstanceUserMembershipSummary
    -> Maybe POSIX -> AppInstanceUserMembershipSummary)
-> Lens
     AppInstanceUserMembershipSummary
     AppInstanceUserMembershipSummary
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppInstanceUserMembershipSummary' {Maybe POSIX
readMarkerTimestamp :: Maybe POSIX
$sel:readMarkerTimestamp:AppInstanceUserMembershipSummary' :: AppInstanceUserMembershipSummary -> Maybe POSIX
readMarkerTimestamp} -> Maybe POSIX
readMarkerTimestamp) (\s :: AppInstanceUserMembershipSummary
s@AppInstanceUserMembershipSummary' {} Maybe POSIX
a -> AppInstanceUserMembershipSummary
s {$sel:readMarkerTimestamp:AppInstanceUserMembershipSummary' :: Maybe POSIX
readMarkerTimestamp = Maybe POSIX
a} :: AppInstanceUserMembershipSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> AppInstanceUserMembershipSummary
 -> f AppInstanceUserMembershipSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AppInstanceUserMembershipSummary
-> f AppInstanceUserMembershipSummary
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 type of @ChannelMembership@.
appInstanceUserMembershipSummary_type :: Lens.Lens' AppInstanceUserMembershipSummary (Prelude.Maybe ChannelMembershipType)
appInstanceUserMembershipSummary_type :: (Maybe ChannelMembershipType -> f (Maybe ChannelMembershipType))
-> AppInstanceUserMembershipSummary
-> f AppInstanceUserMembershipSummary
appInstanceUserMembershipSummary_type = (AppInstanceUserMembershipSummary -> Maybe ChannelMembershipType)
-> (AppInstanceUserMembershipSummary
    -> Maybe ChannelMembershipType -> AppInstanceUserMembershipSummary)
-> Lens
     AppInstanceUserMembershipSummary
     AppInstanceUserMembershipSummary
     (Maybe ChannelMembershipType)
     (Maybe ChannelMembershipType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppInstanceUserMembershipSummary' {Maybe ChannelMembershipType
type' :: Maybe ChannelMembershipType
$sel:type':AppInstanceUserMembershipSummary' :: AppInstanceUserMembershipSummary -> Maybe ChannelMembershipType
type'} -> Maybe ChannelMembershipType
type') (\s :: AppInstanceUserMembershipSummary
s@AppInstanceUserMembershipSummary' {} Maybe ChannelMembershipType
a -> AppInstanceUserMembershipSummary
s {$sel:type':AppInstanceUserMembershipSummary' :: Maybe ChannelMembershipType
type' = Maybe ChannelMembershipType
a} :: AppInstanceUserMembershipSummary)

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

instance
  Prelude.Hashable
    AppInstanceUserMembershipSummary

instance
  Prelude.NFData
    AppInstanceUserMembershipSummary