This library was written in typescript, meaning all entities that the SDK deals with have an associated interface.
Assuming you installed the SDK through NPM, you can access all of the relevant interfaces as required.
Here‘s an example showing how to import an interface:
import {
Foundation,
IConversationMessage
} from "@comapi/sdk-js-foundation"
export class MessagesHelper {
/**
* Method to determine whether a message has been read or not by user
* @param {IConversationMessage} message - the message to check
* @param {string} profileId - the profileId to check read status against
*/
public static isMessageRead(message: IConversationMessage, profileId: string):boolean {
var isRead = false;
// if the message was sent by this person then skip ...
if (message.context.from.id !== profileId) {
// are there status updates and is there one for this user
if (message.statusUpdates && message.statusUpdates[profileId]) {
// is it read ?
if (message.statusUpdates[profileId].status === "read") {
isRead = true;
}
}
} else {
// the user who wrote the message obviously read it ...
isRead = true;
}
return isRead;
}
}
Available interfaces
Look in
node_modles/@comapi/foundation/src/interfaces.d.ts
to see what interfaces are available.