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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the subject or body of an email message, represented as
-- textual email data and the applicable character set.
--
-- /See:/ 'newSimpleEmailPart' smart constructor.
data SimpleEmailPart = SimpleEmailPart'
  { -- | The textual data of the message content.
    SimpleEmailPart -> Maybe Text
data' :: Prelude.Maybe Prelude.Text,
    -- | The applicable character set for the message content.
    SimpleEmailPart -> Maybe Text
charset :: Prelude.Maybe Prelude.Text
  }
  deriving (SimpleEmailPart -> SimpleEmailPart -> Bool
(SimpleEmailPart -> SimpleEmailPart -> Bool)
-> (SimpleEmailPart -> SimpleEmailPart -> Bool)
-> Eq SimpleEmailPart
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SimpleEmailPart -> SimpleEmailPart -> Bool
$c/= :: SimpleEmailPart -> SimpleEmailPart -> Bool
== :: SimpleEmailPart -> SimpleEmailPart -> Bool
$c== :: SimpleEmailPart -> SimpleEmailPart -> Bool
Prelude.Eq, ReadPrec [SimpleEmailPart]
ReadPrec SimpleEmailPart
Int -> ReadS SimpleEmailPart
ReadS [SimpleEmailPart]
(Int -> ReadS SimpleEmailPart)
-> ReadS [SimpleEmailPart]
-> ReadPrec SimpleEmailPart
-> ReadPrec [SimpleEmailPart]
-> Read SimpleEmailPart
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SimpleEmailPart]
$creadListPrec :: ReadPrec [SimpleEmailPart]
readPrec :: ReadPrec SimpleEmailPart
$creadPrec :: ReadPrec SimpleEmailPart
readList :: ReadS [SimpleEmailPart]
$creadList :: ReadS [SimpleEmailPart]
readsPrec :: Int -> ReadS SimpleEmailPart
$creadsPrec :: Int -> ReadS SimpleEmailPart
Prelude.Read, Int -> SimpleEmailPart -> ShowS
[SimpleEmailPart] -> ShowS
SimpleEmailPart -> String
(Int -> SimpleEmailPart -> ShowS)
-> (SimpleEmailPart -> String)
-> ([SimpleEmailPart] -> ShowS)
-> Show SimpleEmailPart
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SimpleEmailPart] -> ShowS
$cshowList :: [SimpleEmailPart] -> ShowS
show :: SimpleEmailPart -> String
$cshow :: SimpleEmailPart -> String
showsPrec :: Int -> SimpleEmailPart -> ShowS
$cshowsPrec :: Int -> SimpleEmailPart -> ShowS
Prelude.Show, (forall x. SimpleEmailPart -> Rep SimpleEmailPart x)
-> (forall x. Rep SimpleEmailPart x -> SimpleEmailPart)
-> Generic SimpleEmailPart
forall x. Rep SimpleEmailPart x -> SimpleEmailPart
forall x. SimpleEmailPart -> Rep SimpleEmailPart x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SimpleEmailPart x -> SimpleEmailPart
$cfrom :: forall x. SimpleEmailPart -> Rep SimpleEmailPart x
Prelude.Generic)

-- |
-- Create a value of 'SimpleEmailPart' 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'', 'simpleEmailPart_data' - The textual data of the message content.
--
-- 'charset', 'simpleEmailPart_charset' - The applicable character set for the message content.
newSimpleEmailPart ::
  SimpleEmailPart
newSimpleEmailPart :: SimpleEmailPart
newSimpleEmailPart =
  SimpleEmailPart' :: Maybe Text -> Maybe Text -> SimpleEmailPart
SimpleEmailPart'
    { $sel:data':SimpleEmailPart' :: Maybe Text
data' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:charset:SimpleEmailPart' :: Maybe Text
charset = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The textual data of the message content.
simpleEmailPart_data :: Lens.Lens' SimpleEmailPart (Prelude.Maybe Prelude.Text)
simpleEmailPart_data :: (Maybe Text -> f (Maybe Text))
-> SimpleEmailPart -> f SimpleEmailPart
simpleEmailPart_data = (SimpleEmailPart -> Maybe Text)
-> (SimpleEmailPart -> Maybe Text -> SimpleEmailPart)
-> Lens SimpleEmailPart SimpleEmailPart (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleEmailPart' {Maybe Text
data' :: Maybe Text
$sel:data':SimpleEmailPart' :: SimpleEmailPart -> Maybe Text
data'} -> Maybe Text
data') (\s :: SimpleEmailPart
s@SimpleEmailPart' {} Maybe Text
a -> SimpleEmailPart
s {$sel:data':SimpleEmailPart' :: Maybe Text
data' = Maybe Text
a} :: SimpleEmailPart)

-- | The applicable character set for the message content.
simpleEmailPart_charset :: Lens.Lens' SimpleEmailPart (Prelude.Maybe Prelude.Text)
simpleEmailPart_charset :: (Maybe Text -> f (Maybe Text))
-> SimpleEmailPart -> f SimpleEmailPart
simpleEmailPart_charset = (SimpleEmailPart -> Maybe Text)
-> (SimpleEmailPart -> Maybe Text -> SimpleEmailPart)
-> Lens SimpleEmailPart SimpleEmailPart (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimpleEmailPart' {Maybe Text
charset :: Maybe Text
$sel:charset:SimpleEmailPart' :: SimpleEmailPart -> Maybe Text
charset} -> Maybe Text
charset) (\s :: SimpleEmailPart
s@SimpleEmailPart' {} Maybe Text
a -> SimpleEmailPart
s {$sel:charset:SimpleEmailPart' :: Maybe Text
charset = Maybe Text
a} :: SimpleEmailPart)

instance Prelude.Hashable SimpleEmailPart

instance Prelude.NFData SimpleEmailPart

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