IChat2Desk

interface IChat2Desk

Interface that may be used for connect to Chat2Desk, make and receive messages.

Inheritors

Properties

Link copied to clipboard
abstract val clientPhone: String?

Client key for current connection

Link copied to clipboard
abstract val connectionStatus: StateFlow<ConnectionState?>

Current connection status.

Link copied to clipboard
abstract val customFields: StateFlow<List<CustomField>>

List of custom fields, declared on company.

Link copied to clipboard
abstract val error: StateFlow<Throwable?>

Flow with errors.

Link copied to clipboard
abstract val messages: StateFlow<List<Message>>

List of Message.

Link copied to clipboard
abstract val operator: StateFlow<Operator?>

Current connected operator.

Functions

Link copied to clipboard
abstract suspend fun fetchMessages()

Fetch all messages from Chat2Desk service. If you want to receive new message we recommend to use IChat2Desk.fetchNewMessages After fetching process the property IChat2Desk.messages will be updated.

Link copied to clipboard
abstract suspend fun fetchNewMessages()

Fetch new messages. This method receive new messages from server if their exists After fetching process the property IChat2Desk.messages will be updated.

Link copied to clipboard
abstract suspend fun flushAll()

Remove all library data like IChat2Desk.messages, IChat2Desk.clientPhone. It will also stop the current connection to the service. After reset, you need to call IChat2Desk.start to start using the library.

Link copied to clipboard
abstract suspend fun read()

Mark chat is read.

Link copied to clipboard
abstract suspend fun resendMessage(message: Message)

Resend message if it have status DeliveryStatus.NOT_DELIVERED.

Link copied to clipboard
abstract suspend fun sendClientParams(name: String = "", phone: String = "", fieldSet: Map<Int, String> = emptyMap())

Send client params. You can send name and phone by default. If you want to send other client field, which declared in Chat2Desk service, you need to use CustomField.id property from IChat2Desk.customFields as key and your value

Link copied to clipboard
abstract suspend fun sendMessage(msg: String)

Send the simple message with text.

abstract suspend fun sendMessage(msg: String, attachedFile: AttachedFile)

Send the message with attachment.

Link copied to clipboard
abstract suspend fun start(): String?

Connect to Chat2Desk and start the chat.

abstract suspend fun start(clientId: String? = null): String?

Connect to Chat2Desk with client key and start the chat.

Link copied to clipboard
abstract suspend fun stop()

Disconnect from Chat2Desk.