relution-sdk
Version:
Relution Software Development Kit for TypeScript and JavaScript
121 lines (120 loc) • 3.78 kB
TypeScript
/// <reference types="lodash" />
/// <reference types="q" />
/**
* @module push
*/
/** */
import * as _ from 'lodash';
import * as Q from 'q';
import * as domain from '../core/domain';
import { Filter } from '../query/Filter';
import { User } from '../security/roles';
/**
* transmission status of a push Job.
*
* This models the Java enum `com.mwaysolutions.gofer2.push.domain.State`.
*/
export declare type State = 'UNUSED' | 'QUEUED' | 'RUNNING' | 'FINISHED';
/**
* represents a push message.
*
* This models the Java class `com.mwaysolutions.gofer2.push.domain.Job`.
*/
export interface Job extends domain.Referenceable {
description?: string;
state?: State;
app?: App;
message: string;
badge?: string;
sound?: string;
extras?: _.Dictionary<string>;
deviceFilter?: Filter;
total?: number;
sent?: number;
failed?: number;
}
/**
* represents a push configuration of a specific client app.
*
* This models the Java class `com.mwaysolutions.gofer2.push.domain.App`.
*/
export interface App extends domain.Referenceable, domain.Secure, domain.HasVersion, domain.HasBundle, domain.HasApplication {
organisationUuid?: string;
name?: string;
description?: string;
devices?: Device[];
jobs?: Job[];
}
/**
* communication provider used to transport push messages to a push Device.
*
* This models the Java enum `com.mwaysolutions.gofer2.push.domain.ProviderType`.
*/
export declare type ProviderType = 'GCM' | 'APNS' | 'MCAP' | 'WNS' | 'PAP';
/**
* represents a push information of a specific mobile device.
*
* This models the Java class `com.mwaysolutions.gofer2.push.domain.Device`.
*/
export interface Device extends domain.Referenceable {
token?: string;
providerType?: ProviderType;
app?: App;
deviceIdentifier?: string;
appPackageName?: string;
user?: string;
vendor?: string;
name?: string;
osVersion?: string;
language?: string;
country?: string;
type?: string;
appVersion?: string;
model?: string;
attributes?: _.Dictionary<string>;
tags?: string[];
badge?: number;
lastConnect?: Date;
}
/**
* set of application specific options for registerPushNotification().
*/
export interface RegistrationOptions {
attributes?: _.Dictionary<string>;
tags?: string[];
badge?: number;
}
/**
* posts push notification(s).
*
* Usually the server sends push notifications on its own behalf. However, this method may be used
* by the client app itself to send push notifications either to other clients, or to itself which
* can be used to test connectivity.
*
* The implementation relies on backend code generated by CLI which forwards the body JSON to the
* server-side implementation of this method.
*
* @param message to deliver.
* @returns promise of async execution resolving to UUIDs of jobs in asynchronous delivery,
* empty when no apps or devices got selected by the message criteria or null when no
* target apps or devices exist at all.
*/
export declare function postPushNotification(message: Job): Q.Promise<string[]>;
/**
* creates a device filter for the user attribute of push devices matching any of a given set of
* users.
*
* @param users* to filter on.
* @returns device filter matching devices of given users.
*/
export declare function pushDeviceFilterByUsers(...users: (User | string)[]): Filter;
/**
* gets push notification status.
*
* The implementation relies on backend code generated by CLI which uses the server-side
* PushService to query for Job by uuid.
*
* @param uuidOrMessage to query.
* @returns promise of async execution resolving to push Job information.
*/
export declare function fetchPushNotification(uuidOrMessage: string | Job): Q.Promise<Job>;