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

-- | A chat message.
--
-- /See:/ 'newChatMessage' smart constructor.
data ChatMessage = ChatMessage'
  { -- | The type of the content. Supported types are @text\/plain@,
    -- @text\/markdown@, and @application\/json@.
    ChatMessage -> Text
contentType :: Prelude.Text,
    -- | The content of the chat message.
    --
    -- -   For @text\/plain@ and @text\/markdown@, the Length Constraints are
    --     Minimum of 1, Maximum of 1024.
    --
    -- -   For @application\/json@, the Length Constraints are Minimum of 1,
    --     Maximum of 12000.
    ChatMessage -> Text
content :: Prelude.Text
  }
  deriving (ChatMessage -> ChatMessage -> Bool
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]
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
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. 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\/plain@,
-- @text\/markdown@, and @application\/json@.
--
-- 'content', 'chatMessage_content' - The content of the chat message.
--
-- -   For @text\/plain@ and @text\/markdown@, the Length Constraints are
--     Minimum of 1, Maximum of 1024.
--
-- -   For @application\/json@, the Length Constraints are Minimum of 1,
--     Maximum of 12000.
newChatMessage ::
  -- | 'contentType'
  Prelude.Text ->
  -- | 'content'
  Prelude.Text ->
  ChatMessage
newChatMessage :: Text -> Text -> ChatMessage
newChatMessage Text
pContentType_ Text
pContent_ =
  ChatMessage'
    { $sel:contentType:ChatMessage' :: Text
contentType = Text
pContentType_,
      $sel:content:ChatMessage' :: Text
content = Text
pContent_
    }

-- | The type of the content. Supported types are @text\/plain@,
-- @text\/markdown@, and @application\/json@.
chatMessage_contentType :: Lens.Lens' ChatMessage Prelude.Text
chatMessage_contentType :: Lens' ChatMessage Text
chatMessage_contentType = 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.
--
-- -   For @text\/plain@ and @text\/markdown@, the Length Constraints are
--     Minimum of 1, Maximum of 1024.
--
-- -   For @application\/json@, the Length Constraints are Minimum of 1,
--     Maximum of 12000.
chatMessage_content :: Lens.Lens' ChatMessage Prelude.Text
chatMessage_content :: Lens' ChatMessage Text
chatMessage_content = 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 where
  hashWithSalt :: Int -> ChatMessage -> Int
hashWithSalt Int
_salt ChatMessage' {Text
content :: Text
contentType :: Text
$sel:content:ChatMessage' :: ChatMessage -> Text
$sel:contentType:ChatMessage' :: ChatMessage -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
contentType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
content

instance Prelude.NFData ChatMessage where
  rnf :: ChatMessage -> ()
rnf ChatMessage' {Text
content :: Text
contentType :: Text
$sel:content:ChatMessage' :: ChatMessage -> Text
$sel:contentType:ChatMessage' :: ChatMessage -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
contentType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
content

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"ContentType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
contentType),
            forall a. a -> Maybe a
Prelude.Just (Key
"Content" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
content)
          ]
      )