{-# 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.ChimeSDKMessaging.Types.ChannelMessageCallback
-- 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.ChimeSDKMessaging.Types.ChannelMessageCallback where

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

-- | Stores information about a callback.
--
-- /See:/ 'newChannelMessageCallback' smart constructor.
data ChannelMessageCallback = ChannelMessageCallback'
  { -- | The message content.
    ChannelMessageCallback -> Maybe (Sensitive Text)
content :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The message metadata.
    ChannelMessageCallback -> Maybe (Sensitive Text)
metadata :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The message ID.
    ChannelMessageCallback -> Text
messageId :: Prelude.Text
  }
  deriving (ChannelMessageCallback -> ChannelMessageCallback -> Bool
(ChannelMessageCallback -> ChannelMessageCallback -> Bool)
-> (ChannelMessageCallback -> ChannelMessageCallback -> Bool)
-> Eq ChannelMessageCallback
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChannelMessageCallback -> ChannelMessageCallback -> Bool
$c/= :: ChannelMessageCallback -> ChannelMessageCallback -> Bool
== :: ChannelMessageCallback -> ChannelMessageCallback -> Bool
$c== :: ChannelMessageCallback -> ChannelMessageCallback -> Bool
Prelude.Eq, Int -> ChannelMessageCallback -> ShowS
[ChannelMessageCallback] -> ShowS
ChannelMessageCallback -> String
(Int -> ChannelMessageCallback -> ShowS)
-> (ChannelMessageCallback -> String)
-> ([ChannelMessageCallback] -> ShowS)
-> Show ChannelMessageCallback
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChannelMessageCallback] -> ShowS
$cshowList :: [ChannelMessageCallback] -> ShowS
show :: ChannelMessageCallback -> String
$cshow :: ChannelMessageCallback -> String
showsPrec :: Int -> ChannelMessageCallback -> ShowS
$cshowsPrec :: Int -> ChannelMessageCallback -> ShowS
Prelude.Show, (forall x. ChannelMessageCallback -> Rep ChannelMessageCallback x)
-> (forall x.
    Rep ChannelMessageCallback x -> ChannelMessageCallback)
-> Generic ChannelMessageCallback
forall x. Rep ChannelMessageCallback x -> ChannelMessageCallback
forall x. ChannelMessageCallback -> Rep ChannelMessageCallback x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChannelMessageCallback x -> ChannelMessageCallback
$cfrom :: forall x. ChannelMessageCallback -> Rep ChannelMessageCallback x
Prelude.Generic)

-- |
-- Create a value of 'ChannelMessageCallback' 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:
--
-- 'content', 'channelMessageCallback_content' - The message content.
--
-- 'metadata', 'channelMessageCallback_metadata' - The message metadata.
--
-- 'messageId', 'channelMessageCallback_messageId' - The message ID.
newChannelMessageCallback ::
  -- | 'messageId'
  Prelude.Text ->
  ChannelMessageCallback
newChannelMessageCallback :: Text -> ChannelMessageCallback
newChannelMessageCallback Text
pMessageId_ =
  ChannelMessageCallback' :: Maybe (Sensitive Text)
-> Maybe (Sensitive Text) -> Text -> ChannelMessageCallback
ChannelMessageCallback'
    { $sel:content:ChannelMessageCallback' :: Maybe (Sensitive Text)
content = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:metadata:ChannelMessageCallback' :: Maybe (Sensitive Text)
metadata = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:messageId:ChannelMessageCallback' :: Text
messageId = Text
pMessageId_
    }

-- | The message content.
channelMessageCallback_content :: Lens.Lens' ChannelMessageCallback (Prelude.Maybe Prelude.Text)
channelMessageCallback_content :: (Maybe Text -> f (Maybe Text))
-> ChannelMessageCallback -> f ChannelMessageCallback
channelMessageCallback_content = (ChannelMessageCallback -> Maybe (Sensitive Text))
-> (ChannelMessageCallback
    -> Maybe (Sensitive Text) -> ChannelMessageCallback)
-> Lens
     ChannelMessageCallback
     ChannelMessageCallback
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelMessageCallback' {Maybe (Sensitive Text)
content :: Maybe (Sensitive Text)
$sel:content:ChannelMessageCallback' :: ChannelMessageCallback -> Maybe (Sensitive Text)
content} -> Maybe (Sensitive Text)
content) (\s :: ChannelMessageCallback
s@ChannelMessageCallback' {} Maybe (Sensitive Text)
a -> ChannelMessageCallback
s {$sel:content:ChannelMessageCallback' :: Maybe (Sensitive Text)
content = Maybe (Sensitive Text)
a} :: ChannelMessageCallback) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> ChannelMessageCallback -> f ChannelMessageCallback)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> ChannelMessageCallback
-> f ChannelMessageCallback
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The message metadata.
channelMessageCallback_metadata :: Lens.Lens' ChannelMessageCallback (Prelude.Maybe Prelude.Text)
channelMessageCallback_metadata :: (Maybe Text -> f (Maybe Text))
-> ChannelMessageCallback -> f ChannelMessageCallback
channelMessageCallback_metadata = (ChannelMessageCallback -> Maybe (Sensitive Text))
-> (ChannelMessageCallback
    -> Maybe (Sensitive Text) -> ChannelMessageCallback)
-> Lens
     ChannelMessageCallback
     ChannelMessageCallback
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelMessageCallback' {Maybe (Sensitive Text)
metadata :: Maybe (Sensitive Text)
$sel:metadata:ChannelMessageCallback' :: ChannelMessageCallback -> Maybe (Sensitive Text)
metadata} -> Maybe (Sensitive Text)
metadata) (\s :: ChannelMessageCallback
s@ChannelMessageCallback' {} Maybe (Sensitive Text)
a -> ChannelMessageCallback
s {$sel:metadata:ChannelMessageCallback' :: Maybe (Sensitive Text)
metadata = Maybe (Sensitive Text)
a} :: ChannelMessageCallback) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> ChannelMessageCallback -> f ChannelMessageCallback)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> ChannelMessageCallback
-> f ChannelMessageCallback
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The message ID.
channelMessageCallback_messageId :: Lens.Lens' ChannelMessageCallback Prelude.Text
channelMessageCallback_messageId :: (Text -> f Text)
-> ChannelMessageCallback -> f ChannelMessageCallback
channelMessageCallback_messageId = (ChannelMessageCallback -> Text)
-> (ChannelMessageCallback -> Text -> ChannelMessageCallback)
-> Lens ChannelMessageCallback ChannelMessageCallback Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelMessageCallback' {Text
messageId :: Text
$sel:messageId:ChannelMessageCallback' :: ChannelMessageCallback -> Text
messageId} -> Text
messageId) (\s :: ChannelMessageCallback
s@ChannelMessageCallback' {} Text
a -> ChannelMessageCallback
s {$sel:messageId:ChannelMessageCallback' :: Text
messageId = Text
a} :: ChannelMessageCallback)

instance Prelude.Hashable ChannelMessageCallback

instance Prelude.NFData ChannelMessageCallback

instance Core.ToJSON ChannelMessageCallback where
  toJSON :: ChannelMessageCallback -> Value
toJSON ChannelMessageCallback' {Maybe (Sensitive Text)
Text
messageId :: Text
metadata :: Maybe (Sensitive Text)
content :: Maybe (Sensitive Text)
$sel:messageId:ChannelMessageCallback' :: ChannelMessageCallback -> Text
$sel:metadata:ChannelMessageCallback' :: ChannelMessageCallback -> Maybe (Sensitive Text)
$sel:content:ChannelMessageCallback' :: ChannelMessageCallback -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Content" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
content,
            (Text
"Metadata" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
metadata,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MessageId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
messageId)
          ]
      )