diff --git a/lib/base-apis.js b/lib/base-apis.js index 497859a91..2d65ff590 100644 --- a/lib/base-apis.js +++ b/lib/base-apis.js @@ -476,6 +476,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 // ===============