Skip to content
Snippets Groups Projects
Commit 607008d8 authored by Oda Alida Fønstelien Hjelljord's avatar Oda Alida Fønstelien Hjelljord
Browse files

Merge branch 'doc' into 'main'

Doc

See merge request idatt2106_2022_02/boco-frontend!168
parents 94f5fc96 c04ac1dd
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,14 @@ import { tokenHeader } from "@/utils/token-utils"; ...@@ -3,7 +3,14 @@ import { tokenHeader } from "@/utils/token-utils";
const API_URL = process.env.VUE_APP_BASEURL; const API_URL = process.env.VUE_APP_BASEURL;
/**
* Service class acting as a middle layer between our components and the API
*/
class ChatService { class ChatService {
/**
* Service method to get the logged in user's conversations.
* @returns an array of objects containing two objects containing the last message and the recipient.
*/
async getConversations() { async getConversations() {
return await axios return await axios
.get(API_URL + "chats/users", { .get(API_URL + "chats/users", {
......
...@@ -7,6 +7,11 @@ const API_URL = process.env.VUE_APP_BASEURL; ...@@ -7,6 +7,11 @@ const API_URL = process.env.VUE_APP_BASEURL;
* Service class acting as a middle layer between our components and the API * Service class acting as a middle layer between our components and the API
*/ */
class CommunityAdminService { class CommunityAdminService {
/**
* Checks if the current user is an admin in the community that is being accessed.
* @param {Number} communityID ID of the community to the if the user is an admin in.
* @returns a boolean.
*/
async isUserAdmin(communityID) { async isUserAdmin(communityID) {
return await axios return await axios
.get(API_URL + "communities/" + communityID + "/user/admin", { .get(API_URL + "communities/" + communityID + "/user/admin", {
...@@ -17,7 +22,12 @@ class CommunityAdminService { ...@@ -17,7 +22,12 @@ class CommunityAdminService {
}); });
} }
//TODO /**
* Accepts a member request.
* @param {Number} communityID the community to accept the request into.
* @param {Number} userID the user id of the user being accepted into the community.
* @returns the response.
*/
async acceptUserIntoCommunity(communityID, userID) { async acceptUserIntoCommunity(communityID, userID) {
return await axios.post( return await axios.post(
API_URL + "communities/" + communityID + "/requests", API_URL + "communities/" + communityID + "/requests",
...@@ -26,7 +36,12 @@ class CommunityAdminService { ...@@ -26,7 +36,12 @@ class CommunityAdminService {
); );
} }
//TODO /**
* Reject a user's request to join a community.
* @param {Number} communityID id of the community to reject the request from.
* @param {Number} userID id of the user being rejected.
* @returns the response.
*/
async rejectUserFromCommunity(communityID, userID) { async rejectUserFromCommunity(communityID, userID) {
return await axios.patch( return await axios.patch(
API_URL + "communitites/" + communityID + "/requests/reject", API_URL + "communitites/" + communityID + "/requests/reject",
...@@ -37,9 +52,9 @@ class CommunityAdminService { ...@@ -37,9 +52,9 @@ class CommunityAdminService {
/** /**
* Method that kicks a user from a community * Method that kicks a user from a community
* @param {int} communityID the community to remove the user from * @param {Number} communityID the community to remove the user from
* @param {int} userID the user to remove * @param {Number} userID the user to remove
* @returns TODO * @returns the response.
*/ */
async removeUserFromCommunity(communityID, userID) { async removeUserFromCommunity(communityID, userID) {
return await axios.patch( return await axios.patch(
...@@ -56,8 +71,8 @@ class CommunityAdminService { ...@@ -56,8 +71,8 @@ class CommunityAdminService {
/** /**
* Method to delete a community * Method to delete a community
* @param {int} communityID id of the community to delete. * @param {Number} communityID id of the community to delete.
* @returns TODO * @returns the response.
*/ */
async deleteCommunity(communityID) { async deleteCommunity(communityID) {
return await axios.delete( return await axios.delete(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment