splitwise
Version:
A TypeScript SDK for the Splitwise API.
57 lines • 1.94 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Groups = void 0;
const base_js_1 = require("./base.js");
class Groups extends base_js_1.BaseResource {
async list(_params, overrides) {
return this.http.get('/get_groups', {
unwrapKey: 'groups',
...overrides,
});
}
async get(params, overrides) {
return this.http.get(`/get_group/${params.id}`, {
unwrapKey: 'group',
...overrides,
});
}
async create(params, overrides) {
return this.http.post('/create_group', {
body: { ...params },
unwrapKey: 'group',
...overrides,
});
}
/** Deletes a group. Throws SplitwiseConstraintError if the API refuses. */
async delete(params, overrides) {
await this.http.post(`/delete_group/${params.id}`, overrides);
}
/** Restores a previously-deleted group. Throws on failure. */
async restore(params, overrides) {
await this.http.post(`/undelete_group/${params.id}`, overrides);
}
/**
* Adds a user to a group. Returns the added user object (useful when
* adding by email -- the response gives you back the assigned user_id).
* Throws SplitwiseConstraintError if the API refuses (e.g. unknown user).
*/
async addUser(params, overrides) {
return this.http.post('/add_user_to_group', {
body: { ...params },
unwrapKey: 'user',
...overrides,
});
}
/**
* Removes a user from a group. Throws SplitwiseConstraintError if the API
* refuses (e.g. the user has unsettled debts in this group).
*/
async removeUser(params, overrides) {
await this.http.post('/remove_user_from_group', {
body: { ...params },
...overrides,
});
}
}
exports.Groups = Groups;
//# sourceMappingURL=groups.js.map