@foru-ms/sdk 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/resources/Notifications.d.ts +3 -3
- package/dist/resources/Posts.d.ts +5 -5
- package/dist/resources/Posts.js +12 -4
- package/dist/resources/Tags.d.ts +3 -3
- package/dist/resources/Tags.js +2 -1
- package/dist/resources/Threads.d.ts +10 -10
- package/dist/resources/Threads.js +12 -6
- package/examples/error-handling.ts +0 -1
- package/examples/managing-threads.ts +0 -2
- package/examples/pagination.ts +1 -2
- package/package.json +1 -1
- package/src/resources/Notifications.ts +3 -3
- package/src/resources/Posts.ts +17 -9
- package/src/resources/Tags.ts +5 -4
- package/src/resources/Threads.ts +22 -16
package/README.md
CHANGED
|
@@ -43,7 +43,6 @@ client.setToken('user_jwt_token');
|
|
|
43
43
|
const thread = await client.threads.create({
|
|
44
44
|
title: 'My First Thread',
|
|
45
45
|
body: 'Hello, Foru.ms!',
|
|
46
|
-
userId: 'user-123',
|
|
47
46
|
});
|
|
48
47
|
|
|
49
48
|
// List threads with auto-pagination
|
|
@@ -137,7 +136,7 @@ const users = await client.users.list({ limit: 10 });
|
|
|
137
136
|
|
|
138
137
|
// Limit applies to all paginated endpoints
|
|
139
138
|
const posts = await client.posts.list({ limit: 25 });
|
|
140
|
-
const notifications = await client.notifications.list({
|
|
139
|
+
const notifications = await client.notifications.list({ limit: 30 });
|
|
141
140
|
```
|
|
142
141
|
|
|
143
142
|
## Webhooks
|
|
@@ -553,6 +552,9 @@ We welcome contributions! Please see our contributing guidelines for more inform
|
|
|
553
552
|
|
|
554
553
|
## Changelog
|
|
555
554
|
|
|
555
|
+
### v1.2.5
|
|
556
|
+
- Added optional `userId` parameter to methods that accept it
|
|
557
|
+
|
|
556
558
|
### v1.2.4
|
|
557
559
|
- Pagination Enhancement: Added configurable `limit` query parameter to all paginated endpoints
|
|
558
560
|
- Allows clients to control page size (min: 1, max: 50, default: 15)
|
|
@@ -4,13 +4,13 @@ export declare class NotificationsResource {
|
|
|
4
4
|
private client;
|
|
5
5
|
constructor(client: ForumClient);
|
|
6
6
|
list(params: {
|
|
7
|
-
userId
|
|
7
|
+
userId?: string;
|
|
8
8
|
read?: boolean;
|
|
9
9
|
filter?: 'newest' | 'oldest';
|
|
10
10
|
cursor?: string;
|
|
11
11
|
limit?: number;
|
|
12
12
|
}): Promise<NotificationListResponse>;
|
|
13
|
-
markAllAsRead(userId
|
|
13
|
+
markAllAsRead(userId?: string, read?: boolean): Promise<{
|
|
14
14
|
count: number;
|
|
15
15
|
}>;
|
|
16
16
|
retrieve(id: string): Promise<Notification>;
|
|
@@ -24,7 +24,7 @@ export declare class NotificationsResource {
|
|
|
24
24
|
threadId?: string;
|
|
25
25
|
postId?: string;
|
|
26
26
|
privateMessageId?: string;
|
|
27
|
-
notifierId
|
|
27
|
+
notifierId?: string;
|
|
28
28
|
notifiedId: string;
|
|
29
29
|
type: string;
|
|
30
30
|
description?: string;
|
|
@@ -15,7 +15,7 @@ export declare class PostsResource {
|
|
|
15
15
|
retrieve(postId: string): Promise<import('../types').Post>;
|
|
16
16
|
update(postId: string, payload: import('../types').UpdatePostPayload): Promise<import('../types').Post>;
|
|
17
17
|
delete(postId: string, payload?: {
|
|
18
|
-
userId
|
|
18
|
+
userId?: string;
|
|
19
19
|
}): Promise<import('../types').Post & {
|
|
20
20
|
deleted: boolean;
|
|
21
21
|
}>;
|
|
@@ -26,25 +26,25 @@ export declare class PostsResource {
|
|
|
26
26
|
limit?: number;
|
|
27
27
|
}): Promise<any>;
|
|
28
28
|
like(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
29
|
-
unlike(id: string, userId
|
|
29
|
+
unlike(id: string, userId?: string): Promise<any>;
|
|
30
30
|
getLikes(id: string, params?: {
|
|
31
31
|
cursor?: string;
|
|
32
32
|
limit?: number;
|
|
33
33
|
}): Promise<any>;
|
|
34
34
|
dislike(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
35
|
-
undislike(id: string, userId
|
|
35
|
+
undislike(id: string, userId?: string): Promise<any>;
|
|
36
36
|
getDislikes(id: string, params?: {
|
|
37
37
|
cursor?: string;
|
|
38
38
|
limit?: number;
|
|
39
39
|
}): Promise<any>;
|
|
40
40
|
upvote(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
41
|
-
unupvote(id: string, userId
|
|
41
|
+
unupvote(id: string, userId?: string): Promise<any>;
|
|
42
42
|
getUpvotes(id: string, params?: {
|
|
43
43
|
cursor?: string;
|
|
44
44
|
limit?: number;
|
|
45
45
|
}): Promise<any>;
|
|
46
46
|
downvote(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
47
|
-
undownvote(id: string, userId
|
|
47
|
+
undownvote(id: string, userId?: string): Promise<any>;
|
|
48
48
|
getDownvotes(id: string, params?: {
|
|
49
49
|
cursor?: string;
|
|
50
50
|
limit?: number;
|
package/dist/resources/Posts.js
CHANGED
|
@@ -59,7 +59,9 @@ class PostsResource {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
async unlike(id, userId) {
|
|
62
|
-
return this.client.request(`/post/${id}/likes?userId=${userId}`, {
|
|
62
|
+
return userId ? this.client.request(`/post/${id}/likes?userId=${userId}`, {
|
|
63
|
+
method: 'DELETE',
|
|
64
|
+
}) : this.client.request(`/post/${id}/likes`, {
|
|
63
65
|
method: 'DELETE',
|
|
64
66
|
});
|
|
65
67
|
}
|
|
@@ -81,7 +83,9 @@ class PostsResource {
|
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
85
|
async undislike(id, userId) {
|
|
84
|
-
return this.client.request(`/post/${id}/dislikes?userId=${userId}`, {
|
|
86
|
+
return userId ? this.client.request(`/post/${id}/dislikes?userId=${userId}`, {
|
|
87
|
+
method: 'DELETE',
|
|
88
|
+
}) : this.client.request(`/post/${id}/dislikes`, {
|
|
85
89
|
method: 'DELETE',
|
|
86
90
|
});
|
|
87
91
|
}
|
|
@@ -103,7 +107,9 @@ class PostsResource {
|
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
109
|
async unupvote(id, userId) {
|
|
106
|
-
return this.client.request(`/post/${id}/upvotes?userId=${userId}`, {
|
|
110
|
+
return userId ? this.client.request(`/post/${id}/upvotes?userId=${userId}`, {
|
|
111
|
+
method: 'DELETE',
|
|
112
|
+
}) : this.client.request(`/post/${id}/upvotes`, {
|
|
107
113
|
method: 'DELETE',
|
|
108
114
|
});
|
|
109
115
|
}
|
|
@@ -125,7 +131,9 @@ class PostsResource {
|
|
|
125
131
|
});
|
|
126
132
|
}
|
|
127
133
|
async undownvote(id, userId) {
|
|
128
|
-
return this.client.request(`/post/${id}/downvotes?userId=${userId}`, {
|
|
134
|
+
return userId ? this.client.request(`/post/${id}/downvotes?userId=${userId}`, {
|
|
135
|
+
method: 'DELETE',
|
|
136
|
+
}) : this.client.request(`/post/${id}/downvotes`, {
|
|
129
137
|
method: 'DELETE',
|
|
130
138
|
});
|
|
131
139
|
}
|
package/dist/resources/Tags.d.ts
CHANGED
|
@@ -34,14 +34,14 @@ export declare class TagsResource {
|
|
|
34
34
|
filter?: 'newest' | 'oldest';
|
|
35
35
|
limit?: number;
|
|
36
36
|
}): Promise<import('../types').ThreadListResponse>;
|
|
37
|
-
subscribe(id: string, userId
|
|
38
|
-
unsubscribe(id: string, userId
|
|
37
|
+
subscribe(id: string, userId?: string): Promise<any>;
|
|
38
|
+
unsubscribe(id: string, userId?: string): Promise<any>;
|
|
39
39
|
getSubscribers(id: string, params?: {
|
|
40
40
|
cursor?: string;
|
|
41
41
|
limit?: number;
|
|
42
42
|
}): Promise<any>;
|
|
43
43
|
listSubscribed(params: {
|
|
44
|
-
userId
|
|
44
|
+
userId?: string;
|
|
45
45
|
query?: string;
|
|
46
46
|
cursor?: string;
|
|
47
47
|
limit?: number;
|
package/dist/resources/Tags.js
CHANGED
|
@@ -63,8 +63,9 @@ class TagsResource {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
async unsubscribe(id, userId) {
|
|
66
|
-
return this.client.request(`/tag/${id}/subscribers
|
|
66
|
+
return this.client.request(`/tag/${id}/subscribers`, {
|
|
67
67
|
method: 'DELETE',
|
|
68
|
+
body: JSON.stringify({ userId }),
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
async getSubscribers(id, params) {
|
|
@@ -16,7 +16,7 @@ export declare class ThreadsResource {
|
|
|
16
16
|
retrieve(threadId: string): Promise<import('../types').Thread>;
|
|
17
17
|
update(threadId: string, payload: import('../types').UpdateThreadPayload): Promise<import('../types').Thread>;
|
|
18
18
|
delete(threadId: string, payload?: {
|
|
19
|
-
userId
|
|
19
|
+
userId?: string;
|
|
20
20
|
}): Promise<import('../types').Thread & {
|
|
21
21
|
deleted: boolean;
|
|
22
22
|
}>;
|
|
@@ -27,37 +27,37 @@ export declare class ThreadsResource {
|
|
|
27
27
|
limit?: number;
|
|
28
28
|
}): Promise<any>;
|
|
29
29
|
like(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
30
|
-
unlike(id: string, userId
|
|
30
|
+
unlike(id: string, userId?: string): Promise<any>;
|
|
31
31
|
getLikes(id: string, params?: {
|
|
32
32
|
cursor?: string;
|
|
33
33
|
limit?: number;
|
|
34
34
|
}): Promise<any>;
|
|
35
35
|
dislike(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
36
|
-
undislike(id: string, userId
|
|
36
|
+
undislike(id: string, userId?: string): Promise<any>;
|
|
37
37
|
getDislikes(id: string, params?: {
|
|
38
38
|
cursor?: string;
|
|
39
39
|
limit?: number;
|
|
40
40
|
}): Promise<any>;
|
|
41
|
-
subscribe(id: string, userId
|
|
42
|
-
unsubscribe(id: string, userId
|
|
41
|
+
subscribe(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
42
|
+
unsubscribe(id: string, userId?: string): Promise<any>;
|
|
43
43
|
getSubscribers(id: string, params?: {
|
|
44
44
|
cursor?: string;
|
|
45
45
|
limit?: number;
|
|
46
46
|
}): Promise<any>;
|
|
47
47
|
upvote(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
48
|
-
unupvote(id: string, userId
|
|
48
|
+
unupvote(id: string, userId?: string): Promise<any>;
|
|
49
49
|
getUpvotes(id: string, params?: {
|
|
50
50
|
cursor?: string;
|
|
51
51
|
limit?: number;
|
|
52
52
|
}): Promise<any>;
|
|
53
53
|
downvote(id: string, userId?: string, extendedData?: any): Promise<any>;
|
|
54
|
-
undownvote(id: string, userId
|
|
54
|
+
undownvote(id: string, userId?: string): Promise<any>;
|
|
55
55
|
getDownvotes(id: string, params?: {
|
|
56
56
|
cursor?: string;
|
|
57
57
|
limit?: number;
|
|
58
58
|
}): Promise<any>;
|
|
59
59
|
getPoll(threadId: string, userId?: string): Promise<any>;
|
|
60
|
-
vote(id: string, optionId: string, userId
|
|
61
|
-
voteUpdate(id: string, optionId: string, userId
|
|
62
|
-
unvote(id: string, userId
|
|
60
|
+
vote(id: string, optionId: string, userId?: string): Promise<any>;
|
|
61
|
+
voteUpdate(id: string, optionId: string, userId?: string): Promise<any>;
|
|
62
|
+
unvote(id: string, userId?: string): Promise<any>;
|
|
63
63
|
}
|
|
@@ -59,8 +59,9 @@ class ThreadsResource {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
async unlike(id, userId) {
|
|
62
|
-
return this.client.request(`/thread/${id}/likes
|
|
62
|
+
return this.client.request(`/thread/${id}/likes`, {
|
|
63
63
|
method: 'DELETE',
|
|
64
|
+
body: JSON.stringify({ userId }),
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
async getLikes(id, params) {
|
|
@@ -81,8 +82,9 @@ class ThreadsResource {
|
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
84
|
async undislike(id, userId) {
|
|
84
|
-
return this.client.request(`/thread/${id}/dislikes
|
|
85
|
+
return this.client.request(`/thread/${id}/dislikes`, {
|
|
85
86
|
method: 'DELETE',
|
|
87
|
+
body: JSON.stringify({ userId }),
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
90
|
async getDislikes(id, params) {
|
|
@@ -103,8 +105,9 @@ class ThreadsResource {
|
|
|
103
105
|
});
|
|
104
106
|
}
|
|
105
107
|
async unsubscribe(id, userId) {
|
|
106
|
-
return this.client.request(`/thread/${id}/subscribers
|
|
108
|
+
return this.client.request(`/thread/${id}/subscribers`, {
|
|
107
109
|
method: 'DELETE',
|
|
110
|
+
body: JSON.stringify({ userId }),
|
|
108
111
|
});
|
|
109
112
|
}
|
|
110
113
|
async getSubscribers(id, params) {
|
|
@@ -125,8 +128,9 @@ class ThreadsResource {
|
|
|
125
128
|
});
|
|
126
129
|
}
|
|
127
130
|
async unupvote(id, userId) {
|
|
128
|
-
return this.client.request(`/thread/${id}/upvotes
|
|
131
|
+
return this.client.request(`/thread/${id}/upvotes`, {
|
|
129
132
|
method: 'DELETE',
|
|
133
|
+
body: JSON.stringify({ userId }),
|
|
130
134
|
});
|
|
131
135
|
}
|
|
132
136
|
async getUpvotes(id, params) {
|
|
@@ -147,8 +151,9 @@ class ThreadsResource {
|
|
|
147
151
|
});
|
|
148
152
|
}
|
|
149
153
|
async undownvote(id, userId) {
|
|
150
|
-
return this.client.request(`/thread/${id}/downvotes
|
|
154
|
+
return this.client.request(`/thread/${id}/downvotes`, {
|
|
151
155
|
method: 'DELETE',
|
|
156
|
+
body: JSON.stringify({ userId }),
|
|
152
157
|
});
|
|
153
158
|
}
|
|
154
159
|
async getDownvotes(id, params) {
|
|
@@ -183,8 +188,9 @@ class ThreadsResource {
|
|
|
183
188
|
});
|
|
184
189
|
}
|
|
185
190
|
async unvote(id, userId) {
|
|
186
|
-
return this.client.request(`/thread/${id}/poll/votes
|
|
191
|
+
return this.client.request(`/thread/${id}/poll/votes`, {
|
|
187
192
|
method: 'DELETE',
|
|
193
|
+
body: JSON.stringify({ userId }),
|
|
188
194
|
});
|
|
189
195
|
}
|
|
190
196
|
}
|
|
@@ -79,7 +79,6 @@ async function main() {
|
|
|
79
79
|
const post = await client.posts.create({
|
|
80
80
|
threadId: newThread.id,
|
|
81
81
|
body: 'Thanks for posting! Check out our documentation.',
|
|
82
|
-
userId: 'moderator-123',
|
|
83
82
|
});
|
|
84
83
|
console.log('Post created:', post.id);
|
|
85
84
|
|
|
@@ -87,7 +86,6 @@ async function main() {
|
|
|
87
86
|
const reply = await client.posts.create({
|
|
88
87
|
threadId: newThread.id,
|
|
89
88
|
body: 'Thank you! That helps a lot.',
|
|
90
|
-
userId,
|
|
91
89
|
parentId: post.id, // This makes it a reply
|
|
92
90
|
});
|
|
93
91
|
console.log('Reply created:', reply.id);
|
package/examples/pagination.ts
CHANGED
|
@@ -58,8 +58,7 @@ async function main() {
|
|
|
58
58
|
const response = await client.posts.list({
|
|
59
59
|
cursor,
|
|
60
60
|
filter: 'newest',
|
|
61
|
-
type: 'created',
|
|
62
|
-
userId: 'user-123',
|
|
61
|
+
type: 'created',
|
|
63
62
|
});
|
|
64
63
|
|
|
65
64
|
console.log(`Page ${++pageCount}:`, response.posts.length, 'posts');
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ export class NotificationsResource {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
async list(params: {
|
|
12
|
-
userId
|
|
12
|
+
userId?: string;
|
|
13
13
|
read?: boolean;
|
|
14
14
|
filter?: 'newest' | 'oldest';
|
|
15
15
|
cursor?: string;
|
|
@@ -27,7 +27,7 @@ export class NotificationsResource {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
async markAllAsRead(userId
|
|
30
|
+
async markAllAsRead(userId?: string, read: boolean = true): Promise<{ count: number }> {
|
|
31
31
|
return this.client.request<{ count: number }>('/notifications', {
|
|
32
32
|
method: 'PATCH',
|
|
33
33
|
body: JSON.stringify({ userId, read }),
|
|
@@ -56,7 +56,7 @@ export class NotificationsResource {
|
|
|
56
56
|
threadId?: string;
|
|
57
57
|
postId?: string;
|
|
58
58
|
privateMessageId?: string;
|
|
59
|
-
notifierId
|
|
59
|
+
notifierId?: string;
|
|
60
60
|
notifiedId: string;
|
|
61
61
|
type: string;
|
|
62
62
|
description?: string;
|
package/src/resources/Posts.ts
CHANGED
|
@@ -50,7 +50,7 @@ export class PostsResource {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
async delete(postId: string, payload?: { userId
|
|
53
|
+
async delete(postId: string, payload?: { userId?: string }): Promise<import('../types').Post & { deleted: boolean }> {
|
|
54
54
|
return this.client.request<import('../types').Post & { deleted: boolean }>(`/post/${postId}`, {
|
|
55
55
|
method: 'DELETE',
|
|
56
56
|
body: payload ? JSON.stringify(payload) : undefined,
|
|
@@ -80,8 +80,10 @@ export class PostsResource {
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
async unlike(id: string, userId
|
|
84
|
-
return this.client.request(`/post/${id}/likes?userId=${userId}`, {
|
|
83
|
+
async unlike(id: string, userId?: string): Promise<any> {
|
|
84
|
+
return userId ? this.client.request(`/post/${id}/likes?userId=${userId}`, {
|
|
85
|
+
method: 'DELETE',
|
|
86
|
+
}) : this.client.request(`/post/${id}/likes`, {
|
|
85
87
|
method: 'DELETE',
|
|
86
88
|
});
|
|
87
89
|
}
|
|
@@ -108,8 +110,10 @@ export class PostsResource {
|
|
|
108
110
|
});
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
async undislike(id: string, userId
|
|
112
|
-
return this.client.request(`/post/${id}/dislikes?userId=${userId}`, {
|
|
113
|
+
async undislike(id: string, userId?: string): Promise<any> {
|
|
114
|
+
return userId ? this.client.request(`/post/${id}/dislikes?userId=${userId}`, {
|
|
115
|
+
method: 'DELETE',
|
|
116
|
+
}) : this.client.request(`/post/${id}/dislikes`, {
|
|
113
117
|
method: 'DELETE',
|
|
114
118
|
});
|
|
115
119
|
}
|
|
@@ -136,8 +140,10 @@ export class PostsResource {
|
|
|
136
140
|
});
|
|
137
141
|
}
|
|
138
142
|
|
|
139
|
-
async unupvote(id: string, userId
|
|
140
|
-
return this.client.request(`/post/${id}/upvotes?userId=${userId}`, {
|
|
143
|
+
async unupvote(id: string, userId?: string): Promise<any> {
|
|
144
|
+
return userId ? this.client.request(`/post/${id}/upvotes?userId=${userId}`, {
|
|
145
|
+
method: 'DELETE',
|
|
146
|
+
}) : this.client.request(`/post/${id}/upvotes`, {
|
|
141
147
|
method: 'DELETE',
|
|
142
148
|
});
|
|
143
149
|
}
|
|
@@ -164,8 +170,10 @@ export class PostsResource {
|
|
|
164
170
|
});
|
|
165
171
|
}
|
|
166
172
|
|
|
167
|
-
async undownvote(id: string, userId
|
|
168
|
-
return this.client.request(`/post/${id}/downvotes?userId=${userId}`, {
|
|
173
|
+
async undownvote(id: string, userId?: string): Promise<any> {
|
|
174
|
+
return userId ? this.client.request(`/post/${id}/downvotes?userId=${userId}`, {
|
|
175
|
+
method: 'DELETE',
|
|
176
|
+
}) : this.client.request(`/post/${id}/downvotes`, {
|
|
169
177
|
method: 'DELETE',
|
|
170
178
|
});
|
|
171
179
|
}
|
package/src/resources/Tags.ts
CHANGED
|
@@ -84,16 +84,17 @@ export class TagsResource {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
async subscribe(id: string, userId
|
|
87
|
+
async subscribe(id: string, userId?: string): Promise<any> {
|
|
88
88
|
return this.client.request(`/tag/${id}/subscribers`, {
|
|
89
89
|
method: 'POST',
|
|
90
90
|
body: JSON.stringify({ userId }),
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
async unsubscribe(id: string, userId
|
|
95
|
-
return this.client.request(`/tag/${id}/subscribers
|
|
94
|
+
async unsubscribe(id: string, userId?: string): Promise<any> {
|
|
95
|
+
return this.client.request(`/tag/${id}/subscribers`, {
|
|
96
96
|
method: 'DELETE',
|
|
97
|
+
body: JSON.stringify({ userId }),
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
|
|
@@ -113,7 +114,7 @@ export class TagsResource {
|
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
async listSubscribed(params: {
|
|
116
|
-
userId
|
|
117
|
+
userId?: string;
|
|
117
118
|
query?: string;
|
|
118
119
|
cursor?: string;
|
|
119
120
|
limit?: number;
|
package/src/resources/Threads.ts
CHANGED
|
@@ -51,7 +51,7 @@ export class ThreadsResource {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
async delete(threadId: string, payload?: { userId
|
|
54
|
+
async delete(threadId: string, payload?: { userId?: string }): Promise<import('../types').Thread & { deleted: boolean }> {
|
|
55
55
|
return this.client.request<import('../types').Thread & { deleted: boolean }>(`/thread/${threadId}`, {
|
|
56
56
|
method: 'DELETE',
|
|
57
57
|
body: payload ? JSON.stringify(payload) : undefined,
|
|
@@ -81,9 +81,10 @@ export class ThreadsResource {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
async unlike(id: string, userId
|
|
85
|
-
return this.client.request(`/thread/${id}/likes
|
|
84
|
+
async unlike(id: string, userId?: string): Promise<any> {
|
|
85
|
+
return this.client.request(`/thread/${id}/likes`, {
|
|
86
86
|
method: 'DELETE',
|
|
87
|
+
body: JSON.stringify({ userId }),
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
|
|
@@ -109,9 +110,10 @@ export class ThreadsResource {
|
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
async undislike(id: string, userId
|
|
113
|
-
return this.client.request(`/thread/${id}/dislikes
|
|
113
|
+
async undislike(id: string, userId?: string): Promise<any> {
|
|
114
|
+
return this.client.request(`/thread/${id}/dislikes`, {
|
|
114
115
|
method: 'DELETE',
|
|
116
|
+
body: JSON.stringify({ userId }),
|
|
115
117
|
});
|
|
116
118
|
}
|
|
117
119
|
|
|
@@ -130,16 +132,17 @@ export class ThreadsResource {
|
|
|
130
132
|
return this.client.request(`/thread/${id}/dislikes?${searchParams.toString()}`, { method: 'GET' });
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
async subscribe(id: string, userId
|
|
135
|
+
async subscribe(id: string, userId?: string, extendedData?: any): Promise<any> {
|
|
134
136
|
return this.client.request(`/thread/${id}/subscribers`, {
|
|
135
137
|
method: 'POST',
|
|
136
138
|
body: JSON.stringify({ userId, extendedData }),
|
|
137
139
|
});
|
|
138
140
|
}
|
|
139
141
|
|
|
140
|
-
async unsubscribe(id: string, userId
|
|
141
|
-
return this.client.request(`/thread/${id}/subscribers
|
|
142
|
+
async unsubscribe(id: string, userId?: string): Promise<any> {
|
|
143
|
+
return this.client.request(`/thread/${id}/subscribers`, {
|
|
142
144
|
method: 'DELETE',
|
|
145
|
+
body: JSON.stringify({ userId }),
|
|
143
146
|
});
|
|
144
147
|
}
|
|
145
148
|
|
|
@@ -165,9 +168,10 @@ export class ThreadsResource {
|
|
|
165
168
|
});
|
|
166
169
|
}
|
|
167
170
|
|
|
168
|
-
async unupvote(id: string, userId
|
|
169
|
-
return this.client.request(`/thread/${id}/upvotes
|
|
171
|
+
async unupvote(id: string, userId?: string): Promise<any> {
|
|
172
|
+
return this.client.request(`/thread/${id}/upvotes`, {
|
|
170
173
|
method: 'DELETE',
|
|
174
|
+
body: JSON.stringify({ userId }),
|
|
171
175
|
});
|
|
172
176
|
}
|
|
173
177
|
|
|
@@ -193,9 +197,10 @@ export class ThreadsResource {
|
|
|
193
197
|
});
|
|
194
198
|
}
|
|
195
199
|
|
|
196
|
-
async undownvote(id: string, userId
|
|
197
|
-
return this.client.request(`/thread/${id}/downvotes
|
|
200
|
+
async undownvote(id: string, userId?: string): Promise<any> {
|
|
201
|
+
return this.client.request(`/thread/${id}/downvotes`, {
|
|
198
202
|
method: 'DELETE',
|
|
203
|
+
body: JSON.stringify({ userId }),
|
|
199
204
|
});
|
|
200
205
|
}
|
|
201
206
|
|
|
@@ -227,23 +232,24 @@ export class ThreadsResource {
|
|
|
227
232
|
);
|
|
228
233
|
}
|
|
229
234
|
|
|
230
|
-
async vote(id: string, optionId: string, userId
|
|
235
|
+
async vote(id: string, optionId: string, userId?: string): Promise<any> {
|
|
231
236
|
return this.client.request(`/thread/${id}/poll/votes`, {
|
|
232
237
|
method: 'POST',
|
|
233
238
|
body: JSON.stringify({ optionId, userId }),
|
|
234
239
|
});
|
|
235
240
|
}
|
|
236
241
|
|
|
237
|
-
async voteUpdate(id: string, optionId: string, userId
|
|
242
|
+
async voteUpdate(id: string, optionId: string, userId?: string): Promise<any> {
|
|
238
243
|
return this.client.request(`/thread/${id}/poll/votes`, {
|
|
239
244
|
method: 'PUT',
|
|
240
245
|
body: JSON.stringify({ optionId, userId }),
|
|
241
246
|
});
|
|
242
247
|
}
|
|
243
248
|
|
|
244
|
-
async unvote(id: string, userId
|
|
245
|
-
return this.client.request(`/thread/${id}/poll/votes
|
|
249
|
+
async unvote(id: string, userId?: string): Promise<any> {
|
|
250
|
+
return this.client.request(`/thread/${id}/poll/votes`, {
|
|
246
251
|
method: 'DELETE',
|
|
252
|
+
body: JSON.stringify({ userId }),
|
|
247
253
|
});
|
|
248
254
|
}
|
|
249
255
|
}
|