{-# 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.Pinpoint.Types.RawEmail
-- 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.Pinpoint.Types.RawEmail 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

-- | Specifies the contents of an email message, represented as a raw MIME
-- message.
--
-- /See:/ 'newRawEmail' smart constructor.
data RawEmail = RawEmail'
  { -- | The email message, represented as a raw MIME message. The entire message
    -- must be base64 encoded.
    RawEmail -> Maybe Base64
data' :: Prelude.Maybe Data.Base64
  }
  deriving (RawEmail -> RawEmail -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RawEmail -> RawEmail -> Bool
$c/= :: RawEmail -> RawEmail -> Bool
== :: RawEmail -> RawEmail -> Bool
$c== :: RawEmail -> RawEmail -> Bool
Prelude.Eq, ReadPrec [RawEmail]
ReadPrec RawEmail
Int -> ReadS RawEmail
ReadS [RawEmail]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RawEmail]
$creadListPrec :: ReadPrec [RawEmail]
readPrec :: ReadPrec RawEmail
$creadPrec :: ReadPrec RawEmail
readList :: ReadS [RawEmail]
$creadList :: ReadS [RawEmail]
readsPrec :: Int -> ReadS RawEmail
$creadsPrec :: Int -> ReadS RawEmail
Prelude.Read, Int -> RawEmail -> ShowS
[RawEmail] -> ShowS
RawEmail -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RawEmail] -> ShowS
$cshowList :: [RawEmail] -> ShowS
show :: RawEmail -> String
$cshow :: RawEmail -> String
showsPrec :: Int -> RawEmail -> ShowS
$cshowsPrec :: Int -> RawEmail -> ShowS
Prelude.Show, forall x. Rep RawEmail x -> RawEmail
forall x. RawEmail -> Rep RawEmail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RawEmail x -> RawEmail
$cfrom :: forall x. RawEmail -> Rep RawEmail x
Prelude.Generic)

-- |
-- Create a value of 'RawEmail' 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'', 'rawEmail_data' - The email message, represented as a raw MIME message. The entire message
-- must be base64 encoded.--
-- -- /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.
newRawEmail ::
  RawEmail
newRawEmail :: RawEmail
newRawEmail = RawEmail' {$sel:data':RawEmail' :: Maybe Base64
data' = forall a. Maybe a
Prelude.Nothing}

-- | The email message, represented as a raw MIME message. The entire message
-- must be base64 encoded.--
-- -- /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.
rawEmail_data :: Lens.Lens' RawEmail (Prelude.Maybe Prelude.ByteString)
rawEmail_data :: Lens' RawEmail (Maybe ByteString)
rawEmail_data = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RawEmail' {Maybe Base64
data' :: Maybe Base64
$sel:data':RawEmail' :: RawEmail -> Maybe Base64
data'} -> Maybe Base64
data') (\s :: RawEmail
s@RawEmail' {} Maybe Base64
a -> RawEmail
s {$sel:data':RawEmail' :: Maybe Base64
data' = Maybe Base64
a} :: RawEmail) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping Iso' Base64 ByteString
Data._Base64

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

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

instance Data.ToJSON RawEmail where
  toJSON :: RawEmail -> Value
toJSON RawEmail' {Maybe Base64
data' :: Maybe Base64
$sel:data':RawEmail' :: RawEmail -> Maybe Base64
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Data" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Base64
data']
      )