1
0
Fork 0
mirror of synced 2024-07-13 10:26:15 +12:00
appwrite/app/sdks/node/lib/services/account.js
2019-10-19 20:21:36 +03:00

187 lines
4.5 KiB
JavaScript

const Service = require('../service.js');
class Account extends Service {
/**
* Get Account
*
* Get currently logged in user data as JSON object.
*
* @throws Exception
* @return {}
*/
async get() {
let path = '/account';
return await this.client.call('get', path, {
'content-type': 'application/json',
},
{
});
}
/**
* Delete Account
*
* Delete currently logged in user account.
*
* @throws Exception
* @return {}
*/
async delete() {
let path = '/account';
return await this.client.call('delete', path, {
'content-type': 'application/json',
},
{
});
}
/**
* Update Account Email
*
* Update currently logged in user account email address. After changing user
* address, user confirmation status is being reset and a new confirmation
* mail is sent. For security measures, user password is required to complete
* this request.
*
* @param string email
* @param string password
* @throws Exception
* @return {}
*/
async updateEmail(email, password) {
let path = '/account/email';
return await this.client.call('patch', path, {
'content-type': 'application/json',
},
{
'email': email,
'password': password
});
}
/**
* Update Account Name
*
* Update currently logged in user account name.
*
* @param string name
* @throws Exception
* @return {}
*/
async updateName(name) {
let path = '/account/name';
return await this.client.call('patch', path, {
'content-type': 'application/json',
},
{
'name': name
});
}
/**
* Update Account Password
*
* Update currently logged in user password. For validation, user is required
* to pass the password twice.
*
* @param string password
* @param string oldPassword
* @throws Exception
* @return {}
*/
async updatePassword(password, oldPassword) {
let path = '/account/password';
return await this.client.call('patch', path, {
'content-type': 'application/json',
},
{
'password': password,
'old-password': oldPassword
});
}
/**
* Get Account Preferences
*
* Get currently logged in user preferences key-value object.
*
* @throws Exception
* @return {}
*/
async getPrefs() {
let path = '/account/prefs';
return await this.client.call('get', path, {
'content-type': 'application/json',
},
{
});
}
/**
* Update Account Prefs
*
* Update currently logged in user account preferences. You can pass only the
* specific settings you wish to update.
*
* @param string prefs
* @throws Exception
* @return {}
*/
async updatePrefs(prefs) {
let path = '/account/prefs';
return await this.client.call('patch', path, {
'content-type': 'application/json',
},
{
'prefs': prefs
});
}
/**
* Get Account Security Log
*
* Get currently logged in user list of latest security activity logs. Each
* log returns user IP address, location and date and time of log.
*
* @throws Exception
* @return {}
*/
async getSecurity() {
let path = '/account/security';
return await this.client.call('get', path, {
'content-type': 'application/json',
},
{
});
}
/**
* Get Account Active Sessions
*
* Get currently logged in user list of active sessions across different
* devices.
*
* @throws Exception
* @return {}
*/
async getSessions() {
let path = '/account/sessions';
return await this.client.call('get', path, {
'content-type': 'application/json',
},
{
});
}
}
module.exports = Account;