From 064bc5492d9f428963eb56a8f2f5e83a0b0d929d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=A1=D0=B5=D1=80?= =?UTF-8?q?=D0=B3=D0=B5=D0=B9=20=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B5=D0=B2?= =?UTF-8?q?=D0=B8=D1=87?= Date: Sat, 8 Oct 2022 09:34:39 +0300 Subject: [PATCH 1/4] feat(plugins): Add Webim SDK plugin --- .../plugins/webim/index.ts | 203 ++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 src/@awesome-cordova-plugins/plugins/webim/index.ts diff --git a/src/@awesome-cordova-plugins/plugins/webim/index.ts b/src/@awesome-cordova-plugins/plugins/webim/index.ts new file mode 100644 index 0000000000..415a5d6756 --- /dev/null +++ b/src/@awesome-cordova-plugins/plugins/webim/index.ts @@ -0,0 +1,203 @@ +import { Injectable } from '@angular/core'; +import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core'; + +export interface InitParams { + accountName: string; + closeWithClearVisitorData: boolean; + storeHistoryLocally: boolean; + pushToken: string; + location: string; + visitorFields: string; +} + +export interface InitResponse { + result: string; +} + + +/** + * @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: 'webim-cordova-plugin', + pluginRef: 'Webim', + 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): Promise{ + return; + } + + @Cordova() + sendFile(filePath: string): Promise{ + return; + } + + @Cordova() + sendSurveyAnswer(surveyAnswer: string): Promise{ + return; + } + + @Cordova() + cancelSurvey(): Promise{ + return; + } + + @Cordova() + onMessage(): Promise{ + return; + } + + @Cordova() + onDeletedMessage(): Promise{ + return; + } + + @Cordova() + onFile(message: string): Promise{ + return; + } + + @Cordova() + onTyping(): Promise{ + return; + } + + @Cordova() + onConfirm(): Promise{ + return; + } + + @Cordova() + onDialog(): Promise{ + return; + } + + @Cordova() + onBan(): Promise{ + 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() + onUnreadByVisitorMessageCount(): Promise{ + return; + } + + @Cordova() + onSurvey(): Promise{ + return; + } + + @Cordova() + onNextQuestion(): Promise{ + return; + } + + @Cordova() + onSurveyCancel(): Promise{ + return; + } + + @Cordova() + getUnreadByVisitorMessageCount(): Promise{ + return; + } + + @Cordova() + sendKeyboardRequest(): Promise{ + return; + } + + @Cordova() + setChatRead(): Promise{ + return; + } + + @Cordova() + getShowEmailButton(): Promise{ + return; + } + + @Cordova() + showRateOperatorWindow(): Promise{ + return; + } + + @Cordova() + onLogging(): Promise{ + return; + } + +} From e78cf6c81e16048deff3715ee941e03d00d090f7 Mon Sep 17 00:00:00 2001 From: SerjMalko Date: Sat, 15 Oct 2022 09:55:43 +0300 Subject: [PATCH 2/4] feat(webim): Add request/response models --- .../plugins/webim/index.ts | 148 ++++++++++++------ 1 file changed, 103 insertions(+), 45 deletions(-) diff --git a/src/@awesome-cordova-plugins/plugins/webim/index.ts b/src/@awesome-cordova-plugins/plugins/webim/index.ts index 415a5d6756..7bfd10b61b 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,21 +11,84 @@ 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 + * @name WebimSDK * @description * A cordova plugin, a JS version of Webim SDK * @usage * ```typescript - * import { Webim } from '@awesome-cordova-plugins/webim/ngx'; + * import { WebimSDK } from '@awesome-cordova-plugins/webim/ngx'; * * - * constructor(private webim: Webim) { } + * constructor(private webim: WebimSDK) { } * * ... * @@ -36,168 +100,162 @@ export interface InitResponse { * ``` */ @Plugin({ - pluginName: 'Webim', - plugin: 'webim-cordova-plugin', - pluginRef: 'Webim', + pluginName: 'WebimSDK', + 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 { - - +export class WebimSDK 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{ + onMessage(): Observable { return; } @Cordova() - onDeletedMessage(): Promise{ + onDeletedMessage(): Observable { return; } @Cordova() - onFile(message: string): Promise{ + onFile(message: string): Observable { return; } @Cordova() - onTyping(): Promise{ + onTyping(): Observable { return; } @Cordova() - onConfirm(): Promise{ + onConfirm(): Observable { return; } @Cordova() - onDialog(): Promise{ + onDialog(): Observable { return; } @Cordova() - onBan(): Promise{ + onBan(): Observable { return; } @Cordova() - close(): Promise{ + close(): Observable { 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{ + onUnreadByVisitorMessageCount(): Observable { return; } @Cordova() - onSurvey(): Promise{ + onSurvey(): Observable { return; } @Cordova() - onNextQuestion(): Promise{ + onNextQuestion(): Observable { return; } @Cordova() - onSurveyCancel(): Promise{ + 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{ + onLogging(): Observable { return; } - } From a99ef4131856aebe2de35a3584ac79b4d314b267 Mon Sep 17 00:00:00 2001 From: SerjMalko Date: Thu, 20 Oct 2022 12:25:52 +0300 Subject: [PATCH 3/4] feat(webim): Fix Observable methods --- .../plugins/webim/index.ts | 68 ++++++++++++++----- 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/src/@awesome-cordova-plugins/plugins/webim/index.ts b/src/@awesome-cordova-plugins/plugins/webim/index.ts index 7bfd10b61b..cdfaac6f08 100644 --- a/src/@awesome-cordova-plugins/plugins/webim/index.ts +++ b/src/@awesome-cordova-plugins/plugins/webim/index.ts @@ -80,7 +80,7 @@ export type MessageResponse = Message; export type DialogStateResponse = DialogState; /** - * @name WebimSDK + * @name Webim * @description * A cordova plugin, a JS version of Webim SDK * @usage @@ -100,7 +100,7 @@ export type DialogStateResponse = DialogState; * ``` */ @Plugin({ - pluginName: 'WebimSDK', + pluginName: 'Webim', plugin: 'ru.webim.sdk', pluginRef: 'webimsdk', repo: 'https://github.com/webim/webim-cordova-plugin.git', @@ -108,7 +108,7 @@ export type DialogStateResponse = DialogState; platforms: ['Android', 'iOS', 'Browser'], }) @Injectable() -export class WebimSDK extends AwesomeCordovaNativePlugin { +export class Webim extends AwesomeCordovaNativePlugin { @Cordova() init(params: InitParams): Promise { return; @@ -154,43 +154,64 @@ export class WebimSDK extends AwesomeCordovaNativePlugin { return; } - @Cordova() + @Cordova({ + observable: true, + clearFunction: 'close', + }) onMessage(): Observable { return; } - @Cordova() + @Cordova({ + observable: true, + clearFunction: 'close', + }) onDeletedMessage(): Observable { return; } - @Cordova() + @Cordova({ + observable: true, + clearFunction: 'close', + }) onFile(message: string): Observable { return; } - @Cordova() + @Cordova({ + observable: true, + clearFunction: 'close', + }) onTyping(): Observable { return; } - @Cordova() + @Cordova({ + observable: true, + clearFunction: 'close', + }) onConfirm(): Observable { return; } - @Cordova() + @Cordova({ + observable: true, + clearFunction: 'close', + }) onDialog(): Observable { return; } - @Cordova() + @Cordova({ + observable: true, + clearFunction: 'close', + }) onBan(): Observable { return; } @Cordova() - close(): Observable { + close(): Promise { return; } @@ -209,22 +230,34 @@ export class WebimSDK extends AwesomeCordovaNativePlugin { return; } - @Cordova() + @Cordova({ + observable: true, + clearFunction: 'close', + }) onUnreadByVisitorMessageCount(): Observable { return; } - @Cordova() + @Cordova({ + observable: true, + clearFunction: 'close', + }) onSurvey(): Observable { return; } - @Cordova() + @Cordova({ + observable: true, + clearFunction: 'close', + }) onNextQuestion(): Observable { return; } - @Cordova() + @Cordova({ + observable: true, + clearFunction: 'close', + }) onSurveyCancel(): Observable { return; } @@ -254,7 +287,10 @@ export class WebimSDK extends AwesomeCordovaNativePlugin { return; } - @Cordova() + @Cordova({ + observable: true, + clearFunction: 'close', + }) onLogging(): Observable { return; } From 5dd5bf6906711419a15f383b9f9a674a56d9984f Mon Sep 17 00:00:00 2001 From: Serj Malko Date: Thu, 20 Oct 2022 12:40:01 +0300 Subject: [PATCH 4/4] Update index.ts --- src/@awesome-cordova-plugins/plugins/webim/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/@awesome-cordova-plugins/plugins/webim/index.ts b/src/@awesome-cordova-plugins/plugins/webim/index.ts index cdfaac6f08..a058efabea 100644 --- a/src/@awesome-cordova-plugins/plugins/webim/index.ts +++ b/src/@awesome-cordova-plugins/plugins/webim/index.ts @@ -85,10 +85,10 @@ export type DialogStateResponse = DialogState; * A cordova plugin, a JS version of Webim SDK * @usage * ```typescript - * import { WebimSDK } from '@awesome-cordova-plugins/webim/ngx'; + * import { Webim } from '@awesome-cordova-plugins/webim/ngx'; * * - * constructor(private webim: WebimSDK) { } + * constructor(private webim: Webim) { } * * ... *