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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(Content -> Content -> Bool)
-> (Content -> Content -> Bool) -> Eq Content
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]
(Int -> ReadS Content)
-> ReadS [Content]
-> ReadPrec Content
-> ReadPrec [Content]
-> Read 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
(Int -> Content -> ShowS)
-> (Content -> String) -> ([Content] -> ShowS) -> Show Content
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. Content -> Rep Content x)
-> (forall x. Rep Content x -> Content) -> Generic Content
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' :: Maybe Text -> Text -> Content
Content' {$sel:charset:Content' :: Maybe Text
charset = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> Content -> f Content
content_charset = (Content -> Maybe Text)
-> (Content -> Maybe Text -> Content)
-> Lens Content Content (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> Content -> f Content
content_data = (Content -> Text)
-> (Content -> Text -> Content) -> Lens Content Content Text Text
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

instance Prelude.NFData Content

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"Charset" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
charset, ByteString
"Data" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
data']