From 9274083b248a7a90651d1f9aa353c684aa8b8179 Mon Sep 17 00:00:00 2001 From: Srinidhi Date: Mon, 1 Jul 2019 22:47:38 +0530 Subject: [PATCH] feat(unvired-cordova-sdk): add plugin (#3061) * feat(unvired-cordova-sdk): add plugin * style(unvired-cordova-sdk): fix style --- .../plugins/unvired-cordova-sdk/index.ts | 439 ++++++++++++++++++ 1 file changed, 439 insertions(+) create mode 100644 src/@ionic-native/plugins/unvired-cordova-sdk/index.ts diff --git a/src/@ionic-native/plugins/unvired-cordova-sdk/index.ts b/src/@ionic-native/plugins/unvired-cordova-sdk/index.ts new file mode 100644 index 000000000..d7f668695 --- /dev/null +++ b/src/@ionic-native/plugins/unvired-cordova-sdk/index.ts @@ -0,0 +1,439 @@ +/** + * @name Unvired Cordova S D K + * @description + * This plugin can be used to connect to UMP ( Unvired Mobile Platform ). This plugin has a dependency on the following Cocoapod. In your iOS project, first install the dependent pod and then install the plugin. + * ``` + * pod 'UnviredCordovaSDK' + * ``` + * @usage + * ```typescript + * import { UnviredCordovaSDK } from '@ionic-native/unvired-cordova-sdk/ngx'; + * + * + * constructor(private unviredCordovaSDK: UnviredCordovaSDK) { } + * + * ... + * // Login + * let loginParameters = new LoginParameters() + * loginParameters.appName = 'UNVIRED_DIGITAL_FORMS' + * let loginResult: LoginResult = await this.unviredCordovaSDK.login(loginParameters) + * + * // Make a Sync call. + * let result = await this.unviredCordovaSDK.syncForeground(RequestType.QUERY, null, inputObj, 'UNVIRED_DIGITAL_FORMS_PA_MOBILE_GET_USERS', true) + * // Make Async call. + * let result = await this.unviredCordovaSDK.syncBackground(RequestType.QUERY, null, inputObj, 'UNVIRED_DIGITAL_FORMS_PA_MOBILE_GET_USERS', 'INPUT_GET_USERS', 'GUID', false) + * // Write Logs + * this.unviredCordovaSDK.logInfo("AppComponent", "Initialize", " Some String") + * ``` + */ + +import { Injectable } from '@angular/core'; +import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; +import { Observable } from 'rxjs'; + +export enum LoginListenerType { + auth_activation_required = 0, + app_requires_login, + auth_activation_success, + auth_activation_error, + login_success, + login_error, + app_requires_current_account +} + +export enum LoginType { + unvired = 'UNVIRED_ID', + ads = 'ADS', + sap = 'SAP', + custom = 'CUSTOM' +} + +export enum ResultType { + success = 0, + error +} + +export enum RequestType { + RQST = 0, + PULL, + PUSH, + QUERY, + REQ +} + +export enum NotificationListenerType { + dataSend = 0, // Notify successful asynchronous send of data to the server. + dataChanged = 1, // Notify data changes for each BusinessEntity when received data from server. + dataReceived = 2, // Notify data receive completion on receive of all BusinessEntity + appReset = 3, // Notify application data reset. + attachmentDownloadSuccess = 4, // Notify application with error message and attchment item on attachment download error + attachmentDownloadError = 5, // Notify application with error message and attchment item on attachment download success + incomingDataProcessingFinished = 6, // Notify application when incoming data handling finished + attachmentDownloadWaiting = 7, // Notify application when attachment download is waiting on the server + infoMessage = 8, // Notify application with any InfoMessages + serverError = 9, // Notify application with Server errors + attachmentDownloadCompleted = 10 // Notify attachment downloads completed +} + +export enum AttachmentItemStatus { + DEFAULT = 0, + QUEUED_FOR_DOWNLOAD, + DOWNLOADED, + ERROR_IN_DOWNLOAD, + SAVED_FOR_UPLOAD, + UPLOADED, + ERROR_IN_UPLOAD, + MARKED_FOR_DELETE, + EXTERNAL +} + +export class Settings { + loginType: LoginType; + ADS_DOMAIN: string; + SAP_PORT_NAME: string; + EMAIL: string; + ADS_USER_ID: string; + SAP_USER_ID: string; + FULL_NAME: string; + URL: string; + USER_ID: string; +} + +export class UnviredResult { + data: any; + message: string; + type: number; + error: string; + errorDetail: string; +} + +export class NotifResult extends UnviredResult { + type: NotificationListenerType; +} + +export class SettingsResult extends UnviredResult { + data: Settings; + type: ResultType; +} + +export class SyncResult extends UnviredResult { + type: ResultType; +} + +export class DbResult extends UnviredResult { + type: ResultType; +} + +export class LoginParameters { + appName: string; + company: string; + username: string; + password: string; + url: string; + domain: string; + loginType: LoginType; + feUserId: string; + port: string; + metadataPath: string; + isRequiredAttachmentBase64: boolean; + autoSendTime: string; + autoSyncTime: string; +} +export class LoginResult extends UnviredResult { + type: LoginListenerType; +} +@Plugin({ + pluginName: 'UnviredCordovaSDK', + plugin: 'cordova-plugin-unvired-sdk', // npm package name, example: cordova-plugin-camera + pluginRef: 'ump', // the variable reference to call the plugin, example: navigator.geolocation + repo: 'https://github.com/unvired/cordova-plugin-unvired-sdk/', // the github repository URL for the plugin + install: 'ionic cordova plugin add @ionic-native/unvired-cordova-sdk', // OPTIONAL install command, in case the plugin requires variables + installVariables: [], // OPTIONAL the plugin requires variables + platforms: ['iOS'] // Array of platforms supported, example: ['Android', 'iOS'] +}) +@Injectable() +export class UnviredCordovaSDK extends IonicNativePlugin { + + loginParameters: LoginParameters; + + @Cordova() + logDebug(sourceClass: string, method: string, message: string): Promise { + return; + } + + @Cordova() + logError(sourceClass: string, method: string, message: string): Promise { + return; + } + + @Cordova() + logInfo(sourceClass: string, method: string, message: string): Promise { + return; + } + + @Cordova() + logRead(): Promise { + return; + } + + @Cordova() + logDelete(): Promise { + return; + } + + @Cordova() + sendLogToServer(): Promise { + return; + } + + @Cordova() + sendLogViaEmail(): Promise { + return; + } + + /** + * This api initiatilizes the Unvired Application. + * @param loginParameters + */ + @Cordova() + login(loginParameters: LoginParameters): Promise { + return; + } + + @Cordova() + logout(): Promise { + return; + } + + /** + * Authenticates & activates the app against UMP + * @param loginParameters Send username & Password through loginParameters + */ + @Cordova() + authenticateAndActivate(loginParameters: LoginParameters): Promise { + return; + } + + /** + * Authenticates the user against the locally saved username & password. + * For ADS Login, authentication is performed with the ADS Server. + * @param loginParameters Send username & Password through loginParameters + */ + @Cordova() + authenticateLocal(loginParameters: LoginParameters): Promise { + return; + } + + @Cordova() + getAllAccounts(): Promise { + return; + } + + @Cordova() + switchAccount(account: any): Promise { + return; + } + + @Cordova() + deleteAccount(account: any): Promise { + return; + } + + @Cordova() + getInfoMessages(headerName: string, lid: string): Promise { + return; + } + + @Cordova() + showSettings(): Promise { + return; + } + + @Cordova() + userSettings(): Promise { + return; + } + + @Cordova() + updateSystemCredentials(credentials: any): Promise { + return; + } + + @Cordova() + getSystemCredentials(): Promise { + return; + } + + @Cordova() + getVersionNumbers(): Promise { + return; + } + + @Cordova() + clearData(): Promise { + return; + } + + @Cordova() + hasInternet(): Promise { + return; + } + + @Cordova() + guid() { + return; + } + + @Cordova() + dbSelect(tableName: string, whereClause: string): Promise { + return; + } + + @Cordova() + dbInsert(tableName: string, structureObject: any, isHeader: boolean): Promise { + return; + } + + @Cordova() + dbInsertOrUpdate(tableName: string, structureObject: any, isHeader: boolean): Promise { + return; + } + + @Cordova() + dbDelete(tableName: string, whereClause: string): Promise { + return; + } + + @Cordova() + dbUpdate(tableName: string, updatedObject: any, whereClause: string): Promise { + return; + } + + @Cordova() + dbExecuteStatement(query: string): Promise { + return; + } + + @Cordova() + dbCreateSavePoint(savePoint: string): Promise { + return; + } + + @Cordova() + dbReleaseSavePoint(savePoint: string): Promise { + return; + } + + @Cordova() + dbRollbackToSavePoint(savePoint: string): Promise { + return; + } + + @Cordova() + dbBeginTransaction(): Promise { + return; + } + + @Cordova() + dbEndTransaction(): Promise { + return; + } + + @Cordova() + launchFile(filePath: string): Promise { + return; + } + + @Cordova() + launchBase64(base64string: string, fileName: string, extension: string): Promise { + return; + } + + @Cordova() + unzip(srcPath: string, destPath: string) { + return; + } + + @Cordova() + getAttachmentFolderPath(): Promise { + return; + } + + @Cordova() + createAttachmentItem(tableName: string, structureObject: any): Promise { + return; + } + + @Cordova() + uploadAttachment(tableName: string, structureObject: any, isAsync: boolean): Promise { + return; + } + + @Cordova() + downloadAttachment(tableName: string, structureObject: any): Promise { + return; + } + + @Cordova() + syncForeground(reqype: any, header: any, customData: any, paFunction: string, autoSave: boolean): Promise { + return; + } + + @Cordova() + syncBackground(reqype: any, header: any, customData: any, paFunction: string, beName: string, belid: string, bypassAttachment: boolean): Promise { + return; + } + + @Cordova() + getMessages() { + return; + } + + @Cordova({ + observable: true, + clearFunction: 'unRegisterNotifListener' + }) + registerNotifListener(): Observable { + return; + } + + @Cordova() + unRegisterNotifListener(): Promise { + return; + } + + @Cordova() + isInOutBox(beLid: string): Promise { + return; + } + + @Cordova() + outBoxItemCount(): Promise { + return; + } + + @Cordova() + isInSentItem(beLid: string): Promise { + return; + } + + @Cordova() + sentItemCount(): Promise { + return; + } + + @Cordova() + inBoxItemCount(): Promise { + return; + } + + @Cordova() + deleteOutBoxEntry(beLid: string): Promise { + return; + } + + @Cordova() + resetApplicationSyncData(): Promise { + return; + } +}