{-# 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.PinpointEmail.Types.Content
-- 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.PinpointEmail.Types.Content 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

-- | An object that represents the content of the email, and optionally a
-- character set specification.
--
-- /See:/ 'newContent' smart constructor.
data Content = Content'
  { -- | The character set for the content. Because of the constraints of the
    -- SMTP protocol, Amazon Pinpoint uses 7-bit ASCII by default. If the text
    -- includes characters outside of the ASCII range, you have to specify a
    -- character set. For example, you could specify @UTF-8@, @ISO-8859-1@, or
    -- @Shift_JIS@.
    Content -> Maybe Text
charset :: Prelude.Maybe Prelude.Text,
    -- | The content of the message itself.
    Content -> Text
data' :: Prelude.Text
  }
  deriving (Content -> Content -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Content -> Content -> Bool
$c/= :: Content -> Content -> Bool
== :: Content -> Content -> Bool
$c== :: Content -> Content -> Bool
Prelude.Eq, ReadPrec [Content]
ReadPrec Content
Int -> ReadS Content
ReadS [Content]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Content]
$creadListPrec :: ReadPrec [Content]
readPrec :: ReadPrec Content
$creadPrec :: ReadPrec Content
readList :: ReadS [Content]
$creadList :: ReadS [Content]
readsPrec :: Int -> ReadS Content
$creadsPrec :: Int -> ReadS Content
Prelude.Read, Int -> Content -> ShowS
[Content] -> ShowS
Content -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Content] -> ShowS
$cshowList :: [Content] -> ShowS
show :: Content -> String
$cshow :: Content -> String
showsPrec :: Int -> Content -> ShowS
$cshowsPrec :: Int -> Content -> ShowS
Prelude.Show, forall x. Rep Content x -> Content
forall x. Content -> Rep Content x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Content x -> Content
$cfrom :: forall x. Content -> Rep Content x
Prelude.Generic)

-- |
-- Create a value of 'Content' 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:
--
-- 'charset', 'content_charset' - The character set for the content. Because of the constraints of the
-- SMTP protocol, Amazon Pinpoint uses 7-bit ASCII by default. If the text
-- includes characters outside of the ASCII range, you have to specify a
-- character set. For example, you could specify @UTF-8@, @ISO-8859-1@, or
-- @Shift_JIS@.
--
-- 'data'', 'content_data' - The content of the message itself.
newContent ::
  -- | 'data''
  Prelude.Text ->
  Content
newContent :: Text -> Content
newContent Text
pData_ =
  Content' {$sel:charset:Content' :: Maybe Text
charset = forall a. Maybe a
Prelude.Nothing, $sel:data':Content' :: Text
data' = Text
pData_}

-- | The character set for the content. Because of the constraints of the
-- SMTP protocol, Amazon Pinpoint uses 7-bit ASCII by default. If the text
-- includes characters outside of the ASCII range, you have to specify a
-- character set. For example, you could specify @UTF-8@, @ISO-8859-1@, or
-- @Shift_JIS@.
content_charset :: Lens.Lens' Content (Prelude.Maybe Prelude.Text)
content_charset :: Lens' Content (Maybe Text)
content_charset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Content' {Maybe Text
charset :: Maybe Text
$sel:charset:Content' :: Content -> Maybe Text
charset} -> Maybe Text
charset) (\s :: Content
s@Content' {} Maybe Text
a -> Content
s {$sel:charset:Content' :: Maybe Text
charset = Maybe Text
a} :: Content)

-- | The content of the message itself.
content_data :: Lens.Lens' Content Prelude.Text
content_data :: Lens' Content Text
content_data = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Content' {Text
data' :: Text
$sel:data':Content' :: Content -> Text
data'} -> Text
data') (\s :: Content
s@Content' {} Text
a -> Content
s {$sel:data':Content' :: Text
data' = Text
a} :: Content)

instance Prelude.Hashable Content where
  hashWithSalt :: Int -> Content -> Int
hashWithSalt Int
_salt Content' {Maybe Text
Text
data' :: Text
charset :: Maybe Text
$sel:data':Content' :: Content -> Text
$sel:charset:Content' :: Content -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
charset
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
data'

instance Prelude.NFData Content where
  rnf :: Content -> ()
rnf Content' {Maybe Text
Text
data' :: Text
charset :: Maybe Text
$sel:data':Content' :: Content -> Text
$sel:charset:Content' :: Content -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
charset seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
data'

instance Data.ToJSON Content where
  toJSON :: Content -> Value
toJSON Content' {Maybe Text
Text
data' :: Text
charset :: Maybe Text
$sel:data':Content' :: Content -> Text
$sel:charset:Content' :: Content -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Charset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
charset,
            forall a. a -> Maybe a
Prelude.Just (Key
"Data" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
data')
          ]
      )