# Class ApiClient | EchoHub Documentation

# Class ApiClient

Namespace
  EchoHub.Client.Services

Assembly
  EchoHub.Client.dll

    public sealed class ApiClient : IDisposable

Inheritance
  object
  ApiClient

Implements
  IDisposable

Inherited Members
  object.GetType()
  object.ToString()
  object.Equals(object)
  object.Equals(object, object)
  object.ReferenceEquals(object, object)
  object.GetHashCode()

## Constructors

### ApiClient(string)

    public ApiClient(string baseUrl)

#### Parameters

`baseUrl` string

## Properties

### BaseUrl

    public string BaseUrl { get; }

#### Property Value

string

### RefreshToken

    public string? RefreshToken { get; }

#### Property Value

string

### Token

    public string? Token { get; }

#### Property Value

string

## Methods

### CreateChannelAsync(string, string?)

    public Task<ChannelDto?> CreateChannelAsync(string name, string? topic = null)

#### Parameters

`name` string
`topic` string

#### Returns

Task<ChannelDto>

### DeleteChannelAsync(string)

    public Task DeleteChannelAsync(string channelName)

#### Parameters

`channelName` string

#### Returns

Task

### Dispose()

    public void Dispose()

### GetChannelsAsync()

    public Task<List<ChannelDto>> GetChannelsAsync()

#### Returns

Task<List<ChannelDto>>

### GetServerInfoAsync()

    public Task<ServerStatusDto?> GetServerInfoAsync()

#### Returns

Task<ServerStatusDto>

### GetUserProfileAsync(string)

    public Task<UserProfileDto?> GetUserProfileAsync(string username)

#### Parameters

`username` string

#### Returns

Task<UserProfileDto>

### GetValidTokenAsync()

Returns a valid access token, refreshing if expired. Used by EchoHubConnection for SignalR token provider.

    public Task<string?> GetValidTokenAsync()

#### Returns

Task<string>

### LoginAsync(string, string)

    public Task<LoginResponse> LoginAsync(string username, string password)

#### Parameters

`username` string
`password` string

#### Returns

Task<LoginResponse>

### LogoutAsync()

    public Task LogoutAsync()

#### Returns

Task

### RefreshTokenAsync()

    public Task RefreshTokenAsync()

#### Returns

Task

### RegisterAsync(string, string, string?)

    public Task<LoginResponse> RegisterAsync(string username, string password, string? displayName = null)

#### Parameters

`username` string
`password` string
`displayName` string

#### Returns

Task<LoginResponse>

### SendUrlAsync(string, string)

    public Task<MessageDto?> SendUrlAsync(string channelName, string url)

#### Parameters

`channelName` string
`url` string

#### Returns

Task<MessageDto>

### UpdateChannelTopicAsync(string, string?)

    public Task<ChannelDto?> UpdateChannelTopicAsync(string channelName, string? topic)

#### Parameters

`channelName` string
`topic` string

#### Returns

Task<ChannelDto>

### UpdateProfileAsync(UpdateProfileRequest)

    public Task<UserProfileDto?> UpdateProfileAsync(UpdateProfileRequest request)

#### Parameters

`request` UpdateProfileRequest

#### Returns

Task<UserProfileDto>

### UploadAvatarAsync(Stream, string)

    public Task<string?> UploadAvatarAsync(Stream imageStream, string fileName)

#### Parameters

`imageStream` Stream
`fileName` string

#### Returns

Task<string>

### UploadFileAsync(string, Stream, string)

    public Task<MessageDto?> UploadFileAsync(string channelName, Stream fileStream, string fileName)

#### Parameters

`channelName` string
`fileStream` Stream
`fileName` string

#### Returns

Task<MessageDto>