{-# 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.Connect.Types.ChatMessage
-- 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.Connect.Types.ChatMessage where

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

-- | A chat message.
--
-- /See:/ 'newChatMessage' smart constructor.
data ChatMessage = ChatMessage'
  { -- | The type of the content. Supported types are text and plain.
    ChatMessage -> Text
contentType :: Prelude.Text,
    -- | The content of the chat message.
    ChatMessage -> Text
content :: Prelude.Text
  }
  deriving (ChatMessage -> ChatMessage -> Bool
(ChatMessage -> ChatMessage -> Bool)
-> (ChatMessage -> ChatMessage -> Bool) -> Eq ChatMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChatMessage -> ChatMessage -> Bool
$c/= :: ChatMessage -> ChatMessage -> Bool
== :: ChatMessage -> ChatMessage -> Bool
$c== :: ChatMessage -> ChatMessage -> Bool
Prelude.Eq, ReadPrec [ChatMessage]
ReadPrec ChatMessage
Int -> ReadS ChatMessage
ReadS [ChatMessage]
(Int -> ReadS ChatMessage)
-> ReadS [ChatMessage]
-> ReadPrec ChatMessage
-> ReadPrec [ChatMessage]
-> Read ChatMessage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChatMessage]
$creadListPrec :: ReadPrec [ChatMessage]
readPrec :: ReadPrec ChatMessage
$creadPrec :: ReadPrec ChatMessage
readList :: ReadS [ChatMessage]
$creadList :: ReadS [ChatMessage]
readsPrec :: Int -> ReadS ChatMessage
$creadsPrec :: Int -> ReadS ChatMessage
Prelude.Read, Int -> ChatMessage -> ShowS
[ChatMessage] -> ShowS
ChatMessage -> String
(Int -> ChatMessage -> ShowS)
-> (ChatMessage -> String)
-> ([ChatMessage] -> ShowS)
-> Show ChatMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChatMessage] -> ShowS
$cshowList :: [ChatMessage] -> ShowS
show :: ChatMessage -> String
$cshow :: ChatMessage -> String
showsPrec :: Int -> ChatMessage -> ShowS
$cshowsPrec :: Int -> ChatMessage -> ShowS
Prelude.Show, (forall x. ChatMessage -> Rep ChatMessage x)
-> (forall x. Rep ChatMessage x -> ChatMessage)
-> Generic ChatMessage
forall x. Rep ChatMessage x -> ChatMessage
forall x. ChatMessage -> Rep ChatMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChatMessage x -> ChatMessage
$cfrom :: forall x. ChatMessage -> Rep ChatMessage x
Prelude.Generic)

-- |
-- Create a value of 'ChatMessage' 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:
--
-- 'contentType', 'chatMessage_contentType' - The type of the content. Supported types are text and plain.
--
-- 'content', 'chatMessage_content' - The content of the chat message.
newChatMessage ::
  -- | 'contentType'
  Prelude.Text ->
  -- | 'content'
  Prelude.Text ->
  ChatMessage
newChatMessage :: Text -> Text -> ChatMessage
newChatMessage Text
pContentType_ Text
pContent_ =
  ChatMessage' :: Text -> Text -> ChatMessage
ChatMessage'
    { $sel:contentType:ChatMessage' :: Text
contentType = Text
pContentType_,
      $sel:content:ChatMessage' :: Text
content = Text
pContent_
    }

-- | The type of the content. Supported types are text and plain.
chatMessage_contentType :: Lens.Lens' ChatMessage Prelude.Text
chatMessage_contentType :: (Text -> f Text) -> ChatMessage -> f ChatMessage
chatMessage_contentType = (ChatMessage -> Text)
-> (ChatMessage -> Text -> ChatMessage)
-> Lens ChatMessage ChatMessage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChatMessage' {Text
contentType :: Text
$sel:contentType:ChatMessage' :: ChatMessage -> Text
contentType} -> Text
contentType) (\s :: ChatMessage
s@ChatMessage' {} Text
a -> ChatMessage
s {$sel:contentType:ChatMessage' :: Text
contentType = Text
a} :: ChatMessage)

-- | The content of the chat message.
chatMessage_content :: Lens.Lens' ChatMessage Prelude.Text
chatMessage_content :: (Text -> f Text) -> ChatMessage -> f ChatMessage
chatMessage_content = (ChatMessage -> Text)
-> (ChatMessage -> Text -> ChatMessage)
-> Lens ChatMessage ChatMessage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChatMessage' {Text
content :: Text
$sel:content:ChatMessage' :: ChatMessage -> Text
content} -> Text
content) (\s :: ChatMessage
s@ChatMessage' {} Text
a -> ChatMessage
s {$sel:content:ChatMessage' :: Text
content = Text
a} :: ChatMessage)

instance Prelude.Hashable ChatMessage

instance Prelude.NFData ChatMessage

instance Core.ToJSON ChatMessage where
  toJSON :: ChatMessage -> Value
toJSON ChatMessage' {Text
content :: Text
contentType :: Text
$sel:content:ChatMessage' :: ChatMessage -> Text
$sel:contentType:ChatMessage' :: ChatMessage -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ContentType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contentType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Content" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
content)
          ]
      )