Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chamilo-lms/assets/vue/services/socialService.js

154 lines
3.4 KiB

import axios from "axios"
const API_URL = "/social-network"
export default {
async fetchPersonalData(userId) {
try {
const response = await axios.get(`${API_URL}/personal-data/${userId}`)
return response.data.personalData
} catch (error) {
console.error("Error fetching personal data:", error)
throw error
}
},
async fetchTermsAndConditions(userId) {
try {
const response = await axios.get(`${API_URL}/terms-and-conditions/${userId}`)
return response.data.terms
} catch (error) {
console.error("Error fetching terms and conditions:", error)
throw error
}
},
async fetchLegalStatus(userId) {
try {
const response = await axios.get(`${API_URL}/legal-status/${userId}`)
return response.data
} catch (error) {
console.error("Error fetching legal status:", error)
throw error
}
},
async submitPrivacyRequest({ userId, explanation, requestType }) {
try {
const response = await axios.post(`${API_URL}/handle-privacy-request`, {
explanation,
userId,
requestType,
})
return response.data
} catch (error) {
console.error("Error submitting privacy request:", error)
throw error
}
},
async submitAcceptTerm(userId) {
try {
const response = await axios.post(`${API_URL}/send-legal-term`, {
userId,
})
return response.data
} catch (error) {
console.error("Error accepting the term:", error)
throw error
}
},
async fetchInvitations(userId) {
try {
const response = await axios.get(`${API_URL}/invitations/${userId}`)
return response.data
} catch (error) {
console.error("Error fetching invitations:", error)
throw error
}
},
async acceptInvitation(userId, targetUserId) {
try {
const response = await axios.post(`${API_URL}/user-action`, {
userId,
targetUserId,
action: "add_friend",
is_my_friend: true,
})
return response.data
} catch (error) {
console.error("Error accepting invitation:", error)
throw error
}
},
async denyInvitation(userId, targetUserId) {
try {
const response = await axios.post(`${API_URL}/user-action`, {
userId,
targetUserId,
action: "deny_friend",
})
return response.data
} catch (error) {
console.error("Error denying invitation:", error)
throw error
}
},
async acceptGroupInvitation(userId, groupId) {
try {
const response = await axios.post(`${API_URL}/group-action`, {
userId,
groupId,
action: "accept",
})
return response.data
} catch (error) {
console.error("Error accepting group invitation:", error)
throw error
}
},
async denyGroupInvitation(userId, groupId) {
try {
const response = await axios.post(`${API_URL}/group-action`, {
userId,
groupId,
action: "deny",
})
return response.data
} catch (error) {
console.error("Error denying group invitation:", error)
throw error
}
},
async joinGroup(userId, groupId) {
try {
const response = await axios.post(`${API_URL}/group-action`, {
userId,
groupId,
action: "join",
})
return response.data
} catch (error) {
console.error("Error joining the group:", error)
throw error
}
},
}