Skip to content
Snippets Groups Projects
Commit b7e1e3af authored by Erik Borgeteien Hansen's avatar Erik Borgeteien Hansen
Browse files

add some service files

parent 189763f0
No related branches found
No related tags found
2 merge requests!87Community request,!86Community admin
import axios from "axios";
import { tokenHeader } from "@/utils/token-utils";
const API_URL = process.env.VUE_APP_BASEURL;
class ChatService {
async getConversations() {
return await axios
.get(API_URL + "chats/users", {
headers: tokenHeader(),
})
.then((response) => {
return response.data;
})
.catch((error) => {
console.error(error);
});
}
}
export default new ChatService();
import axios from "axios";
import { tokenHeader } from "@/utils/token-utils";
const API_URL = process.env.VUE_APP_BASEURL;
/**
* Service class acting as a middle layer between our components and the API
*/
class CommunityAdminService {
//TODO
acceptUserIntoCommunity() {}
//TODO
rejectUserFromCommunity() {}
//TODO
async removeUserFromCommunity(user, community) {
return await axios.post(API_URL + "communities/" + community.id + "/leave");
}
/**
* Method to delete a community
* @param {int} communityId id of the community to delete.
* @returns TODO
*/
async deleteCommunity(communityId) {
return await axios.post(
API_URL + "communities/" + communityId + "/remove",
tokenHeader
);
}
}
export default new CommunityAdminService();
import { tokenHeader } from "@/utils/token-utils";
import axios from "axios";
const API_URL = process.env.VUE_APP_BASEURL;
class CommunityService {
async getCommunity(communityId) {
return await axios
.get(API_URL + "community/" + communityId, {
headers: tokenHeader(),
})
.then((response) => {
return response.data;
})
.catch((error) => {
console.error(error);
});
}
async getPublicCommunities() {
return await axios
.get(API_URL + "communities")
.then((response) => {
return response.data;
})
.catch((error) => {
console.error(error);
});
}
async getCommunityMembers(communityId) {
return await axios
.get(API_URL + "community/" + communityId + "/members", {
headers: tokenHeader(),
})
.then((response) => {
return response.data;
})
.catch((error) => {
console.error(error);
});
}
}
export default new CommunityService();
// import { tokenHeader } from "@/utils/token-utils";
import axios from "axios";
const API_URL = process.env.VUE_APP_BASEURL;
class UserService {
async getUserFromId(userId) {
return await axios
.get(API_URL + "/users/" + userId + "/profile")
.then((res) => {
return res.data;
})
.catch((err) => console.log(err));
}
async getUserRatingAverage(userId) {
return await axios
.get(API_URL + "rating/" + userId + "/average")
.then((res) => {
return res.data;
})
.catch((err) => console.log(err));
}
//TODO
getUserRatingAsOwner() {}
//TODO
getUserRatingAsRenter() {}
}
export default new UserService();
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