Skip to content

mattermost MattermostClient

BigMakCode edited this page Aug 5, 2024 · 1 revision

MattermostClient Public class

Description

.NET API client for Mattermost servers with websocket polling.

Diagram

  flowchart LR
  classDef interfaceStyle stroke-dasharray: 5 5;
  classDef abstractStyle stroke-width:4px
  subgraph Mattermost
  Mattermost.MattermostClient[[MattermostClient]]
  Mattermost.IMattermostClient[[IMattermostClient]]
  class Mattermost.IMattermostClient interfaceStyle;
  end
Mattermost.IMattermostClient --> Mattermost.MattermostClient
Loading

Members

Properties

Public properties

Type Name Methods
User CurrentUserInfo
Bot user information.
get
Uri ServerAddress
Base server address.
get

Methods

Public methods

Returns Name
Task<ChannelUserInfo> AddUserToChannelAsync(string channelId, string userId)
Add user to channel.
Task<bool> ArchiveChannelAsync(string channelId)
Archive channel by specified channel identifier.
Task<Channel> CreateChannelAsync(string teamId, string name, string displayName, ChannelType channelType, string purpose, string header)
Create simple channel with specified users.
Task<Channel> CreateGroupChannelAsync(string``[] userIds)
Create group channel with specified users.
Task<bool> DeletePostAsync(string postId)
Delete post with specified post identifier.
Task<bool> DeleteUserFromChannelAsync(string channelId, string userId)
Delete user from channel.
Task<Channel> FindChannelByName(string teamId, string channelName)
Find channel by channel name and team identifier.
Task<byte``[]> GetFileAsync(string fileId)
Get file by identifier.
Task<FileDetails> GetFileDetailsAsync(string fileId)
Get file details by specified identifier.
Task<Post> GetPostAsync(string postId)
Get post by identifier.
Task<User> GetUserAsync(string userId)
Get user by identifier.
Task<User> GetUserByUsernameAsync(string username)
Get user by username.
Task<Post> SendMessageAsync(string channelId, string message, string replyToPostId, MessagePriority priority, IEnumerable<string> files)
Task<bool> SetChannelCallStateAsync(string channelId, bool isCallsEnabled)
Set call state for channel identifier.
Task StartReceivingAsync(...)
Create receiver Task with websocket polling.
Task<Post> UpdatePostAsync(string postId, string newText)
Update message text for specified post identifier.
Task<FileDetails> UploadFileAsync(string channelId, string filePath, Action<int> progressChanged)

Details

Summary

.NET API client for Mattermost servers with websocket polling.

Inheritance

Constructors

MattermostClient [1/3]

public MattermostClient(string apiToken)
Arguments
Type Name Description
string apiToken JWT API token.
Summary

Create MattermostClient with specified JWT access token.

Exceptions
Name Description
ArgumentException

MattermostClient [2/3]

public MattermostClient(string serverUrl, string apiToken)
Arguments
Type Name Description
string serverUrl Server URL with HTTP(S) scheme.
string apiToken JWT API token.
Summary

Create MattermostClient with specified server address JWT access token.

Exceptions
Name Description
ArgumentException

MattermostClient [3/3]

public MattermostClient(Uri serverUri, string apiToken)
Arguments
Type Name Description
Uri serverUri Server URI with HTTP(S) scheme.
string apiToken JWT API token.
Summary

Create MattermostClient with specified server address JWT access token.

Exceptions
Name Description
ArgumentException

Methods

StartReceivingAsync [1/2]

public virtual Task StartReceivingAsync()
Summary

Create receiver Task with websocket polling.

Returns

Receiver task.

Exceptions
Name Description
ApiKeyException

StartReceivingAsync [2/2]

public virtual async Task StartReceivingAsync(CancellationToken cancellationToken)
Arguments
Type Name Description
CancellationToken cancellationToken
Summary

Create receiver Task with websocket polling.

Returns

Receiver task.

Exceptions
Name Description
ApiKeyException

SendMessageAsync

public virtual async Task<Post> SendMessageAsync(string channelId, string message, string replyToPostId, MessagePriority priority, IEnumerable<string> files)
Arguments
Type Name Description
string channelId
string message
string replyToPostId
MessagePriority priority
IEnumerable<string> files

UpdatePostAsync

public virtual async Task<Post> UpdatePostAsync(string postId, string newText)
Arguments
Type Name Description
string postId Post identifier.
string newText New message text (Markdown supported).
Summary

Update message text for specified post identifier.

Returns

Updated post.

DeletePostAsync

public virtual async Task<bool> DeletePostAsync(string postId)
Arguments
Type Name Description
string postId Post identifier.
Summary

Delete post with specified post identifier.

Returns

True if deleted, otherwise false.

CreateGroupChannelAsync

public virtual async Task<Channel> CreateGroupChannelAsync(string[] userIds)
Arguments
Type Name Description
string``[] userIds Participant users.
Summary

Create group channel with specified users.

Returns

Created channel info.

CreateChannelAsync

public virtual async Task<Channel> CreateChannelAsync(string teamId, string name, string displayName, ChannelType channelType, string purpose, string header)
Arguments
Type Name Description
string teamId Team identifier.
string name Channel name.
string displayName Channel display name.
ChannelType channelType Channel type: open or private.
string purpose Channel purpose (optional).
string header Channel header (optional).
Summary

Create simple channel with specified users.

Returns

Created channel info.

GetUserAsync

public virtual async Task<User> GetUserAsync(string userId)
Arguments
Type Name Description
string userId User identifier.
Summary

Get user by identifier.

Returns

User information.

GetUserByUsernameAsync

public virtual async Task<User> GetUserByUsernameAsync(string username)
Arguments
Type Name Description
string username Username.
Summary

Get user by username.

Returns

User information.

AddUserToChannelAsync

public virtual async Task<ChannelUserInfo> AddUserToChannelAsync(string channelId, string userId)
Arguments
Type Name Description
string channelId Channel identifier.
string userId User identifier.
Summary

Add user to channel.

Returns

Channel user information.

DeleteUserFromChannelAsync

public virtual async Task<bool> DeleteUserFromChannelAsync(string channelId, string userId)
Arguments
Type Name Description
string channelId Channel identifier.
string userId User identifier.
Summary

Delete user from channel.

Returns

True if deleted, otherwise false.

UploadFileAsync

public virtual async Task<FileDetails> UploadFileAsync(string channelId, string filePath, Action<int> progressChanged)
Arguments
Type Name Description
string channelId
string filePath
Action<int> progressChanged

GetFileDetailsAsync

public virtual async Task<FileDetails> GetFileDetailsAsync(string fileId)
Arguments
Type Name Description
string fileId File identifier.
Summary

Get file details by specified identifier.

Returns

File details.

FindChannelByName

public virtual async Task<Channel> FindChannelByName(string teamId, string channelName)
Arguments
Type Name Description
string teamId Team identifier where channel is exists.
string channelName Channel name.
Summary

Find channel by channel name and team identifier.

Returns

Channel info.

SetChannelCallStateAsync

public virtual async Task<bool> SetChannelCallStateAsync(string channelId, bool isCallsEnabled)
Arguments
Type Name Description
string channelId Channel identifier where calls must be in specified state.
bool isCallsEnabled New state.
Summary

Set call state for channel identifier.

ArchiveChannelAsync

public virtual async Task<bool> ArchiveChannelAsync(string channelId)
Arguments
Type Name Description
string channelId Channel identifier.
Summary

Archive channel by specified channel identifier.

GetPostAsync

public virtual async Task<Post> GetPostAsync(string postId)
Arguments
Type Name Description
string postId Post identifier.
Summary

Get post by identifier.

Returns

Post information.

GetFileAsync

public virtual async Task<byte> GetFileAsync(string fileId)
Arguments
Type Name Description
string fileId File identifier.
Summary

Get file by identifier.

Returns

File bytes.

Properties

CurrentUserInfo

public virtual User CurrentUserInfo { get; }
Summary

Bot user information.

ServerAddress

public virtual Uri ServerAddress { get; }
Summary

Base server address.

Events

OnMessageReceived

public event EventHandler<MessageEventArgs> OnMessageReceived
Summary

Event called when new message received.

OnLogMessage

public event EventHandler<LogEventArgs> OnLogMessage
Summary

Event callen when log message created.

Generated with ModularDoc

Clone this wiki locally