import { Injectable } from '@angular/core'; import { AwesomeCordovaNativePlugin, Cordova, Plugin } from '@awesome-cordova-plugins/core'; import { Observable } from 'rxjs'; export interface InitParams { accountName: string; closeWithClearVisitorData: boolean; storeHistoryLocally: boolean; pushToken: string; location: string; visitorFields: string; } export interface DefaultResponse { result: string; } export interface Quote { state: string; id: string; text: string; url: string; timestamp: string; senderName: string; authorID: string; } export interface Employee { id: string; firstname: string; avatar: string; } export interface Keyboard { state: string; buttons: Array; keyboardResponse: KeyboardResponse; } export interface KeyboardRequest { messageID: string; button: KeyboardButton; } export interface KeyboardButton { text: string; id: string; } export interface KeyboardResponse { buttonID: string; messageID: string; } export interface Message { id: string; currentChatID: string; text: string; url: string; imageWidth: number; imageHeight: number; thumbUrl: string; timestamp: string; sender: string; quote: Quote; operator: Employee; keyboard: Keyboard; keyboardRequest: KeyboardRequest; isFirst: boolean; isReadByOperator: boolean; canBeReplied: boolean; } export interface DialogState { employee: Employee; } export type MessagesHistoryResponse = Array; export type MessageResponse = Message; export type DialogStateResponse = DialogState; /** * @name Webim * @description * A cordova plugin, a JS version of Webim SDK * @usage * ```typescript * import { Webim } from '@awesome-cordova-plugins/webim/ngx'; * * * constructor(private webim: Webim) { } * * ... * * * this.webim.functionName('Hi bro', 42) * .then((res: any) => console.log(res)) * .catch((error: any) => console.error(error)); * * ``` */ @Plugin({ pluginName: 'Webim', plugin: 'ru.webim.sdk', pluginRef: 'webimsdk', repo: 'https://github.com/webim/webim-cordova-plugin.git', install: 'cordova plugin add https://github.com/webim/webim-cordova-plugin.git', platforms: ['Android', 'iOS', 'Browser'], }) @Injectable() export class Webim extends AwesomeCordovaNativePlugin { @Cordova() init(params: InitParams): Promise { return; } @Cordova() requestDialog(): Promise { return; } @Cordova() getMessagesHistory(limit: number, offset: number): Promise { return; } @Cordova() typingMessage(message: string): Promise { return; } @Cordova() sendMessage(message: string): Promise { return; } @Cordova() replyMessage(message: string, repliedMessage: Message): Promise { return; } @Cordova() sendFile(filePath: string): Promise { return; } @Cordova() sendSurveyAnswer(surveyAnswer: string): Promise { return; } @Cordova() cancelSurvey(): Promise { return; } @Cordova({ observable: true, clearFunction: 'close', }) onMessage(): Observable { return; } @Cordova({ observable: true, clearFunction: 'close', }) onDeletedMessage(): Observable { return; } @Cordova({ observable: true, clearFunction: 'close', }) onFile(message: string): Observable { return; } @Cordova({ observable: true, clearFunction: 'close', }) onTyping(): Observable { return; } @Cordova({ observable: true, clearFunction: 'close', }) onConfirm(): Observable { return; } @Cordova({ observable: true, clearFunction: 'close', }) onDialog(): Observable { return; } @Cordova({ observable: true, clearFunction: 'close', }) onBan(): Observable { return; } @Cordova() close(): Promise { return; } @Cordova() rateOperator(id: string, rating: number): Promise { return; } @Cordova() rateOperatorWithNote(id: string, rating: number, note: string): Promise { return; } @Cordova() sendDialogToEmailAddress(emailAddress: string): Promise { return; } @Cordova({ observable: true, clearFunction: 'close', }) onUnreadByVisitorMessageCount(): Observable { return; } @Cordova({ observable: true, clearFunction: 'close', }) onSurvey(): Observable { return; } @Cordova({ observable: true, clearFunction: 'close', }) onNextQuestion(): Observable { return; } @Cordova({ observable: true, clearFunction: 'close', }) onSurveyCancel(): Observable { return; } @Cordova() getUnreadByVisitorMessageCount(): Promise { return; } @Cordova() sendKeyboardRequest(): Promise { return; } @Cordova() setChatRead(): Promise { return; } @Cordova() getShowEmailButton(): Promise { return; } @Cordova() showRateOperatorWindow(): Promise { return; } @Cordova({ observable: true, clearFunction: 'close', }) onLogging(): Observable { return; } }