{-# 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.MessageResponse
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Pinpoint.Types.MessageResponse where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pinpoint.Types.EndpointMessageResult
import Amazonka.Pinpoint.Types.MessageResult
import qualified Amazonka.Prelude as Prelude

-- | Provides information about the results of a request to send a message to
-- an endpoint address.
--
-- /See:/ 'newMessageResponse' smart constructor.
data MessageResponse = MessageResponse'
  { -- | A map that contains a multipart response for each address that the
    -- message was sent to. In the map, the endpoint ID is the key and the
    -- result is the value.
    MessageResponse -> Maybe (HashMap Text EndpointMessageResult)
endpointResult :: Prelude.Maybe (Prelude.HashMap Prelude.Text EndpointMessageResult),
    -- | The identifier for the original request that the message was delivered
    -- for.
    MessageResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | A map that contains a multipart response for each address (email
    -- address, phone number, or push notification token) that the message was
    -- sent to. In the map, the address is the key and the result is the value.
    MessageResponse -> Maybe (HashMap Text MessageResult)
result :: Prelude.Maybe (Prelude.HashMap Prelude.Text MessageResult),
    -- | The unique identifier for the application that was used to send the
    -- message.
    MessageResponse -> Text
applicationId :: Prelude.Text
  }
  deriving (MessageResponse -> MessageResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MessageResponse -> MessageResponse -> Bool
$c/= :: MessageResponse -> MessageResponse -> Bool
== :: MessageResponse -> MessageResponse -> Bool
$c== :: MessageResponse -> MessageResponse -> Bool
Prelude.Eq, ReadPrec [MessageResponse]
ReadPrec MessageResponse
Int -> ReadS MessageResponse
ReadS [MessageResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MessageResponse]
$creadListPrec :: ReadPrec [MessageResponse]
readPrec :: ReadPrec MessageResponse
$creadPrec :: ReadPrec MessageResponse
readList :: ReadS [MessageResponse]
$creadList :: ReadS [MessageResponse]
readsPrec :: Int -> ReadS MessageResponse
$creadsPrec :: Int -> ReadS MessageResponse
Prelude.Read, Int -> MessageResponse -> ShowS
[MessageResponse] -> ShowS
MessageResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MessageResponse] -> ShowS
$cshowList :: [MessageResponse] -> ShowS
show :: MessageResponse -> String
$cshow :: MessageResponse -> String
showsPrec :: Int -> MessageResponse -> ShowS
$cshowsPrec :: Int -> MessageResponse -> ShowS
Prelude.Show, forall x. Rep MessageResponse x -> MessageResponse
forall x. MessageResponse -> Rep MessageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MessageResponse x -> MessageResponse
$cfrom :: forall x. MessageResponse -> Rep MessageResponse x
Prelude.Generic)

-- |
-- Create a value of 'MessageResponse' 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:
--
-- 'endpointResult', 'messageResponse_endpointResult' - A map that contains a multipart response for each address that the
-- message was sent to. In the map, the endpoint ID is the key and the
-- result is the value.
--
-- 'requestId', 'messageResponse_requestId' - The identifier for the original request that the message was delivered
-- for.
--
-- 'result', 'messageResponse_result' - A map that contains a multipart response for each address (email
-- address, phone number, or push notification token) that the message was
-- sent to. In the map, the address is the key and the result is the value.
--
-- 'applicationId', 'messageResponse_applicationId' - The unique identifier for the application that was used to send the
-- message.
newMessageResponse ::
  -- | 'applicationId'
  Prelude.Text ->
  MessageResponse
newMessageResponse :: Text -> MessageResponse
newMessageResponse Text
pApplicationId_ =
  MessageResponse'
    { $sel:endpointResult:MessageResponse' :: Maybe (HashMap Text EndpointMessageResult)
endpointResult = forall a. Maybe a
Prelude.Nothing,
      $sel:requestId:MessageResponse' :: Maybe Text
requestId = forall a. Maybe a
Prelude.Nothing,
      $sel:result:MessageResponse' :: Maybe (HashMap Text MessageResult)
result = forall a. Maybe a
Prelude.Nothing,
      $sel:applicationId:MessageResponse' :: Text
applicationId = Text
pApplicationId_
    }

-- | A map that contains a multipart response for each address that the
-- message was sent to. In the map, the endpoint ID is the key and the
-- result is the value.
messageResponse_endpointResult :: Lens.Lens' MessageResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text EndpointMessageResult))
messageResponse_endpointResult :: Lens' MessageResponse (Maybe (HashMap Text EndpointMessageResult))
messageResponse_endpointResult = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageResponse' {Maybe (HashMap Text EndpointMessageResult)
endpointResult :: Maybe (HashMap Text EndpointMessageResult)
$sel:endpointResult:MessageResponse' :: MessageResponse -> Maybe (HashMap Text EndpointMessageResult)
endpointResult} -> Maybe (HashMap Text EndpointMessageResult)
endpointResult) (\s :: MessageResponse
s@MessageResponse' {} Maybe (HashMap Text EndpointMessageResult)
a -> MessageResponse
s {$sel:endpointResult:MessageResponse' :: Maybe (HashMap Text EndpointMessageResult)
endpointResult = Maybe (HashMap Text EndpointMessageResult)
a} :: MessageResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The identifier for the original request that the message was delivered
-- for.
messageResponse_requestId :: Lens.Lens' MessageResponse (Prelude.Maybe Prelude.Text)
messageResponse_requestId :: Lens' MessageResponse (Maybe Text)
messageResponse_requestId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:MessageResponse' :: MessageResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: MessageResponse
s@MessageResponse' {} Maybe Text
a -> MessageResponse
s {$sel:requestId:MessageResponse' :: Maybe Text
requestId = Maybe Text
a} :: MessageResponse)

-- | A map that contains a multipart response for each address (email
-- address, phone number, or push notification token) that the message was
-- sent to. In the map, the address is the key and the result is the value.
messageResponse_result :: Lens.Lens' MessageResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text MessageResult))
messageResponse_result :: Lens' MessageResponse (Maybe (HashMap Text MessageResult))
messageResponse_result = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageResponse' {Maybe (HashMap Text MessageResult)
result :: Maybe (HashMap Text MessageResult)
$sel:result:MessageResponse' :: MessageResponse -> Maybe (HashMap Text MessageResult)
result} -> Maybe (HashMap Text MessageResult)
result) (\s :: MessageResponse
s@MessageResponse' {} Maybe (HashMap Text MessageResult)
a -> MessageResponse
s {$sel:result:MessageResponse' :: Maybe (HashMap Text MessageResult)
result = Maybe (HashMap Text MessageResult)
a} :: MessageResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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.
messageResponse_applicationId :: Lens.Lens' MessageResponse Prelude.Text
messageResponse_applicationId :: Lens' MessageResponse Text
messageResponse_applicationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageResponse' {Text
applicationId :: Text
$sel:applicationId:MessageResponse' :: MessageResponse -> Text
applicationId} -> Text
applicationId) (\s :: MessageResponse
s@MessageResponse' {} Text
a -> MessageResponse
s {$sel:applicationId:MessageResponse' :: Text
applicationId = Text
a} :: MessageResponse)

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

instance Prelude.Hashable MessageResponse where
  hashWithSalt :: Int -> MessageResponse -> Int
hashWithSalt Int
_salt MessageResponse' {Maybe Text
Maybe (HashMap Text EndpointMessageResult)
Maybe (HashMap Text MessageResult)
Text
applicationId :: Text
result :: Maybe (HashMap Text MessageResult)
requestId :: Maybe Text
endpointResult :: Maybe (HashMap Text EndpointMessageResult)
$sel:applicationId:MessageResponse' :: MessageResponse -> Text
$sel:result:MessageResponse' :: MessageResponse -> Maybe (HashMap Text MessageResult)
$sel:requestId:MessageResponse' :: MessageResponse -> Maybe Text
$sel:endpointResult:MessageResponse' :: MessageResponse -> Maybe (HashMap Text EndpointMessageResult)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text EndpointMessageResult)
endpointResult
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
requestId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text MessageResult)
result
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationId

instance Prelude.NFData MessageResponse where
  rnf :: MessageResponse -> ()
rnf MessageResponse' {Maybe Text
Maybe (HashMap Text EndpointMessageResult)
Maybe (HashMap Text MessageResult)
Text
applicationId :: Text
result :: Maybe (HashMap Text MessageResult)
requestId :: Maybe Text
endpointResult :: Maybe (HashMap Text EndpointMessageResult)
$sel:applicationId:MessageResponse' :: MessageResponse -> Text
$sel:result:MessageResponse' :: MessageResponse -> Maybe (HashMap Text MessageResult)
$sel:requestId:MessageResponse' :: MessageResponse -> Maybe Text
$sel:endpointResult:MessageResponse' :: MessageResponse -> Maybe (HashMap Text EndpointMessageResult)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text EndpointMessageResult)
endpointResult
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
requestId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text MessageResult)
result
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
applicationId