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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.EndpointItemResponse
import Amazonka.Pinpoint.Types.EventItemResponse
import qualified Amazonka.Prelude as Prelude

-- | Provides information about the results of a request to create or update
-- an endpoint that\'s associated with an event.
--
-- /See:/ 'newItemResponse' smart constructor.
data ItemResponse = ItemResponse'
  { -- | The response that was received after the endpoint data was accepted.
    ItemResponse -> Maybe EndpointItemResponse
endpointItemResponse :: Prelude.Maybe EndpointItemResponse,
    -- | A multipart response object that contains a key and a value for each
    -- event in the request. In each object, the event ID is the key and an
    -- EventItemResponse object is the value.
    ItemResponse -> Maybe (HashMap Text EventItemResponse)
eventsItemResponse :: Prelude.Maybe (Prelude.HashMap Prelude.Text EventItemResponse)
  }
  deriving (ItemResponse -> ItemResponse -> Bool
(ItemResponse -> ItemResponse -> Bool)
-> (ItemResponse -> ItemResponse -> Bool) -> Eq ItemResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ItemResponse -> ItemResponse -> Bool
$c/= :: ItemResponse -> ItemResponse -> Bool
== :: ItemResponse -> ItemResponse -> Bool
$c== :: ItemResponse -> ItemResponse -> Bool
Prelude.Eq, ReadPrec [ItemResponse]
ReadPrec ItemResponse
Int -> ReadS ItemResponse
ReadS [ItemResponse]
(Int -> ReadS ItemResponse)
-> ReadS [ItemResponse]
-> ReadPrec ItemResponse
-> ReadPrec [ItemResponse]
-> Read ItemResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ItemResponse]
$creadListPrec :: ReadPrec [ItemResponse]
readPrec :: ReadPrec ItemResponse
$creadPrec :: ReadPrec ItemResponse
readList :: ReadS [ItemResponse]
$creadList :: ReadS [ItemResponse]
readsPrec :: Int -> ReadS ItemResponse
$creadsPrec :: Int -> ReadS ItemResponse
Prelude.Read, Int -> ItemResponse -> ShowS
[ItemResponse] -> ShowS
ItemResponse -> String
(Int -> ItemResponse -> ShowS)
-> (ItemResponse -> String)
-> ([ItemResponse] -> ShowS)
-> Show ItemResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ItemResponse] -> ShowS
$cshowList :: [ItemResponse] -> ShowS
show :: ItemResponse -> String
$cshow :: ItemResponse -> String
showsPrec :: Int -> ItemResponse -> ShowS
$cshowsPrec :: Int -> ItemResponse -> ShowS
Prelude.Show, (forall x. ItemResponse -> Rep ItemResponse x)
-> (forall x. Rep ItemResponse x -> ItemResponse)
-> Generic ItemResponse
forall x. Rep ItemResponse x -> ItemResponse
forall x. ItemResponse -> Rep ItemResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ItemResponse x -> ItemResponse
$cfrom :: forall x. ItemResponse -> Rep ItemResponse x
Prelude.Generic)

-- |
-- Create a value of 'ItemResponse' 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:
--
-- 'endpointItemResponse', 'itemResponse_endpointItemResponse' - The response that was received after the endpoint data was accepted.
--
-- 'eventsItemResponse', 'itemResponse_eventsItemResponse' - A multipart response object that contains a key and a value for each
-- event in the request. In each object, the event ID is the key and an
-- EventItemResponse object is the value.
newItemResponse ::
  ItemResponse
newItemResponse :: ItemResponse
newItemResponse =
  ItemResponse' :: Maybe EndpointItemResponse
-> Maybe (HashMap Text EventItemResponse) -> ItemResponse
ItemResponse'
    { $sel:endpointItemResponse:ItemResponse' :: Maybe EndpointItemResponse
endpointItemResponse =
        Maybe EndpointItemResponse
forall a. Maybe a
Prelude.Nothing,
      $sel:eventsItemResponse:ItemResponse' :: Maybe (HashMap Text EventItemResponse)
eventsItemResponse = Maybe (HashMap Text EventItemResponse)
forall a. Maybe a
Prelude.Nothing
    }

-- | The response that was received after the endpoint data was accepted.
itemResponse_endpointItemResponse :: Lens.Lens' ItemResponse (Prelude.Maybe EndpointItemResponse)
itemResponse_endpointItemResponse :: (Maybe EndpointItemResponse -> f (Maybe EndpointItemResponse))
-> ItemResponse -> f ItemResponse
itemResponse_endpointItemResponse = (ItemResponse -> Maybe EndpointItemResponse)
-> (ItemResponse -> Maybe EndpointItemResponse -> ItemResponse)
-> Lens
     ItemResponse
     ItemResponse
     (Maybe EndpointItemResponse)
     (Maybe EndpointItemResponse)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemResponse' {Maybe EndpointItemResponse
endpointItemResponse :: Maybe EndpointItemResponse
$sel:endpointItemResponse:ItemResponse' :: ItemResponse -> Maybe EndpointItemResponse
endpointItemResponse} -> Maybe EndpointItemResponse
endpointItemResponse) (\s :: ItemResponse
s@ItemResponse' {} Maybe EndpointItemResponse
a -> ItemResponse
s {$sel:endpointItemResponse:ItemResponse' :: Maybe EndpointItemResponse
endpointItemResponse = Maybe EndpointItemResponse
a} :: ItemResponse)

-- | A multipart response object that contains a key and a value for each
-- event in the request. In each object, the event ID is the key and an
-- EventItemResponse object is the value.
itemResponse_eventsItemResponse :: Lens.Lens' ItemResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text EventItemResponse))
itemResponse_eventsItemResponse :: (Maybe (HashMap Text EventItemResponse)
 -> f (Maybe (HashMap Text EventItemResponse)))
-> ItemResponse -> f ItemResponse
itemResponse_eventsItemResponse = (ItemResponse -> Maybe (HashMap Text EventItemResponse))
-> (ItemResponse
    -> Maybe (HashMap Text EventItemResponse) -> ItemResponse)
-> Lens
     ItemResponse
     ItemResponse
     (Maybe (HashMap Text EventItemResponse))
     (Maybe (HashMap Text EventItemResponse))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ItemResponse' {Maybe (HashMap Text EventItemResponse)
eventsItemResponse :: Maybe (HashMap Text EventItemResponse)
$sel:eventsItemResponse:ItemResponse' :: ItemResponse -> Maybe (HashMap Text EventItemResponse)
eventsItemResponse} -> Maybe (HashMap Text EventItemResponse)
eventsItemResponse) (\s :: ItemResponse
s@ItemResponse' {} Maybe (HashMap Text EventItemResponse)
a -> ItemResponse
s {$sel:eventsItemResponse:ItemResponse' :: Maybe (HashMap Text EventItemResponse)
eventsItemResponse = Maybe (HashMap Text EventItemResponse)
a} :: ItemResponse) ((Maybe (HashMap Text EventItemResponse)
  -> f (Maybe (HashMap Text EventItemResponse)))
 -> ItemResponse -> f ItemResponse)
-> ((Maybe (HashMap Text EventItemResponse)
     -> f (Maybe (HashMap Text EventItemResponse)))
    -> Maybe (HashMap Text EventItemResponse)
    -> f (Maybe (HashMap Text EventItemResponse)))
-> (Maybe (HashMap Text EventItemResponse)
    -> f (Maybe (HashMap Text EventItemResponse)))
-> ItemResponse
-> f ItemResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text EventItemResponse)
  (HashMap Text EventItemResponse)
  (HashMap Text EventItemResponse)
  (HashMap Text EventItemResponse)
-> Iso
     (Maybe (HashMap Text EventItemResponse))
     (Maybe (HashMap Text EventItemResponse))
     (Maybe (HashMap Text EventItemResponse))
     (Maybe (HashMap Text EventItemResponse))
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 EventItemResponse)
  (HashMap Text EventItemResponse)
  (HashMap Text EventItemResponse)
  (HashMap Text EventItemResponse)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable ItemResponse

instance Prelude.NFData ItemResponse