{-# 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.Body
-- 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.Body 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
import Amazonka.SES.Types.Content

-- | Represents the body of the message. You can specify text, HTML, or both.
-- If you use both, then the message should display correctly in the widest
-- variety of email clients.
--
-- /See:/ 'newBody' smart constructor.
data Body = Body'
  { -- | The content of the message, in HTML format. Use this for email clients
    -- that can process HTML. You can include clickable links, formatted text,
    -- and much more in an HTML message.
    Body -> Maybe Content
html :: Prelude.Maybe Content,
    -- | The content of the message, in text format. Use this for text-based
    -- email clients, or clients on high-latency networks (such as mobile
    -- devices).
    Body -> Maybe Content
text :: Prelude.Maybe Content
  }
  deriving (Body -> Body -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Body -> Body -> Bool
$c/= :: Body -> Body -> Bool
== :: Body -> Body -> Bool
$c== :: Body -> Body -> Bool
Prelude.Eq, ReadPrec [Body]
ReadPrec Body
Int -> ReadS Body
ReadS [Body]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Body]
$creadListPrec :: ReadPrec [Body]
readPrec :: ReadPrec Body
$creadPrec :: ReadPrec Body
readList :: ReadS [Body]
$creadList :: ReadS [Body]
readsPrec :: Int -> ReadS Body
$creadsPrec :: Int -> ReadS Body
Prelude.Read, Int -> Body -> ShowS
[Body] -> ShowS
Body -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Body] -> ShowS
$cshowList :: [Body] -> ShowS
show :: Body -> String
$cshow :: Body -> String
showsPrec :: Int -> Body -> ShowS
$cshowsPrec :: Int -> Body -> ShowS
Prelude.Show, forall x. Rep Body x -> Body
forall x. Body -> Rep Body x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Body x -> Body
$cfrom :: forall x. Body -> Rep Body x
Prelude.Generic)

-- |
-- Create a value of 'Body' 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:
--
-- 'html', 'body_html' - The content of the message, in HTML format. Use this for email clients
-- that can process HTML. You can include clickable links, formatted text,
-- and much more in an HTML message.
--
-- 'text', 'body_text' - The content of the message, in text format. Use this for text-based
-- email clients, or clients on high-latency networks (such as mobile
-- devices).
newBody ::
  Body
newBody :: Body
newBody =
  Body'
    { $sel:html:Body' :: Maybe Content
html = forall a. Maybe a
Prelude.Nothing,
      $sel:text:Body' :: Maybe Content
text = forall a. Maybe a
Prelude.Nothing
    }

-- | The content of the message, in HTML format. Use this for email clients
-- that can process HTML. You can include clickable links, formatted text,
-- and much more in an HTML message.
body_html :: Lens.Lens' Body (Prelude.Maybe Content)
body_html :: Lens' Body (Maybe Content)
body_html = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Body' {Maybe Content
html :: Maybe Content
$sel:html:Body' :: Body -> Maybe Content
html} -> Maybe Content
html) (\s :: Body
s@Body' {} Maybe Content
a -> Body
s {$sel:html:Body' :: Maybe Content
html = Maybe Content
a} :: Body)

-- | The content of the message, in text format. Use this for text-based
-- email clients, or clients on high-latency networks (such as mobile
-- devices).
body_text :: Lens.Lens' Body (Prelude.Maybe Content)
body_text :: Lens' Body (Maybe Content)
body_text = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Body' {Maybe Content
text :: Maybe Content
$sel:text:Body' :: Body -> Maybe Content
text} -> Maybe Content
text) (\s :: Body
s@Body' {} Maybe Content
a -> Body
s {$sel:text:Body' :: Maybe Content
text = Maybe Content
a} :: Body)

instance Prelude.Hashable Body where
  hashWithSalt :: Int -> Body -> Int
hashWithSalt Int
_salt Body' {Maybe Content
text :: Maybe Content
html :: Maybe Content
$sel:text:Body' :: Body -> Maybe Content
$sel:html:Body' :: Body -> Maybe Content
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Content
html
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Content
text

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

instance Data.ToQuery Body where
  toQuery :: Body -> QueryString
toQuery Body' {Maybe Content
text :: Maybe Content
html :: Maybe Content
$sel:text:Body' :: Body -> Maybe Content
$sel:html:Body' :: Body -> Maybe Content
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"Html" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Content
html, ByteString
"Text" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Content
text]