{-# 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-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.Body where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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
  }
  deriving (Body -> Body -> Bool
(Body -> Body -> Bool) -> (Body -> Body -> Bool) -> Eq Body
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]
(Int -> ReadS Body)
-> ReadS [Body] -> ReadPrec Body -> ReadPrec [Body] -> Read 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
(Int -> Body -> ShowS)
-> (Body -> String) -> ([Body] -> ShowS) -> Show Body
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. Body -> Rep Body x)
-> (forall x. Rep Body x -> Body) -> Generic Body
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:
--
-- '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).
--
-- '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.
newBody ::
  Body
newBody :: Body
newBody =
  Body' :: Maybe Content -> Maybe Content -> Body
Body'
    { $sel:text:Body' :: Maybe Content
text = Maybe Content
forall a. Maybe a
Prelude.Nothing,
      $sel:html:Body' :: Maybe Content
html = Maybe Content
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Content -> f (Maybe Content)) -> Body -> f Body
body_text = (Body -> Maybe Content)
-> (Body -> Maybe Content -> Body)
-> Lens Body Body (Maybe Content) (Maybe Content)
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)

-- | 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 :: (Maybe Content -> f (Maybe Content)) -> Body -> f Body
body_html = (Body -> Maybe Content)
-> (Body -> Maybe Content -> Body)
-> Lens Body Body (Maybe Content) (Maybe Content)
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)

instance Prelude.Hashable Body

instance Prelude.NFData Body

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