feat(webim): update plugin wrapper (#4370)

* feat(plugins): Add Webim SDK plugin

* feat(webim): Add request/response models

* feat(webim): Fix Observable methods

* Update index.ts

Co-authored-by: Малько Сергей Сергеевич <malko@softclub.by>
Co-authored-by: SerjMalko <serhey_rti@mail.ru>
This commit is contained in:
Serj Malko 2022-10-22 19:04:29 +02:00 committed by GitHub
parent 6f14ba6031
commit 81a8b42a29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
import { Injectable } from '@angular/core'; 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 { export interface InitParams {
accountName: string; accountName: string;
@ -10,10 +11,73 @@ export interface InitParams {
visitorFields: string; visitorFields: string;
} }
export interface InitResponse { export interface DefaultResponse {
result: string; 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<KeyboardButton>;
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<Message>;
export type MessageResponse = Message;
export type DialogStateResponse = DialogState;
/** /**
* @name Webim * @name Webim
@ -37,167 +101,197 @@ export interface InitResponse {
*/ */
@Plugin({ @Plugin({
pluginName: 'Webim', pluginName: 'Webim',
plugin: 'webim-cordova-plugin', plugin: 'ru.webim.sdk',
pluginRef: 'Webim', pluginRef: 'webimsdk',
repo: 'https://github.com/webim/webim-cordova-plugin.git', repo: 'https://github.com/webim/webim-cordova-plugin.git',
install: 'cordova plugin add https://github.com/webim/webim-cordova-plugin.git', install: 'cordova plugin add https://github.com/webim/webim-cordova-plugin.git',
platforms: ['Android', 'iOS', 'Browser'], platforms: ['Android', 'iOS', 'Browser'],
}) })
@Injectable() @Injectable()
export class Webim extends AwesomeCordovaNativePlugin { export class Webim extends AwesomeCordovaNativePlugin {
@Cordova() @Cordova()
init(params: InitParams): Promise<InitResponse>{ init(params: InitParams): Promise<DefaultResponse> {
return;
}
@Cordova()
requestDialog(): Promise<any> {
return;
}
@Cordova()
getMessagesHistory(limit: number, offset: number): Promise<any>{
return;
}
@Cordova()
typingMessage(message: string): Promise<any>{
return; return;
} }
@Cordova() @Cordova()
sendMessage(message: string): Promise<any>{ requestDialog(): Promise<DefaultResponse> {
return; return;
} }
@Cordova() @Cordova()
replyMessage(message: string): Promise<any>{ getMessagesHistory(limit: number, offset: number): Promise<MessagesHistoryResponse | DefaultResponse> {
return; return;
} }
@Cordova() @Cordova()
sendFile(filePath: string): Promise<any>{ typingMessage(message: string): Promise<string> {
return; return;
} }
@Cordova() @Cordova()
sendSurveyAnswer(surveyAnswer: string): Promise<any>{ sendMessage(message: string): Promise<MessageResponse | DefaultResponse> {
return; return;
} }
@Cordova() @Cordova()
cancelSurvey(): Promise<any>{ replyMessage(message: string, repliedMessage: Message): Promise<MessageResponse | DefaultResponse> {
return; return;
} }
@Cordova() @Cordova()
onMessage(): Promise<any>{ sendFile(filePath: string): Promise<string | DefaultResponse> {
return; return;
} }
@Cordova() @Cordova()
onDeletedMessage(): Promise<any>{ sendSurveyAnswer(surveyAnswer: string): Promise<any> {
return; return;
} }
@Cordova() @Cordova()
onFile(message: string): Promise<any>{ cancelSurvey(): Promise<any> {
return;
}
@Cordova({
observable: true,
clearFunction: 'close',
})
onMessage(): Observable<MessageResponse> {
return;
}
@Cordova({
observable: true,
clearFunction: 'close',
})
onDeletedMessage(): Observable<MessageResponse> {
return;
}
@Cordova({
observable: true,
clearFunction: 'close',
})
onFile(message: string): Observable<MessageResponse> {
return;
}
@Cordova({
observable: true,
clearFunction: 'close',
})
onTyping(): Observable<unknown> {
return;
}
@Cordova({
observable: true,
clearFunction: 'close',
})
onConfirm(): Observable<MessageResponse> {
return;
}
@Cordova({
observable: true,
clearFunction: 'close',
})
onDialog(): Observable<DialogStateResponse> {
return;
}
@Cordova({
observable: true,
clearFunction: 'close',
})
onBan(): Observable<unknown> {
return; return;
} }
@Cordova() @Cordova()
onTyping(): Promise<any>{ close(): Promise<DefaultResponse> {
return; return;
} }
@Cordova() @Cordova()
onConfirm(): Promise<any>{ rateOperator(id: string, rating: number): Promise<any> {
return; return;
} }
@Cordova() @Cordova()
onDialog(): Promise<any>{ rateOperatorWithNote(id: string, rating: number, note: string): Promise<any> {
return; return;
} }
@Cordova() @Cordova()
onBan(): Promise<any>{ sendDialogToEmailAddress(emailAddress: string): Promise<any> {
return;
}
@Cordova({
observable: true,
clearFunction: 'close',
})
onUnreadByVisitorMessageCount(): Observable<unknown> {
return;
}
@Cordova({
observable: true,
clearFunction: 'close',
})
onSurvey(): Observable<unknown> {
return;
}
@Cordova({
observable: true,
clearFunction: 'close',
})
onNextQuestion(): Observable<unknown> {
return;
}
@Cordova({
observable: true,
clearFunction: 'close',
})
onSurveyCancel(): Observable<unknown> {
return; return;
} }
@Cordova() @Cordova()
close(): Promise<any>{ getUnreadByVisitorMessageCount(): Promise<any> {
return; return;
} }
@Cordova() @Cordova()
rateOperator(id: string, rating: number): Promise<any>{ sendKeyboardRequest(): Promise<any> {
return; return;
} }
@Cordova() @Cordova()
rateOperatorWithNote(id: string, rating: number, note: string): Promise<any>{ setChatRead(): Promise<any> {
return; return;
} }
@Cordova() @Cordova()
sendDialogToEmailAddress(emailAddress: string): Promise<any>{ getShowEmailButton(): Promise<any> {
return; return;
} }
@Cordova() @Cordova()
onUnreadByVisitorMessageCount(): Promise<any>{ showRateOperatorWindow(): Promise<any> {
return; return;
} }
@Cordova() @Cordova({
onSurvey(): Promise<any>{ observable: true,
clearFunction: 'close',
})
onLogging(): Observable<unknown> {
return; return;
} }
@Cordova()
onNextQuestion(): Promise<any>{
return;
}
@Cordova()
onSurveyCancel(): Promise<any>{
return;
}
@Cordova()
getUnreadByVisitorMessageCount(): Promise<any>{
return;
}
@Cordova()
sendKeyboardRequest(): Promise<any>{
return;
}
@Cordova()
setChatRead(): Promise<any>{
return;
}
@Cordova()
getShowEmailButton(): Promise<any>{
return;
}
@Cordova()
showRateOperatorWindow(): Promise<any>{
return;
}
@Cordova()
onLogging(): Promise<any>{
return;
}
} }