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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(EventsResponse -> EventsResponse -> Bool)
-> (EventsResponse -> EventsResponse -> Bool) -> Eq EventsResponse
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]
(Int -> ReadS EventsResponse)
-> ReadS [EventsResponse]
-> ReadPrec EventsResponse
-> ReadPrec [EventsResponse]
-> Read 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
(Int -> EventsResponse -> ShowS)
-> (EventsResponse -> String)
-> ([EventsResponse] -> ShowS)
-> Show EventsResponse
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. EventsResponse -> Rep EventsResponse x)
-> (forall x. Rep EventsResponse x -> EventsResponse)
-> Generic EventsResponse
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' :: Maybe (HashMap Text ItemResponse) -> EventsResponse
EventsResponse' {$sel:results:EventsResponse' :: Maybe (HashMap Text ItemResponse)
results = Maybe (HashMap Text ItemResponse)
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 :: (Maybe (HashMap Text ItemResponse)
 -> f (Maybe (HashMap Text ItemResponse)))
-> EventsResponse -> f EventsResponse
eventsResponse_results = (EventsResponse -> Maybe (HashMap Text ItemResponse))
-> (EventsResponse
    -> Maybe (HashMap Text ItemResponse) -> EventsResponse)
-> Lens
     EventsResponse
     EventsResponse
     (Maybe (HashMap Text ItemResponse))
     (Maybe (HashMap Text ItemResponse))
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) ((Maybe (HashMap Text ItemResponse)
  -> f (Maybe (HashMap Text ItemResponse)))
 -> EventsResponse -> f EventsResponse)
-> ((Maybe (HashMap Text ItemResponse)
     -> f (Maybe (HashMap Text ItemResponse)))
    -> Maybe (HashMap Text ItemResponse)
    -> f (Maybe (HashMap Text ItemResponse)))
-> (Maybe (HashMap Text ItemResponse)
    -> f (Maybe (HashMap Text ItemResponse)))
-> EventsResponse
-> f EventsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text ItemResponse)
  (HashMap Text ItemResponse)
  (HashMap Text ItemResponse)
  (HashMap Text ItemResponse)
-> Iso
     (Maybe (HashMap Text ItemResponse))
     (Maybe (HashMap Text ItemResponse))
     (Maybe (HashMap Text ItemResponse))
     (Maybe (HashMap Text ItemResponse))
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 ItemResponse)
  (HashMap Text ItemResponse)
  (HashMap Text ItemResponse)
  (HashMap Text ItemResponse)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable EventsResponse

instance Prelude.NFData EventsResponse