Search documentation of ExStreamClient

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

View Source

Modules for interacting with the `chat/channels` 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

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

Deletes channel

delete_channels(payload, opts \\ [])

Allows to delete several channels at once asynchronously

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

Deletes a draft

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

Deletes previously uploaded file

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

Deletes previously uploaded image

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

Get a draft

get_many_messages(type, id, ids, opts \\ [])

Returns list messages found by IDs

get_or_create_channel(type, id, payload, opts \\ [])

This Method creates a channel or returns an existing one with matching attributes

get_or_create_distinct_channel(type, payload, opts \\ [])

This Method creates a channel or returns an existing one with matching attributes

hide_channel(type, id, payload, opts \\ [])

Marks channel as hidden for current user

mark_channels_read(payload, opts \\ [])

Marks channels as read up to the specific message. If no channels is given, mark all channel as read

mark_read(type, id, payload, opts \\ [])

Marks channel as read up to the specific message

mark_unread(type, id, payload, opts \\ [])

Marks channel as unread from a specific message

query_channels(payload, opts \\ [])

Query channels with filter query

send_event(type, id, payload, opts \\ [])

Sends event to the channel

send_message(type, id, payload, opts \\ [])

Sends new message to the specified channel

show_channel(type, id, payload, opts \\ [])

Shows previously hidden channel

truncate_channel(type, id, payload, opts \\ [])

Truncates messages from a channel. Can be applied to the entire channel or scoped to specific members.

update_channel(type, id, payload, opts \\ [])

Change channel data

update_channel_partial(type, id, payload, opts \\ [])

Updates certain fields of the channel

update_member_partial(type, id, payload, opts \\ [])
upload_file(type, id, payload, opts \\ [])

Uploads file

upload_image(type, id, payload, opts \\ [])

Uploads image

# Types

# shared_opts()

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

# Functions

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

    @spec delete_channel(String.t(), String.t(), [
      {:hard_delete, boolean()} | shared_opts()
    ]) ::
      {:ok, ExStreamClient.Model.DeleteChannelResponse.t()} | {:error, any()}

Deletes channel

### Sends events:

- `channel.deleted`
- `channel.deleted`

### Required Arguments:

- `type`
- `id`

### Optional Arguments:

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

# delete_channels(payload, opts \\ [])

    @spec delete_channels(ExStreamClient.Model.DeleteChannelsRequest.t(), shared_opts()) ::
      {:ok, ExStreamClient.Model.DeleteChannelsResponse.t()} | {:error, any()}

Allows to delete several channels at once asynchronously

### Sends events:

- `channel.deleted`
- `channel.deleted`

### Required Arguments:

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

### Optional Arguments:

- All options from Shared Options are supported.

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

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

Deletes a draft

### Sends events:

- `draft.deleted`

### Required Arguments:

- `type`
- `id`

### Optional Arguments:

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

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

    @spec delete_file(String.t(), String.t(), [{:url, String.t()} | shared_opts()]) ::
      {:ok, ExStreamClient.Model.Response.t()} | {:error, any()}

Deletes previously uploaded file

### Required Arguments:

- `type`
- `id`

### Optional Arguments:

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

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

    @spec delete_image(String.t(), String.t(), [{:url, String.t()} | shared_opts()]) ::
      {:ok, ExStreamClient.Model.Response.t()} | {:error, any()}

Deletes previously uploaded image

### Required Arguments:

- `type`
- `id`

### Optional Arguments:

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

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

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

Get a draft

### Required Arguments:

- `type`
- `id`

### Optional Arguments:

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

# get_many_messages(type, id, ids, opts \\ [])

    @spec get_many_messages(String.t(), String.t(), list(), shared_opts()) ::
      {:ok, ExStreamClient.Model.GetManyMessagesResponse.t()} | {:error, any()}

Returns list messages found by IDs

### Required Arguments:

- `type`
- `id`
- `ids`

### Optional Arguments:

- All options from Shared Options are supported.

# get_or_create_channel(type, id, payload, opts \\ [])

    @spec get_or_create_channel(
      String.t(),
      String.t(),
      ExStreamClient.Model.ChannelGetOrCreateRequest.t(),
      shared_opts()
    ) :: {:ok, ExStreamClient.Model.ChannelStateResponse.t()} | {:error, any()}

This Method creates a channel or returns an existing one with matching attributes

### Sends events:

- `channel.created`
- `member.added`
- `member.removed`
- `member.updated`
- `user.watching.start`

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.ChannelGetOrCreateRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# get_or_create_distinct_channel(type, payload, opts \\ [])

    @spec get_or_create_distinct_channel(
      String.t(),
      ExStreamClient.Model.ChannelGetOrCreateRequest.t(),
      shared_opts()
    ) :: {:ok, ExStreamClient.Model.ChannelStateResponse.t()} | {:error, any()}

This Method creates a channel or returns an existing one with matching attributes

### Sends events:

- `channel.created`
- `member.added`
- `member.removed`
- `member.updated`
- `user.watching.start`

### Required Arguments:

- `type`
- `payload`: `Elixir.ExStreamClient.Model.ChannelGetOrCreateRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# hide_channel(type, id, payload, opts \\ [])

    @spec hide_channel(
      String.t(),
      String.t(),
      ExStreamClient.Model.HideChannelRequest.t(),
      shared_opts()
    ) :: {:ok, ExStreamClient.Model.HideChannelResponse.t()} | {:error, any()}

Marks channel as hidden for current user

### Sends events:

- `channel.hidden`
- `channel.hidden`

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.HideChannelRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# mark_channels_read(payload, opts \\ [])

    @spec mark_channels_read(
      ExStreamClient.Model.MarkChannelsReadRequest.t(),
      shared_opts()
    ) ::
      {:ok, ExStreamClient.Model.MarkReadResponse.t()} | {:error, any()}

Marks channels as read up to the specific message. If no channels is given, mark all channel as read

### Sends events:

- `message.read`
- `message.read`

### Required Arguments:

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

### Optional Arguments:

- All options from Shared Options are supported.

# mark_read(type, id, payload, opts \\ [])

    @spec mark_read(
      String.t(),
      String.t(),
      ExStreamClient.Model.MarkReadRequest.t(),
      shared_opts()
    ) ::
      {:ok, ExStreamClient.Model.MarkReadResponse.t()} | {:error, any()}

Marks channel as read up to the specific message

### Sends events:

- `message.read`
- `message.read`

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.MarkReadRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# mark_unread(type, id, payload, opts \\ [])

    @spec mark_unread(
      String.t(),
      String.t(),
      ExStreamClient.Model.MarkUnreadRequest.t(),
      shared_opts()
    ) :: {:ok, ExStreamClient.Model.Response.t()} | {:error, any()}

Marks channel as unread from a specific message

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.MarkUnreadRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# query_channels(payload, opts \\ [])

    @spec query_channels(ExStreamClient.Model.QueryChannelsRequest.t(), shared_opts()) ::
      {:ok, ExStreamClient.Model.QueryChannelsResponse.t()} | {:error, any()}

Query channels with filter query

### Required Arguments:

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

### Optional Arguments:

- All options from Shared Options are supported.

# send_event(type, id, payload, opts \\ [])

    @spec send_event(
      String.t(),
      String.t(),
      ExStreamClient.Model.SendEventRequest.t(),
      shared_opts()
    ) ::
      {:ok, ExStreamClient.Model.EventResponse.t()} | {:error, any()}

Sends event to the channel

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.SendEventRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# send_message(type, id, payload, opts \\ [])

    @spec send_message(
      String.t(),
      String.t(),
      ExStreamClient.Model.SendMessageRequest.t(),
      shared_opts()
    ) :: {:ok, ExStreamClient.Model.SendMessageResponse.t()} | {:error, any()}

Sends new message to the specified channel

### Sends events:

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

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.SendMessageRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# show_channel(type, id, payload, opts \\ [])

    @spec show_channel(
      String.t(),
      String.t(),
      ExStreamClient.Model.ShowChannelRequest.t(),
      shared_opts()
    ) :: {:ok, ExStreamClient.Model.ShowChannelResponse.t()} | {:error, any()}

Shows previously hidden channel

### Sends events:

- `channel.visible`
- `channel.visible`

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.ShowChannelRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# truncate_channel(type, id, payload, opts \\ [])

    @spec truncate_channel(
      String.t(),
      String.t(),
      ExStreamClient.Model.TruncateChannelRequest.t(),
      shared_opts()
    ) :: {:ok, ExStreamClient.Model.TruncateChannelResponse.t()} | {:error, any()}

Truncates messages from a channel. Can be applied to the entire channel or scoped to specific members.

### Sends events:

- `channel.truncated`
- `channel.truncated`

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.TruncateChannelRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# update_channel(type, id, payload, opts \\ [])

    @spec update_channel(
      String.t(),
      String.t(),
      ExStreamClient.Model.UpdateChannelRequest.t(),
      shared_opts()
    ) :: {:ok, ExStreamClient.Model.UpdateChannelResponse.t()} | {:error, any()}

Change channel data

### Sends events:

- `channel.updated`
- `member.added`
- `member.removed`
- `member.updated`
- `message.new`
- `channel.updated`
- `member.added`
- `member.removed`
- `member.updated`
- `message.new`

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.UpdateChannelRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# update_channel_partial(type, id, payload, opts \\ [])

    @spec update_channel_partial(
      String.t(),
      String.t(),
      ExStreamClient.Model.UpdateChannelPartialRequest.t(),
      shared_opts()
    ) ::
      {:ok, ExStreamClient.Model.UpdateChannelPartialResponse.t()} | {:error, any()}

Updates certain fields of the channel

### Sends events:

- `channel.updated`
- `channel.updated`

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.UpdateChannelPartialRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# update_member_partial(type, id, payload, opts \\ [])

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

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.UpdateMemberPartialRequest`

### Optional Arguments:

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

# upload_file(type, id, payload, opts \\ [])

    @spec upload_file(
      String.t(),
      String.t(),
      ExStreamClient.Model.FileUploadRequest.t(),
      shared_opts()
    ) :: {:ok, ExStreamClient.Model.FileUploadResponse.t()} | {:error, any()}

Uploads file

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.FileUploadRequest`

### Optional Arguments:

- All options from Shared Options are supported.

# upload_image(type, id, payload, opts \\ [])

    @spec upload_image(
      String.t(),
      String.t(),
      ExStreamClient.Model.ImageUploadRequest.t(),
      shared_opts()
    ) :: {:ok, ExStreamClient.Model.ImageUploadResponse.t()} | {:error, any()}

Uploads image

### Required Arguments:

- `type`
- `id`
- `payload`: `Elixir.ExStreamClient.Model.ImageUploadRequest`

### Optional Arguments:

- All options from Shared Options are supported.