UNPKG

backendless-console-sdk

Version:

Backendless Console SDK for Node.js and browser

96 lines (95 loc) 3.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.community = void 0; var _routes = require("./utils/routes"); var routes = (0, _routes.prepareRoutes)({ comments: '/console/community/comments', comment: '/console/community/comments/:commentId', commentAction: '/console/community/comments/:commentId/:action', reviews: '/console/community/reviews', review: '/console/community/reviews/:reviewId', vote: '/console/community/vote/like', likers: '/console/community/vote/likers', blacklistStatus: '/console/community/blacklist/status', onProductInstall: '/console/community/activity/products/install', reportUserActivity: '/console/community/activity/report', devSuicide: '/console/community/dev/suicide' }); var community = function community(req) { return { //---- COMMENTS ----// getComments: function getComments(context, itemId, sorting) { return req.community.get(routes.comments()).query({ context: context, itemId: itemId, sorting: sorting }); }, createComments: function createComments(comment) { return req.community.post(routes.comments(), comment); }, editComment: function editComment(commentId, body) { return req.community.put(routes.comment(commentId), { commentId: commentId, body: body }); }, deleteComment: function deleteComment(commentId) { return req.community["delete"](routes.comment(commentId)); }, hideComment: function hideComment(commentId) { return req.community.put(routes.commentAction(commentId, 'hide')); }, displayComment: function displayComment(commentId) { return req.community.put(routes.commentAction(commentId, 'display')); }, //---- REVIEWS ----// getReviews: function getReviews(context, itemId, sorting) { return req.community.get(routes.reviews()).query({ context: context, itemId: itemId, sorting: sorting }); }, createReview: function createReview(review) { return req.community.post(routes.reviews(), review); }, editReview: function editReview(reviewId, body, rating) { return req.community.put(routes.review(reviewId), { body: body, rating: rating }); }, deleteReview: function deleteReview(reviewId) { return req.community["delete"](routes.review(reviewId)); }, //---- VOTES ----// vote: function vote(_vote) { return req.community.post(routes.vote(), _vote); }, getLikers: function getLikers(type, itemId) { return req.community.get(routes.likers()).query({ type: type, itemId: itemId }); }, getUserBlacklistStatus: function getUserBlacklistStatus() { return req.community.get(routes.blacklistStatus()); }, //---- ACTIVITY ----// onProductInstall: function onProductInstall(productId) { return req.community.post(routes.onProductInstall(), { productId: productId }); }, reportUserActivity: function reportUserActivity() { return req.community.post(routes.reportUserActivity()); }, onDeveloperSuicide: function onDeveloperSuicide() { return req.community["delete"](routes.devSuicide()); } }; }; exports.community = community;