26 lines
587 B
JavaScript
26 lines
587 B
JavaScript
/** Persist the people referenced by CMap concept tags through the wiki API. */
|
|
export class PeopleRepository {
|
|
constructor(api) {
|
|
this.api = api;
|
|
}
|
|
|
|
async all() {
|
|
const result = await this.api("/api/people");
|
|
return Array.isArray(result.people) ? result.people : [];
|
|
}
|
|
|
|
create(name) {
|
|
return this.api("/api/people", {
|
|
method: "POST",
|
|
body: JSON.stringify({ name })
|
|
});
|
|
}
|
|
|
|
update(person, active) {
|
|
return this.api(`/api/people/${person.id}`, {
|
|
method: "PUT",
|
|
body: JSON.stringify({ name: person.name, active })
|
|
});
|
|
}
|
|
}
|