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

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

-- | Provides information about an API request or response.
--
-- /See:/ 'newMessageBody' smart constructor.
data MessageBody = MessageBody'
  { -- | The unique identifier for the request or response.
    MessageBody -> Maybe Text
requestID :: Prelude.Maybe Prelude.Text,
    -- | The message that\'s returned from the API.
    MessageBody -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (MessageBody -> MessageBody -> Bool
(MessageBody -> MessageBody -> Bool)
-> (MessageBody -> MessageBody -> Bool) -> Eq MessageBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MessageBody -> MessageBody -> Bool
$c/= :: MessageBody -> MessageBody -> Bool
== :: MessageBody -> MessageBody -> Bool
$c== :: MessageBody -> MessageBody -> Bool
Prelude.Eq, ReadPrec [MessageBody]
ReadPrec MessageBody
Int -> ReadS MessageBody
ReadS [MessageBody]
(Int -> ReadS MessageBody)
-> ReadS [MessageBody]
-> ReadPrec MessageBody
-> ReadPrec [MessageBody]
-> Read MessageBody
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MessageBody]
$creadListPrec :: ReadPrec [MessageBody]
readPrec :: ReadPrec MessageBody
$creadPrec :: ReadPrec MessageBody
readList :: ReadS [MessageBody]
$creadList :: ReadS [MessageBody]
readsPrec :: Int -> ReadS MessageBody
$creadsPrec :: Int -> ReadS MessageBody
Prelude.Read, Int -> MessageBody -> ShowS
[MessageBody] -> ShowS
MessageBody -> String
(Int -> MessageBody -> ShowS)
-> (MessageBody -> String)
-> ([MessageBody] -> ShowS)
-> Show MessageBody
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MessageBody] -> ShowS
$cshowList :: [MessageBody] -> ShowS
show :: MessageBody -> String
$cshow :: MessageBody -> String
showsPrec :: Int -> MessageBody -> ShowS
$cshowsPrec :: Int -> MessageBody -> ShowS
Prelude.Show, (forall x. MessageBody -> Rep MessageBody x)
-> (forall x. Rep MessageBody x -> MessageBody)
-> Generic MessageBody
forall x. Rep MessageBody x -> MessageBody
forall x. MessageBody -> Rep MessageBody x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MessageBody x -> MessageBody
$cfrom :: forall x. MessageBody -> Rep MessageBody x
Prelude.Generic)

-- |
-- Create a value of 'MessageBody' 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:
--
-- 'requestID', 'messageBody_requestID' - The unique identifier for the request or response.
--
-- 'message', 'messageBody_message' - The message that\'s returned from the API.
newMessageBody ::
  MessageBody
newMessageBody :: MessageBody
newMessageBody =
  MessageBody' :: Maybe Text -> Maybe Text -> MessageBody
MessageBody'
    { $sel:requestID:MessageBody' :: Maybe Text
requestID = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:message:MessageBody' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier for the request or response.
messageBody_requestID :: Lens.Lens' MessageBody (Prelude.Maybe Prelude.Text)
messageBody_requestID :: (Maybe Text -> f (Maybe Text)) -> MessageBody -> f MessageBody
messageBody_requestID = (MessageBody -> Maybe Text)
-> (MessageBody -> Maybe Text -> MessageBody)
-> Lens MessageBody MessageBody (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageBody' {Maybe Text
requestID :: Maybe Text
$sel:requestID:MessageBody' :: MessageBody -> Maybe Text
requestID} -> Maybe Text
requestID) (\s :: MessageBody
s@MessageBody' {} Maybe Text
a -> MessageBody
s {$sel:requestID:MessageBody' :: Maybe Text
requestID = Maybe Text
a} :: MessageBody)

-- | The message that\'s returned from the API.
messageBody_message :: Lens.Lens' MessageBody (Prelude.Maybe Prelude.Text)
messageBody_message :: (Maybe Text -> f (Maybe Text)) -> MessageBody -> f MessageBody
messageBody_message = (MessageBody -> Maybe Text)
-> (MessageBody -> Maybe Text -> MessageBody)
-> Lens MessageBody MessageBody (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MessageBody' {Maybe Text
message :: Maybe Text
$sel:message:MessageBody' :: MessageBody -> Maybe Text
message} -> Maybe Text
message) (\s :: MessageBody
s@MessageBody' {} Maybe Text
a -> MessageBody
s {$sel:message:MessageBody' :: Maybe Text
message = Maybe Text
a} :: MessageBody)

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

instance Prelude.Hashable MessageBody

instance Prelude.NFData MessageBody