{-# 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.RawMessage
-- 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.RawMessage 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

-- | Represents the raw data of the message.
--
-- /See:/ 'newRawMessage' smart constructor.
data RawMessage = RawMessage'
  { -- | The raw data of the message. This data needs to base64-encoded if you
    -- are accessing Amazon SES directly through the HTTPS interface. If you
    -- are accessing Amazon SES using an AWS SDK, the SDK takes care of the
    -- base 64-encoding for you. In all cases, the client must ensure that the
    -- message format complies with Internet email standards regarding email
    -- header fields, MIME types, and MIME encoding.
    --
    -- The To:, CC:, and BCC: headers in the raw message can contain a group
    -- list.
    --
    -- If you are using @SendRawEmail@ with sending authorization, you can
    -- include X-headers in the raw message to specify the \"Source,\"
    -- \"From,\" and \"Return-Path\" addresses. For more information, see the
    -- documentation for @SendRawEmail@.
    --
    -- Do not include these X-headers in the DKIM signature, because they are
    -- removed by Amazon SES before sending the email.
    --
    -- For more information, go to the
    -- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-raw.html Amazon SES Developer Guide>.
    RawMessage -> Base64
data' :: Data.Base64
  }
  deriving (RawMessage -> RawMessage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RawMessage -> RawMessage -> Bool
$c/= :: RawMessage -> RawMessage -> Bool
== :: RawMessage -> RawMessage -> Bool
$c== :: RawMessage -> RawMessage -> Bool
Prelude.Eq, ReadPrec [RawMessage]
ReadPrec RawMessage
Int -> ReadS RawMessage
ReadS [RawMessage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RawMessage]
$creadListPrec :: ReadPrec [RawMessage]
readPrec :: ReadPrec RawMessage
$creadPrec :: ReadPrec RawMessage
readList :: ReadS [RawMessage]
$creadList :: ReadS [RawMessage]
readsPrec :: Int -> ReadS RawMessage
$creadsPrec :: Int -> ReadS RawMessage
Prelude.Read, Int -> RawMessage -> ShowS
[RawMessage] -> ShowS
RawMessage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RawMessage] -> ShowS
$cshowList :: [RawMessage] -> ShowS
show :: RawMessage -> String
$cshow :: RawMessage -> String
showsPrec :: Int -> RawMessage -> ShowS
$cshowsPrec :: Int -> RawMessage -> ShowS
Prelude.Show, forall x. Rep RawMessage x -> RawMessage
forall x. RawMessage -> Rep RawMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RawMessage x -> RawMessage
$cfrom :: forall x. RawMessage -> Rep RawMessage x
Prelude.Generic)

-- |
-- Create a value of 'RawMessage' 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:
--
-- 'data'', 'rawMessage_data' - The raw data of the message. This data needs to base64-encoded if you
-- are accessing Amazon SES directly through the HTTPS interface. If you
-- are accessing Amazon SES using an AWS SDK, the SDK takes care of the
-- base 64-encoding for you. In all cases, the client must ensure that the
-- message format complies with Internet email standards regarding email
-- header fields, MIME types, and MIME encoding.
--
-- The To:, CC:, and BCC: headers in the raw message can contain a group
-- list.
--
-- If you are using @SendRawEmail@ with sending authorization, you can
-- include X-headers in the raw message to specify the \"Source,\"
-- \"From,\" and \"Return-Path\" addresses. For more information, see the
-- documentation for @SendRawEmail@.
--
-- Do not include these X-headers in the DKIM signature, because they are
-- removed by Amazon SES before sending the email.
--
-- For more information, go to the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-raw.html Amazon SES Developer Guide>.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
newRawMessage ::
  -- | 'data''
  Prelude.ByteString ->
  RawMessage
newRawMessage :: ByteString -> RawMessage
newRawMessage ByteString
pData_ =
  RawMessage' {$sel:data':RawMessage' :: Base64
data' = Iso' Base64 ByteString
Data._Base64 forall t b. AReview t b -> b -> t
Lens.# ByteString
pData_}

-- | The raw data of the message. This data needs to base64-encoded if you
-- are accessing Amazon SES directly through the HTTPS interface. If you
-- are accessing Amazon SES using an AWS SDK, the SDK takes care of the
-- base 64-encoding for you. In all cases, the client must ensure that the
-- message format complies with Internet email standards regarding email
-- header fields, MIME types, and MIME encoding.
--
-- The To:, CC:, and BCC: headers in the raw message can contain a group
-- list.
--
-- If you are using @SendRawEmail@ with sending authorization, you can
-- include X-headers in the raw message to specify the \"Source,\"
-- \"From,\" and \"Return-Path\" addresses. For more information, see the
-- documentation for @SendRawEmail@.
--
-- Do not include these X-headers in the DKIM signature, because they are
-- removed by Amazon SES before sending the email.
--
-- For more information, go to the
-- <https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-raw.html Amazon SES Developer Guide>.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
rawMessage_data :: Lens.Lens' RawMessage Prelude.ByteString
rawMessage_data :: Lens' RawMessage ByteString
rawMessage_data = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RawMessage' {Base64
data' :: Base64
$sel:data':RawMessage' :: RawMessage -> Base64
data'} -> Base64
data') (\s :: RawMessage
s@RawMessage' {} Base64
a -> RawMessage
s {$sel:data':RawMessage' :: Base64
data' = Base64
a} :: RawMessage) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64

instance Prelude.Hashable RawMessage where
  hashWithSalt :: Int -> RawMessage -> Int
hashWithSalt Int
_salt RawMessage' {Base64
data' :: Base64
$sel:data':RawMessage' :: RawMessage -> Base64
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Base64
data'

instance Prelude.NFData RawMessage where
  rnf :: RawMessage -> ()
rnf RawMessage' {Base64
data' :: Base64
$sel:data':RawMessage' :: RawMessage -> Base64
..} = forall a. NFData a => a -> ()
Prelude.rnf Base64
data'

instance Data.ToQuery RawMessage where
  toQuery :: RawMessage -> QueryString
toQuery RawMessage' {Base64
data' :: Base64
$sel:data':RawMessage' :: RawMessage -> Base64
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"Data" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Base64
data']