{-# 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.SESV2.Types.ContactList
-- 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.SESV2.Types.ContactList where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A list that contains contacts that have subscribed to a particular topic
-- or topics.
--
-- /See:/ 'newContactList' smart constructor.
data ContactList = ContactList'
  { -- | The name of the contact list.
    ContactList -> Maybe Text
contactListName :: Prelude.Maybe Prelude.Text,
    -- | A timestamp noting the last time the contact list was updated.
    ContactList -> Maybe POSIX
lastUpdatedTimestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (ContactList -> ContactList -> Bool
(ContactList -> ContactList -> Bool)
-> (ContactList -> ContactList -> Bool) -> Eq ContactList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContactList -> ContactList -> Bool
$c/= :: ContactList -> ContactList -> Bool
== :: ContactList -> ContactList -> Bool
$c== :: ContactList -> ContactList -> Bool
Prelude.Eq, ReadPrec [ContactList]
ReadPrec ContactList
Int -> ReadS ContactList
ReadS [ContactList]
(Int -> ReadS ContactList)
-> ReadS [ContactList]
-> ReadPrec ContactList
-> ReadPrec [ContactList]
-> Read ContactList
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContactList]
$creadListPrec :: ReadPrec [ContactList]
readPrec :: ReadPrec ContactList
$creadPrec :: ReadPrec ContactList
readList :: ReadS [ContactList]
$creadList :: ReadS [ContactList]
readsPrec :: Int -> ReadS ContactList
$creadsPrec :: Int -> ReadS ContactList
Prelude.Read, Int -> ContactList -> ShowS
[ContactList] -> ShowS
ContactList -> String
(Int -> ContactList -> ShowS)
-> (ContactList -> String)
-> ([ContactList] -> ShowS)
-> Show ContactList
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContactList] -> ShowS
$cshowList :: [ContactList] -> ShowS
show :: ContactList -> String
$cshow :: ContactList -> String
showsPrec :: Int -> ContactList -> ShowS
$cshowsPrec :: Int -> ContactList -> ShowS
Prelude.Show, (forall x. ContactList -> Rep ContactList x)
-> (forall x. Rep ContactList x -> ContactList)
-> Generic ContactList
forall x. Rep ContactList x -> ContactList
forall x. ContactList -> Rep ContactList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContactList x -> ContactList
$cfrom :: forall x. ContactList -> Rep ContactList x
Prelude.Generic)

-- |
-- Create a value of 'ContactList' 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:
--
-- 'contactListName', 'contactList_contactListName' - The name of the contact list.
--
-- 'lastUpdatedTimestamp', 'contactList_lastUpdatedTimestamp' - A timestamp noting the last time the contact list was updated.
newContactList ::
  ContactList
newContactList :: ContactList
newContactList =
  ContactList' :: Maybe Text -> Maybe POSIX -> ContactList
ContactList'
    { $sel:contactListName:ContactList' :: Maybe Text
contactListName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdatedTimestamp:ContactList' :: Maybe POSIX
lastUpdatedTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the contact list.
contactList_contactListName :: Lens.Lens' ContactList (Prelude.Maybe Prelude.Text)
contactList_contactListName :: (Maybe Text -> f (Maybe Text)) -> ContactList -> f ContactList
contactList_contactListName = (ContactList -> Maybe Text)
-> (ContactList -> Maybe Text -> ContactList)
-> Lens ContactList ContactList (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactList' {Maybe Text
contactListName :: Maybe Text
$sel:contactListName:ContactList' :: ContactList -> Maybe Text
contactListName} -> Maybe Text
contactListName) (\s :: ContactList
s@ContactList' {} Maybe Text
a -> ContactList
s {$sel:contactListName:ContactList' :: Maybe Text
contactListName = Maybe Text
a} :: ContactList)

-- | A timestamp noting the last time the contact list was updated.
contactList_lastUpdatedTimestamp :: Lens.Lens' ContactList (Prelude.Maybe Prelude.UTCTime)
contactList_lastUpdatedTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ContactList -> f ContactList
contactList_lastUpdatedTimestamp = (ContactList -> Maybe POSIX)
-> (ContactList -> Maybe POSIX -> ContactList)
-> Lens ContactList ContactList (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContactList' {Maybe POSIX
lastUpdatedTimestamp :: Maybe POSIX
$sel:lastUpdatedTimestamp:ContactList' :: ContactList -> Maybe POSIX
lastUpdatedTimestamp} -> Maybe POSIX
lastUpdatedTimestamp) (\s :: ContactList
s@ContactList' {} Maybe POSIX
a -> ContactList
s {$sel:lastUpdatedTimestamp:ContactList' :: Maybe POSIX
lastUpdatedTimestamp = Maybe POSIX
a} :: ContactList) ((Maybe POSIX -> f (Maybe POSIX)) -> ContactList -> f ContactList)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ContactList
-> f ContactList
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

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

instance Prelude.Hashable ContactList

instance Prelude.NFData ContactList