Search documentation of ExStreamClient

# ExStreamClient.Operations.Chat.Messages (ExStreamClient v0.1.10)

View Source

Modules for interacting with the `chat/messages` group of Stream APIs

API Reference: https://getstream.github.io/protocol/?urls.primaryName=Chat%20v2

### Shared options

All functions in this module accept the following optional parameters:

- `api_key` - API key to use. If not provided, the default key from config will be used
- `api_key_secret` - API key secret to use. If not provided, the default secret from config will be used
- `endpoint` - endpoint to use. If not provided, the default endpoint from config will be used
- `client` - HTTP client to use. Must implement `ExStreamClient.Http.Behavior`. Defaults to `ExStreamClient.Http`
- `req_opts` - all of these options will be forwarded to req. See `Req.new/1` for available options

# Summary

## Types

shared_opts()

## Functions

cast_poll_vote(message_id, poll_id, payload, opts \\ [])

Cast a vote on a poll

commit_message(id, payload, opts \\ [])

Commits a pending message, which will make it visible in the channel

delete_message(id, opts \\ [])

Deletes message

delete_reaction(id, type, opts \\ [])

Removes user reaction from the message

get_message(id, opts \\ [])

Returns message by ID

get_reactions(id, opts \\ [])

Returns list of reactions of specific message

get_replies(parent_id, opts \\ [])

Returns replies (thread) of the message

query_message_history(payload, opts \\ [])

Queries history for one message

query_reactions(id, payload, opts \\ [])

Get reactions on a message

remove_poll_vote(message_id, poll_id, vote_id, opts \\ [])

Delete a vote from a poll

run_message_action(id, payload, opts \\ [])

Executes message command action with given parameters

send_reaction(id, payload, opts \\ [])

Sends reaction to specified message

translate_message(id, payload, opts \\ [])

Translates message to a given language using automated translation software

undelete_message(id, payload, opts \\ [])

Undelete a message that was previously soft-deleted

update_message(id, payload, opts \\ [])

Updates message with new data

update_message_partial(id, payload, opts \\ [])

Updates certain fields of the message

# Types

# shared_opts()

    @type shared_opts() :: [
      api_key: String.t(),
      api_key_secret: String.t(),
      client: module(),
      endpoint: String.t(),
      req_opts: keyword()
    ]

# Functions

# cast_poll_vote(message_id, poll_id, payload, opts \\ [])

    @spec cast_poll_vote(
      String.t(),
      String.t(),
      ExStreamClient.Model.CastPollVoteRequest.t(),
      shared_opts()
    ) :: {:ok, ExStreamClient.Model.PollVoteResponse.t()} | {:error, any()}

Cast a vote on a poll

### Sends events:

- `poll.vote_casted`

### Required Arguments:

- `message_id`
- `poll_id`
- `payload`: `Elixir.ExStreamClient.Model.CastPollVoteRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# commit_message(id, payload, opts \\ [])

    @spec commit_message(
      String.t(),
      ExStreamClient.Model.CommitMessageRequest.t(),
      shared_opts()
    ) ::
      {:ok, ExStreamClient.Model.MessageResponse.t()} | {:error, any()}

Commits a pending message, which will make it visible in the channel

### Sends events:

- `message.new`
- `message.updated`
- `message.new`
- `message.updated`

### Required Arguments:

- `id`
- `payload`: `Elixir.ExStreamClient.Model.CommitMessageRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# delete_message(id, opts \\ [])

    @spec delete_message(
      String.t(),
      [({:deleted_by, String.t()} | {:hard, boolean()}) | shared_opts()]
    ) :: {:ok, ExStreamClient.Model.DeleteMessageResponse.t()} | {:error, any()}

Deletes message

### Sends events:

- `message.deleted`
- `message.deleted`

### Required Arguments:

- `id`

### Optional Arguments:

- `deleted_by`
- `hard`
- All options from Shared Options are supported.

# delete_reaction(id, type, opts \\ [])

    @spec delete_reaction(String.t(), String.t(), [{:user_id, String.t()} | shared_opts()]) ::
      {:ok, ExStreamClient.Model.DeleteReactionResponse.t()} | {:error, any()}

Removes user reaction from the message

### Sends events:

- `reaction.deleted`

### Required Arguments:

- `id`
- `type`

### Optional Arguments:

- `user_id`
- All options from Shared Options are supported.

# get_message(id, opts \\ [])

    @spec get_message(String.t(), [{:show_deleted_message, boolean()} | shared_opts()]) ::
      {:ok, ExStreamClient.Model.GetMessageResponse.t()} | {:error, any()}

Returns message by ID

### Required Arguments:

- `id`

### Optional Arguments:

- `show_deleted_message`
- All options from Shared Options are supported.

# get_reactions(id, opts \\ [])

    @spec get_reactions(String.t(), [
      ({:offset, integer()} | {:limit, integer()}) | shared_opts()
    ]) ::
      {:ok, ExStreamClient.Model.GetReactionsResponse.t()} | {:error, any()}

Returns list of reactions of specific message

### Required Arguments:

- `id`

### Optional Arguments:

- `limit`
- `offset`
- All options from Shared Options are supported.

# get_replies(parent_id, opts \\ [])

    @spec get_replies(
      String.t(),
      [
        ({:created_at_around, float()}
         | {:id_around, String.t()}
         | {:created_at_before, float()}
         | {:created_at_before_or_equal, float()}
         | {:created_at_after, float()}
         | {:created_at_after_or_equal, float()}
         | {:id_lt, String.t()}
         | {:id_lte, String.t()}
         | {:id_gt, String.t()}
         | {:id_gte, String.t()}
         | {:offset, integer()}
         | {:limit, integer()}
         | {:sort, list()})
        | shared_opts()
      ]
    ) :: {:ok, ExStreamClient.Model.GetRepliesResponse.t()} | {:error, any()}

Returns replies (thread) of the message

### Required Arguments:

- `parent_id`

### Optional Arguments:

- `created_at_after`
- `created_at_after_or_equal`
- `created_at_around`
- `created_at_before`
- `created_at_before_or_equal`
- `id_around`
- `id_gt`
- `id_gte`
- `id_lt`
- `id_lte`
- `limit`
- `offset`
- `sort`
- All options from Shared Options are supported.

# query_message_history(payload, opts \\ [])

    @spec query_message_history(
      ExStreamClient.Model.QueryMessageHistoryRequest.t(),
      shared_opts()
    ) ::
      {:ok, ExStreamClient.Model.QueryMessageHistoryResponse.t()} | {:error, any()}

Queries history for one message

### Required Arguments:

- `payload`: `Elixir.ExStreamClient.Model.QueryMessageHistoryRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# query_reactions(id, payload, opts \\ [])

    @spec query_reactions(
      String.t(),
      ExStreamClient.Model.QueryReactionsRequest.t(),
      shared_opts()
    ) ::
      {:ok, ExStreamClient.Model.QueryReactionsResponse.t()} | {:error, any()}

Get reactions on a message

### Required Arguments:

- `id`
- `payload`: `Elixir.ExStreamClient.Model.QueryReactionsRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# remove_poll_vote(message_id, poll_id, vote_id, opts \\ [])

    @spec remove_poll_vote(String.t(), String.t(), String.t(), [
      {:user_id, String.t()} | shared_opts()
    ]) ::
      {:ok, ExStreamClient.Model.PollVoteResponse.t()} | {:error, any()}

Delete a vote from a poll

### Sends events:

- `poll.vote_removed`

### Required Arguments:

- `message_id`
- `poll_id`
- `vote_id`

### Optional Arguments:

- `user_id`
- All options from Shared Options are supported.

# run_message_action(id, payload, opts \\ [])

    @spec run_message_action(
      String.t(),
      ExStreamClient.Model.MessageActionRequest.t(),
      shared_opts()
    ) ::
      {:ok, ExStreamClient.Model.MessageResponse.t()} | {:error, any()}

Executes message command action with given parameters

### Sends events:

- `message.new`
- `message.new`

### Required Arguments:

- `id`
- `payload`: `Elixir.ExStreamClient.Model.MessageActionRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# send_reaction(id, payload, opts \\ [])

    @spec send_reaction(
      String.t(),
      ExStreamClient.Model.SendReactionRequest.t(),
      shared_opts()
    ) ::
      {:ok, ExStreamClient.Model.SendReactionResponse.t()} | {:error, any()}

Sends reaction to specified message

### Sends events:

- `reaction.new`
- `reaction.updated`

### Required Arguments:

- `id`
- `payload`: `Elixir.ExStreamClient.Model.SendReactionRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# translate_message(id, payload, opts \\ [])

    @spec translate_message(
      String.t(),
      ExStreamClient.Model.TranslateMessageRequest.t(),
      shared_opts()
    ) :: {:ok, ExStreamClient.Model.MessageResponse.t()} | {:error, any()}

Translates message to a given language using automated translation software

### Sends events:

- `message.updated`
- `message.updated`

### Required Arguments:

- `id`
- `payload`: `Elixir.ExStreamClient.Model.TranslateMessageRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# undelete_message(id, payload, opts \\ [])

    @spec undelete_message(
      String.t(),
      ExStreamClient.Model.UpdateMessageRequest.t(),
      shared_opts()
    ) ::
      {:ok, ExStreamClient.Model.UpdateMessageResponse.t()} | {:error, any()}

Undelete a message that was previously soft-deleted

### Sends events:

- `message.undeleted`
- `message.undeleted`

### Required Arguments:

- `id`
- `payload`: `Elixir.ExStreamClient.Model.UpdateMessageRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# update_message(id, payload, opts \\ [])

    @spec update_message(
      String.t(),
      ExStreamClient.Model.UpdateMessageRequest.t(),
      shared_opts()
    ) ::
      {:ok, ExStreamClient.Model.UpdateMessageResponse.t()} | {:error, any()}

Updates message with new data

### Sends events:

- `message.updated`
- `message.updated`

### Required Arguments:

- `id`
- `payload`: `Elixir.ExStreamClient.Model.UpdateMessageRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# update_message_partial(id, payload, opts \\ [])

    @spec update_message_partial(
      String.t(),
      ExStreamClient.Model.UpdateMessagePartialRequest.t(),
      shared_opts()
    ) ::
      {:ok, ExStreamClient.Model.UpdateMessagePartialResponse.t()} | {:error, any()}

Updates certain fields of the message

### Sends events:

- `message.updated`
- `message.updated`

### Required Arguments:

- `id`
- `payload`: `Elixir.ExStreamClient.Model.UpdateMessagePartialRequest`

### Optional Arguments:

- All options from Shared Options are supported.