From fb94e6e5eda24e3b896274083674af56e6412c33 Mon Sep 17 00:00:00 2001 From: Peter <43360094+not-so-smart@users.noreply.github.com> Date: Tue, 8 Feb 2022 19:16:59 -0500 Subject: [PATCH 1/3] chore: :arrow_up: groupme-api-types@1.1.0 this update adds support for v4 and relationships --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5735468..b24dad8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@discordjs/collection": "^0.1.6", - "groupme-api-types": "^1.0.1", + "groupme-api-types": "^1.1.0", "node-fetch": "^2.6.1", "ws": "^8.1.0" }, @@ -2935,9 +2935,9 @@ "dev": true }, "node_modules/groupme-api-types": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/groupme-api-types/-/groupme-api-types-1.0.1.tgz", - "integrity": "sha512-YMvEcqP4s6r7blL0iKMKgeO/u9+iK66Tly5NzYxklyhAv83knc+eJEhDhYGhgjBlr+gssGMLXalU9yfJbWu6gw==" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/groupme-api-types/-/groupme-api-types-1.1.0.tgz", + "integrity": "sha512-pUwhyuip//hXxix7Nqd6ayyg6FgPG01Lyh69be9QFRYbRKEgBE4FGRFU/PW+yEdROo+rPNs0EU41nO/n1vrHOA==" }, "node_modules/growl": { "version": "1.10.5", @@ -10948,9 +10948,9 @@ "dev": true }, "groupme-api-types": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/groupme-api-types/-/groupme-api-types-1.0.1.tgz", - "integrity": "sha512-YMvEcqP4s6r7blL0iKMKgeO/u9+iK66Tly5NzYxklyhAv83knc+eJEhDhYGhgjBlr+gssGMLXalU9yfJbWu6gw==" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/groupme-api-types/-/groupme-api-types-1.1.0.tgz", + "integrity": "sha512-pUwhyuip//hXxix7Nqd6ayyg6FgPG01Lyh69be9QFRYbRKEgBE4FGRFU/PW+yEdROo+rPNs0EU41nO/n1vrHOA==" }, "growl": { "version": "1.10.5", diff --git a/package.json b/package.json index 30e4197..61e3b7e 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ }, "dependencies": { "@discordjs/collection": "^0.1.6", - "groupme-api-types": "^1.0.1", + "groupme-api-types": "^1.1.0", "node-fetch": "^2.6.1", "ws": "^8.1.0" }, From 9d5b534882b42327725aa122ee805cea6ddaa490 Mon Sep 17 00:00:00 2001 From: Peter <43360094+not-so-smart@users.noreply.github.com> Date: Tue, 8 Feb 2022 19:19:27 -0500 Subject: [PATCH 2/3] feat(Relationships): :sparkles: add relationship support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ❤️ --- src/client/Client.ts | 7 +++--- src/index.ts | 2 ++ src/managers/RelationshipManager.ts | 25 +++++++++++++++++++++ src/structures/Relationship.ts | 34 +++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 src/managers/RelationshipManager.ts create mode 100644 src/structures/Relationship.ts diff --git a/src/client/Client.ts b/src/client/Client.ts index fc4d2c4..b549209 100644 --- a/src/client/Client.ts +++ b/src/client/Client.ts @@ -1,13 +1,12 @@ import EventEmitter from 'events' import type { APIClientUser } from 'groupme-api-types' -import ChatManager from '../managers/ChatManager' -import GroupManager from '../managers/GroupManager' -import UserManager from '../managers/UserManager' +import { ChatManager, GroupManager, RelationshipManager, UserManager } from '..' import RESTManager from '../rest/rest' import WS from '../util/Websocket' import ClientUser from './ClientUser' interface ClientInterface { + relationships: RelationshipManager groups: GroupManager chats: ChatManager users: UserManager @@ -17,6 +16,7 @@ interface ClientInterface { } export default class Client extends EventEmitter implements ClientInterface { + relationships: RelationshipManager groups: GroupManager users: UserManager chats: ChatManager @@ -27,6 +27,7 @@ export default class Client extends EventEmitter implements ClientInterface { constructor(token: string) { super() this.token = token + this.relationships = new RelationshipManager(this) this.groups = new GroupManager(this) this.users = new UserManager(this) this.chats = new ChatManager(this) diff --git a/src/index.ts b/src/index.ts index 253acad..62b354f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,6 +24,8 @@ export { default as Group } from './structures/Group' export { default as FormerGroupManager } from './managers/FormerGroupManager' export { default as ChatManager } from './managers/ChatManager' export { default as GroupManager } from './managers/GroupManager' +export { default as Relationship } from './structures/Relationship' +export { default as RelationshipManager } from './managers/RelationshipManager' export { default as Attachment } from './structures/Attachment' export { default as PollOption } from './structures/PollOption' diff --git a/src/managers/RelationshipManager.ts b/src/managers/RelationshipManager.ts new file mode 100644 index 0000000..ecc569e --- /dev/null +++ b/src/managers/RelationshipManager.ts @@ -0,0 +1,25 @@ +import type { GetRelationshipsQuery, GetRelationshipsResponse } from 'groupme-api-types/v4' +import type { Client, Collection } from '..' +import { BaseManager, Relationship } from '..' + +export default class RelationshipManager extends BaseManager { + constructor(client: Client) { + super(client, Relationship) + } + + async fetch(includeBlocked = true): Promise> { + const query: GetRelationshipsQuery = { include_blocked: includeBlocked } + let response: GetRelationshipsResponse + do { + response = await this.client.rest.api( + 'GET', + 'relationships', + { query }, + { version: 'v4' }, + ) + response.forEach(data => this._upsert(new Relationship(this.client, data))) + query.since = response[response.length - 1]?.updated_at_iso8601 + } while (response.length) + return this.cache + } +} diff --git a/src/structures/Relationship.ts b/src/structures/Relationship.ts new file mode 100644 index 0000000..ac74a8f --- /dev/null +++ b/src/structures/Relationship.ts @@ -0,0 +1,34 @@ +import type { APIRelationship } from 'groupme-api-types/v4' +import type { Client } from '..' +import { User } from '..' + +export default class Relationship { + client: Client + user: User + id: string + reason: number + hidden: boolean + appInstalled: boolean + mri: string + createdAt: number + updatedAt: number + _iso8601: string + constructor(client: Client, data: APIRelationship) { + this.client = client + this.user = client.users._upsert( + new User(client, { + id: data.user_id, + name: data.name, + avatar: data.avatar_url, + }), + ) + this.id = data.id + this.reason = data.reason + this.hidden = data.hidden + this.appInstalled = data.app_installed + this.mri = data.mri + this.createdAt = data.created_at + this.updatedAt = data.updated_at + this._iso8601 = data.updated_at_iso8601 + } +} From 31e268136790e9660471930e8bf23608d5d36705 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 9 Feb 2022 00:22:11 +0000 Subject: [PATCH 3/3] chore(release): 2.2.0 [skip ci] # [2.2.0](https://github.com/groupme-js/node-groupme/compare/v2.1.0...v2.2.0) (2022-02-09) ### Features * **Relationships:** :sparkles: add relationship support ([9d5b534](https://github.com/groupme-js/node-groupme/commit/9d5b534882b42327725aa122ee805cea6ddaa490)) --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec92f83..548c30d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [2.2.0](https://github.com/groupme-js/node-groupme/compare/v2.1.0...v2.2.0) (2022-02-09) + + +### Features + +* **Relationships:** :sparkles: add relationship support ([9d5b534](https://github.com/groupme-js/node-groupme/commit/9d5b534882b42327725aa122ee805cea6ddaa490)) + # [2.1.0](https://github.com/groupme-js/node-groupme/compare/v2.0.0...v2.1.0) (2022-02-08) diff --git a/package-lock.json b/package-lock.json index b24dad8..7b8eac8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "node-groupme", - "version": "2.1.0", + "version": "2.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "node-groupme", - "version": "2.1.0", + "version": "2.2.0", "license": "MIT", "dependencies": { "@discordjs/collection": "^0.1.6", diff --git a/package.json b/package.json index 61e3b7e..4b022b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-groupme", - "version": "2.1.0", + "version": "2.2.0", "description": "The only GroupMe API library that isn't a million years old.", "main": "dist/index.js", "scripts": {