{-# 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.SSMContacts.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.SSMContacts.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
import Amazonka.SSMContacts.Types.ReceiptType

-- | Records events during an engagement.
--
-- /See:/ 'newReceipt' smart constructor.
data Receipt = Receipt'
  { -- | The Amazon Resource Name (ARN) of the contact channel Incident Manager
    -- engaged.
    Receipt -> Maybe Text
contactChannelArn :: Prelude.Maybe Prelude.Text,
    -- | Information provided during the page acknowledgement.
    Receipt -> Maybe Text
receiptInfo :: Prelude.Maybe Prelude.Text,
    -- | The type follows the engagement cycle, @SENT@, @DELIVERED@, and @READ@.
    Receipt -> ReceiptType
receiptType :: ReceiptType,
    -- | The time receipt was @SENT@, @DELIVERED@, or @READ@.
    Receipt -> POSIX
receiptTime :: Data.POSIX
  }
  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:
--
-- 'contactChannelArn', 'receipt_contactChannelArn' - The Amazon Resource Name (ARN) of the contact channel Incident Manager
-- engaged.
--
-- 'receiptInfo', 'receipt_receiptInfo' - Information provided during the page acknowledgement.
--
-- 'receiptType', 'receipt_receiptType' - The type follows the engagement cycle, @SENT@, @DELIVERED@, and @READ@.
--
-- 'receiptTime', 'receipt_receiptTime' - The time receipt was @SENT@, @DELIVERED@, or @READ@.
newReceipt ::
  -- | 'receiptType'
  ReceiptType ->
  -- | 'receiptTime'
  Prelude.UTCTime ->
  Receipt
newReceipt :: ReceiptType -> UTCTime -> Receipt
newReceipt ReceiptType
pReceiptType_ UTCTime
pReceiptTime_ =
  Receipt'
    { $sel:contactChannelArn:Receipt' :: Maybe Text
contactChannelArn = forall a. Maybe a
Prelude.Nothing,
      $sel:receiptInfo:Receipt' :: Maybe Text
receiptInfo = forall a. Maybe a
Prelude.Nothing,
      $sel:receiptType:Receipt' :: ReceiptType
receiptType = ReceiptType
pReceiptType_,
      $sel:receiptTime:Receipt' :: POSIX
receiptTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pReceiptTime_
    }

-- | The Amazon Resource Name (ARN) of the contact channel Incident Manager
-- engaged.
receipt_contactChannelArn :: Lens.Lens' Receipt (Prelude.Maybe Prelude.Text)
receipt_contactChannelArn :: Lens' Receipt (Maybe Text)
receipt_contactChannelArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Receipt' {Maybe Text
contactChannelArn :: Maybe Text
$sel:contactChannelArn:Receipt' :: Receipt -> Maybe Text
contactChannelArn} -> Maybe Text
contactChannelArn) (\s :: Receipt
s@Receipt' {} Maybe Text
a -> Receipt
s {$sel:contactChannelArn:Receipt' :: Maybe Text
contactChannelArn = Maybe Text
a} :: Receipt)

-- | Information provided during the page acknowledgement.
receipt_receiptInfo :: Lens.Lens' Receipt (Prelude.Maybe Prelude.Text)
receipt_receiptInfo :: Lens' Receipt (Maybe Text)
receipt_receiptInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Receipt' {Maybe Text
receiptInfo :: Maybe Text
$sel:receiptInfo:Receipt' :: Receipt -> Maybe Text
receiptInfo} -> Maybe Text
receiptInfo) (\s :: Receipt
s@Receipt' {} Maybe Text
a -> Receipt
s {$sel:receiptInfo:Receipt' :: Maybe Text
receiptInfo = Maybe Text
a} :: Receipt)

-- | The type follows the engagement cycle, @SENT@, @DELIVERED@, and @READ@.
receipt_receiptType :: Lens.Lens' Receipt ReceiptType
receipt_receiptType :: Lens' Receipt ReceiptType
receipt_receiptType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Receipt' {ReceiptType
receiptType :: ReceiptType
$sel:receiptType:Receipt' :: Receipt -> ReceiptType
receiptType} -> ReceiptType
receiptType) (\s :: Receipt
s@Receipt' {} ReceiptType
a -> Receipt
s {$sel:receiptType:Receipt' :: ReceiptType
receiptType = ReceiptType
a} :: Receipt)

-- | The time receipt was @SENT@, @DELIVERED@, or @READ@.
receipt_receiptTime :: Lens.Lens' Receipt Prelude.UTCTime
receipt_receiptTime :: Lens' Receipt UTCTime
receipt_receiptTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Receipt' {POSIX
receiptTime :: POSIX
$sel:receiptTime:Receipt' :: Receipt -> POSIX
receiptTime} -> POSIX
receiptTime) (\s :: Receipt
s@Receipt' {} POSIX
a -> Receipt
s {$sel:receiptTime:Receipt' :: POSIX
receiptTime = POSIX
a} :: Receipt) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

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 -> ReceiptType -> POSIX -> 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
"ContactChannelArn")
            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
"ReceiptInfo")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ReceiptType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ReceiptTime")
      )

instance Prelude.Hashable Receipt where
  hashWithSalt :: Int -> Receipt -> Int
hashWithSalt Int
_salt Receipt' {Maybe Text
POSIX
ReceiptType
receiptTime :: POSIX
receiptType :: ReceiptType
receiptInfo :: Maybe Text
contactChannelArn :: Maybe Text
$sel:receiptTime:Receipt' :: Receipt -> POSIX
$sel:receiptType:Receipt' :: Receipt -> ReceiptType
$sel:receiptInfo:Receipt' :: Receipt -> Maybe Text
$sel:contactChannelArn:Receipt' :: Receipt -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
contactChannelArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
receiptInfo
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ReceiptType
receiptType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
receiptTime

instance Prelude.NFData Receipt where
  rnf :: Receipt -> ()
rnf Receipt' {Maybe Text
POSIX
ReceiptType
receiptTime :: POSIX
receiptType :: ReceiptType
receiptInfo :: Maybe Text
contactChannelArn :: Maybe Text
$sel:receiptTime:Receipt' :: Receipt -> POSIX
$sel:receiptType:Receipt' :: Receipt -> ReceiptType
$sel:receiptInfo:Receipt' :: Receipt -> Maybe Text
$sel:contactChannelArn:Receipt' :: Receipt -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contactChannelArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
receiptInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ReceiptType
receiptType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
receiptTime