{-# 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.ConnectCases.Types.CommentContent
-- 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.ConnectCases.Types.CommentContent where

import Amazonka.ConnectCases.Types.CommentBodyTextType
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

-- | Represents the content of a @Comment@ to be returned to agents.
--
-- /See:/ 'newCommentContent' smart constructor.
data CommentContent = CommentContent'
  { -- | Text in the body of a @Comment@ on a case.
    CommentContent -> Text
body :: Prelude.Text,
    -- | Type of the text in the box of a @Comment@ on a case.
    CommentContent -> CommentBodyTextType
contentType :: CommentBodyTextType
  }
  deriving (CommentContent -> CommentContent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CommentContent -> CommentContent -> Bool
$c/= :: CommentContent -> CommentContent -> Bool
== :: CommentContent -> CommentContent -> Bool
$c== :: CommentContent -> CommentContent -> Bool
Prelude.Eq, ReadPrec [CommentContent]
ReadPrec CommentContent
Int -> ReadS CommentContent
ReadS [CommentContent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CommentContent]
$creadListPrec :: ReadPrec [CommentContent]
readPrec :: ReadPrec CommentContent
$creadPrec :: ReadPrec CommentContent
readList :: ReadS [CommentContent]
$creadList :: ReadS [CommentContent]
readsPrec :: Int -> ReadS CommentContent
$creadsPrec :: Int -> ReadS CommentContent
Prelude.Read, Int -> CommentContent -> ShowS
[CommentContent] -> ShowS
CommentContent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CommentContent] -> ShowS
$cshowList :: [CommentContent] -> ShowS
show :: CommentContent -> String
$cshow :: CommentContent -> String
showsPrec :: Int -> CommentContent -> ShowS
$cshowsPrec :: Int -> CommentContent -> ShowS
Prelude.Show, forall x. Rep CommentContent x -> CommentContent
forall x. CommentContent -> Rep CommentContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CommentContent x -> CommentContent
$cfrom :: forall x. CommentContent -> Rep CommentContent x
Prelude.Generic)

-- |
-- Create a value of 'CommentContent' 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:
--
-- 'body', 'commentContent_body' - Text in the body of a @Comment@ on a case.
--
-- 'contentType', 'commentContent_contentType' - Type of the text in the box of a @Comment@ on a case.
newCommentContent ::
  -- | 'body'
  Prelude.Text ->
  -- | 'contentType'
  CommentBodyTextType ->
  CommentContent
newCommentContent :: Text -> CommentBodyTextType -> CommentContent
newCommentContent Text
pBody_ CommentBodyTextType
pContentType_ =
  CommentContent'
    { $sel:body:CommentContent' :: Text
body = Text
pBody_,
      $sel:contentType:CommentContent' :: CommentBodyTextType
contentType = CommentBodyTextType
pContentType_
    }

-- | Text in the body of a @Comment@ on a case.
commentContent_body :: Lens.Lens' CommentContent Prelude.Text
commentContent_body :: Lens' CommentContent Text
commentContent_body = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommentContent' {Text
body :: Text
$sel:body:CommentContent' :: CommentContent -> Text
body} -> Text
body) (\s :: CommentContent
s@CommentContent' {} Text
a -> CommentContent
s {$sel:body:CommentContent' :: Text
body = Text
a} :: CommentContent)

-- | Type of the text in the box of a @Comment@ on a case.
commentContent_contentType :: Lens.Lens' CommentContent CommentBodyTextType
commentContent_contentType :: Lens' CommentContent CommentBodyTextType
commentContent_contentType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommentContent' {CommentBodyTextType
contentType :: CommentBodyTextType
$sel:contentType:CommentContent' :: CommentContent -> CommentBodyTextType
contentType} -> CommentBodyTextType
contentType) (\s :: CommentContent
s@CommentContent' {} CommentBodyTextType
a -> CommentContent
s {$sel:contentType:CommentContent' :: CommentBodyTextType
contentType = CommentBodyTextType
a} :: CommentContent)

instance Data.FromJSON CommentContent where
  parseJSON :: Value -> Parser CommentContent
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CommentContent"
      ( \Object
x ->
          Text -> CommentBodyTextType -> CommentContent
CommentContent'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"body")
            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
"contentType")
      )

instance Prelude.Hashable CommentContent where
  hashWithSalt :: Int -> CommentContent -> Int
hashWithSalt Int
_salt CommentContent' {Text
CommentBodyTextType
contentType :: CommentBodyTextType
body :: Text
$sel:contentType:CommentContent' :: CommentContent -> CommentBodyTextType
$sel:body:CommentContent' :: CommentContent -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
body
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CommentBodyTextType
contentType

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

instance Data.ToJSON CommentContent where
  toJSON :: CommentContent -> Value
toJSON CommentContent' {Text
CommentBodyTextType
contentType :: CommentBodyTextType
body :: Text
$sel:contentType:CommentContent' :: CommentContent -> CommentBodyTextType
$sel:body:CommentContent' :: CommentContent -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"body" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
body),
            forall a. a -> Maybe a
Prelude.Just (Key
"contentType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= CommentBodyTextType
contentType)
          ]
      )