{-# 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.EventsResponse
-- 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.EventsResponse 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.ItemResponse
import qualified Amazonka.Prelude as Prelude

-- | Provides information about endpoints and the events that they\'re
-- associated with.
--
-- /See:/ 'newEventsResponse' smart constructor.
data EventsResponse = EventsResponse'
  { -- | A map that contains a multipart response for each endpoint. For each
    -- item in this object, the endpoint ID is the key and the item response is
    -- the value. If no item response exists, the value can also be one of the
    -- following: 202, the request was processed successfully; or 400, the
    -- payload wasn\'t valid or required fields were missing.
    EventsResponse -> Maybe (HashMap Text ItemResponse)
results :: Prelude.Maybe (Prelude.HashMap Prelude.Text ItemResponse)
  }
  deriving (EventsResponse -> EventsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventsResponse -> EventsResponse -> Bool
$c/= :: EventsResponse -> EventsResponse -> Bool
== :: EventsResponse -> EventsResponse -> Bool
$c== :: EventsResponse -> EventsResponse -> Bool
Prelude.Eq, ReadPrec [EventsResponse]
ReadPrec EventsResponse
Int -> ReadS EventsResponse
ReadS [EventsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventsResponse]
$creadListPrec :: ReadPrec [EventsResponse]
readPrec :: ReadPrec EventsResponse
$creadPrec :: ReadPrec EventsResponse
readList :: ReadS [EventsResponse]
$creadList :: ReadS [EventsResponse]
readsPrec :: Int -> ReadS EventsResponse
$creadsPrec :: Int -> ReadS EventsResponse
Prelude.Read, Int -> EventsResponse -> ShowS
[EventsResponse] -> ShowS
EventsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventsResponse] -> ShowS
$cshowList :: [EventsResponse] -> ShowS
show :: EventsResponse -> String
$cshow :: EventsResponse -> String
showsPrec :: Int -> EventsResponse -> ShowS
$cshowsPrec :: Int -> EventsResponse -> ShowS
Prelude.Show, forall x. Rep EventsResponse x -> EventsResponse
forall x. EventsResponse -> Rep EventsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventsResponse x -> EventsResponse
$cfrom :: forall x. EventsResponse -> Rep EventsResponse x
Prelude.Generic)

-- |
-- Create a value of 'EventsResponse' 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:
--
-- 'results', 'eventsResponse_results' - A map that contains a multipart response for each endpoint. For each
-- item in this object, the endpoint ID is the key and the item response is
-- the value. If no item response exists, the value can also be one of the
-- following: 202, the request was processed successfully; or 400, the
-- payload wasn\'t valid or required fields were missing.
newEventsResponse ::
  EventsResponse
newEventsResponse :: EventsResponse
newEventsResponse =
  EventsResponse' {$sel:results:EventsResponse' :: Maybe (HashMap Text ItemResponse)
results = forall a. Maybe a
Prelude.Nothing}

-- | A map that contains a multipart response for each endpoint. For each
-- item in this object, the endpoint ID is the key and the item response is
-- the value. If no item response exists, the value can also be one of the
-- following: 202, the request was processed successfully; or 400, the
-- payload wasn\'t valid or required fields were missing.
eventsResponse_results :: Lens.Lens' EventsResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text ItemResponse))
eventsResponse_results :: Lens' EventsResponse (Maybe (HashMap Text ItemResponse))
eventsResponse_results = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventsResponse' {Maybe (HashMap Text ItemResponse)
results :: Maybe (HashMap Text ItemResponse)
$sel:results:EventsResponse' :: EventsResponse -> Maybe (HashMap Text ItemResponse)
results} -> Maybe (HashMap Text ItemResponse)
results) (\s :: EventsResponse
s@EventsResponse' {} Maybe (HashMap Text ItemResponse)
a -> EventsResponse
s {$sel:results:EventsResponse' :: Maybe (HashMap Text ItemResponse)
results = Maybe (HashMap Text ItemResponse)
a} :: EventsResponse) 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

instance Data.FromJSON EventsResponse where
  parseJSON :: Value -> Parser EventsResponse
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EventsResponse"
      ( \Object
x ->
          Maybe (HashMap Text ItemResponse) -> EventsResponse
EventsResponse'
            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
"Results" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable EventsResponse where
  hashWithSalt :: Int -> EventsResponse -> Int
hashWithSalt Int
_salt EventsResponse' {Maybe (HashMap Text ItemResponse)
results :: Maybe (HashMap Text ItemResponse)
$sel:results:EventsResponse' :: EventsResponse -> Maybe (HashMap Text ItemResponse)
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text ItemResponse)
results

instance Prelude.NFData EventsResponse where
  rnf :: EventsResponse -> ()
rnf EventsResponse' {Maybe (HashMap Text ItemResponse)
results :: Maybe (HashMap Text ItemResponse)
$sel:results:EventsResponse' :: EventsResponse -> Maybe (HashMap Text ItemResponse)
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text ItemResponse)
results