You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +03:00
Merge pull request #158 from matrix-org/rav/devices_api
Wrappers for devices API
This commit is contained in:
@@ -498,6 +498,61 @@ MatrixBaseApis.prototype.setPassword = function(authDict, newPassword, callback)
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Device operations
|
||||||
|
// =================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all devices recorded for the logged-in user
|
||||||
|
* @return {module:client.Promise} Resolves: result object
|
||||||
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
|
*/
|
||||||
|
MatrixBaseApis.prototype.getDevices = function() {
|
||||||
|
var path = "/devices";
|
||||||
|
return this._http.authedRequestWithPrefix(
|
||||||
|
undefined, "GET", path, undefined, undefined,
|
||||||
|
httpApi.PREFIX_UNSTABLE
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the given device
|
||||||
|
*
|
||||||
|
* @param {string} device_id device to update
|
||||||
|
* @param {Object} body body of request
|
||||||
|
* @return {module:client.Promise} Resolves: result object
|
||||||
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
|
*/
|
||||||
|
MatrixBaseApis.prototype.setDeviceDetails = function(device_id, body) {
|
||||||
|
var path = utils.encodeUri("/devices/$device_id", {
|
||||||
|
$device_id: device_id,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return this._http.authedRequestWithPrefix(
|
||||||
|
undefined, "PUT", path, undefined, body,
|
||||||
|
httpApi.PREFIX_UNSTABLE
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the given device
|
||||||
|
*
|
||||||
|
* @param {string} device_id device to delete
|
||||||
|
* @return {module:client.Promise} Resolves: result object
|
||||||
|
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||||
|
*/
|
||||||
|
MatrixBaseApis.prototype.deleteDevice = function(device_id) {
|
||||||
|
var path = utils.encodeUri("/devices/$device_id", {
|
||||||
|
$device_id: device_id,
|
||||||
|
});
|
||||||
|
|
||||||
|
return this._http.authedRequestWithPrefix(
|
||||||
|
undefined, "DELETE", path, undefined, undefined,
|
||||||
|
httpApi.PREFIX_UNSTABLE
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Push operations
|
// Push operations
|
||||||
// ===============
|
// ===============
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user