{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.SendChannelMessage
-- 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)
--
-- Sends a message to a particular channel that the member is a part of.
--
-- The @x-amz-chime-bearer@ request header is mandatory. Use the
-- @AppInstanceUserArn@ of the user that makes the API call as the value in
-- the header.
--
-- Also, @STANDARD@ messages can contain 4KB of data and the 1KB of
-- metadata. @CONTROL@ messages can contain 30 bytes of data and no
-- metadata.
module Amazonka.ChimeSDKMessaging.SendChannelMessage
  ( -- * Creating a Request
    SendChannelMessage (..),
    newSendChannelMessage,

    -- * Request Lenses
    sendChannelMessage_metadata,
    sendChannelMessage_channelArn,
    sendChannelMessage_content,
    sendChannelMessage_type,
    sendChannelMessage_persistence,
    sendChannelMessage_clientRequestToken,
    sendChannelMessage_chimeBearer,

    -- * Destructuring the Response
    SendChannelMessageResponse (..),
    newSendChannelMessageResponse,

    -- * Response Lenses
    sendChannelMessageResponse_status,
    sendChannelMessageResponse_channelArn,
    sendChannelMessageResponse_messageId,
    sendChannelMessageResponse_httpStatus,
  )
where

import Amazonka.ChimeSDKMessaging.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newSendChannelMessage' smart constructor.
data SendChannelMessage = SendChannelMessage'
  { -- | The optional metadata for each message.
    SendChannelMessage -> Maybe (Sensitive Text)
metadata :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The ARN of the channel.
    SendChannelMessage -> Text
channelArn :: Prelude.Text,
    -- | The content of the message.
    SendChannelMessage -> Sensitive Text
content :: Core.Sensitive Prelude.Text,
    -- | The type of message, @STANDARD@ or @CONTROL@.
    SendChannelMessage -> ChannelMessageType
type' :: ChannelMessageType,
    -- | Boolean that controls whether the message is persisted on the back end.
    -- Required.
    SendChannelMessage -> ChannelMessagePersistenceType
persistence :: ChannelMessagePersistenceType,
    -- | The @Idempotency@ token for each client request.
    SendChannelMessage -> Sensitive Text
clientRequestToken :: Core.Sensitive Prelude.Text,
    -- | The @AppInstanceUserArn@ of the user that makes the API call.
    SendChannelMessage -> Text
chimeBearer :: Prelude.Text
  }
  deriving (SendChannelMessage -> SendChannelMessage -> Bool
(SendChannelMessage -> SendChannelMessage -> Bool)
-> (SendChannelMessage -> SendChannelMessage -> Bool)
-> Eq SendChannelMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendChannelMessage -> SendChannelMessage -> Bool
$c/= :: SendChannelMessage -> SendChannelMessage -> Bool
== :: SendChannelMessage -> SendChannelMessage -> Bool
$c== :: SendChannelMessage -> SendChannelMessage -> Bool
Prelude.Eq, Int -> SendChannelMessage -> ShowS
[SendChannelMessage] -> ShowS
SendChannelMessage -> String
(Int -> SendChannelMessage -> ShowS)
-> (SendChannelMessage -> String)
-> ([SendChannelMessage] -> ShowS)
-> Show SendChannelMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendChannelMessage] -> ShowS
$cshowList :: [SendChannelMessage] -> ShowS
show :: SendChannelMessage -> String
$cshow :: SendChannelMessage -> String
showsPrec :: Int -> SendChannelMessage -> ShowS
$cshowsPrec :: Int -> SendChannelMessage -> ShowS
Prelude.Show, (forall x. SendChannelMessage -> Rep SendChannelMessage x)
-> (forall x. Rep SendChannelMessage x -> SendChannelMessage)
-> Generic SendChannelMessage
forall x. Rep SendChannelMessage x -> SendChannelMessage
forall x. SendChannelMessage -> Rep SendChannelMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendChannelMessage x -> SendChannelMessage
$cfrom :: forall x. SendChannelMessage -> Rep SendChannelMessage x
Prelude.Generic)

-- |
-- Create a value of 'SendChannelMessage' 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:
--
-- 'metadata', 'sendChannelMessage_metadata' - The optional metadata for each message.
--
-- 'channelArn', 'sendChannelMessage_channelArn' - The ARN of the channel.
--
-- 'content', 'sendChannelMessage_content' - The content of the message.
--
-- 'type'', 'sendChannelMessage_type' - The type of message, @STANDARD@ or @CONTROL@.
--
-- 'persistence', 'sendChannelMessage_persistence' - Boolean that controls whether the message is persisted on the back end.
-- Required.
--
-- 'clientRequestToken', 'sendChannelMessage_clientRequestToken' - The @Idempotency@ token for each client request.
--
-- 'chimeBearer', 'sendChannelMessage_chimeBearer' - The @AppInstanceUserArn@ of the user that makes the API call.
newSendChannelMessage ::
  -- | 'channelArn'
  Prelude.Text ->
  -- | 'content'
  Prelude.Text ->
  -- | 'type''
  ChannelMessageType ->
  -- | 'persistence'
  ChannelMessagePersistenceType ->
  -- | 'clientRequestToken'
  Prelude.Text ->
  -- | 'chimeBearer'
  Prelude.Text ->
  SendChannelMessage
newSendChannelMessage :: Text
-> Text
-> ChannelMessageType
-> ChannelMessagePersistenceType
-> Text
-> Text
-> SendChannelMessage
newSendChannelMessage
  Text
pChannelArn_
  Text
pContent_
  ChannelMessageType
pType_
  ChannelMessagePersistenceType
pPersistence_
  Text
pClientRequestToken_
  Text
pChimeBearer_ =
    SendChannelMessage' :: Maybe (Sensitive Text)
-> Text
-> Sensitive Text
-> ChannelMessageType
-> ChannelMessagePersistenceType
-> Sensitive Text
-> Text
-> SendChannelMessage
SendChannelMessage'
      { $sel:metadata:SendChannelMessage' :: Maybe (Sensitive Text)
metadata = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:channelArn:SendChannelMessage' :: Text
channelArn = Text
pChannelArn_,
        $sel:content:SendChannelMessage' :: Sensitive Text
content = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pContent_,
        $sel:type':SendChannelMessage' :: ChannelMessageType
type' = ChannelMessageType
pType_,
        $sel:persistence:SendChannelMessage' :: ChannelMessagePersistenceType
persistence = ChannelMessagePersistenceType
pPersistence_,
        $sel:clientRequestToken:SendChannelMessage' :: Sensitive Text
clientRequestToken =
          Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pClientRequestToken_,
        $sel:chimeBearer:SendChannelMessage' :: Text
chimeBearer = Text
pChimeBearer_
      }

-- | The optional metadata for each message.
sendChannelMessage_metadata :: Lens.Lens' SendChannelMessage (Prelude.Maybe Prelude.Text)
sendChannelMessage_metadata :: (Maybe Text -> f (Maybe Text))
-> SendChannelMessage -> f SendChannelMessage
sendChannelMessage_metadata = (SendChannelMessage -> Maybe (Sensitive Text))
-> (SendChannelMessage
    -> Maybe (Sensitive Text) -> SendChannelMessage)
-> Lens
     SendChannelMessage
     SendChannelMessage
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendChannelMessage' {Maybe (Sensitive Text)
metadata :: Maybe (Sensitive Text)
$sel:metadata:SendChannelMessage' :: SendChannelMessage -> Maybe (Sensitive Text)
metadata} -> Maybe (Sensitive Text)
metadata) (\s :: SendChannelMessage
s@SendChannelMessage' {} Maybe (Sensitive Text)
a -> SendChannelMessage
s {$sel:metadata:SendChannelMessage' :: Maybe (Sensitive Text)
metadata = Maybe (Sensitive Text)
a} :: SendChannelMessage) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> SendChannelMessage -> f SendChannelMessage)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> SendChannelMessage
-> f SendChannelMessage
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 ARN of the channel.
sendChannelMessage_channelArn :: Lens.Lens' SendChannelMessage Prelude.Text
sendChannelMessage_channelArn :: (Text -> f Text) -> SendChannelMessage -> f SendChannelMessage
sendChannelMessage_channelArn = (SendChannelMessage -> Text)
-> (SendChannelMessage -> Text -> SendChannelMessage)
-> Lens SendChannelMessage SendChannelMessage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendChannelMessage' {Text
channelArn :: Text
$sel:channelArn:SendChannelMessage' :: SendChannelMessage -> Text
channelArn} -> Text
channelArn) (\s :: SendChannelMessage
s@SendChannelMessage' {} Text
a -> SendChannelMessage
s {$sel:channelArn:SendChannelMessage' :: Text
channelArn = Text
a} :: SendChannelMessage)

-- | The content of the message.
sendChannelMessage_content :: Lens.Lens' SendChannelMessage Prelude.Text
sendChannelMessage_content :: (Text -> f Text) -> SendChannelMessage -> f SendChannelMessage
sendChannelMessage_content = (SendChannelMessage -> Sensitive Text)
-> (SendChannelMessage -> Sensitive Text -> SendChannelMessage)
-> Lens
     SendChannelMessage
     SendChannelMessage
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendChannelMessage' {Sensitive Text
content :: Sensitive Text
$sel:content:SendChannelMessage' :: SendChannelMessage -> Sensitive Text
content} -> Sensitive Text
content) (\s :: SendChannelMessage
s@SendChannelMessage' {} Sensitive Text
a -> SendChannelMessage
s {$sel:content:SendChannelMessage' :: Sensitive Text
content = Sensitive Text
a} :: SendChannelMessage) ((Sensitive Text -> f (Sensitive Text))
 -> SendChannelMessage -> f SendChannelMessage)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> SendChannelMessage
-> f SendChannelMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The type of message, @STANDARD@ or @CONTROL@.
sendChannelMessage_type :: Lens.Lens' SendChannelMessage ChannelMessageType
sendChannelMessage_type :: (ChannelMessageType -> f ChannelMessageType)
-> SendChannelMessage -> f SendChannelMessage
sendChannelMessage_type = (SendChannelMessage -> ChannelMessageType)
-> (SendChannelMessage -> ChannelMessageType -> SendChannelMessage)
-> Lens
     SendChannelMessage
     SendChannelMessage
     ChannelMessageType
     ChannelMessageType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendChannelMessage' {ChannelMessageType
type' :: ChannelMessageType
$sel:type':SendChannelMessage' :: SendChannelMessage -> ChannelMessageType
type'} -> ChannelMessageType
type') (\s :: SendChannelMessage
s@SendChannelMessage' {} ChannelMessageType
a -> SendChannelMessage
s {$sel:type':SendChannelMessage' :: ChannelMessageType
type' = ChannelMessageType
a} :: SendChannelMessage)

-- | Boolean that controls whether the message is persisted on the back end.
-- Required.
sendChannelMessage_persistence :: Lens.Lens' SendChannelMessage ChannelMessagePersistenceType
sendChannelMessage_persistence :: (ChannelMessagePersistenceType -> f ChannelMessagePersistenceType)
-> SendChannelMessage -> f SendChannelMessage
sendChannelMessage_persistence = (SendChannelMessage -> ChannelMessagePersistenceType)
-> (SendChannelMessage
    -> ChannelMessagePersistenceType -> SendChannelMessage)
-> Lens
     SendChannelMessage
     SendChannelMessage
     ChannelMessagePersistenceType
     ChannelMessagePersistenceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendChannelMessage' {ChannelMessagePersistenceType
persistence :: ChannelMessagePersistenceType
$sel:persistence:SendChannelMessage' :: SendChannelMessage -> ChannelMessagePersistenceType
persistence} -> ChannelMessagePersistenceType
persistence) (\s :: SendChannelMessage
s@SendChannelMessage' {} ChannelMessagePersistenceType
a -> SendChannelMessage
s {$sel:persistence:SendChannelMessage' :: ChannelMessagePersistenceType
persistence = ChannelMessagePersistenceType
a} :: SendChannelMessage)

-- | The @Idempotency@ token for each client request.
sendChannelMessage_clientRequestToken :: Lens.Lens' SendChannelMessage Prelude.Text
sendChannelMessage_clientRequestToken :: (Text -> f Text) -> SendChannelMessage -> f SendChannelMessage
sendChannelMessage_clientRequestToken = (SendChannelMessage -> Sensitive Text)
-> (SendChannelMessage -> Sensitive Text -> SendChannelMessage)
-> Lens
     SendChannelMessage
     SendChannelMessage
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendChannelMessage' {Sensitive Text
clientRequestToken :: Sensitive Text
$sel:clientRequestToken:SendChannelMessage' :: SendChannelMessage -> Sensitive Text
clientRequestToken} -> Sensitive Text
clientRequestToken) (\s :: SendChannelMessage
s@SendChannelMessage' {} Sensitive Text
a -> SendChannelMessage
s {$sel:clientRequestToken:SendChannelMessage' :: Sensitive Text
clientRequestToken = Sensitive Text
a} :: SendChannelMessage) ((Sensitive Text -> f (Sensitive Text))
 -> SendChannelMessage -> f SendChannelMessage)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> SendChannelMessage
-> f SendChannelMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The @AppInstanceUserArn@ of the user that makes the API call.
sendChannelMessage_chimeBearer :: Lens.Lens' SendChannelMessage Prelude.Text
sendChannelMessage_chimeBearer :: (Text -> f Text) -> SendChannelMessage -> f SendChannelMessage
sendChannelMessage_chimeBearer = (SendChannelMessage -> Text)
-> (SendChannelMessage -> Text -> SendChannelMessage)
-> Lens SendChannelMessage SendChannelMessage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendChannelMessage' {Text
chimeBearer :: Text
$sel:chimeBearer:SendChannelMessage' :: SendChannelMessage -> Text
chimeBearer} -> Text
chimeBearer) (\s :: SendChannelMessage
s@SendChannelMessage' {} Text
a -> SendChannelMessage
s {$sel:chimeBearer:SendChannelMessage' :: Text
chimeBearer = Text
a} :: SendChannelMessage)

instance Core.AWSRequest SendChannelMessage where
  type
    AWSResponse SendChannelMessage =
      SendChannelMessageResponse
  request :: SendChannelMessage -> Request SendChannelMessage
request = Service -> SendChannelMessage -> Request SendChannelMessage
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy SendChannelMessage
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SendChannelMessage)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse SendChannelMessage))
-> Logger
-> Service
-> Proxy SendChannelMessage
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SendChannelMessage)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ChannelMessageStatusStructure
-> Maybe Text -> Maybe Text -> Int -> SendChannelMessageResponse
SendChannelMessageResponse'
            (Maybe ChannelMessageStatusStructure
 -> Maybe Text -> Maybe Text -> Int -> SendChannelMessageResponse)
-> Either String (Maybe ChannelMessageStatusStructure)
-> Either
     String
     (Maybe Text -> Maybe Text -> Int -> SendChannelMessageResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Either String (Maybe ChannelMessageStatusStructure)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Status")
            Either
  String
  (Maybe Text -> Maybe Text -> Int -> SendChannelMessageResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> SendChannelMessageResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ChannelArn")
            Either String (Maybe Text -> Int -> SendChannelMessageResponse)
-> Either String (Maybe Text)
-> Either String (Int -> SendChannelMessageResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"MessageId")
            Either String (Int -> SendChannelMessageResponse)
-> Either String Int -> Either String SendChannelMessageResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable SendChannelMessage

instance Prelude.NFData SendChannelMessage

instance Core.ToHeaders SendChannelMessage where
  toHeaders :: SendChannelMessage -> ResponseHeaders
toHeaders SendChannelMessage' {Maybe (Sensitive Text)
Text
Sensitive Text
ChannelMessagePersistenceType
ChannelMessageType
chimeBearer :: Text
clientRequestToken :: Sensitive Text
persistence :: ChannelMessagePersistenceType
type' :: ChannelMessageType
content :: Sensitive Text
channelArn :: Text
metadata :: Maybe (Sensitive Text)
$sel:chimeBearer:SendChannelMessage' :: SendChannelMessage -> Text
$sel:clientRequestToken:SendChannelMessage' :: SendChannelMessage -> Sensitive Text
$sel:persistence:SendChannelMessage' :: SendChannelMessage -> ChannelMessagePersistenceType
$sel:type':SendChannelMessage' :: SendChannelMessage -> ChannelMessageType
$sel:content:SendChannelMessage' :: SendChannelMessage -> Sensitive Text
$sel:channelArn:SendChannelMessage' :: SendChannelMessage -> Text
$sel:metadata:SendChannelMessage' :: SendChannelMessage -> Maybe (Sensitive Text)
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [HeaderName
"x-amz-chime-bearer" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
chimeBearer]

instance Core.ToJSON SendChannelMessage where
  toJSON :: SendChannelMessage -> Value
toJSON SendChannelMessage' {Maybe (Sensitive Text)
Text
Sensitive Text
ChannelMessagePersistenceType
ChannelMessageType
chimeBearer :: Text
clientRequestToken :: Sensitive Text
persistence :: ChannelMessagePersistenceType
type' :: ChannelMessageType
content :: Sensitive Text
channelArn :: Text
metadata :: Maybe (Sensitive Text)
$sel:chimeBearer:SendChannelMessage' :: SendChannelMessage -> Text
$sel:clientRequestToken:SendChannelMessage' :: SendChannelMessage -> Sensitive Text
$sel:persistence:SendChannelMessage' :: SendChannelMessage -> ChannelMessagePersistenceType
$sel:type':SendChannelMessage' :: SendChannelMessage -> ChannelMessageType
$sel:content:SendChannelMessage' :: SendChannelMessage -> Sensitive Text
$sel:channelArn:SendChannelMessage' :: SendChannelMessage -> Text
$sel:metadata:SendChannelMessage' :: SendChannelMessage -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"Content" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
content),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> ChannelMessageType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ChannelMessageType
type'),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Persistence" Text -> ChannelMessagePersistenceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ChannelMessagePersistenceType
persistence),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ClientRequestToken" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
clientRequestToken)
          ]
      )

instance Core.ToPath SendChannelMessage where
  toPath :: SendChannelMessage -> ByteString
toPath SendChannelMessage' {Maybe (Sensitive Text)
Text
Sensitive Text
ChannelMessagePersistenceType
ChannelMessageType
chimeBearer :: Text
clientRequestToken :: Sensitive Text
persistence :: ChannelMessagePersistenceType
type' :: ChannelMessageType
content :: Sensitive Text
channelArn :: Text
metadata :: Maybe (Sensitive Text)
$sel:chimeBearer:SendChannelMessage' :: SendChannelMessage -> Text
$sel:clientRequestToken:SendChannelMessage' :: SendChannelMessage -> Sensitive Text
$sel:persistence:SendChannelMessage' :: SendChannelMessage -> ChannelMessagePersistenceType
$sel:type':SendChannelMessage' :: SendChannelMessage -> ChannelMessageType
$sel:content:SendChannelMessage' :: SendChannelMessage -> Sensitive Text
$sel:channelArn:SendChannelMessage' :: SendChannelMessage -> Text
$sel:metadata:SendChannelMessage' :: SendChannelMessage -> Maybe (Sensitive Text)
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/channels/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
channelArn, ByteString
"/messages"]

instance Core.ToQuery SendChannelMessage where
  toQuery :: SendChannelMessage -> QueryString
toQuery = QueryString -> SendChannelMessage -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newSendChannelMessageResponse' smart constructor.
data SendChannelMessageResponse = SendChannelMessageResponse'
  { -- | The status of the channel message.
    SendChannelMessageResponse -> Maybe ChannelMessageStatusStructure
status :: Prelude.Maybe ChannelMessageStatusStructure,
    -- | The ARN of the channel.
    SendChannelMessageResponse -> Maybe Text
channelArn :: Prelude.Maybe Prelude.Text,
    -- | The ID string assigned to each message.
    SendChannelMessageResponse -> Maybe Text
messageId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    SendChannelMessageResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SendChannelMessageResponse -> SendChannelMessageResponse -> Bool
(SendChannelMessageResponse -> SendChannelMessageResponse -> Bool)
-> (SendChannelMessageResponse
    -> SendChannelMessageResponse -> Bool)
-> Eq SendChannelMessageResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendChannelMessageResponse -> SendChannelMessageResponse -> Bool
$c/= :: SendChannelMessageResponse -> SendChannelMessageResponse -> Bool
== :: SendChannelMessageResponse -> SendChannelMessageResponse -> Bool
$c== :: SendChannelMessageResponse -> SendChannelMessageResponse -> Bool
Prelude.Eq, ReadPrec [SendChannelMessageResponse]
ReadPrec SendChannelMessageResponse
Int -> ReadS SendChannelMessageResponse
ReadS [SendChannelMessageResponse]
(Int -> ReadS SendChannelMessageResponse)
-> ReadS [SendChannelMessageResponse]
-> ReadPrec SendChannelMessageResponse
-> ReadPrec [SendChannelMessageResponse]
-> Read SendChannelMessageResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendChannelMessageResponse]
$creadListPrec :: ReadPrec [SendChannelMessageResponse]
readPrec :: ReadPrec SendChannelMessageResponse
$creadPrec :: ReadPrec SendChannelMessageResponse
readList :: ReadS [SendChannelMessageResponse]
$creadList :: ReadS [SendChannelMessageResponse]
readsPrec :: Int -> ReadS SendChannelMessageResponse
$creadsPrec :: Int -> ReadS SendChannelMessageResponse
Prelude.Read, Int -> SendChannelMessageResponse -> ShowS
[SendChannelMessageResponse] -> ShowS
SendChannelMessageResponse -> String
(Int -> SendChannelMessageResponse -> ShowS)
-> (SendChannelMessageResponse -> String)
-> ([SendChannelMessageResponse] -> ShowS)
-> Show SendChannelMessageResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendChannelMessageResponse] -> ShowS
$cshowList :: [SendChannelMessageResponse] -> ShowS
show :: SendChannelMessageResponse -> String
$cshow :: SendChannelMessageResponse -> String
showsPrec :: Int -> SendChannelMessageResponse -> ShowS
$cshowsPrec :: Int -> SendChannelMessageResponse -> ShowS
Prelude.Show, (forall x.
 SendChannelMessageResponse -> Rep SendChannelMessageResponse x)
-> (forall x.
    Rep SendChannelMessageResponse x -> SendChannelMessageResponse)
-> Generic SendChannelMessageResponse
forall x.
Rep SendChannelMessageResponse x -> SendChannelMessageResponse
forall x.
SendChannelMessageResponse -> Rep SendChannelMessageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SendChannelMessageResponse x -> SendChannelMessageResponse
$cfrom :: forall x.
SendChannelMessageResponse -> Rep SendChannelMessageResponse x
Prelude.Generic)

-- |
-- Create a value of 'SendChannelMessageResponse' 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:
--
-- 'status', 'sendChannelMessageResponse_status' - The status of the channel message.
--
-- 'channelArn', 'sendChannelMessageResponse_channelArn' - The ARN of the channel.
--
-- 'messageId', 'sendChannelMessageResponse_messageId' - The ID string assigned to each message.
--
-- 'httpStatus', 'sendChannelMessageResponse_httpStatus' - The response's http status code.
newSendChannelMessageResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SendChannelMessageResponse
newSendChannelMessageResponse :: Int -> SendChannelMessageResponse
newSendChannelMessageResponse Int
pHttpStatus_ =
  SendChannelMessageResponse' :: Maybe ChannelMessageStatusStructure
-> Maybe Text -> Maybe Text -> Int -> SendChannelMessageResponse
SendChannelMessageResponse'
    { $sel:status:SendChannelMessageResponse' :: Maybe ChannelMessageStatusStructure
status =
        Maybe ChannelMessageStatusStructure
forall a. Maybe a
Prelude.Nothing,
      $sel:channelArn:SendChannelMessageResponse' :: Maybe Text
channelArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:messageId:SendChannelMessageResponse' :: Maybe Text
messageId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SendChannelMessageResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the channel message.
sendChannelMessageResponse_status :: Lens.Lens' SendChannelMessageResponse (Prelude.Maybe ChannelMessageStatusStructure)
sendChannelMessageResponse_status :: (Maybe ChannelMessageStatusStructure
 -> f (Maybe ChannelMessageStatusStructure))
-> SendChannelMessageResponse -> f SendChannelMessageResponse
sendChannelMessageResponse_status = (SendChannelMessageResponse -> Maybe ChannelMessageStatusStructure)
-> (SendChannelMessageResponse
    -> Maybe ChannelMessageStatusStructure
    -> SendChannelMessageResponse)
-> Lens
     SendChannelMessageResponse
     SendChannelMessageResponse
     (Maybe ChannelMessageStatusStructure)
     (Maybe ChannelMessageStatusStructure)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendChannelMessageResponse' {Maybe ChannelMessageStatusStructure
status :: Maybe ChannelMessageStatusStructure
$sel:status:SendChannelMessageResponse' :: SendChannelMessageResponse -> Maybe ChannelMessageStatusStructure
status} -> Maybe ChannelMessageStatusStructure
status) (\s :: SendChannelMessageResponse
s@SendChannelMessageResponse' {} Maybe ChannelMessageStatusStructure
a -> SendChannelMessageResponse
s {$sel:status:SendChannelMessageResponse' :: Maybe ChannelMessageStatusStructure
status = Maybe ChannelMessageStatusStructure
a} :: SendChannelMessageResponse)

-- | The ARN of the channel.
sendChannelMessageResponse_channelArn :: Lens.Lens' SendChannelMessageResponse (Prelude.Maybe Prelude.Text)
sendChannelMessageResponse_channelArn :: (Maybe Text -> f (Maybe Text))
-> SendChannelMessageResponse -> f SendChannelMessageResponse
sendChannelMessageResponse_channelArn = (SendChannelMessageResponse -> Maybe Text)
-> (SendChannelMessageResponse
    -> Maybe Text -> SendChannelMessageResponse)
-> Lens
     SendChannelMessageResponse
     SendChannelMessageResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendChannelMessageResponse' {Maybe Text
channelArn :: Maybe Text
$sel:channelArn:SendChannelMessageResponse' :: SendChannelMessageResponse -> Maybe Text
channelArn} -> Maybe Text
channelArn) (\s :: SendChannelMessageResponse
s@SendChannelMessageResponse' {} Maybe Text
a -> SendChannelMessageResponse
s {$sel:channelArn:SendChannelMessageResponse' :: Maybe Text
channelArn = Maybe Text
a} :: SendChannelMessageResponse)

-- | The ID string assigned to each message.
sendChannelMessageResponse_messageId :: Lens.Lens' SendChannelMessageResponse (Prelude.Maybe Prelude.Text)
sendChannelMessageResponse_messageId :: (Maybe Text -> f (Maybe Text))
-> SendChannelMessageResponse -> f SendChannelMessageResponse
sendChannelMessageResponse_messageId = (SendChannelMessageResponse -> Maybe Text)
-> (SendChannelMessageResponse
    -> Maybe Text -> SendChannelMessageResponse)
-> Lens
     SendChannelMessageResponse
     SendChannelMessageResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendChannelMessageResponse' {Maybe Text
messageId :: Maybe Text
$sel:messageId:SendChannelMessageResponse' :: SendChannelMessageResponse -> Maybe Text
messageId} -> Maybe Text
messageId) (\s :: SendChannelMessageResponse
s@SendChannelMessageResponse' {} Maybe Text
a -> SendChannelMessageResponse
s {$sel:messageId:SendChannelMessageResponse' :: Maybe Text
messageId = Maybe Text
a} :: SendChannelMessageResponse)

-- | The response's http status code.
sendChannelMessageResponse_httpStatus :: Lens.Lens' SendChannelMessageResponse Prelude.Int
sendChannelMessageResponse_httpStatus :: (Int -> f Int)
-> SendChannelMessageResponse -> f SendChannelMessageResponse
sendChannelMessageResponse_httpStatus = (SendChannelMessageResponse -> Int)
-> (SendChannelMessageResponse
    -> Int -> SendChannelMessageResponse)
-> Lens
     SendChannelMessageResponse SendChannelMessageResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendChannelMessageResponse' {Int
httpStatus :: Int
$sel:httpStatus:SendChannelMessageResponse' :: SendChannelMessageResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: SendChannelMessageResponse
s@SendChannelMessageResponse' {} Int
a -> SendChannelMessageResponse
s {$sel:httpStatus:SendChannelMessageResponse' :: Int
httpStatus = Int
a} :: SendChannelMessageResponse)

instance Prelude.NFData SendChannelMessageResponse