@pubby/sdk
Version:
Pubby Development Kit
90 lines (86 loc) • 2.83 kB
JavaScript
;
var tslib = require('tslib');
var Rest = require('../../../lib/Rest.js');
var RoomService = /** @class */ (function (_super) {
tslib.__extends(RoomService, _super);
function RoomService(api) {
return _super.call(this, api, "rooms") || this;
}
RoomService.prototype.myRooms = function (params) {
if (params === void 0) { params = {}; }
return this.request({
method: "GET",
baseURL: this.baseURL + "/me/rooms",
url: "/",
params: params,
});
};
RoomService.prototype.getCurrent = function () {
return this.request({
method: "GET",
baseURL: this.baseURL + "/me/rooms",
url: "current",
});
};
RoomService.prototype.save = function (room) {
var _a;
return this.request({
method: room.id ? "PATCH" : "POST",
baseURL: this.baseURL + "/me/rooms",
url: (_a = room.id) !== null && _a !== void 0 ? _a : "/",
data: room,
});
};
RoomService.prototype.getRoles = function (roomId) {
return this.request({
method: "GET",
url: roomId + "/roles",
})
.then(function (res) { return res.map(function (role) { return [role.id, role]; }); })
.then(function (role) { return new Map(role); });
};
RoomService.prototype.addRole = function (roomId, role, params) {
if (params === void 0) { params = {}; }
return this.request({
method: "POST",
url: roomId + "/roles",
data: role,
params: params,
});
};
RoomService.prototype.browser = function (params) {
if (params === void 0) { params = {}; }
return this.request({
method: "GET",
url: "browser",
params: params,
});
};
RoomService.prototype.getBans = function (roomId, params) {
if (params === void 0) { params = {}; }
return this.request({
method: "GET",
url: roomId + "/bans",
params: params,
});
};
RoomService.prototype.banUser = function (roomId, userId, reason, expires) {
return this.request({
method: "POST",
url: roomId + "/bans",
data: {
userId: userId,
reason: reason,
expires: expires,
},
});
};
RoomService.prototype.unbanUser = function (roomId, banId) {
return this.request({
method: "DELETE",
url: roomId + "/bans/" + banId,
});
};
return RoomService;
}(Rest.Rest));
module.exports = RoomService;