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(vibes): add support for inbox messaging #3466

Merged
merged 1 commit into from
Jun 23, 2020
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
95 changes: 87 additions & 8 deletions src/@ionic-native/plugins/vibes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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({
Expand All @@ -58,7 +74,8 @@ export interface PersonResponse {
@Injectable()
export class Vibes extends IonicNativePlugin {
/**
* Register device
* Register this device with the Vibes platform
*
* @return {Promise<DeviceResponse>}
*/
@Cordova()
Expand All @@ -67,7 +84,8 @@ export class Vibes extends IonicNativePlugin {
}

/**
* Unregister device
* Unregister this device with the Vibes platform
*
* @return {Promise<void>}
*/
@Cordova()
Expand All @@ -76,7 +94,8 @@ export class Vibes extends IonicNativePlugin {
}

/**
* Associate person
* Associate an external ID with the current person.
*
* @param {string} externalPersonId
* @return {Promise<void>}
*/
Expand All @@ -86,7 +105,8 @@ export class Vibes extends IonicNativePlugin {
}

/**
* Register push
* Register this device to receive push notifications
*
* @return {Promise<void>}
*/
@Cordova()
Expand All @@ -95,15 +115,17 @@ export class Vibes extends IonicNativePlugin {
}

/**
* Unregister push
* Unregister the device from receiving push notifications
*
* @return {Promise<void>}
*/
@Cordova()
unregisterPush(): Promise<void> {
return;
}
/**
* getVibesDeviceInfo
* Fetches a DeviceInfoResponse with details about the Vibes Device ID and Push Token
*
* @return {Promise<DeviceInfoResponse>}
*/
@Cordova()
Expand All @@ -112,7 +134,8 @@ export class Vibes extends IonicNativePlugin {
}

/**
* getPerson
* Fetches the PersonResponse associated with this device currently
*
* @return {Promise<PersonResponse>}
*/
@Cordova()
Expand All @@ -122,6 +145,7 @@ export class Vibes extends IonicNativePlugin {

/**
* Get notified when the user opens a notification
*
* @return {Observable<void>}
*/
@Cordova({
Expand All @@ -130,4 +154,59 @@ export class Vibes extends IonicNativePlugin {
onNotificationOpened(): Observable<void> {
return;
}

/**
* Fetches an array of inbox messages for the person associated with this device.
*
* @return {Promise<InboxMessage[]>}
*/
@Cordova()
fetchInboxMessages(): Promise<InboxMessage[]> {
return;
}

/**
* Fetches a single inbox message by it's id.
*
* @param {string} message_uid
* @return {Promise<InboxMessage>}
*/
@Cordova()
fetchInboxMessage(message_uid: string): Promise<InboxMessage> {
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<InboxMessage>} an updated version of the InboxMessage with expires_at date updated
*/
@Cordova()
expireInboxMessage(message_uid: string, date: string): Promise<InboxMessage> {
return;
}

/**
* Marks an inbox message as read.
*
* @param {string} message_uid
* @return {Promise<InboxMessage>} an updated version of the InboxMessage with read field updated
*/
@Cordova()
markInboxMessageAsRead(message_uid: string): Promise<InboxMessage> {
return;
}

/**
* Records an event for when the user opens an inbox message.
*
* @param inbox_message_stringified stringified version of the InboxMessage
* @return {Promise<void>}
*/
@Cordova()
onInboxMessageOpen(inbox_message_stringified: string): Promise<void> {
return;
}
}