{-# 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.Item
-- 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.ConnectParticipant.Types.Item where

import Amazonka.ConnectParticipant.Types.AttachmentItem
import Amazonka.ConnectParticipant.Types.ChatItemType
import Amazonka.ConnectParticipant.Types.ParticipantRole
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An item - message or event - that has been sent.
--
-- /See:/ 'newItem' smart constructor.
data Item = Item'
  { -- | The ID of the sender in the session.
    Item -> Maybe Text
participantId :: Prelude.Maybe Prelude.Text,
    -- | The time when the message or event was sent.
    --
    -- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
    -- example, 2019-11-08T02:41:28.172Z.
    Item -> Maybe Text
absoluteTime :: Prelude.Maybe Prelude.Text,
    -- | Provides information about the attachments.
    Item -> Maybe [AttachmentItem]
attachments :: Prelude.Maybe [AttachmentItem],
    -- | The role of the sender. For example, is it a customer, agent, or system.
    Item -> Maybe ParticipantRole
participantRole :: Prelude.Maybe ParticipantRole,
    -- | The content of the message or event.
    Item -> Maybe Text
content :: Prelude.Maybe Prelude.Text,
    -- | The ID of the item.
    Item -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The chat display name of the sender.
    Item -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | Type of the item: message or event.
    Item -> Maybe ChatItemType
type' :: Prelude.Maybe ChatItemType,
    -- | The type of content of the item.
    Item -> Maybe Text
contentType :: Prelude.Maybe Prelude.Text
  }
  deriving (Item -> Item -> Bool
(Item -> Item -> Bool) -> (Item -> Item -> Bool) -> Eq Item
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Item -> Item -> Bool
$c/= :: Item -> Item -> Bool
== :: Item -> Item -> Bool
$c== :: Item -> Item -> Bool
Prelude.Eq, ReadPrec [Item]
ReadPrec Item
Int -> ReadS Item
ReadS [Item]
(Int -> ReadS Item)
-> ReadS [Item] -> ReadPrec Item -> ReadPrec [Item] -> Read Item
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Item]
$creadListPrec :: ReadPrec [Item]
readPrec :: ReadPrec Item
$creadPrec :: ReadPrec Item
readList :: ReadS [Item]
$creadList :: ReadS [Item]
readsPrec :: Int -> ReadS Item
$creadsPrec :: Int -> ReadS Item
Prelude.Read, Int -> Item -> ShowS
[Item] -> ShowS
Item -> String
(Int -> Item -> ShowS)
-> (Item -> String) -> ([Item] -> ShowS) -> Show Item
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Item] -> ShowS
$cshowList :: [Item] -> ShowS
show :: Item -> String
$cshow :: Item -> String
showsPrec :: Int -> Item -> ShowS
$cshowsPrec :: Int -> Item -> ShowS
Prelude.Show, (forall x. Item -> Rep Item x)
-> (forall x. Rep Item x -> Item) -> Generic Item
forall x. Rep Item x -> Item
forall x. Item -> Rep Item x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Item x -> Item
$cfrom :: forall x. Item -> Rep Item x
Prelude.Generic)

-- |
-- Create a value of 'Item' 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:
--
-- 'participantId', 'item_participantId' - The ID of the sender in the session.
--
-- 'absoluteTime', 'item_absoluteTime' - The time when the message or event was sent.
--
-- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
-- example, 2019-11-08T02:41:28.172Z.
--
-- 'attachments', 'item_attachments' - Provides information about the attachments.
--
-- 'participantRole', 'item_participantRole' - The role of the sender. For example, is it a customer, agent, or system.
--
-- 'content', 'item_content' - The content of the message or event.
--
-- 'id', 'item_id' - The ID of the item.
--
-- 'displayName', 'item_displayName' - The chat display name of the sender.
--
-- 'type'', 'item_type' - Type of the item: message or event.
--
-- 'contentType', 'item_contentType' - The type of content of the item.
newItem ::
  Item
newItem :: Item
newItem =
  Item' :: Maybe Text
-> Maybe Text
-> Maybe [AttachmentItem]
-> Maybe ParticipantRole
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ChatItemType
-> Maybe Text
-> Item
Item'
    { $sel:participantId:Item' :: Maybe Text
participantId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:absoluteTime:Item' :: Maybe Text
absoluteTime = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attachments:Item' :: Maybe [AttachmentItem]
attachments = Maybe [AttachmentItem]
forall a. Maybe a
Prelude.Nothing,
      $sel:participantRole:Item' :: Maybe ParticipantRole
participantRole = Maybe ParticipantRole
forall a. Maybe a
Prelude.Nothing,
      $sel:content:Item' :: Maybe Text
content = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Item' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:displayName:Item' :: Maybe Text
displayName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Item' :: Maybe ChatItemType
type' = Maybe ChatItemType
forall a. Maybe a
Prelude.Nothing,
      $sel:contentType:Item' :: Maybe Text
contentType = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the sender in the session.
item_participantId :: Lens.Lens' Item (Prelude.Maybe Prelude.Text)
item_participantId :: (Maybe Text -> f (Maybe Text)) -> Item -> f Item
item_participantId = (Item -> Maybe Text)
-> (Item -> Maybe Text -> Item)
-> Lens Item Item (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Item' {Maybe Text
participantId :: Maybe Text
$sel:participantId:Item' :: Item -> Maybe Text
participantId} -> Maybe Text
participantId) (\s :: Item
s@Item' {} Maybe Text
a -> Item
s {$sel:participantId:Item' :: Maybe Text
participantId = Maybe Text
a} :: Item)

-- | The time when the message or event was sent.
--
-- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
-- example, 2019-11-08T02:41:28.172Z.
item_absoluteTime :: Lens.Lens' Item (Prelude.Maybe Prelude.Text)
item_absoluteTime :: (Maybe Text -> f (Maybe Text)) -> Item -> f Item
item_absoluteTime = (Item -> Maybe Text)
-> (Item -> Maybe Text -> Item)
-> Lens Item Item (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Item' {Maybe Text
absoluteTime :: Maybe Text
$sel:absoluteTime:Item' :: Item -> Maybe Text
absoluteTime} -> Maybe Text
absoluteTime) (\s :: Item
s@Item' {} Maybe Text
a -> Item
s {$sel:absoluteTime:Item' :: Maybe Text
absoluteTime = Maybe Text
a} :: Item)

-- | Provides information about the attachments.
item_attachments :: Lens.Lens' Item (Prelude.Maybe [AttachmentItem])
item_attachments :: (Maybe [AttachmentItem] -> f (Maybe [AttachmentItem]))
-> Item -> f Item
item_attachments = (Item -> Maybe [AttachmentItem])
-> (Item -> Maybe [AttachmentItem] -> Item)
-> Lens Item Item (Maybe [AttachmentItem]) (Maybe [AttachmentItem])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Item' {Maybe [AttachmentItem]
attachments :: Maybe [AttachmentItem]
$sel:attachments:Item' :: Item -> Maybe [AttachmentItem]
attachments} -> Maybe [AttachmentItem]
attachments) (\s :: Item
s@Item' {} Maybe [AttachmentItem]
a -> Item
s {$sel:attachments:Item' :: Maybe [AttachmentItem]
attachments = Maybe [AttachmentItem]
a} :: Item) ((Maybe [AttachmentItem] -> f (Maybe [AttachmentItem]))
 -> Item -> f Item)
-> ((Maybe [AttachmentItem] -> f (Maybe [AttachmentItem]))
    -> Maybe [AttachmentItem] -> f (Maybe [AttachmentItem]))
-> (Maybe [AttachmentItem] -> f (Maybe [AttachmentItem]))
-> Item
-> f Item
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AttachmentItem] [AttachmentItem] [AttachmentItem] [AttachmentItem]
-> Iso
     (Maybe [AttachmentItem])
     (Maybe [AttachmentItem])
     (Maybe [AttachmentItem])
     (Maybe [AttachmentItem])
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
  [AttachmentItem] [AttachmentItem] [AttachmentItem] [AttachmentItem]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The role of the sender. For example, is it a customer, agent, or system.
item_participantRole :: Lens.Lens' Item (Prelude.Maybe ParticipantRole)
item_participantRole :: (Maybe ParticipantRole -> f (Maybe ParticipantRole))
-> Item -> f Item
item_participantRole = (Item -> Maybe ParticipantRole)
-> (Item -> Maybe ParticipantRole -> Item)
-> Lens Item Item (Maybe ParticipantRole) (Maybe ParticipantRole)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Item' {Maybe ParticipantRole
participantRole :: Maybe ParticipantRole
$sel:participantRole:Item' :: Item -> Maybe ParticipantRole
participantRole} -> Maybe ParticipantRole
participantRole) (\s :: Item
s@Item' {} Maybe ParticipantRole
a -> Item
s {$sel:participantRole:Item' :: Maybe ParticipantRole
participantRole = Maybe ParticipantRole
a} :: Item)

-- | The content of the message or event.
item_content :: Lens.Lens' Item (Prelude.Maybe Prelude.Text)
item_content :: (Maybe Text -> f (Maybe Text)) -> Item -> f Item
item_content = (Item -> Maybe Text)
-> (Item -> Maybe Text -> Item)
-> Lens Item Item (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Item' {Maybe Text
content :: Maybe Text
$sel:content:Item' :: Item -> Maybe Text
content} -> Maybe Text
content) (\s :: Item
s@Item' {} Maybe Text
a -> Item
s {$sel:content:Item' :: Maybe Text
content = Maybe Text
a} :: Item)

-- | The ID of the item.
item_id :: Lens.Lens' Item (Prelude.Maybe Prelude.Text)
item_id :: (Maybe Text -> f (Maybe Text)) -> Item -> f Item
item_id = (Item -> Maybe Text)
-> (Item -> Maybe Text -> Item)
-> Lens Item Item (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Item' {Maybe Text
id :: Maybe Text
$sel:id:Item' :: Item -> Maybe Text
id} -> Maybe Text
id) (\s :: Item
s@Item' {} Maybe Text
a -> Item
s {$sel:id:Item' :: Maybe Text
id = Maybe Text
a} :: Item)

-- | The chat display name of the sender.
item_displayName :: Lens.Lens' Item (Prelude.Maybe Prelude.Text)
item_displayName :: (Maybe Text -> f (Maybe Text)) -> Item -> f Item
item_displayName = (Item -> Maybe Text)
-> (Item -> Maybe Text -> Item)
-> Lens Item Item (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Item' {Maybe Text
displayName :: Maybe Text
$sel:displayName:Item' :: Item -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: Item
s@Item' {} Maybe Text
a -> Item
s {$sel:displayName:Item' :: Maybe Text
displayName = Maybe Text
a} :: Item)

-- | Type of the item: message or event.
item_type :: Lens.Lens' Item (Prelude.Maybe ChatItemType)
item_type :: (Maybe ChatItemType -> f (Maybe ChatItemType)) -> Item -> f Item
item_type = (Item -> Maybe ChatItemType)
-> (Item -> Maybe ChatItemType -> Item)
-> Lens Item Item (Maybe ChatItemType) (Maybe ChatItemType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Item' {Maybe ChatItemType
type' :: Maybe ChatItemType
$sel:type':Item' :: Item -> Maybe ChatItemType
type'} -> Maybe ChatItemType
type') (\s :: Item
s@Item' {} Maybe ChatItemType
a -> Item
s {$sel:type':Item' :: Maybe ChatItemType
type' = Maybe ChatItemType
a} :: Item)

-- | The type of content of the item.
item_contentType :: Lens.Lens' Item (Prelude.Maybe Prelude.Text)
item_contentType :: (Maybe Text -> f (Maybe Text)) -> Item -> f Item
item_contentType = (Item -> Maybe Text)
-> (Item -> Maybe Text -> Item)
-> Lens Item Item (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Item' {Maybe Text
contentType :: Maybe Text
$sel:contentType:Item' :: Item -> Maybe Text
contentType} -> Maybe Text
contentType) (\s :: Item
s@Item' {} Maybe Text
a -> Item
s {$sel:contentType:Item' :: Maybe Text
contentType = Maybe Text
a} :: Item)

instance Core.FromJSON Item where
  parseJSON :: Value -> Parser Item
parseJSON =
    String -> (Object -> Parser Item) -> Value -> Parser Item
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Item"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe [AttachmentItem]
-> Maybe ParticipantRole
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ChatItemType
-> Maybe Text
-> Item
Item'
            (Maybe Text
 -> Maybe Text
 -> Maybe [AttachmentItem]
 -> Maybe ParticipantRole
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe ChatItemType
 -> Maybe Text
 -> Item)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe [AttachmentItem]
      -> Maybe ParticipantRole
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe ChatItemType
      -> Maybe Text
      -> Item)
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
"ParticipantId")
            Parser
  (Maybe Text
   -> Maybe [AttachmentItem]
   -> Maybe ParticipantRole
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe ChatItemType
   -> Maybe Text
   -> Item)
-> Parser (Maybe Text)
-> Parser
     (Maybe [AttachmentItem]
      -> Maybe ParticipantRole
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe ChatItemType
      -> Maybe Text
      -> Item)
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
"AbsoluteTime")
            Parser
  (Maybe [AttachmentItem]
   -> Maybe ParticipantRole
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe ChatItemType
   -> Maybe Text
   -> Item)
-> Parser (Maybe [AttachmentItem])
-> Parser
     (Maybe ParticipantRole
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe ChatItemType
      -> Maybe Text
      -> Item)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [AttachmentItem]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Attachments" Parser (Maybe (Maybe [AttachmentItem]))
-> Maybe [AttachmentItem] -> Parser (Maybe [AttachmentItem])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AttachmentItem]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe ParticipantRole
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe ChatItemType
   -> Maybe Text
   -> Item)
-> Parser (Maybe ParticipantRole)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe ChatItemType
      -> Maybe Text
      -> Item)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ParticipantRole)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ParticipantRole")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe ChatItemType
   -> Maybe Text
   -> Item)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe ChatItemType -> Maybe Text -> Item)
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
"Content")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe ChatItemType -> Maybe Text -> Item)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe ChatItemType -> Maybe Text -> Item)
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
"Id")
            Parser (Maybe Text -> Maybe ChatItemType -> Maybe Text -> Item)
-> Parser (Maybe Text)
-> Parser (Maybe ChatItemType -> Maybe Text -> Item)
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
"DisplayName")
            Parser (Maybe ChatItemType -> Maybe Text -> Item)
-> Parser (Maybe ChatItemType) -> Parser (Maybe Text -> Item)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ChatItemType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Maybe Text -> Item) -> Parser (Maybe Text) -> Parser Item
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
"ContentType")
      )

instance Prelude.Hashable Item

instance Prelude.NFData Item