{-# 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-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.SSMContacts.Types.Receipt where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSMContacts.Types.ReceiptType

-- | Records events during an engagement.
--
-- /See:/ 'newReceipt' smart constructor.
data Receipt = Receipt'
  { -- | Information provided during the page acknowledgement.
    Receipt -> Maybe Text
receiptInfo :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the contact channel Incident Manager
    -- engaged.
    Receipt -> Maybe Text
contactChannelArn :: 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 :: Core.POSIX
  }
  deriving (Receipt -> Receipt -> Bool
(Receipt -> Receipt -> Bool)
-> (Receipt -> Receipt -> Bool) -> Eq Receipt
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]
(Int -> ReadS Receipt)
-> ReadS [Receipt]
-> ReadPrec Receipt
-> ReadPrec [Receipt]
-> Read 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
(Int -> Receipt -> ShowS)
-> (Receipt -> String) -> ([Receipt] -> ShowS) -> Show Receipt
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. Receipt -> Rep Receipt x)
-> (forall x. Rep Receipt x -> Receipt) -> Generic Receipt
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:
--
-- 'receiptInfo', 'receipt_receiptInfo' - Information provided during the page acknowledgement.
--
-- 'contactChannelArn', 'receipt_contactChannelArn' - The Amazon Resource Name (ARN) of the contact channel Incident Manager
-- engaged.
--
-- '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' :: Maybe Text -> Maybe Text -> ReceiptType -> POSIX -> Receipt
Receipt'
    { $sel:receiptInfo:Receipt' :: Maybe Text
receiptInfo = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contactChannelArn:Receipt' :: Maybe Text
contactChannelArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:receiptType:Receipt' :: ReceiptType
receiptType = ReceiptType
pReceiptType_,
      $sel:receiptTime:Receipt' :: POSIX
receiptTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pReceiptTime_
    }

-- | Information provided during the page acknowledgement.
receipt_receiptInfo :: Lens.Lens' Receipt (Prelude.Maybe Prelude.Text)
receipt_receiptInfo :: (Maybe Text -> f (Maybe Text)) -> Receipt -> f Receipt
receipt_receiptInfo = (Receipt -> Maybe Text)
-> (Receipt -> Maybe Text -> Receipt)
-> Lens Receipt Receipt (Maybe Text) (Maybe Text)
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 Amazon Resource Name (ARN) of the contact channel Incident Manager
-- engaged.
receipt_contactChannelArn :: Lens.Lens' Receipt (Prelude.Maybe Prelude.Text)
receipt_contactChannelArn :: (Maybe Text -> f (Maybe Text)) -> Receipt -> f Receipt
receipt_contactChannelArn = (Receipt -> Maybe Text)
-> (Receipt -> Maybe Text -> Receipt)
-> Lens Receipt Receipt (Maybe Text) (Maybe Text)
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)

-- | The type follows the engagement cycle, @SENT@, @DELIVERED@, and @READ@.
receipt_receiptType :: Lens.Lens' Receipt ReceiptType
receipt_receiptType :: (ReceiptType -> f ReceiptType) -> Receipt -> f Receipt
receipt_receiptType = (Receipt -> ReceiptType)
-> (Receipt -> ReceiptType -> Receipt)
-> Lens Receipt Receipt ReceiptType 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 :: (UTCTime -> f UTCTime) -> Receipt -> f Receipt
receipt_receiptTime = (Receipt -> POSIX)
-> (Receipt -> POSIX -> Receipt)
-> Lens Receipt Receipt POSIX POSIX
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) ((POSIX -> f POSIX) -> Receipt -> f Receipt)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> Receipt
-> f Receipt
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Prelude.Hashable Receipt

instance Prelude.NFData Receipt