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.
CoreID/app/assets/app/service/Profile.service.js

34 lines
1.2 KiB

import {message_service} from './Message.service.js'
4 years ago
class ProfileService {
async get_profile(user_id = 'me') {
const results = await axios.get(`/api/v1/profile/${user_id}`)
if ( results && results.data && results.data.data ) return results.data.data
}
async get_notify(user_id = 'me') {
const results = await axios.get(`/api/v1/profile/${user_id}/notify`)
if ( results && results.data && results.data.data ) return results.data.data
}
async update_profile({ user_id, first_name, last_name, email, login_shell = undefined, tagline = undefined }) {
const results = await axios.patch(`/api/v1/profile/${user_id}`, { first_name, last_name, email, tagline, login_shell })
if ( results && results.data && results.data.data && results.data.data.force_message_refresh ) {
await message_service._listener_tick()
}
4 years ago
}
async update_notify({ user_id = 'me', app_key, gateway_url }) {
await axios.patch(`/api/v1/profile/${user_id}/notify`, { app_key, gateway_url })
}
async test_notify({ user_id = 'me' }) {
await axios.post(`/api/v1/profile/${user_id}/notify/test`)
}
4 years ago
}
const profile_service = new ProfileService()
export { profile_service }