From 9bf1eafc4eb1e3562dfeff54f87f1da95d0a9fe4 Mon Sep 17 00:00:00 2001 From: Edem Morny Date: Tue, 23 Jun 2020 17:03:09 +0000 Subject: [PATCH] feat(vibes): add support for inbox messaging (#3466) --- src/@ionic-native/plugins/vibes/index.ts | 95 ++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 8 deletions(-) diff --git a/src/@ionic-native/plugins/vibes/index.ts b/src/@ionic-native/plugins/vibes/index.ts index 7d290c28c7..2010fae3d4 100644 --- a/src/@ionic-native/plugins/vibes/index.ts +++ b/src/@ionic-native/plugins/vibes/index.ts @@ -16,6 +16,19 @@ export interface PersonResponse { external_person_id?: string; } +export interface InboxMessage { + content?: string; + created_at?: string; + expires_at?: string; + message_uid?: string; + read?: boolean; + subject?: string; + detail?: string; + collapse_key?: string; + apprefdata?: any; + images?: any; + inbox_custom_data: any; +} /** * @name Vibes * @description @@ -41,8 +54,11 @@ export interface PersonResponse { * * this.vibes.getVibesDeviceInfo() * .then((res: any) => console.log(res)) // retrieve the `device_id` and `push_token` from the JSON object - * .catch((error: any) => console.error('Error retrieving deviceinfo push', error)); + * .catch((error: any) => console.error('Error retrieving deviceinfo', error)); * + * this.vibes.fetchInboxMessages() + * .then((res: any) => console.log(res)) // fetches inbox messages for this person. + * .catch((error: any) => console.error('Error fetching inbox messages for this person', error)); * ``` */ @Plugin({ @@ -58,7 +74,8 @@ export interface PersonResponse { @Injectable() export class Vibes extends IonicNativePlugin { /** - * Register device + * Register this device with the Vibes platform + * * @return {Promise} */ @Cordova() @@ -67,7 +84,8 @@ export class Vibes extends IonicNativePlugin { } /** - * Unregister device + * Unregister this device with the Vibes platform + * * @return {Promise} */ @Cordova() @@ -76,7 +94,8 @@ export class Vibes extends IonicNativePlugin { } /** - * Associate person + * Associate an external ID with the current person. + * * @param {string} externalPersonId * @return {Promise} */ @@ -86,7 +105,8 @@ export class Vibes extends IonicNativePlugin { } /** - * Register push + * Register this device to receive push notifications + * * @return {Promise} */ @Cordova() @@ -95,7 +115,8 @@ export class Vibes extends IonicNativePlugin { } /** - * Unregister push + * Unregister the device from receiving push notifications + * * @return {Promise} */ @Cordova() @@ -103,7 +124,8 @@ export class Vibes extends IonicNativePlugin { return; } /** - * getVibesDeviceInfo + * Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token + * * @return {Promise} */ @Cordova() @@ -112,7 +134,8 @@ export class Vibes extends IonicNativePlugin { } /** - * getPerson + * Fetches the PersonResponse associated with this device currently + * * @return {Promise} */ @Cordova() @@ -122,6 +145,7 @@ export class Vibes extends IonicNativePlugin { /** * Get notified when the user opens a notification + * * @return {Observable} */ @Cordova({ @@ -130,4 +154,59 @@ export class Vibes extends IonicNativePlugin { onNotificationOpened(): Observable { return; } + + /** + * Fetches an array of inbox messages for the person associated with this device. + * + * @return {Promise} + */ + @Cordova() + fetchInboxMessages(): Promise { + return; + } + + /** + * Fetches a single inbox message by it's id. + * + * @param {string} message_uid + * @return {Promise} + */ + @Cordova() + fetchInboxMessage(message_uid: string): Promise { + return; + } + + /** + * Marks an inbox message as expired using message_uid and the expiry date supplied. Uses current date if null or invalid date is supplied. + * + * @param {string} message_uid + * @param {string} An ISO-8601 formatted date string. + * @return {Promise} an updated version of the InboxMessage with expires_at date updated + */ + @Cordova() + expireInboxMessage(message_uid: string, date: string): Promise { + return; + } + + /** + * Marks an inbox message as read. + * + * @param {string} message_uid + * @return {Promise} an updated version of the InboxMessage with read field updated + */ + @Cordova() + markInboxMessageAsRead(message_uid: string): Promise { + return; + } + + /** + * Records an event for when the user opens an inbox message. + * + * @param inbox_message_stringified stringified version of the InboxMessage + * @return {Promise} + */ + @Cordova() + onInboxMessageOpen(inbox_message_stringified: string): Promise { + return; + } }