node-groupme
Version:
The only GroupMe API library that isn't a million years old.
30 lines • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const __1 = require("..");
class FormerGroupManager extends __1.BaseManager {
constructor(client) {
super(client, __1.FormerGroup);
}
async fetch(id) {
const groupsFormerResponse = await this.client.rest.api('GET', 'groups/former');
const batch = new __1.Collection();
groupsFormerResponse.forEach(g => {
/** The Group object to store data in. */
const formerGroup = this._upsert(new __1.FormerGroup(this.client, g));
// we know that g.members is always defined for former groups
// however, it would be nice if the types reflected that...
g.members.forEach(data => {
const user = this.client.users._add({
id: data.user_id,
avatar_url: data.image_url,
name: data.name,
});
formerGroup.members._upsert(new __1.Member(this.client, formerGroup, user, data));
});
batch.set(formerGroup.id, formerGroup);
});
return batch;
}
}
exports.default = FormerGroupManager;
//# sourceMappingURL=FormerGroupManager.js.map