mail/src/js/service/invitation.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2014-10-02 16:05:44 -04:00
'use strict';
var ngModule = angular.module('woServices');
ngModule.service('invitation', Invitation);
module.exports = Invitation;
2014-10-02 16:05:44 -04:00
/**
* The Invitation is a high level Data Access Object that access the invitation service REST endpoint.
2014-10-02 16:05:44 -04:00
* @param {Object} restDao The REST Data Access Object abstraction
*/
2014-12-11 12:12:37 -05:00
function Invitation(invitationRestDao) {
this._restDao = invitationRestDao;
}
2014-10-02 16:05:44 -04:00
//
// API
//
/**
* Notes an invite for the recipient by the sender in the invitation web service
* @param {String} options.recipient User ID of the recipient
* @param {String} options.sender User ID of the sender
2014-12-10 11:20:55 -05:00
* @return {Promise}
2014-10-02 16:05:44 -04:00
*/
2014-12-10 11:20:55 -05:00
Invitation.prototype.invite = function(options) {
var self = this;
2014-12-11 12:12:37 -05:00
return new Promise(function(resolve) {
2014-12-10 11:20:55 -05:00
if (typeof options !== 'object' || typeof options.recipient !== 'string' || typeof options.sender !== 'string') {
throw new Error('erroneous usage of api: incorrect parameters!');
2013-11-20 06:17:21 -05:00
}
2014-12-10 11:20:55 -05:00
resolve();
2013-11-20 06:17:21 -05:00
2014-12-10 11:20:55 -05:00
}).then(function() {
var uri = '/invitation/recipient/' + options.recipient + '/sender/' + options.sender;
return self._restDao.put({}, uri);
});
};