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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SES.Types.Body
import Amazonka.SES.Types.Content

-- | Represents the message to be sent, composed of a subject and a body.
--
-- /See:/ 'newMessage' smart constructor.
data Message = Message'
  { -- | The subject of the message: A short summary of the content, which will
    -- appear in the recipient\'s inbox.
    Message -> Content
subject :: Content,
    -- | The message body.
    Message -> Body
body :: Body
  }
  deriving (Message -> Message -> Bool
(Message -> Message -> Bool)
-> (Message -> Message -> Bool) -> Eq Message
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Message -> Message -> Bool
$c/= :: Message -> Message -> Bool
== :: Message -> Message -> Bool
$c== :: Message -> Message -> Bool
Prelude.Eq, ReadPrec [Message]
ReadPrec Message
Int -> ReadS Message
ReadS [Message]
(Int -> ReadS Message)
-> ReadS [Message]
-> ReadPrec Message
-> ReadPrec [Message]
-> Read Message
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Message]
$creadListPrec :: ReadPrec [Message]
readPrec :: ReadPrec Message
$creadPrec :: ReadPrec Message
readList :: ReadS [Message]
$creadList :: ReadS [Message]
readsPrec :: Int -> ReadS Message
$creadsPrec :: Int -> ReadS Message
Prelude.Read, Int -> Message -> ShowS
[Message] -> ShowS
Message -> String
(Int -> Message -> ShowS)
-> (Message -> String) -> ([Message] -> ShowS) -> Show Message
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Message] -> ShowS
$cshowList :: [Message] -> ShowS
show :: Message -> String
$cshow :: Message -> String
showsPrec :: Int -> Message -> ShowS
$cshowsPrec :: Int -> Message -> ShowS
Prelude.Show, (forall x. Message -> Rep Message x)
-> (forall x. Rep Message x -> Message) -> Generic Message
forall x. Rep Message x -> Message
forall x. Message -> Rep Message x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Message x -> Message
$cfrom :: forall x. Message -> Rep Message x
Prelude.Generic)

-- |
-- Create a value of 'Message' 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:
--
-- 'subject', 'message_subject' - The subject of the message: A short summary of the content, which will
-- appear in the recipient\'s inbox.
--
-- 'body', 'message_body' - The message body.
newMessage ::
  -- | 'subject'
  Content ->
  -- | 'body'
  Body ->
  Message
newMessage :: Content -> Body -> Message
newMessage Content
pSubject_ Body
pBody_ =
  Message' :: Content -> Body -> Message
Message' {$sel:subject:Message' :: Content
subject = Content
pSubject_, $sel:body:Message' :: Body
body = Body
pBody_}

-- | The subject of the message: A short summary of the content, which will
-- appear in the recipient\'s inbox.
message_subject :: Lens.Lens' Message Content
message_subject :: (Content -> f Content) -> Message -> f Message
message_subject = (Message -> Content)
-> (Message -> Content -> Message)
-> Lens Message Message Content Content
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Content
subject :: Content
$sel:subject:Message' :: Message -> Content
subject} -> Content
subject) (\s :: Message
s@Message' {} Content
a -> Message
s {$sel:subject:Message' :: Content
subject = Content
a} :: Message)

-- | The message body.
message_body :: Lens.Lens' Message Body
message_body :: (Body -> f Body) -> Message -> f Message
message_body = (Message -> Body)
-> (Message -> Body -> Message) -> Lens Message Message Body Body
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Message' {Body
body :: Body
$sel:body:Message' :: Message -> Body
body} -> Body
body) (\s :: Message
s@Message' {} Body
a -> Message
s {$sel:body:Message' :: Body
body = Body
a} :: Message)

instance Prelude.Hashable Message

instance Prelude.NFData Message

instance Core.ToQuery Message where
  toQuery :: Message -> QueryString
toQuery Message' {Content
Body
body :: Body
subject :: Content
$sel:body:Message' :: Message -> Body
$sel:subject:Message' :: Message -> Content
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"Subject" ByteString -> Content -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Content
subject, ByteString
"Body" ByteString -> Body -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Body
body]