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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.EndpointMessageResult
import qualified Amazonka.Prelude as Prelude

-- | Provides information about which users and endpoints a message was sent
-- to.
--
-- /See:/ 'newSendUsersMessageResponse' smart constructor.
data SendUsersMessageResponse = SendUsersMessageResponse'
  { -- | The unique identifier that was assigned to the message request.
    SendUsersMessageResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | An object that indicates which endpoints the message was sent to, for
    -- each user. The object lists user IDs and, for each user ID, provides the
    -- endpoint IDs that the message was sent to. For each endpoint ID, it
    -- provides an EndpointMessageResult object.
    SendUsersMessageResponse
-> Maybe (HashMap Text (HashMap Text EndpointMessageResult))
result :: Prelude.Maybe (Prelude.HashMap Prelude.Text (Prelude.HashMap Prelude.Text EndpointMessageResult)),
    -- | The unique identifier for the application that was used to send the
    -- message.
    SendUsersMessageResponse -> Text
applicationId :: Prelude.Text
  }
  deriving (SendUsersMessageResponse -> SendUsersMessageResponse -> Bool
(SendUsersMessageResponse -> SendUsersMessageResponse -> Bool)
-> (SendUsersMessageResponse -> SendUsersMessageResponse -> Bool)
-> Eq SendUsersMessageResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendUsersMessageResponse -> SendUsersMessageResponse -> Bool
$c/= :: SendUsersMessageResponse -> SendUsersMessageResponse -> Bool
== :: SendUsersMessageResponse -> SendUsersMessageResponse -> Bool
$c== :: SendUsersMessageResponse -> SendUsersMessageResponse -> Bool
Prelude.Eq, ReadPrec [SendUsersMessageResponse]
ReadPrec SendUsersMessageResponse
Int -> ReadS SendUsersMessageResponse
ReadS [SendUsersMessageResponse]
(Int -> ReadS SendUsersMessageResponse)
-> ReadS [SendUsersMessageResponse]
-> ReadPrec SendUsersMessageResponse
-> ReadPrec [SendUsersMessageResponse]
-> Read SendUsersMessageResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendUsersMessageResponse]
$creadListPrec :: ReadPrec [SendUsersMessageResponse]
readPrec :: ReadPrec SendUsersMessageResponse
$creadPrec :: ReadPrec SendUsersMessageResponse
readList :: ReadS [SendUsersMessageResponse]
$creadList :: ReadS [SendUsersMessageResponse]
readsPrec :: Int -> ReadS SendUsersMessageResponse
$creadsPrec :: Int -> ReadS SendUsersMessageResponse
Prelude.Read, Int -> SendUsersMessageResponse -> ShowS
[SendUsersMessageResponse] -> ShowS
SendUsersMessageResponse -> String
(Int -> SendUsersMessageResponse -> ShowS)
-> (SendUsersMessageResponse -> String)
-> ([SendUsersMessageResponse] -> ShowS)
-> Show SendUsersMessageResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendUsersMessageResponse] -> ShowS
$cshowList :: [SendUsersMessageResponse] -> ShowS
show :: SendUsersMessageResponse -> String
$cshow :: SendUsersMessageResponse -> String
showsPrec :: Int -> SendUsersMessageResponse -> ShowS
$cshowsPrec :: Int -> SendUsersMessageResponse -> ShowS
Prelude.Show, (forall x.
 SendUsersMessageResponse -> Rep SendUsersMessageResponse x)
-> (forall x.
    Rep SendUsersMessageResponse x -> SendUsersMessageResponse)
-> Generic SendUsersMessageResponse
forall x.
Rep SendUsersMessageResponse x -> SendUsersMessageResponse
forall x.
SendUsersMessageResponse -> Rep SendUsersMessageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SendUsersMessageResponse x -> SendUsersMessageResponse
$cfrom :: forall x.
SendUsersMessageResponse -> Rep SendUsersMessageResponse x
Prelude.Generic)

-- |
-- Create a value of 'SendUsersMessageResponse' 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:
--
-- 'requestId', 'sendUsersMessageResponse_requestId' - The unique identifier that was assigned to the message request.
--
-- 'result', 'sendUsersMessageResponse_result' - An object that indicates which endpoints the message was sent to, for
-- each user. The object lists user IDs and, for each user ID, provides the
-- endpoint IDs that the message was sent to. For each endpoint ID, it
-- provides an EndpointMessageResult object.
--
-- 'applicationId', 'sendUsersMessageResponse_applicationId' - The unique identifier for the application that was used to send the
-- message.
newSendUsersMessageResponse ::
  -- | 'applicationId'
  Prelude.Text ->
  SendUsersMessageResponse
newSendUsersMessageResponse :: Text -> SendUsersMessageResponse
newSendUsersMessageResponse Text
pApplicationId_ =
  SendUsersMessageResponse' :: Maybe Text
-> Maybe (HashMap Text (HashMap Text EndpointMessageResult))
-> Text
-> SendUsersMessageResponse
SendUsersMessageResponse'
    { $sel:requestId:SendUsersMessageResponse' :: Maybe Text
requestId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:result:SendUsersMessageResponse' :: Maybe (HashMap Text (HashMap Text EndpointMessageResult))
result = Maybe (HashMap Text (HashMap Text EndpointMessageResult))
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationId:SendUsersMessageResponse' :: Text
applicationId = Text
pApplicationId_
    }

-- | The unique identifier that was assigned to the message request.
sendUsersMessageResponse_requestId :: Lens.Lens' SendUsersMessageResponse (Prelude.Maybe Prelude.Text)
sendUsersMessageResponse_requestId :: (Maybe Text -> f (Maybe Text))
-> SendUsersMessageResponse -> f SendUsersMessageResponse
sendUsersMessageResponse_requestId = (SendUsersMessageResponse -> Maybe Text)
-> (SendUsersMessageResponse
    -> Maybe Text -> SendUsersMessageResponse)
-> Lens
     SendUsersMessageResponse
     SendUsersMessageResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendUsersMessageResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:SendUsersMessageResponse' :: SendUsersMessageResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: SendUsersMessageResponse
s@SendUsersMessageResponse' {} Maybe Text
a -> SendUsersMessageResponse
s {$sel:requestId:SendUsersMessageResponse' :: Maybe Text
requestId = Maybe Text
a} :: SendUsersMessageResponse)

-- | An object that indicates which endpoints the message was sent to, for
-- each user. The object lists user IDs and, for each user ID, provides the
-- endpoint IDs that the message was sent to. For each endpoint ID, it
-- provides an EndpointMessageResult object.
sendUsersMessageResponse_result :: Lens.Lens' SendUsersMessageResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text (Prelude.HashMap Prelude.Text EndpointMessageResult)))
sendUsersMessageResponse_result :: (Maybe (HashMap Text (HashMap Text EndpointMessageResult))
 -> f (Maybe (HashMap Text (HashMap Text EndpointMessageResult))))
-> SendUsersMessageResponse -> f SendUsersMessageResponse
sendUsersMessageResponse_result = (SendUsersMessageResponse
 -> Maybe (HashMap Text (HashMap Text EndpointMessageResult)))
-> (SendUsersMessageResponse
    -> Maybe (HashMap Text (HashMap Text EndpointMessageResult))
    -> SendUsersMessageResponse)
-> Lens
     SendUsersMessageResponse
     SendUsersMessageResponse
     (Maybe (HashMap Text (HashMap Text EndpointMessageResult)))
     (Maybe (HashMap Text (HashMap Text EndpointMessageResult)))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendUsersMessageResponse' {Maybe (HashMap Text (HashMap Text EndpointMessageResult))
result :: Maybe (HashMap Text (HashMap Text EndpointMessageResult))
$sel:result:SendUsersMessageResponse' :: SendUsersMessageResponse
-> Maybe (HashMap Text (HashMap Text EndpointMessageResult))
result} -> Maybe (HashMap Text (HashMap Text EndpointMessageResult))
result) (\s :: SendUsersMessageResponse
s@SendUsersMessageResponse' {} Maybe (HashMap Text (HashMap Text EndpointMessageResult))
a -> SendUsersMessageResponse
s {$sel:result:SendUsersMessageResponse' :: Maybe (HashMap Text (HashMap Text EndpointMessageResult))
result = Maybe (HashMap Text (HashMap Text EndpointMessageResult))
a} :: SendUsersMessageResponse) ((Maybe (HashMap Text (HashMap Text EndpointMessageResult))
  -> f (Maybe (HashMap Text (HashMap Text EndpointMessageResult))))
 -> SendUsersMessageResponse -> f SendUsersMessageResponse)
-> ((Maybe (HashMap Text (HashMap Text EndpointMessageResult))
     -> f (Maybe (HashMap Text (HashMap Text EndpointMessageResult))))
    -> Maybe (HashMap Text (HashMap Text EndpointMessageResult))
    -> f (Maybe (HashMap Text (HashMap Text EndpointMessageResult))))
-> (Maybe (HashMap Text (HashMap Text EndpointMessageResult))
    -> f (Maybe (HashMap Text (HashMap Text EndpointMessageResult))))
-> SendUsersMessageResponse
-> f SendUsersMessageResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text (HashMap Text EndpointMessageResult))
  (HashMap Text (HashMap Text EndpointMessageResult))
  (HashMap Text (HashMap Text EndpointMessageResult))
  (HashMap Text (HashMap Text EndpointMessageResult))
-> Iso
     (Maybe (HashMap Text (HashMap Text EndpointMessageResult)))
     (Maybe (HashMap Text (HashMap Text EndpointMessageResult)))
     (Maybe (HashMap Text (HashMap Text EndpointMessageResult)))
     (Maybe (HashMap Text (HashMap Text EndpointMessageResult)))
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 (HashMap Text EndpointMessageResult))
  (HashMap Text (HashMap Text EndpointMessageResult))
  (HashMap Text (HashMap Text EndpointMessageResult))
  (HashMap Text (HashMap Text EndpointMessageResult))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unique identifier for the application that was used to send the
-- message.
sendUsersMessageResponse_applicationId :: Lens.Lens' SendUsersMessageResponse Prelude.Text
sendUsersMessageResponse_applicationId :: (Text -> f Text)
-> SendUsersMessageResponse -> f SendUsersMessageResponse
sendUsersMessageResponse_applicationId = (SendUsersMessageResponse -> Text)
-> (SendUsersMessageResponse -> Text -> SendUsersMessageResponse)
-> Lens SendUsersMessageResponse SendUsersMessageResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendUsersMessageResponse' {Text
applicationId :: Text
$sel:applicationId:SendUsersMessageResponse' :: SendUsersMessageResponse -> Text
applicationId} -> Text
applicationId) (\s :: SendUsersMessageResponse
s@SendUsersMessageResponse' {} Text
a -> SendUsersMessageResponse
s {$sel:applicationId:SendUsersMessageResponse' :: Text
applicationId = Text
a} :: SendUsersMessageResponse)

instance Core.FromJSON SendUsersMessageResponse where
  parseJSON :: Value -> Parser SendUsersMessageResponse
parseJSON =
    String
-> (Object -> Parser SendUsersMessageResponse)
-> Value
-> Parser SendUsersMessageResponse
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SendUsersMessageResponse"
      ( \Object
x ->
          Maybe Text
-> Maybe (HashMap Text (HashMap Text EndpointMessageResult))
-> Text
-> SendUsersMessageResponse
SendUsersMessageResponse'
            (Maybe Text
 -> Maybe (HashMap Text (HashMap Text EndpointMessageResult))
 -> Text
 -> SendUsersMessageResponse)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text (HashMap Text EndpointMessageResult))
      -> Text -> SendUsersMessageResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RequestId")
            Parser
  (Maybe (HashMap Text (HashMap Text EndpointMessageResult))
   -> Text -> SendUsersMessageResponse)
-> Parser
     (Maybe (HashMap Text (HashMap Text EndpointMessageResult)))
-> Parser (Text -> SendUsersMessageResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text
-> Parser
     (Maybe (Maybe (HashMap Text (HashMap Text EndpointMessageResult))))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Result" Parser
  (Maybe (Maybe (HashMap Text (HashMap Text EndpointMessageResult))))
-> Maybe (HashMap Text (HashMap Text EndpointMessageResult))
-> Parser
     (Maybe (HashMap Text (HashMap Text EndpointMessageResult)))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text (HashMap Text EndpointMessageResult))
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> SendUsersMessageResponse)
-> Parser Text -> Parser SendUsersMessageResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ApplicationId")
      )

instance Prelude.Hashable SendUsersMessageResponse

instance Prelude.NFData SendUsersMessageResponse