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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(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 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' :: 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 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 :: (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 content of the message itself.
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.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Charset" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
charset,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Data" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
data')
          ]
      )