forked from dilame/instagram-private-api
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmedia-comments.feed.ts
35 lines (31 loc) · 1008 Bytes
/
media-comments.feed.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Expose } from 'class-transformer';
import { Feed } from '../core/feed';
import { MediaCommentsFeedResponse, MediaCommentsFeedResponseCommentsItem } from '../responses/';
export class MediaCommentsFeed extends Feed<MediaCommentsFeedResponse, MediaCommentsFeedResponseCommentsItem> {
id: string;
@Expose()
private nextMaxId: string;
@Expose()
private nextMinId: string;
set state(body: MediaCommentsFeedResponse) {
this.moreAvailable = !!body.next_max_id || !!body.next_min_id;
this.nextMaxId = body.next_max_id;
this.nextMinId = body.next_min_id;
}
async request() {
const { body } = await this.client.request.send<MediaCommentsFeedResponse>({
url: `/api/v1/media/${this.id}/comments/`,
qs: {
can_support_threading: true,
max_id: this.nextMaxId,
min_id: this.nextMinId,
},
});
this.state = body;
return body;
}
async items() {
const response = await this.request();
return response.comments;
}
}