Commit 689bc919 authored by Sang D NGO's avatar Sang D NGO
Browse files

add frontend api

parent 6c467465
(function(angular) {
'use strict';
angular.module('linagora.esn.most')
.factory('mostProposalApiClient', mostProposalApiClient);
var API_PATH = 'proposals';
function mostProposalApiClient(mostRestangular) {
return {
createProposal: createProposal,
getProposals: getProposals,
getProposal: getProposal,
updateProposal: updateProposal
};
function createProposal(data) {
return mostRestangular.all(API_PATH).post(data).then(_stripAndReturnData);
}
function getProposals(options) {
return mostRestangular.all(API_PATH).getList(options).then(_stripAndReturnData);
}
function getProposal(id) {
return mostRestangular.one(API_PATH, id).get().then(_stripAndReturnData);
}
function updateProposal(id, updateFields) {
return mostRestangular.one(API_PATH, id).customPOST(updateFields);
}
function _stripAndReturnData(resp) {
return mostRestangular.stripRestangular(resp.data);
}
}
})(angular);
(function(angular) {
'use strict';
angular.module('linagora.esn.most')
.factory('mostReviewApiClient', mostReviewApiClient);
var API_PATH = 'reviews';
function mostReviewApiClient(mostRestangular) {
return {
createReview: createReview,
getReviews: getReviews,
getReview: getReview,
updateReview: updateReview
};
function createReview(data) {
return mostRestangular.all(API_PATH).post(data).then(_stripAndReturnData);
}
function getReviews(options) {
return mostRestangular.all(API_PATH).getList(options).then(_stripAndReturnData);
}
function getReview(id) {
return mostRestangular.one(API_PATH, id).get().then(_stripAndReturnData);
}
function updateReview(id, updateFields) {
return mostRestangular.one(API_PATH, id).customPOST(updateFields);
}
function _stripAndReturnData(resp) {
return mostRestangular.stripRestangular(resp.data);
}
}
})(angular);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment