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

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

-- | Represents the destination of the message, consisting of To:, CC:, and
-- BCC: fields.
--
-- Amazon SES does not support the SMTPUTF8 extension, as described in
-- <https://tools.ietf.org/html/rfc6531 RFC6531>. For this reason, the
-- /local part/ of a destination email address (the part of the email
-- address that precedes the \@ sign) may only contain
-- <https://en.wikipedia.org/wiki/Email_address#Local-part 7-bit ASCII characters>.
-- If the /domain part/ of an address (the part after the \@ sign) contains
-- non-ASCII characters, they must be encoded using Punycode, as described
-- in <https://tools.ietf.org/html/rfc3492.html RFC3492>.
--
-- /See:/ 'newDestination' smart constructor.
data Destination = Destination'
  { -- | The recipients to place on the BCC: line of the message.
    Destination -> Maybe [Text]
bccAddresses :: Prelude.Maybe [Prelude.Text],
    -- | The recipients to place on the CC: line of the message.
    Destination -> Maybe [Text]
ccAddresses :: Prelude.Maybe [Prelude.Text],
    -- | The recipients to place on the To: line of the message.
    Destination -> Maybe [Text]
toAddresses :: Prelude.Maybe [Prelude.Text]
  }
  deriving (Destination -> Destination -> Bool
(Destination -> Destination -> Bool)
-> (Destination -> Destination -> Bool) -> Eq Destination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Destination -> Destination -> Bool
$c/= :: Destination -> Destination -> Bool
== :: Destination -> Destination -> Bool
$c== :: Destination -> Destination -> Bool
Prelude.Eq, ReadPrec [Destination]
ReadPrec Destination
Int -> ReadS Destination
ReadS [Destination]
(Int -> ReadS Destination)
-> ReadS [Destination]
-> ReadPrec Destination
-> ReadPrec [Destination]
-> Read Destination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Destination]
$creadListPrec :: ReadPrec [Destination]
readPrec :: ReadPrec Destination
$creadPrec :: ReadPrec Destination
readList :: ReadS [Destination]
$creadList :: ReadS [Destination]
readsPrec :: Int -> ReadS Destination
$creadsPrec :: Int -> ReadS Destination
Prelude.Read, Int -> Destination -> ShowS
[Destination] -> ShowS
Destination -> String
(Int -> Destination -> ShowS)
-> (Destination -> String)
-> ([Destination] -> ShowS)
-> Show Destination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Destination] -> ShowS
$cshowList :: [Destination] -> ShowS
show :: Destination -> String
$cshow :: Destination -> String
showsPrec :: Int -> Destination -> ShowS
$cshowsPrec :: Int -> Destination -> ShowS
Prelude.Show, (forall x. Destination -> Rep Destination x)
-> (forall x. Rep Destination x -> Destination)
-> Generic Destination
forall x. Rep Destination x -> Destination
forall x. Destination -> Rep Destination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Destination x -> Destination
$cfrom :: forall x. Destination -> Rep Destination x
Prelude.Generic)

-- |
-- Create a value of 'Destination' 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:
--
-- 'bccAddresses', 'destination_bccAddresses' - The recipients to place on the BCC: line of the message.
--
-- 'ccAddresses', 'destination_ccAddresses' - The recipients to place on the CC: line of the message.
--
-- 'toAddresses', 'destination_toAddresses' - The recipients to place on the To: line of the message.
newDestination ::
  Destination
newDestination :: Destination
newDestination =
  Destination' :: Maybe [Text] -> Maybe [Text] -> Maybe [Text] -> Destination
Destination'
    { $sel:bccAddresses:Destination' :: Maybe [Text]
bccAddresses = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:ccAddresses:Destination' :: Maybe [Text]
ccAddresses = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:toAddresses:Destination' :: Maybe [Text]
toAddresses = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The recipients to place on the BCC: line of the message.
destination_bccAddresses :: Lens.Lens' Destination (Prelude.Maybe [Prelude.Text])
destination_bccAddresses :: (Maybe [Text] -> f (Maybe [Text])) -> Destination -> f Destination
destination_bccAddresses = (Destination -> Maybe [Text])
-> (Destination -> Maybe [Text] -> Destination)
-> Lens Destination Destination (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Destination' {Maybe [Text]
bccAddresses :: Maybe [Text]
$sel:bccAddresses:Destination' :: Destination -> Maybe [Text]
bccAddresses} -> Maybe [Text]
bccAddresses) (\s :: Destination
s@Destination' {} Maybe [Text]
a -> Destination
s {$sel:bccAddresses:Destination' :: Maybe [Text]
bccAddresses = Maybe [Text]
a} :: Destination) ((Maybe [Text] -> f (Maybe [Text]))
 -> Destination -> f Destination)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Destination
-> f Destination
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The recipients to place on the CC: line of the message.
destination_ccAddresses :: Lens.Lens' Destination (Prelude.Maybe [Prelude.Text])
destination_ccAddresses :: (Maybe [Text] -> f (Maybe [Text])) -> Destination -> f Destination
destination_ccAddresses = (Destination -> Maybe [Text])
-> (Destination -> Maybe [Text] -> Destination)
-> Lens Destination Destination (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Destination' {Maybe [Text]
ccAddresses :: Maybe [Text]
$sel:ccAddresses:Destination' :: Destination -> Maybe [Text]
ccAddresses} -> Maybe [Text]
ccAddresses) (\s :: Destination
s@Destination' {} Maybe [Text]
a -> Destination
s {$sel:ccAddresses:Destination' :: Maybe [Text]
ccAddresses = Maybe [Text]
a} :: Destination) ((Maybe [Text] -> f (Maybe [Text]))
 -> Destination -> f Destination)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Destination
-> f Destination
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The recipients to place on the To: line of the message.
destination_toAddresses :: Lens.Lens' Destination (Prelude.Maybe [Prelude.Text])
destination_toAddresses :: (Maybe [Text] -> f (Maybe [Text])) -> Destination -> f Destination
destination_toAddresses = (Destination -> Maybe [Text])
-> (Destination -> Maybe [Text] -> Destination)
-> Lens Destination Destination (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Destination' {Maybe [Text]
toAddresses :: Maybe [Text]
$sel:toAddresses:Destination' :: Destination -> Maybe [Text]
toAddresses} -> Maybe [Text]
toAddresses) (\s :: Destination
s@Destination' {} Maybe [Text]
a -> Destination
s {$sel:toAddresses:Destination' :: Maybe [Text]
toAddresses = Maybe [Text]
a} :: Destination) ((Maybe [Text] -> f (Maybe [Text]))
 -> Destination -> f Destination)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Destination
-> f Destination
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable Destination

instance Prelude.NFData Destination

instance Core.ToQuery Destination where
  toQuery :: Destination -> QueryString
toQuery Destination' {Maybe [Text]
toAddresses :: Maybe [Text]
ccAddresses :: Maybe [Text]
bccAddresses :: Maybe [Text]
$sel:toAddresses:Destination' :: Destination -> Maybe [Text]
$sel:ccAddresses:Destination' :: Destination -> Maybe [Text]
$sel:bccAddresses:Destination' :: Destination -> Maybe [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"BccAddresses"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
bccAddresses),
        ByteString
"CcAddresses"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
ccAddresses),
        ByteString
"ToAddresses"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
toAddresses)
      ]