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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.DirectMessageConfiguration
import Amazonka.Pinpoint.Types.EndpointSendConfiguration
import Amazonka.Pinpoint.Types.TemplateConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Specifies the configuration and other settings for a message to send to
-- all the endpoints that are associated with a list of users.
--
-- /See:/ 'newSendUsersMessageRequest' smart constructor.
data SendUsersMessageRequest = SendUsersMessageRequest'
  { -- | The unique identifier for tracing the message. This identifier is
    -- visible to message recipients.
    SendUsersMessageRequest -> Maybe Text
traceId :: Prelude.Maybe Prelude.Text,
    -- | A map of custom attribute-value pairs. For a push notification, Amazon
    -- Pinpoint adds these attributes to the data.pinpoint object in the body
    -- of the notification payload. Amazon Pinpoint also provides these
    -- attributes in the events that it generates for users-messages
    -- deliveries.
    SendUsersMessageRequest -> Maybe (HashMap Text Text)
context :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The message template to use for the message.
    SendUsersMessageRequest -> Maybe TemplateConfiguration
templateConfiguration :: Prelude.Maybe TemplateConfiguration,
    -- | The settings and content for the default message and any default
    -- messages that you defined for specific channels.
    SendUsersMessageRequest -> DirectMessageConfiguration
messageConfiguration :: DirectMessageConfiguration,
    -- | A map that associates user IDs with
    -- <https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html#apps-application-id-messages-model-endpointsendconfiguration EndpointSendConfiguration>
    -- objects. You can use an
    -- <https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html#apps-application-id-messages-model-endpointsendconfiguration EndpointSendConfiguration>
    -- object to tailor the message for a user by specifying settings such as
    -- content overrides and message variables.
    SendUsersMessageRequest -> HashMap Text EndpointSendConfiguration
users :: Prelude.HashMap Prelude.Text EndpointSendConfiguration
  }
  deriving (SendUsersMessageRequest -> SendUsersMessageRequest -> Bool
(SendUsersMessageRequest -> SendUsersMessageRequest -> Bool)
-> (SendUsersMessageRequest -> SendUsersMessageRequest -> Bool)
-> Eq SendUsersMessageRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendUsersMessageRequest -> SendUsersMessageRequest -> Bool
$c/= :: SendUsersMessageRequest -> SendUsersMessageRequest -> Bool
== :: SendUsersMessageRequest -> SendUsersMessageRequest -> Bool
$c== :: SendUsersMessageRequest -> SendUsersMessageRequest -> Bool
Prelude.Eq, ReadPrec [SendUsersMessageRequest]
ReadPrec SendUsersMessageRequest
Int -> ReadS SendUsersMessageRequest
ReadS [SendUsersMessageRequest]
(Int -> ReadS SendUsersMessageRequest)
-> ReadS [SendUsersMessageRequest]
-> ReadPrec SendUsersMessageRequest
-> ReadPrec [SendUsersMessageRequest]
-> Read SendUsersMessageRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendUsersMessageRequest]
$creadListPrec :: ReadPrec [SendUsersMessageRequest]
readPrec :: ReadPrec SendUsersMessageRequest
$creadPrec :: ReadPrec SendUsersMessageRequest
readList :: ReadS [SendUsersMessageRequest]
$creadList :: ReadS [SendUsersMessageRequest]
readsPrec :: Int -> ReadS SendUsersMessageRequest
$creadsPrec :: Int -> ReadS SendUsersMessageRequest
Prelude.Read, Int -> SendUsersMessageRequest -> ShowS
[SendUsersMessageRequest] -> ShowS
SendUsersMessageRequest -> String
(Int -> SendUsersMessageRequest -> ShowS)
-> (SendUsersMessageRequest -> String)
-> ([SendUsersMessageRequest] -> ShowS)
-> Show SendUsersMessageRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendUsersMessageRequest] -> ShowS
$cshowList :: [SendUsersMessageRequest] -> ShowS
show :: SendUsersMessageRequest -> String
$cshow :: SendUsersMessageRequest -> String
showsPrec :: Int -> SendUsersMessageRequest -> ShowS
$cshowsPrec :: Int -> SendUsersMessageRequest -> ShowS
Prelude.Show, (forall x.
 SendUsersMessageRequest -> Rep SendUsersMessageRequest x)
-> (forall x.
    Rep SendUsersMessageRequest x -> SendUsersMessageRequest)
-> Generic SendUsersMessageRequest
forall x. Rep SendUsersMessageRequest x -> SendUsersMessageRequest
forall x. SendUsersMessageRequest -> Rep SendUsersMessageRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendUsersMessageRequest x -> SendUsersMessageRequest
$cfrom :: forall x. SendUsersMessageRequest -> Rep SendUsersMessageRequest x
Prelude.Generic)

-- |
-- Create a value of 'SendUsersMessageRequest' 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:
--
-- 'traceId', 'sendUsersMessageRequest_traceId' - The unique identifier for tracing the message. This identifier is
-- visible to message recipients.
--
-- 'context', 'sendUsersMessageRequest_context' - A map of custom attribute-value pairs. For a push notification, Amazon
-- Pinpoint adds these attributes to the data.pinpoint object in the body
-- of the notification payload. Amazon Pinpoint also provides these
-- attributes in the events that it generates for users-messages
-- deliveries.
--
-- 'templateConfiguration', 'sendUsersMessageRequest_templateConfiguration' - The message template to use for the message.
--
-- 'messageConfiguration', 'sendUsersMessageRequest_messageConfiguration' - The settings and content for the default message and any default
-- messages that you defined for specific channels.
--
-- 'users', 'sendUsersMessageRequest_users' - A map that associates user IDs with
-- <https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html#apps-application-id-messages-model-endpointsendconfiguration EndpointSendConfiguration>
-- objects. You can use an
-- <https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html#apps-application-id-messages-model-endpointsendconfiguration EndpointSendConfiguration>
-- object to tailor the message for a user by specifying settings such as
-- content overrides and message variables.
newSendUsersMessageRequest ::
  -- | 'messageConfiguration'
  DirectMessageConfiguration ->
  SendUsersMessageRequest
newSendUsersMessageRequest :: DirectMessageConfiguration -> SendUsersMessageRequest
newSendUsersMessageRequest DirectMessageConfiguration
pMessageConfiguration_ =
  SendUsersMessageRequest' :: Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe TemplateConfiguration
-> DirectMessageConfiguration
-> HashMap Text EndpointSendConfiguration
-> SendUsersMessageRequest
SendUsersMessageRequest'
    { $sel:traceId:SendUsersMessageRequest' :: Maybe Text
traceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:context:SendUsersMessageRequest' :: Maybe (HashMap Text Text)
context = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:templateConfiguration:SendUsersMessageRequest' :: Maybe TemplateConfiguration
templateConfiguration = Maybe TemplateConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:messageConfiguration:SendUsersMessageRequest' :: DirectMessageConfiguration
messageConfiguration = DirectMessageConfiguration
pMessageConfiguration_,
      $sel:users:SendUsersMessageRequest' :: HashMap Text EndpointSendConfiguration
users = HashMap Text EndpointSendConfiguration
forall a. Monoid a => a
Prelude.mempty
    }

-- | The unique identifier for tracing the message. This identifier is
-- visible to message recipients.
sendUsersMessageRequest_traceId :: Lens.Lens' SendUsersMessageRequest (Prelude.Maybe Prelude.Text)
sendUsersMessageRequest_traceId :: (Maybe Text -> f (Maybe Text))
-> SendUsersMessageRequest -> f SendUsersMessageRequest
sendUsersMessageRequest_traceId = (SendUsersMessageRequest -> Maybe Text)
-> (SendUsersMessageRequest
    -> Maybe Text -> SendUsersMessageRequest)
-> Lens
     SendUsersMessageRequest
     SendUsersMessageRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendUsersMessageRequest' {Maybe Text
traceId :: Maybe Text
$sel:traceId:SendUsersMessageRequest' :: SendUsersMessageRequest -> Maybe Text
traceId} -> Maybe Text
traceId) (\s :: SendUsersMessageRequest
s@SendUsersMessageRequest' {} Maybe Text
a -> SendUsersMessageRequest
s {$sel:traceId:SendUsersMessageRequest' :: Maybe Text
traceId = Maybe Text
a} :: SendUsersMessageRequest)

-- | A map of custom attribute-value pairs. For a push notification, Amazon
-- Pinpoint adds these attributes to the data.pinpoint object in the body
-- of the notification payload. Amazon Pinpoint also provides these
-- attributes in the events that it generates for users-messages
-- deliveries.
sendUsersMessageRequest_context :: Lens.Lens' SendUsersMessageRequest (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
sendUsersMessageRequest_context :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> SendUsersMessageRequest -> f SendUsersMessageRequest
sendUsersMessageRequest_context = (SendUsersMessageRequest -> Maybe (HashMap Text Text))
-> (SendUsersMessageRequest
    -> Maybe (HashMap Text Text) -> SendUsersMessageRequest)
-> Lens
     SendUsersMessageRequest
     SendUsersMessageRequest
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendUsersMessageRequest' {Maybe (HashMap Text Text)
context :: Maybe (HashMap Text Text)
$sel:context:SendUsersMessageRequest' :: SendUsersMessageRequest -> Maybe (HashMap Text Text)
context} -> Maybe (HashMap Text Text)
context) (\s :: SendUsersMessageRequest
s@SendUsersMessageRequest' {} Maybe (HashMap Text Text)
a -> SendUsersMessageRequest
s {$sel:context:SendUsersMessageRequest' :: Maybe (HashMap Text Text)
context = Maybe (HashMap Text Text)
a} :: SendUsersMessageRequest) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> SendUsersMessageRequest -> f SendUsersMessageRequest)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> SendUsersMessageRequest
-> f SendUsersMessageRequest
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The message template to use for the message.
sendUsersMessageRequest_templateConfiguration :: Lens.Lens' SendUsersMessageRequest (Prelude.Maybe TemplateConfiguration)
sendUsersMessageRequest_templateConfiguration :: (Maybe TemplateConfiguration -> f (Maybe TemplateConfiguration))
-> SendUsersMessageRequest -> f SendUsersMessageRequest
sendUsersMessageRequest_templateConfiguration = (SendUsersMessageRequest -> Maybe TemplateConfiguration)
-> (SendUsersMessageRequest
    -> Maybe TemplateConfiguration -> SendUsersMessageRequest)
-> Lens
     SendUsersMessageRequest
     SendUsersMessageRequest
     (Maybe TemplateConfiguration)
     (Maybe TemplateConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendUsersMessageRequest' {Maybe TemplateConfiguration
templateConfiguration :: Maybe TemplateConfiguration
$sel:templateConfiguration:SendUsersMessageRequest' :: SendUsersMessageRequest -> Maybe TemplateConfiguration
templateConfiguration} -> Maybe TemplateConfiguration
templateConfiguration) (\s :: SendUsersMessageRequest
s@SendUsersMessageRequest' {} Maybe TemplateConfiguration
a -> SendUsersMessageRequest
s {$sel:templateConfiguration:SendUsersMessageRequest' :: Maybe TemplateConfiguration
templateConfiguration = Maybe TemplateConfiguration
a} :: SendUsersMessageRequest)

-- | The settings and content for the default message and any default
-- messages that you defined for specific channels.
sendUsersMessageRequest_messageConfiguration :: Lens.Lens' SendUsersMessageRequest DirectMessageConfiguration
sendUsersMessageRequest_messageConfiguration :: (DirectMessageConfiguration -> f DirectMessageConfiguration)
-> SendUsersMessageRequest -> f SendUsersMessageRequest
sendUsersMessageRequest_messageConfiguration = (SendUsersMessageRequest -> DirectMessageConfiguration)
-> (SendUsersMessageRequest
    -> DirectMessageConfiguration -> SendUsersMessageRequest)
-> Lens
     SendUsersMessageRequest
     SendUsersMessageRequest
     DirectMessageConfiguration
     DirectMessageConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendUsersMessageRequest' {DirectMessageConfiguration
messageConfiguration :: DirectMessageConfiguration
$sel:messageConfiguration:SendUsersMessageRequest' :: SendUsersMessageRequest -> DirectMessageConfiguration
messageConfiguration} -> DirectMessageConfiguration
messageConfiguration) (\s :: SendUsersMessageRequest
s@SendUsersMessageRequest' {} DirectMessageConfiguration
a -> SendUsersMessageRequest
s {$sel:messageConfiguration:SendUsersMessageRequest' :: DirectMessageConfiguration
messageConfiguration = DirectMessageConfiguration
a} :: SendUsersMessageRequest)

-- | A map that associates user IDs with
-- <https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html#apps-application-id-messages-model-endpointsendconfiguration EndpointSendConfiguration>
-- objects. You can use an
-- <https://docs.aws.amazon.com/pinpoint/latest/apireference/apps-application-id-messages.html#apps-application-id-messages-model-endpointsendconfiguration EndpointSendConfiguration>
-- object to tailor the message for a user by specifying settings such as
-- content overrides and message variables.
sendUsersMessageRequest_users :: Lens.Lens' SendUsersMessageRequest (Prelude.HashMap Prelude.Text EndpointSendConfiguration)
sendUsersMessageRequest_users :: (HashMap Text EndpointSendConfiguration
 -> f (HashMap Text EndpointSendConfiguration))
-> SendUsersMessageRequest -> f SendUsersMessageRequest
sendUsersMessageRequest_users = (SendUsersMessageRequest -> HashMap Text EndpointSendConfiguration)
-> (SendUsersMessageRequest
    -> HashMap Text EndpointSendConfiguration
    -> SendUsersMessageRequest)
-> Lens
     SendUsersMessageRequest
     SendUsersMessageRequest
     (HashMap Text EndpointSendConfiguration)
     (HashMap Text EndpointSendConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendUsersMessageRequest' {HashMap Text EndpointSendConfiguration
users :: HashMap Text EndpointSendConfiguration
$sel:users:SendUsersMessageRequest' :: SendUsersMessageRequest -> HashMap Text EndpointSendConfiguration
users} -> HashMap Text EndpointSendConfiguration
users) (\s :: SendUsersMessageRequest
s@SendUsersMessageRequest' {} HashMap Text EndpointSendConfiguration
a -> SendUsersMessageRequest
s {$sel:users:SendUsersMessageRequest' :: HashMap Text EndpointSendConfiguration
users = HashMap Text EndpointSendConfiguration
a} :: SendUsersMessageRequest) ((HashMap Text EndpointSendConfiguration
  -> f (HashMap Text EndpointSendConfiguration))
 -> SendUsersMessageRequest -> f SendUsersMessageRequest)
-> ((HashMap Text EndpointSendConfiguration
     -> f (HashMap Text EndpointSendConfiguration))
    -> HashMap Text EndpointSendConfiguration
    -> f (HashMap Text EndpointSendConfiguration))
-> (HashMap Text EndpointSendConfiguration
    -> f (HashMap Text EndpointSendConfiguration))
-> SendUsersMessageRequest
-> f SendUsersMessageRequest
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text EndpointSendConfiguration
 -> f (HashMap Text EndpointSendConfiguration))
-> HashMap Text EndpointSendConfiguration
-> f (HashMap Text EndpointSendConfiguration)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable SendUsersMessageRequest

instance Prelude.NFData SendUsersMessageRequest

instance Core.ToJSON SendUsersMessageRequest where
  toJSON :: SendUsersMessageRequest -> Value
toJSON SendUsersMessageRequest' {Maybe Text
Maybe (HashMap Text Text)
Maybe TemplateConfiguration
HashMap Text EndpointSendConfiguration
DirectMessageConfiguration
users :: HashMap Text EndpointSendConfiguration
messageConfiguration :: DirectMessageConfiguration
templateConfiguration :: Maybe TemplateConfiguration
context :: Maybe (HashMap Text Text)
traceId :: Maybe Text
$sel:users:SendUsersMessageRequest' :: SendUsersMessageRequest -> HashMap Text EndpointSendConfiguration
$sel:messageConfiguration:SendUsersMessageRequest' :: SendUsersMessageRequest -> DirectMessageConfiguration
$sel:templateConfiguration:SendUsersMessageRequest' :: SendUsersMessageRequest -> Maybe TemplateConfiguration
$sel:context:SendUsersMessageRequest' :: SendUsersMessageRequest -> Maybe (HashMap Text Text)
$sel:traceId:SendUsersMessageRequest' :: SendUsersMessageRequest -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TraceId" 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
traceId,
            (Text
"Context" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
context,
            (Text
"TemplateConfiguration" Text -> TemplateConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TemplateConfiguration -> Pair)
-> Maybe TemplateConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TemplateConfiguration
templateConfiguration,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"MessageConfiguration"
                  Text -> DirectMessageConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DirectMessageConfiguration
messageConfiguration
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Users" Text -> HashMap Text EndpointSendConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text EndpointSendConfiguration
users)
          ]
      )