angular.module("vocabulary") .service("categoryApi", ["createApi", function (createApi) { var api = createApi("/api/categories"); function getLessonsForCategory(categoryId){ return api.get("/" + categoryId + "/lessons"); } function getPremadeCategoryTree(){ return api.get('/premadeCategories'); } function validateNewCategoryNameForUser(categoryName){ return api.get("/validate/" + categoryName); } function getCategoryList(){ return api.get("/allCategories"); } function getEntireCategoryTree() { return api.get("/entireCategoryTree"); } function getPremadeCategoryDescription(categoryId){ return api.get("/premade/description/" + categoryId); } function updateCategoryLesson(data){ return api.put("/updateCategoryLesson", data); } function updateCategoryName(categoryId, categoryName){ return api.patch("/name/" + categoryId + "/" + categoryName); } function deleteCategory(categoryId, parentCategoryId){ return api.delete("/" + categoryId + "/" + parentCategoryId); } function createCategory(data){ return api.post("", data); } return { getCategoryList: getCategoryList, getEntireCategoryTree: getEntireCategoryTree, getLessonsForCategory: getLessonsForCategory, getPremadeCategoryTree: getPremadeCategoryTree, getPremadeCategoryDescription: getPremadeCategoryDescription, createCategory: createCategory, deleteCategory: deleteCategory, validateNewCategoryNameForUser: validateNewCategoryNameForUser, updateCategoryLesson: updateCategoryLesson, updateCategoryName: updateCategoryName }; }]);