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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 Core.Base64
  }
  deriving (RawEmail -> RawEmail -> Bool
(RawEmail -> RawEmail -> Bool)
-> (RawEmail -> RawEmail -> Bool) -> Eq RawEmail
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]
(Int -> ReadS RawEmail)
-> ReadS [RawEmail]
-> ReadPrec RawEmail
-> ReadPrec [RawEmail]
-> Read 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
(Int -> RawEmail -> ShowS)
-> (RawEmail -> String) -> ([RawEmail] -> ShowS) -> Show RawEmail
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. RawEmail -> Rep RawEmail x)
-> (forall x. Rep RawEmail x -> RawEmail) -> Generic RawEmail
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' :: Maybe Base64 -> RawEmail
RawEmail' {$sel:data':RawEmail' :: Maybe Base64
data' = Maybe Base64
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 :: (Maybe ByteString -> f (Maybe ByteString))
-> RawEmail -> f RawEmail
rawEmail_data = (RawEmail -> Maybe Base64)
-> (RawEmail -> Maybe Base64 -> RawEmail)
-> Lens RawEmail RawEmail (Maybe Base64) (Maybe Base64)
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) ((Maybe Base64 -> f (Maybe Base64)) -> RawEmail -> f RawEmail)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe Base64 -> f (Maybe Base64))
-> (Maybe ByteString -> f (Maybe ByteString))
-> RawEmail
-> f RawEmail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso Base64 Base64 ByteString ByteString
-> Iso
     (Maybe Base64) (Maybe Base64) (Maybe ByteString) (Maybe ByteString)
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 AnIso Base64 Base64 ByteString ByteString
Iso' Base64 ByteString
Core._Base64

instance Prelude.Hashable RawEmail

instance Prelude.NFData RawEmail

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