Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webim): update plugin wrapper #4370

Merged
merged 5 commits into from
Oct 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 146 additions & 52 deletions src/@awesome-cordova-plugins/plugins/webim/index.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<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
Expand All @@ -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<InitResponse>{
init(params: InitParams): Promise<DefaultResponse> {
return;
}


@Cordova()
requestDialog(): Promise<any> {
requestDialog(): Promise<DefaultResponse> {
return;
}


@Cordova()
getMessagesHistory(limit: number, offset: number): Promise<any>{
getMessagesHistory(limit: number, offset: number): Promise<MessagesHistoryResponse | DefaultResponse> {
return;
}


@Cordova()
typingMessage(message: string): Promise<any>{
typingMessage(message: string): Promise<string> {
return;
}

@Cordova()
sendMessage(message: string): Promise<any>{
sendMessage(message: string): Promise<MessageResponse | DefaultResponse> {
return;
}

@Cordova()
replyMessage(message: string): Promise<any>{
replyMessage(message: string, repliedMessage: Message): Promise<MessageResponse | DefaultResponse> {
return;
}

@Cordova()
sendFile(filePath: string): Promise<any>{
sendFile(filePath: string): Promise<string | DefaultResponse> {
return;
}

@Cordova()
sendSurveyAnswer(surveyAnswer: string): Promise<any>{
sendSurveyAnswer(surveyAnswer: string): Promise<any> {
return;
}

@Cordova()
cancelSurvey(): Promise<any>{
cancelSurvey(): Promise<any> {
return;
}

@Cordova()
onMessage(): Promise<any>{
@Cordova({
observable: true,
clearFunction: 'close',
})
onMessage(): Observable<MessageResponse> {
return;
}

@Cordova()
onDeletedMessage(): Promise<any>{
@Cordova({
observable: true,
clearFunction: 'close',
})
onDeletedMessage(): Observable<MessageResponse> {
return;
}

@Cordova()
onFile(message: string): Promise<any>{
@Cordova({
observable: true,
clearFunction: 'close',
})
onFile(message: string): Observable<MessageResponse> {
return;
}

@Cordova()
onTyping(): Promise<any>{
@Cordova({
observable: true,
clearFunction: 'close',
})
onTyping(): Observable<unknown> {
return;
}

@Cordova()
onConfirm(): Promise<any>{
@Cordova({
observable: true,
clearFunction: 'close',
})
onConfirm(): Observable<MessageResponse> {
return;
}

@Cordova()
onDialog(): Promise<any>{
@Cordova({
observable: true,
clearFunction: 'close',
})
onDialog(): Observable<DialogStateResponse> {
return;
}

@Cordova()
onBan(): Promise<any>{
@Cordova({
observable: true,
clearFunction: 'close',
})
onBan(): Observable<unknown> {
return;
}

@Cordova()
close(): Promise<any>{
close(): Promise<DefaultResponse> {
return;
}

@Cordova()
rateOperator(id: string, rating: number): Promise<any>{
rateOperator(id: string, rating: number): Promise<any> {
return;
}

@Cordova()
rateOperatorWithNote(id: string, rating: number, note: string): Promise<any>{
rateOperatorWithNote(id: string, rating: number, note: string): Promise<any> {
return;
}

@Cordova()
sendDialogToEmailAddress(emailAddress: string): Promise<any>{
sendDialogToEmailAddress(emailAddress: string): Promise<any> {
return;
}

@Cordova()
onUnreadByVisitorMessageCount(): Promise<any>{
@Cordova({
observable: true,
clearFunction: 'close',
})
onUnreadByVisitorMessageCount(): Observable<unknown> {
return;
}

@Cordova()
onSurvey(): Promise<any>{
@Cordova({
observable: true,
clearFunction: 'close',
})
onSurvey(): Observable<unknown> {
return;
}

@Cordova()
onNextQuestion(): Promise<any>{
@Cordova({
observable: true,
clearFunction: 'close',
})
onNextQuestion(): Observable<unknown> {
return;
}

@Cordova()
onSurveyCancel(): Promise<any>{
@Cordova({
observable: true,
clearFunction: 'close',
})
onSurveyCancel(): Observable<unknown> {
return;
}

@Cordova()
getUnreadByVisitorMessageCount(): Promise<any>{
getUnreadByVisitorMessageCount(): Promise<any> {
return;
}

@Cordova()
sendKeyboardRequest(): Promise<any>{
sendKeyboardRequest(): Promise<any> {
return;
}

@Cordova()
setChatRead(): Promise<any>{
setChatRead(): Promise<any> {
return;
}

@Cordova()
getShowEmailButton(): Promise<any>{
getShowEmailButton(): Promise<any> {
return;
}

@Cordova()
showRateOperatorWindow(): Promise<any>{
showRateOperatorWindow(): Promise<any> {
return;
}

@Cordova()
onLogging(): Promise<any>{
@Cordova({
observable: true,
clearFunction: 'close',
})
onLogging(): Observable<unknown> {
return;
}

}