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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides the status code and message that result from processing an
-- event.
--
-- /See:/ 'newEventItemResponse' smart constructor.
data EventItemResponse = EventItemResponse'
  { -- | A custom message that\'s returned in the response as a result of
    -- processing the event.
    EventItemResponse -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | The status code that\'s returned in the response as a result of
    -- processing the event. Possible values are: 202, for events that were
    -- accepted; and, 400, for events that weren\'t valid.
    EventItemResponse -> Maybe Int
statusCode :: Prelude.Maybe Prelude.Int
  }
  deriving (EventItemResponse -> EventItemResponse -> Bool
(EventItemResponse -> EventItemResponse -> Bool)
-> (EventItemResponse -> EventItemResponse -> Bool)
-> Eq EventItemResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventItemResponse -> EventItemResponse -> Bool
$c/= :: EventItemResponse -> EventItemResponse -> Bool
== :: EventItemResponse -> EventItemResponse -> Bool
$c== :: EventItemResponse -> EventItemResponse -> Bool
Prelude.Eq, ReadPrec [EventItemResponse]
ReadPrec EventItemResponse
Int -> ReadS EventItemResponse
ReadS [EventItemResponse]
(Int -> ReadS EventItemResponse)
-> ReadS [EventItemResponse]
-> ReadPrec EventItemResponse
-> ReadPrec [EventItemResponse]
-> Read EventItemResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventItemResponse]
$creadListPrec :: ReadPrec [EventItemResponse]
readPrec :: ReadPrec EventItemResponse
$creadPrec :: ReadPrec EventItemResponse
readList :: ReadS [EventItemResponse]
$creadList :: ReadS [EventItemResponse]
readsPrec :: Int -> ReadS EventItemResponse
$creadsPrec :: Int -> ReadS EventItemResponse
Prelude.Read, Int -> EventItemResponse -> ShowS
[EventItemResponse] -> ShowS
EventItemResponse -> String
(Int -> EventItemResponse -> ShowS)
-> (EventItemResponse -> String)
-> ([EventItemResponse] -> ShowS)
-> Show EventItemResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventItemResponse] -> ShowS
$cshowList :: [EventItemResponse] -> ShowS
show :: EventItemResponse -> String
$cshow :: EventItemResponse -> String
showsPrec :: Int -> EventItemResponse -> ShowS
$cshowsPrec :: Int -> EventItemResponse -> ShowS
Prelude.Show, (forall x. EventItemResponse -> Rep EventItemResponse x)
-> (forall x. Rep EventItemResponse x -> EventItemResponse)
-> Generic EventItemResponse
forall x. Rep EventItemResponse x -> EventItemResponse
forall x. EventItemResponse -> Rep EventItemResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventItemResponse x -> EventItemResponse
$cfrom :: forall x. EventItemResponse -> Rep EventItemResponse x
Prelude.Generic)

-- |
-- Create a value of 'EventItemResponse' 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:
--
-- 'message', 'eventItemResponse_message' - A custom message that\'s returned in the response as a result of
-- processing the event.
--
-- 'statusCode', 'eventItemResponse_statusCode' - The status code that\'s returned in the response as a result of
-- processing the event. Possible values are: 202, for events that were
-- accepted; and, 400, for events that weren\'t valid.
newEventItemResponse ::
  EventItemResponse
newEventItemResponse :: EventItemResponse
newEventItemResponse =
  EventItemResponse' :: Maybe Text -> Maybe Int -> EventItemResponse
EventItemResponse'
    { $sel:message:EventItemResponse' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:statusCode:EventItemResponse' :: Maybe Int
statusCode = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | A custom message that\'s returned in the response as a result of
-- processing the event.
eventItemResponse_message :: Lens.Lens' EventItemResponse (Prelude.Maybe Prelude.Text)
eventItemResponse_message :: (Maybe Text -> f (Maybe Text))
-> EventItemResponse -> f EventItemResponse
eventItemResponse_message = (EventItemResponse -> Maybe Text)
-> (EventItemResponse -> Maybe Text -> EventItemResponse)
-> Lens
     EventItemResponse EventItemResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventItemResponse' {Maybe Text
message :: Maybe Text
$sel:message:EventItemResponse' :: EventItemResponse -> Maybe Text
message} -> Maybe Text
message) (\s :: EventItemResponse
s@EventItemResponse' {} Maybe Text
a -> EventItemResponse
s {$sel:message:EventItemResponse' :: Maybe Text
message = Maybe Text
a} :: EventItemResponse)

-- | The status code that\'s returned in the response as a result of
-- processing the event. Possible values are: 202, for events that were
-- accepted; and, 400, for events that weren\'t valid.
eventItemResponse_statusCode :: Lens.Lens' EventItemResponse (Prelude.Maybe Prelude.Int)
eventItemResponse_statusCode :: (Maybe Int -> f (Maybe Int))
-> EventItemResponse -> f EventItemResponse
eventItemResponse_statusCode = (EventItemResponse -> Maybe Int)
-> (EventItemResponse -> Maybe Int -> EventItemResponse)
-> Lens EventItemResponse EventItemResponse (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventItemResponse' {Maybe Int
statusCode :: Maybe Int
$sel:statusCode:EventItemResponse' :: EventItemResponse -> Maybe Int
statusCode} -> Maybe Int
statusCode) (\s :: EventItemResponse
s@EventItemResponse' {} Maybe Int
a -> EventItemResponse
s {$sel:statusCode:EventItemResponse' :: Maybe Int
statusCode = Maybe Int
a} :: EventItemResponse)

instance Core.FromJSON EventItemResponse where
  parseJSON :: Value -> Parser EventItemResponse
parseJSON =
    String
-> (Object -> Parser EventItemResponse)
-> Value
-> Parser EventItemResponse
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventItemResponse"
      ( \Object
x ->
          Maybe Text -> Maybe Int -> EventItemResponse
EventItemResponse'
            (Maybe Text -> Maybe Int -> EventItemResponse)
-> Parser (Maybe Text) -> Parser (Maybe Int -> EventItemResponse)
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
"Message")
            Parser (Maybe Int -> EventItemResponse)
-> Parser (Maybe Int) -> Parser EventItemResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StatusCode")
      )

instance Prelude.Hashable EventItemResponse

instance Prelude.NFData EventItemResponse