1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-18 05:42:00 +03:00

Tidy up, add deps and add a few more calls.

This commit is contained in:
Kegan Dougal
2015-03-04 14:37:43 +00:00
parent 0dfa52ef63
commit 335198c8f1
2 changed files with 33 additions and 15 deletions

View File

@@ -38,10 +38,34 @@ var init = function(exports){
return this.credentials.accessToken != undefined;
},
// Room operations
// ===============
createRoom: function(options, callback) {
// valid options include: room_alias_name, visibility, invite
return this._doAuthedRequest(
callback, "POST", "/createRoom", undefined, options
);
},
// Public (non-authed) operations
// ==============================
publicRooms: function(callback) {
return this._doRequest(callback, "GET", "/publicRooms");
},
registerFlows: function(callback) {
return this._doRequest(callback, "GET", "/register");
},
loginFlows: function(callback) {
return this._doRequest(callback, "GET", "/login");
},
// Syncing operations
// ==================
initialSync: function(limit, callback) {
var params = {
limit: limit
@@ -51,6 +75,9 @@ var init = function(exports){
);
},
// Internals
// =========
_doAuthedRequest: function(callback, method, path, params, data) {
if (!params) { params = {}; }
params.access_token = this.credentials.accessToken;
@@ -61,7 +88,7 @@ var init = function(exports){
var fullUri = this.credentials.baseUrl + PREFIX + path;
if (!params) { params = {}; }
request(
return request(
{
uri: fullUri,
method: method,
@@ -102,19 +129,6 @@ var init = function(exports){
}
};
};
exports.test = function(){
request({
uri: "http://localhost:8008/_matrix/client/api/v1/publicRooms",
method: "GET",
withCredentials: false,
},
function(err, response, body) {
console.log(body);
});
};
};
if (typeof exports === 'undefined') {

View File

@@ -11,5 +11,9 @@
],
"browserify": "browser/index.js",
"author": "matrix.org",
"license": "Apache 2.0"
"license": "Apache 2.0",
"dependencies": {
"browser-request": "^0.3.3",
"request": "^2.53.0"
}
}