{-# 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.SES.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.SES.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

-- | Represents textual data, plus an optional character set specification.
--
-- By default, the text must be 7-bit ASCII, due to the constraints of the
-- SMTP protocol. If the text must contain any other characters, then you
-- must also specify a character set. Examples include UTF-8, ISO-8859-1,
-- and Shift_JIS.
--
-- /See:/ 'newContent' smart constructor.
data Content = Content'
  { -- | The character set of the content.
    Content -> Maybe Text
charset :: Prelude.Maybe Prelude.Text,
    -- | The textual data of the content.
    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 of the content.
--
-- 'data'', 'content_data' - The textual data of the content.
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 of the content.
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 textual data of the content.
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.ToQuery Content where
  toQuery :: Content -> QueryString
toQuery Content' {Maybe Text
Text
data' :: Text
charset :: Maybe Text
$sel:data':Content' :: Content -> Text
$sel:charset:Content' :: Content -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"Charset" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
charset, ByteString
"Data" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
data']