diff --git a/src/@awesome-cordova-plugins/plugins/webim/index.ts b/src/@awesome-cordova-plugins/plugins/webim/index.ts index 415a5d6756..a058efabea 100644 --- a/src/@awesome-cordova-plugins/plugins/webim/index.ts +++ b/src/@awesome-cordova-plugins/plugins/webim/index.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; -import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core'; +import { AwesomeCordovaNativePlugin, Cordova, Plugin } from '@awesome-cordova-plugins/core'; +import { Observable } from 'rxjs'; export interface InitParams { accountName: string; @@ -10,10 +11,73 @@ export interface InitParams { visitorFields: string; } -export interface InitResponse { +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 @@ -37,167 +101,197 @@ export interface InitResponse { */ @Plugin({ pluginName: 'Webim', - plugin: 'webim-cordova-plugin', - pluginRef: '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{ + init(params: InitParams): Promise { return; } - @Cordova() - requestDialog(): Promise { + requestDialog(): Promise { return; } - @Cordova() - getMessagesHistory(limit: number, offset: number): Promise{ + getMessagesHistory(limit: number, offset: number): Promise { return; } - @Cordova() - typingMessage(message: string): Promise{ + typingMessage(message: string): Promise { return; } @Cordova() - sendMessage(message: string): Promise{ + sendMessage(message: string): Promise { return; } @Cordova() - replyMessage(message: string): Promise{ + replyMessage(message: string, repliedMessage: Message): Promise { return; } @Cordova() - sendFile(filePath: string): Promise{ + sendFile(filePath: string): Promise { return; } @Cordova() - sendSurveyAnswer(surveyAnswer: string): Promise{ + sendSurveyAnswer(surveyAnswer: string): Promise { return; } @Cordova() - cancelSurvey(): Promise{ + cancelSurvey(): Promise { return; } - @Cordova() - onMessage(): Promise{ + @Cordova({ + observable: true, + clearFunction: 'close', + }) + onMessage(): Observable { return; } - @Cordova() - onDeletedMessage(): Promise{ + @Cordova({ + observable: true, + clearFunction: 'close', + }) + onDeletedMessage(): Observable { return; } - @Cordova() - onFile(message: string): Promise{ + @Cordova({ + observable: true, + clearFunction: 'close', + }) + onFile(message: string): Observable { return; } - @Cordova() - onTyping(): Promise{ + @Cordova({ + observable: true, + clearFunction: 'close', + }) + onTyping(): Observable { return; } - @Cordova() - onConfirm(): Promise{ + @Cordova({ + observable: true, + clearFunction: 'close', + }) + onConfirm(): Observable { return; } - @Cordova() - onDialog(): Promise{ + @Cordova({ + observable: true, + clearFunction: 'close', + }) + onDialog(): Observable { return; } - @Cordova() - onBan(): Promise{ + @Cordova({ + observable: true, + clearFunction: 'close', + }) + onBan(): Observable { return; } @Cordova() - close(): Promise{ + close(): Promise { return; } @Cordova() - rateOperator(id: string, rating: number): Promise{ + rateOperator(id: string, rating: number): Promise { return; } @Cordova() - rateOperatorWithNote(id: string, rating: number, note: string): Promise{ + rateOperatorWithNote(id: string, rating: number, note: string): Promise { return; } @Cordova() - sendDialogToEmailAddress(emailAddress: string): Promise{ + sendDialogToEmailAddress(emailAddress: string): Promise { return; } - @Cordova() - onUnreadByVisitorMessageCount(): Promise{ + @Cordova({ + observable: true, + clearFunction: 'close', + }) + onUnreadByVisitorMessageCount(): Observable { return; } - @Cordova() - onSurvey(): Promise{ + @Cordova({ + observable: true, + clearFunction: 'close', + }) + onSurvey(): Observable { return; } - @Cordova() - onNextQuestion(): Promise{ + @Cordova({ + observable: true, + clearFunction: 'close', + }) + onNextQuestion(): Observable { return; } - @Cordova() - onSurveyCancel(): Promise{ + @Cordova({ + observable: true, + clearFunction: 'close', + }) + onSurveyCancel(): Observable { return; } @Cordova() - getUnreadByVisitorMessageCount(): Promise{ + getUnreadByVisitorMessageCount(): Promise { return; } @Cordova() - sendKeyboardRequest(): Promise{ + sendKeyboardRequest(): Promise { return; } @Cordova() - setChatRead(): Promise{ + setChatRead(): Promise { return; } @Cordova() - getShowEmailButton(): Promise{ + getShowEmailButton(): Promise { return; } @Cordova() - showRateOperatorWindow(): Promise{ + showRateOperatorWindow(): Promise { return; } - @Cordova() - onLogging(): Promise{ + @Cordova({ + observable: true, + clearFunction: 'close', + }) + onLogging(): Observable { return; } - }