{-# 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.ConnectParticipant.Types.Receipt
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ConnectParticipant.Types.Receipt where

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

-- | The receipt for the message delivered to the recipient.
--
-- /See:/ 'newReceipt' smart constructor.
data Receipt = Receipt'
  { -- | The time when the message was delivered to the recipient.
    Receipt -> Maybe Text
deliveredTimestamp :: Prelude.Maybe Prelude.Text,
    -- | The time when the message was read by the recipient.
    Receipt -> Maybe Text
readTimestamp :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the recipient of the message.
    Receipt -> Maybe Text
recipientParticipantId :: Prelude.Maybe Prelude.Text
  }
  deriving (Receipt -> Receipt -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Receipt -> Receipt -> Bool
$c/= :: Receipt -> Receipt -> Bool
== :: Receipt -> Receipt -> Bool
$c== :: Receipt -> Receipt -> Bool
Prelude.Eq, ReadPrec [Receipt]
ReadPrec Receipt
Int -> ReadS Receipt
ReadS [Receipt]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Receipt]
$creadListPrec :: ReadPrec [Receipt]
readPrec :: ReadPrec Receipt
$creadPrec :: ReadPrec Receipt
readList :: ReadS [Receipt]
$creadList :: ReadS [Receipt]
readsPrec :: Int -> ReadS Receipt
$creadsPrec :: Int -> ReadS Receipt
Prelude.Read, Int -> Receipt -> ShowS
[Receipt] -> ShowS
Receipt -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Receipt] -> ShowS
$cshowList :: [Receipt] -> ShowS
show :: Receipt -> String
$cshow :: Receipt -> String
showsPrec :: Int -> Receipt -> ShowS
$cshowsPrec :: Int -> Receipt -> ShowS
Prelude.Show, forall x. Rep Receipt x -> Receipt
forall x. Receipt -> Rep Receipt x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Receipt x -> Receipt
$cfrom :: forall x. Receipt -> Rep Receipt x
Prelude.Generic)

-- |
-- Create a value of 'Receipt' 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:
--
-- 'deliveredTimestamp', 'receipt_deliveredTimestamp' - The time when the message was delivered to the recipient.
--
-- 'readTimestamp', 'receipt_readTimestamp' - The time when the message was read by the recipient.
--
-- 'recipientParticipantId', 'receipt_recipientParticipantId' - The identifier of the recipient of the message.
newReceipt ::
  Receipt
newReceipt :: Receipt
newReceipt =
  Receipt'
    { $sel:deliveredTimestamp:Receipt' :: Maybe Text
deliveredTimestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:readTimestamp:Receipt' :: Maybe Text
readTimestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:recipientParticipantId:Receipt' :: Maybe Text
recipientParticipantId = forall a. Maybe a
Prelude.Nothing
    }

-- | The time when the message was delivered to the recipient.
receipt_deliveredTimestamp :: Lens.Lens' Receipt (Prelude.Maybe Prelude.Text)
receipt_deliveredTimestamp :: Lens' Receipt (Maybe Text)
receipt_deliveredTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Receipt' {Maybe Text
deliveredTimestamp :: Maybe Text
$sel:deliveredTimestamp:Receipt' :: Receipt -> Maybe Text
deliveredTimestamp} -> Maybe Text
deliveredTimestamp) (\s :: Receipt
s@Receipt' {} Maybe Text
a -> Receipt
s {$sel:deliveredTimestamp:Receipt' :: Maybe Text
deliveredTimestamp = Maybe Text
a} :: Receipt)

-- | The time when the message was read by the recipient.
receipt_readTimestamp :: Lens.Lens' Receipt (Prelude.Maybe Prelude.Text)
receipt_readTimestamp :: Lens' Receipt (Maybe Text)
receipt_readTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Receipt' {Maybe Text
readTimestamp :: Maybe Text
$sel:readTimestamp:Receipt' :: Receipt -> Maybe Text
readTimestamp} -> Maybe Text
readTimestamp) (\s :: Receipt
s@Receipt' {} Maybe Text
a -> Receipt
s {$sel:readTimestamp:Receipt' :: Maybe Text
readTimestamp = Maybe Text
a} :: Receipt)

-- | The identifier of the recipient of the message.
receipt_recipientParticipantId :: Lens.Lens' Receipt (Prelude.Maybe Prelude.Text)
receipt_recipientParticipantId :: Lens' Receipt (Maybe Text)
receipt_recipientParticipantId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Receipt' {Maybe Text
recipientParticipantId :: Maybe Text
$sel:recipientParticipantId:Receipt' :: Receipt -> Maybe Text
recipientParticipantId} -> Maybe Text
recipientParticipantId) (\s :: Receipt
s@Receipt' {} Maybe Text
a -> Receipt
s {$sel:recipientParticipantId:Receipt' :: Maybe Text
recipientParticipantId = Maybe Text
a} :: Receipt)

instance Data.FromJSON Receipt where
  parseJSON :: Value -> Parser Receipt
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Receipt"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> Receipt
Receipt'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DeliveredTimestamp")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ReadTimestamp")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RecipientParticipantId")
      )

instance Prelude.Hashable Receipt where
  hashWithSalt :: Int -> Receipt -> Int
hashWithSalt Int
_salt Receipt' {Maybe Text
recipientParticipantId :: Maybe Text
readTimestamp :: Maybe Text
deliveredTimestamp :: Maybe Text
$sel:recipientParticipantId:Receipt' :: Receipt -> Maybe Text
$sel:readTimestamp:Receipt' :: Receipt -> Maybe Text
$sel:deliveredTimestamp:Receipt' :: Receipt -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
deliveredTimestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
readTimestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
recipientParticipantId

instance Prelude.NFData Receipt where
  rnf :: Receipt -> ()
rnf Receipt' {Maybe Text
recipientParticipantId :: Maybe Text
readTimestamp :: Maybe Text
deliveredTimestamp :: Maybe Text
$sel:recipientParticipantId:Receipt' :: Receipt -> Maybe Text
$sel:readTimestamp:Receipt' :: Receipt -> Maybe Text
$sel:deliveredTimestamp:Receipt' :: Receipt -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
deliveredTimestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
readTimestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
recipientParticipantId