rettiwt-api 6.0.8 → 6.1.0
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/.github/ISSUE_TEMPLATE/bug-report.yml +57 -0
- package/.github/ISSUE_TEMPLATE/feature-request.yml +20 -0
- package/.github/ISSUE_TEMPLATE/question.yml +15 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +32 -0
- package/.github/workflows/ci.yml +33 -0
- package/.nvmrc +1 -0
- package/README.md +30 -6
- package/dist/Rettiwt.d.ts +3 -0
- package/dist/Rettiwt.js +4 -0
- package/dist/Rettiwt.js.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/collections/Extractors.d.ts +24 -0
- package/dist/collections/Extractors.js +14 -0
- package/dist/collections/Extractors.js.map +1 -1
- package/dist/collections/Groups.js +11 -0
- package/dist/collections/Groups.js.map +1 -1
- package/dist/collections/Requests.js +12 -0
- package/dist/collections/Requests.js.map +1 -1
- package/dist/commands/DirectMessage.d.ts +10 -0
- package/dist/commands/DirectMessage.js +57 -0
- package/dist/commands/DirectMessage.js.map +1 -0
- package/dist/commands/List.js +44 -3
- package/dist/commands/List.js.map +1 -1
- package/dist/commands/Tweet.js +29 -1
- package/dist/commands/Tweet.js.map +1 -1
- package/dist/commands/User.js +39 -1
- package/dist/commands/User.js.map +1 -1
- package/dist/enums/Data.d.ts +3 -1
- package/dist/enums/Data.js +2 -0
- package/dist/enums/Data.js.map +1 -1
- package/dist/enums/Resource.d.ts +11 -0
- package/dist/enums/Resource.js +12 -0
- package/dist/enums/Resource.js.map +1 -1
- package/dist/enums/raw/Analytics.d.ts +6 -3
- package/dist/enums/raw/Analytics.js +5 -2
- package/dist/enums/raw/Analytics.js.map +1 -1
- package/dist/index.d.ts +15 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/models/args/FetchArgs.d.ts +9 -0
- package/dist/models/args/FetchArgs.js +16 -0
- package/dist/models/args/FetchArgs.js.map +1 -1
- package/dist/models/args/PostArgs.d.ts +1 -0
- package/dist/models/args/PostArgs.js +2 -0
- package/dist/models/args/PostArgs.js.map +1 -1
- package/dist/models/data/Analytics.d.ts +43 -0
- package/dist/models/data/Analytics.js +92 -0
- package/dist/models/data/Analytics.js.map +1 -0
- package/dist/models/data/Conversation.d.ts +93 -0
- package/dist/models/data/Conversation.js +293 -0
- package/dist/models/data/Conversation.js.map +1 -0
- package/dist/models/data/CursoredData.d.ts +2 -1
- package/dist/models/data/CursoredData.js +6 -1
- package/dist/models/data/CursoredData.js.map +1 -1
- package/dist/models/data/DirectMessage.d.ts +105 -0
- package/dist/models/data/DirectMessage.js +284 -0
- package/dist/models/data/DirectMessage.js.map +1 -0
- package/dist/models/data/Inbox.d.ts +44 -0
- package/dist/models/data/Inbox.js +106 -0
- package/dist/models/data/Inbox.js.map +1 -0
- package/dist/models/data/List.d.ts +20 -0
- package/dist/models/data/List.js +50 -1
- package/dist/models/data/List.js.map +1 -1
- package/dist/models/data/Tweet.d.ts +6 -6
- package/dist/models/data/Tweet.js +4 -2
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.d.ts +2 -0
- package/dist/models/data/User.js +6 -0
- package/dist/models/data/User.js.map +1 -1
- package/dist/requests/DirectMessage.d.ts +28 -0
- package/dist/requests/DirectMessage.js +149 -0
- package/dist/requests/DirectMessage.js.map +1 -0
- package/dist/requests/List.d.ts +10 -0
- package/dist/requests/List.js +52 -0
- package/dist/requests/List.js.map +1 -1
- package/dist/requests/Tweet.d.ts +8 -0
- package/dist/requests/Tweet.js +30 -0
- package/dist/requests/Tweet.js.map +1 -1
- package/dist/requests/User.d.ts +8 -1
- package/dist/requests/User.js +67 -8
- package/dist/requests/User.js.map +1 -1
- package/dist/services/public/DirectMessageService.d.ts +100 -0
- package/dist/services/public/DirectMessageService.js +143 -0
- package/dist/services/public/DirectMessageService.js.map +1 -0
- package/dist/services/public/FetcherService.d.ts +2 -2
- package/dist/services/public/FetcherService.js +2 -2
- package/dist/services/public/ListService.d.ts +85 -0
- package/dist/services/public/ListService.js +111 -0
- package/dist/services/public/ListService.js.map +1 -1
- package/dist/services/public/TweetService.d.ts +56 -0
- package/dist/services/public/TweetService.js +72 -0
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.d.ts +61 -2
- package/dist/services/public/UserService.js +89 -0
- package/dist/services/public/UserService.js.map +1 -1
- package/dist/types/args/FetchArgs.d.ts +69 -12
- package/dist/types/args/PostArgs.d.ts +29 -11
- package/dist/types/data/Analytics.d.ts +42 -0
- package/dist/types/data/Analytics.js +3 -0
- package/dist/types/data/Analytics.js.map +1 -0
- package/dist/types/data/Conversation.d.ts +32 -0
- package/dist/types/data/Conversation.js +3 -0
- package/dist/types/data/Conversation.js.map +1 -0
- package/dist/types/data/CursoredData.d.ts +4 -1
- package/dist/types/data/DirectMessage.d.ts +25 -0
- package/dist/types/data/DirectMessage.js +3 -0
- package/dist/types/data/DirectMessage.js.map +1 -0
- package/dist/types/data/Inbox.d.ts +18 -0
- package/dist/types/data/Inbox.js +3 -0
- package/dist/types/data/Inbox.js.map +1 -0
- package/dist/types/data/List.d.ts +5 -1
- package/dist/types/data/Tweet.d.ts +6 -6
- package/dist/types/data/User.d.ts +4 -0
- package/dist/types/raw/base/Analytic.d.ts +6 -1
- package/dist/types/raw/base/Message.d.ts +16 -0
- package/dist/types/raw/base/Message.js +4 -0
- package/dist/types/raw/base/Message.js.map +1 -0
- package/dist/types/raw/base/Tweet.d.ts +6 -6
- package/dist/types/raw/base/User.d.ts +2 -1
- package/dist/types/raw/composite/TimelineList.d.ts +9 -0
- package/dist/types/raw/composite/TimelineList.js +3 -0
- package/dist/types/raw/composite/TimelineList.js.map +1 -0
- package/dist/types/raw/dm/Conversation.d.ts +55 -0
- package/dist/types/raw/dm/Conversation.js +4 -0
- package/dist/types/raw/dm/Conversation.js.map +1 -0
- package/dist/types/raw/dm/InboxInitial.d.ts +137 -0
- package/dist/types/raw/dm/InboxInitial.js +4 -0
- package/dist/types/raw/dm/InboxInitial.js.map +1 -0
- package/dist/types/raw/dm/InboxTimeline.d.ts +287 -0
- package/dist/types/raw/dm/InboxTimeline.js +4 -0
- package/dist/types/raw/dm/InboxTimeline.js.map +1 -0
- package/dist/types/raw/dm/UserUpdates.d.ts +41 -0
- package/dist/types/raw/dm/UserUpdates.js +4 -0
- package/dist/types/raw/dm/UserUpdates.js.map +1 -0
- package/dist/types/raw/list/AddMember.d.ts +151 -0
- package/dist/types/raw/list/AddMember.js +4 -0
- package/dist/types/raw/list/AddMember.js.map +1 -0
- package/dist/types/raw/list/Details.d.ts +44 -13
- package/dist/types/raw/list/RemoveMember.d.ts +150 -0
- package/dist/types/raw/list/RemoveMember.js +4 -0
- package/dist/types/raw/list/RemoveMember.js.map +1 -0
- package/dist/types/raw/tweet/Bookmark.d.ts +12 -0
- package/dist/types/raw/tweet/Bookmark.js +4 -0
- package/dist/types/raw/tweet/Bookmark.js.map +1 -0
- package/dist/types/raw/tweet/Unbookmark.d.ts +11 -0
- package/dist/types/raw/tweet/Unbookmark.js +4 -0
- package/dist/types/raw/tweet/Unbookmark.js.map +1 -0
- package/dist/types/raw/user/Analytics.d.ts +6 -18
- package/dist/types/raw/user/Analytics.js +0 -1
- package/dist/types/raw/user/Analytics.js.map +1 -1
- package/dist/types/raw/user/Lists.d.ts +319 -0
- package/dist/types/raw/user/Lists.js +4 -0
- package/dist/types/raw/user/Lists.js.map +1 -0
- package/eslint.config.mjs +1 -1
- package/package.json +11 -6
- package/playground/.env.example +1 -0
- package/playground/README.md +53 -0
- package/playground/index.js +15 -0
- package/playground/package.json +15 -0
- package/src/Rettiwt.ts +5 -0
- package/src/cli.ts +2 -0
- package/src/collections/Extractors.ts +29 -0
- package/src/collections/Groups.ts +11 -0
- package/src/collections/Requests.ts +20 -0
- package/src/commands/DirectMessage.ts +62 -0
- package/src/commands/List.ts +44 -3
- package/src/commands/Tweet.ts +29 -1
- package/src/commands/User.ts +65 -1
- package/src/enums/Data.ts +2 -0
- package/src/enums/Resource.ts +13 -0
- package/src/enums/raw/Analytics.ts +5 -2
- package/src/index.ts +15 -0
- package/src/models/args/FetchArgs.ts +17 -0
- package/src/models/args/PostArgs.ts +2 -0
- package/src/models/data/Analytics.ts +97 -0
- package/src/models/data/Conversation.ts +344 -0
- package/src/models/data/CursoredData.ts +7 -2
- package/src/models/data/DirectMessage.ts +335 -0
- package/src/models/data/Inbox.ts +124 -0
- package/src/models/data/List.ts +60 -1
- package/src/models/data/Tweet.ts +10 -8
- package/src/models/data/User.ts +6 -0
- package/src/requests/DirectMessage.ts +233 -0
- package/src/requests/List.ts +58 -0
- package/src/requests/Tweet.ts +32 -0
- package/src/requests/User.ts +70 -7
- package/src/services/public/DirectMessageService.ts +159 -0
- package/src/services/public/FetcherService.ts +2 -2
- package/src/services/public/ListService.ts +127 -0
- package/src/services/public/TweetService.ts +82 -0
- package/src/services/public/UserService.ts +110 -2
- package/src/types/args/FetchArgs.ts +77 -12
- package/src/types/args/PostArgs.ts +31 -11
- package/src/types/data/Analytics.ts +58 -0
- package/src/types/data/Conversation.ts +44 -0
- package/src/types/data/CursoredData.ts +4 -1
- package/src/types/data/DirectMessage.ts +33 -0
- package/src/types/data/Inbox.ts +23 -0
- package/src/types/data/List.ts +7 -1
- package/src/types/data/Tweet.ts +6 -6
- package/src/types/data/User.ts +6 -0
- package/src/types/raw/base/Analytic.ts +7 -1
- package/src/types/raw/base/Message.ts +22 -0
- package/src/types/raw/base/Tweet.ts +6 -6
- package/src/types/raw/base/User.ts +2 -1
- package/src/types/raw/composite/TimelineList.ts +10 -0
- package/src/types/raw/dm/Conversation.ts +59 -0
- package/src/types/raw/dm/InboxInitial.ts +155 -0
- package/src/types/raw/dm/InboxTimeline.ts +301 -0
- package/src/types/raw/dm/UserUpdates.ts +46 -0
- package/src/types/raw/list/AddMember.ts +175 -0
- package/src/types/raw/list/Details.ts +52 -13
- package/src/types/raw/list/RemoveMember.ts +174 -0
- package/src/types/raw/tweet/Bookmark.ts +14 -0
- package/src/types/raw/tweet/Unbookmark.ts +14 -0
- package/src/types/raw/user/Analytics.ts +6 -22
- package/src/types/raw/user/Lists.ts +378 -0
- package/tsconfig.json +1 -1
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Extractors } from '../../collections/Extractors';
|
|
2
2
|
import { ResourceType } from '../../enums/Resource';
|
|
3
3
|
import { CursoredData } from '../../models/data/CursoredData';
|
|
4
|
+
import { List } from '../../models/data/List';
|
|
4
5
|
import { Tweet } from '../../models/data/Tweet';
|
|
5
6
|
import { User } from '../../models/data/User';
|
|
6
7
|
import { RettiwtConfig } from '../../models/RettiwtConfig';
|
|
8
|
+
import { IListMemberAddResponse } from '../../types/raw/list/AddMember';
|
|
9
|
+
import { IListDetailsResponse } from '../../types/raw/list/Details';
|
|
7
10
|
import { IListMembersResponse } from '../../types/raw/list/Members';
|
|
11
|
+
import { IListMemberRemoveResponse } from '../../types/raw/list/RemoveMember';
|
|
8
12
|
import { IListTweetsResponse } from '../../types/raw/list/Tweets';
|
|
9
13
|
|
|
10
14
|
import { FetcherService } from './FetcherService';
|
|
@@ -19,6 +23,88 @@ export class ListService extends FetcherService {
|
|
|
19
23
|
super(config);
|
|
20
24
|
}
|
|
21
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Add a user as a member of a list.
|
|
28
|
+
*
|
|
29
|
+
* @param listId - The ID of the target list.
|
|
30
|
+
* @param userId - The ID of the target user to be added as a member.
|
|
31
|
+
*
|
|
32
|
+
* @returns The new member count of the list. If adding was unsuccessful, return `undefined`.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
38
|
+
*
|
|
39
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
40
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
41
|
+
*
|
|
42
|
+
* // Adding a user with ID '123456789' as a member to the list with ID '987654321'
|
|
43
|
+
* rettiwt.list.addMember('987654321', '123456789')
|
|
44
|
+
* .then(res => {
|
|
45
|
+
* console.log(res);
|
|
46
|
+
* })
|
|
47
|
+
* .catch(err => {
|
|
48
|
+
* console.log(err);
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
public async addMember(listId: string, userId: string): Promise<number | undefined> {
|
|
53
|
+
const resource: ResourceType = ResourceType.LIST_MEMBER_ADD;
|
|
54
|
+
|
|
55
|
+
// Adding the user as a member
|
|
56
|
+
const response = await this.request<IListMemberAddResponse>(resource, {
|
|
57
|
+
id: listId,
|
|
58
|
+
userId: userId,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Deserializing response
|
|
62
|
+
const data = Extractors[resource](response);
|
|
63
|
+
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get the details of a list.
|
|
69
|
+
*
|
|
70
|
+
* @param id - The ID of the target list.
|
|
71
|
+
*
|
|
72
|
+
* @returns
|
|
73
|
+
* The details of the target list.
|
|
74
|
+
*
|
|
75
|
+
* If list not found, returns undefined.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
*
|
|
79
|
+
* #### Fetching the details of a list
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
82
|
+
*
|
|
83
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
84
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
85
|
+
*
|
|
86
|
+
* // Fetching the details of the list with the id '1234567890'
|
|
87
|
+
* rettiwt.list.details('1234567890')
|
|
88
|
+
* .then(res => {
|
|
89
|
+
* console.log(res);
|
|
90
|
+
* })
|
|
91
|
+
* .catch(err => {
|
|
92
|
+
* console.log(err);
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
public async details(id: string): Promise<List | undefined> {
|
|
97
|
+
const resource: ResourceType = ResourceType.LIST_DETAILS;
|
|
98
|
+
|
|
99
|
+
// Getting the details of the list
|
|
100
|
+
const response = await this.request<IListDetailsResponse>(resource, { id: id });
|
|
101
|
+
|
|
102
|
+
// Deserializing response
|
|
103
|
+
const data = Extractors[resource](response, id);
|
|
104
|
+
|
|
105
|
+
return data;
|
|
106
|
+
}
|
|
107
|
+
|
|
22
108
|
/**
|
|
23
109
|
* Get the list of members of a tweet list.
|
|
24
110
|
*
|
|
@@ -64,6 +150,47 @@ export class ListService extends FetcherService {
|
|
|
64
150
|
return data;
|
|
65
151
|
}
|
|
66
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Remove a member from a list.
|
|
155
|
+
*
|
|
156
|
+
* @param listId - The ID of the target list.
|
|
157
|
+
* @param userId - The ID of the target user to removed from the members.
|
|
158
|
+
*
|
|
159
|
+
* @returns The new member count of the list. If removal was unsuccessful, return `undefined`.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
*
|
|
163
|
+
* ```ts
|
|
164
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
165
|
+
*
|
|
166
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
167
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
168
|
+
*
|
|
169
|
+
* // Removing a user with ID '123456789' from the member of the list with ID '987654321'
|
|
170
|
+
* rettiwt.list.removeMember('987654321', '123456789')
|
|
171
|
+
* .then(res => {
|
|
172
|
+
* console.log(res);
|
|
173
|
+
* })
|
|
174
|
+
* .catch(err => {
|
|
175
|
+
* console.log(err);
|
|
176
|
+
* });
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
public async removeMember(listId: string, userId: string): Promise<number | undefined> {
|
|
180
|
+
const resource: ResourceType = ResourceType.LIST_MEMBER_REMOVE;
|
|
181
|
+
|
|
182
|
+
// Removing the member
|
|
183
|
+
const response = await this.request<IListMemberRemoveResponse>(resource, {
|
|
184
|
+
id: listId,
|
|
185
|
+
userId: userId,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// Deserializing response
|
|
189
|
+
const data = Extractors[resource](response);
|
|
190
|
+
|
|
191
|
+
return data;
|
|
192
|
+
}
|
|
193
|
+
|
|
67
194
|
/**
|
|
68
195
|
* Get the list of tweets from a tweet list.
|
|
69
196
|
*
|
|
@@ -12,6 +12,7 @@ import { ITweetFilter } from '../../types/args/FetchArgs';
|
|
|
12
12
|
import { INewTweet } from '../../types/args/PostArgs';
|
|
13
13
|
import { IMediaInitializeUploadResponse } from '../../types/raw/media/InitalizeUpload';
|
|
14
14
|
|
|
15
|
+
import { ITweetBookmarkResponse } from '../../types/raw/tweet/Bookmark';
|
|
15
16
|
import { ITweetDetailsResponse } from '../../types/raw/tweet/Details';
|
|
16
17
|
import { ITweetDetailsBulkResponse } from '../../types/raw/tweet/DetailsBulk';
|
|
17
18
|
import { ITweetLikeResponse } from '../../types/raw/tweet/Like';
|
|
@@ -22,6 +23,7 @@ import { ITweetRetweetResponse } from '../../types/raw/tweet/Retweet';
|
|
|
22
23
|
import { ITweetRetweetersResponse } from '../../types/raw/tweet/Retweeters';
|
|
23
24
|
import { ITweetScheduleResponse } from '../../types/raw/tweet/Schedule';
|
|
24
25
|
import { ITweetSearchResponse } from '../../types/raw/tweet/Search';
|
|
26
|
+
import { ITweetUnbookmarkResponse } from '../../types/raw/tweet/Unbookmark';
|
|
25
27
|
import { ITweetUnlikeResponse } from '../../types/raw/tweet/Unlike';
|
|
26
28
|
import { ITweetUnpostResponse } from '../../types/raw/tweet/Unpost';
|
|
27
29
|
import { ITweetUnretweetResponse } from '../../types/raw/tweet/Unretweet';
|
|
@@ -44,6 +46,45 @@ export class TweetService extends FetcherService {
|
|
|
44
46
|
super(config);
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Bookmark a tweet.
|
|
51
|
+
*
|
|
52
|
+
* @param id - The ID of the tweet to be bookmarked.
|
|
53
|
+
*
|
|
54
|
+
* @returns Whether bookmarking was successful or not.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
60
|
+
*
|
|
61
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
62
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
63
|
+
*
|
|
64
|
+
* // Bookmarking the Tweet with id '1234567890'
|
|
65
|
+
* rettiwt.tweet.bookmark('1234567890')
|
|
66
|
+
* .then(res => {
|
|
67
|
+
* console.log(res);
|
|
68
|
+
* })
|
|
69
|
+
* .catch(err => {
|
|
70
|
+
* console.log(err);
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
public async bookmark(id: string): Promise<boolean> {
|
|
75
|
+
const resource = ResourceType.TWEET_BOOKMARK;
|
|
76
|
+
|
|
77
|
+
// Favoriting the tweet
|
|
78
|
+
const response = await this.request<ITweetBookmarkResponse>(resource, {
|
|
79
|
+
id: id,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Deserializing response
|
|
83
|
+
const data = Extractors[resource](response) ?? false;
|
|
84
|
+
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
|
|
47
88
|
/**
|
|
48
89
|
* Get the details of one or more tweets.
|
|
49
90
|
*
|
|
@@ -315,6 +356,10 @@ export class TweetService extends FetcherService {
|
|
|
315
356
|
/**
|
|
316
357
|
* Get the list of replies to a tweet.
|
|
317
358
|
*
|
|
359
|
+
* If the target tweet is a thread,
|
|
360
|
+
* the first batch always contains all the tweets in the thread,
|
|
361
|
+
* if `sortBy` is set to {@link TweetRepliesSortType.RELEVANCE}.
|
|
362
|
+
*
|
|
318
363
|
* @param id - The ID of the target tweet.
|
|
319
364
|
* @param cursor - The cursor to the batch of replies to fetch.
|
|
320
365
|
* @param sortBy - The sorting order of the replies to fetch. Default is {@link TweetRepliesSortType.RECENT}.
|
|
@@ -605,6 +650,43 @@ export class TweetService extends FetcherService {
|
|
|
605
650
|
}
|
|
606
651
|
}
|
|
607
652
|
|
|
653
|
+
/**
|
|
654
|
+
* Unbookmark a tweet.
|
|
655
|
+
*
|
|
656
|
+
* @param id - The ID of the target tweet.
|
|
657
|
+
*
|
|
658
|
+
* @returns Whether unbookmarking was successful or not.
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
*
|
|
662
|
+
* ```ts
|
|
663
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
664
|
+
*
|
|
665
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
666
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
667
|
+
*
|
|
668
|
+
* // Unbookmarking the tweet with id '1234567890'
|
|
669
|
+
* rettiwt.tweet.unbookmark('1234567890')
|
|
670
|
+
* .then(res => {
|
|
671
|
+
* console.log(res);
|
|
672
|
+
* })
|
|
673
|
+
* .catch(err => {
|
|
674
|
+
* console.log(err);
|
|
675
|
+
* });
|
|
676
|
+
* ```
|
|
677
|
+
*/
|
|
678
|
+
public async unbookmark(id: string): Promise<boolean> {
|
|
679
|
+
const resource = ResourceType.TWEET_UNBOOKMARK;
|
|
680
|
+
|
|
681
|
+
// Unliking the tweet
|
|
682
|
+
const response = await this.request<ITweetUnbookmarkResponse>(resource, { id: id });
|
|
683
|
+
|
|
684
|
+
// Deserializing the response
|
|
685
|
+
const data = Extractors[resource](response) ?? false;
|
|
686
|
+
|
|
687
|
+
return data;
|
|
688
|
+
}
|
|
689
|
+
|
|
608
690
|
/**
|
|
609
691
|
* Unlike a tweet.
|
|
610
692
|
*
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Extractors } from '../../collections/Extractors';
|
|
2
|
+
import { RawAnalyticsGranularity, RawAnalyticsMetric } from '../../enums/raw/Analytics';
|
|
2
3
|
import { ResourceType } from '../../enums/Resource';
|
|
4
|
+
import { Analytics } from '../../models/data/Analytics';
|
|
3
5
|
import { CursoredData } from '../../models/data/CursoredData';
|
|
6
|
+
import { List } from '../../models/data/List';
|
|
4
7
|
import { Notification } from '../../models/data/Notification';
|
|
5
8
|
import { Tweet } from '../../models/data/Tweet';
|
|
6
9
|
import { User } from '../../models/data/User';
|
|
7
10
|
import { RettiwtConfig } from '../../models/RettiwtConfig';
|
|
8
11
|
import { IUserAffiliatesResponse } from '../../types/raw/user/Affiliates';
|
|
12
|
+
import { IUserAnalyticsResponse } from '../../types/raw/user/Analytics';
|
|
9
13
|
import { IUserBookmarksResponse } from '../../types/raw/user/Bookmarks';
|
|
10
14
|
import { IUserDetailsResponse } from '../../types/raw/user/Details';
|
|
11
15
|
import { IUserDetailsBulkResponse } from '../../types/raw/user/DetailsBulk';
|
|
@@ -15,6 +19,7 @@ import { IUserFollowersResponse } from '../../types/raw/user/Followers';
|
|
|
15
19
|
import { IUserFollowingResponse } from '../../types/raw/user/Following';
|
|
16
20
|
import { IUserHighlightsResponse } from '../../types/raw/user/Highlights';
|
|
17
21
|
import { IUserLikesResponse } from '../../types/raw/user/Likes';
|
|
22
|
+
import { IUserListsResponse } from '../../types/raw/user/Lists';
|
|
18
23
|
import { IUserMediaResponse } from '../../types/raw/user/Media';
|
|
19
24
|
import { IUserNotificationsResponse } from '../../types/raw/user/Notifications';
|
|
20
25
|
import { IUserRecommendedResponse } from '../../types/raw/user/Recommended';
|
|
@@ -83,6 +88,64 @@ export class UserService extends FetcherService {
|
|
|
83
88
|
return data;
|
|
84
89
|
}
|
|
85
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Get the analytics overview of the logged in user.
|
|
93
|
+
*
|
|
94
|
+
* @param fromTime - The start time of the analytics period. Defaults to 7 days ago.
|
|
95
|
+
* @param toTime - The end time of the analytics period. Defaults to now.
|
|
96
|
+
* @param granularity - The granularity of the analytics data. Defaults to daily.
|
|
97
|
+
* @param metrics - The metrics to include in the analytics data. Defaults to all available metrics available.
|
|
98
|
+
* @param showVerifiedFollowers - Whether to include verified follower count and relationship counts in the response. Defaults to true.
|
|
99
|
+
*
|
|
100
|
+
* @returns The raw analytics data of the user.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
*
|
|
104
|
+
* ```ts
|
|
105
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
106
|
+
*
|
|
107
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
108
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
109
|
+
*
|
|
110
|
+
* // Fetching the analytics overview of the logged in user
|
|
111
|
+
* rettiwt.user.analytics().then(res => {
|
|
112
|
+
* console.log(res);
|
|
113
|
+
* })
|
|
114
|
+
* .catch(err => {
|
|
115
|
+
* console.log(err);
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
public async analytics(
|
|
120
|
+
fromTime?: Date,
|
|
121
|
+
toTime?: Date,
|
|
122
|
+
granularity?: RawAnalyticsGranularity,
|
|
123
|
+
metrics?: RawAnalyticsMetric[],
|
|
124
|
+
showVerifiedFollowers?: boolean,
|
|
125
|
+
): Promise<Analytics> {
|
|
126
|
+
const resource = ResourceType.USER_ANALYTICS;
|
|
127
|
+
|
|
128
|
+
// Define default values if not provided
|
|
129
|
+
fromTime = fromTime ?? new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
|
|
130
|
+
toTime = toTime ?? new Date();
|
|
131
|
+
granularity = granularity ?? RawAnalyticsGranularity.DAILY;
|
|
132
|
+
metrics = metrics ?? Object.values(RawAnalyticsMetric);
|
|
133
|
+
showVerifiedFollowers = showVerifiedFollowers ?? true;
|
|
134
|
+
|
|
135
|
+
// Fetching raw analytics
|
|
136
|
+
const response = await this.request<IUserAnalyticsResponse>(resource, {
|
|
137
|
+
fromTime,
|
|
138
|
+
toTime,
|
|
139
|
+
granularity,
|
|
140
|
+
metrics,
|
|
141
|
+
showVerifiedFollowers,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const data = Extractors[resource](response);
|
|
145
|
+
|
|
146
|
+
return data;
|
|
147
|
+
}
|
|
148
|
+
|
|
86
149
|
/**
|
|
87
150
|
* Get the list of bookmarks of the logged in user.
|
|
88
151
|
*
|
|
@@ -165,8 +228,8 @@ export class UserService extends FetcherService {
|
|
|
165
228
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
166
229
|
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
167
230
|
*
|
|
168
|
-
* // Fetching the details of the User with username 'user1'
|
|
169
|
-
* rettiwt.user.details('user1')
|
|
231
|
+
* // Fetching the details of the User with username 'user1' or '@user1'
|
|
232
|
+
* rettiwt.user.details('user1') // or @user1
|
|
170
233
|
* .then(res => {
|
|
171
234
|
* console.log(res);
|
|
172
235
|
* })
|
|
@@ -243,6 +306,9 @@ export class UserService extends FetcherService {
|
|
|
243
306
|
// If username is given
|
|
244
307
|
if (id && isNaN(Number(id))) {
|
|
245
308
|
resource = ResourceType.USER_DETAILS_BY_USERNAME;
|
|
309
|
+
if (id?.startsWith('@')) {
|
|
310
|
+
id = id.slice(1);
|
|
311
|
+
}
|
|
246
312
|
}
|
|
247
313
|
// If id is given (or not, for self details)
|
|
248
314
|
else {
|
|
@@ -515,6 +581,48 @@ export class UserService extends FetcherService {
|
|
|
515
581
|
return data;
|
|
516
582
|
}
|
|
517
583
|
|
|
584
|
+
/**
|
|
585
|
+
* Get the list of of the the logged in user. Includes both followed and owned.
|
|
586
|
+
*
|
|
587
|
+
* @param count - The number of lists to fetch, must be \<= 100.
|
|
588
|
+
* @param cursor - The cursor to the batch of likes to fetch.
|
|
589
|
+
*
|
|
590
|
+
* @returns The list of tweets liked by the target user.
|
|
591
|
+
*
|
|
592
|
+
* @example
|
|
593
|
+
*
|
|
594
|
+
* ```ts
|
|
595
|
+
* import { Rettiwt } from 'rettiwt-api';
|
|
596
|
+
*
|
|
597
|
+
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
598
|
+
* const rettiwt = new Rettiwt({ apiKey: API_KEY });
|
|
599
|
+
*
|
|
600
|
+
* // Fetching the first 100 Lists of the logged in User
|
|
601
|
+
* rettiwt.user.lists()
|
|
602
|
+
* .then(res => {
|
|
603
|
+
* console.log(res);
|
|
604
|
+
* })
|
|
605
|
+
* .catch(err => {
|
|
606
|
+
* console.log(err);
|
|
607
|
+
* });
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
public async lists(count?: number, cursor?: string): Promise<CursoredData<List>> {
|
|
611
|
+
const resource = ResourceType.USER_LISTS;
|
|
612
|
+
|
|
613
|
+
// Fetching raw list of lists
|
|
614
|
+
const response = await this.request<IUserListsResponse>(resource, {
|
|
615
|
+
id: this.config.userId,
|
|
616
|
+
count: count,
|
|
617
|
+
cursor: cursor,
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
// Deserializing response
|
|
621
|
+
const data = Extractors[resource](response);
|
|
622
|
+
|
|
623
|
+
return data;
|
|
624
|
+
}
|
|
625
|
+
|
|
518
626
|
/**
|
|
519
627
|
* Get the media timeline of a user.
|
|
520
628
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RawAnalyticsGranularity, RawAnalyticsMetric } from '../../enums/raw/Analytics';
|
|
1
2
|
import { TweetRepliesSortType } from '../../enums/Tweet';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -6,21 +7,45 @@ import { TweetRepliesSortType } from '../../enums/Tweet';
|
|
|
6
7
|
* @public
|
|
7
8
|
*/
|
|
8
9
|
export interface IFetchArgs {
|
|
10
|
+
/**
|
|
11
|
+
* The id of the active conversation.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* - Required only for {@link ResourceType.DM_USER_UPDATES}.
|
|
15
|
+
*/
|
|
16
|
+
activeConversationId?: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The maximum id of the data to fetch.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* - May be used for {@link ResourceType.DM_INBOX_TIMELINE} and {@link ResourceType.DM_CONVERSATION}.
|
|
23
|
+
*/
|
|
24
|
+
maxId?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The id of the conversation to fetch.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* - Required only for {@link ResourceType.DM_CONVERSATION} and {@link ResourceType.DM_DELETE_CONVERSATION}.
|
|
31
|
+
*/
|
|
32
|
+
conversationId?: string;
|
|
33
|
+
|
|
9
34
|
/**
|
|
10
35
|
* The number of data items to fetch.
|
|
11
36
|
*
|
|
12
37
|
* @remarks
|
|
13
38
|
* - Works only for cursored resources.
|
|
14
|
-
* - Does not work for {@link
|
|
39
|
+
* - Does not work for {@link ResourceType.TWEET_REPLIES}.
|
|
15
40
|
* - Must be \<= 20 for:
|
|
16
|
-
* - {@link
|
|
17
|
-
* - {@link
|
|
18
|
-
* - {@link
|
|
41
|
+
* - {@link ResourceType.USER_TIMELINE}
|
|
42
|
+
* - {@link ResourceType.USER_TIMELINE}
|
|
43
|
+
* - {@link ResourceType.USER_TIMELINE_AND_REPLIES}
|
|
19
44
|
* - Must be \<= 100 for all other cursored resources.
|
|
20
|
-
* - Due a bug on Twitter's end, count does not work for {@link
|
|
45
|
+
* - Due a bug on Twitter's end, count does not work for {@link ResourceType.USER_FOLLOWERS} and {@link ResourceType.USER_FOLLOWING}.
|
|
21
46
|
* - Has not effect for:
|
|
22
|
-
* - {@link
|
|
23
|
-
* - {@link
|
|
47
|
+
* - {@link ResourceType.USER_FEED_FOLLOWED}
|
|
48
|
+
* - {@link ResourceType.USER_FEED_RECOMMENDED}
|
|
24
49
|
*/
|
|
25
50
|
count?: number;
|
|
26
51
|
|
|
@@ -37,7 +62,7 @@ export interface IFetchArgs {
|
|
|
37
62
|
* The filter for searching tweets.
|
|
38
63
|
*
|
|
39
64
|
* @remarks
|
|
40
|
-
* Required when searching for tweets using {@link
|
|
65
|
+
* Required when searching for tweets using {@link ResourceType.TWEET_SEARCH}.
|
|
41
66
|
*/
|
|
42
67
|
filter?: ITweetFilter;
|
|
43
68
|
|
|
@@ -45,8 +70,8 @@ export interface IFetchArgs {
|
|
|
45
70
|
* The id of the target resource.
|
|
46
71
|
*
|
|
47
72
|
* @remarks
|
|
48
|
-
* - Required for all resources except {@link
|
|
49
|
-
* - For {@link
|
|
73
|
+
* - Required for all resources except {@link ResourceType.TWEET_SEARCH} and {@link ResourceType.USER_TIMELINE_RECOMMENDED}.
|
|
74
|
+
* - For {@link ResourceType.USER_DETAILS_BY_USERNAME}, can be alphanumeric, while for others, is strictly numeric.
|
|
50
75
|
*/
|
|
51
76
|
id?: string;
|
|
52
77
|
|
|
@@ -54,7 +79,7 @@ export interface IFetchArgs {
|
|
|
54
79
|
* The IDs of the target resources.
|
|
55
80
|
*
|
|
56
81
|
* @remarks
|
|
57
|
-
* - Required only for {@link
|
|
82
|
+
* - Required only for {@link ResourceType.TWEET_DETAILS_BULK} and {@link ResourceType.USER_DETAILS_BY_IDS_BULK}.
|
|
58
83
|
*/
|
|
59
84
|
ids?: string[];
|
|
60
85
|
|
|
@@ -62,9 +87,49 @@ export interface IFetchArgs {
|
|
|
62
87
|
* The sorting to use for tweet results.
|
|
63
88
|
*
|
|
64
89
|
* @remarks
|
|
65
|
-
* - Only works for {@link
|
|
90
|
+
* - Only works for {@link ResourceType.TWEET_REPLIES}.
|
|
66
91
|
*/
|
|
67
92
|
sortBy?: TweetRepliesSortType;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The date to start fetching data from.
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* - Only works for {@link EResourceType.USER_ANALYTICS}.
|
|
99
|
+
*/
|
|
100
|
+
fromTime?: Date;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The date to end fetching data at.
|
|
104
|
+
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* - Only works for {@link EResourceType.USER_ANALYTICS}.
|
|
107
|
+
*/
|
|
108
|
+
toTime?: Date;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The granularity of the data to fetch.
|
|
112
|
+
*
|
|
113
|
+
* @remarks
|
|
114
|
+
* - Only works for {@link EResourceType.USER_ANALYTICS}.
|
|
115
|
+
*/
|
|
116
|
+
granularity?: RawAnalyticsGranularity;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The metrics to fetch.
|
|
120
|
+
*
|
|
121
|
+
* @remarks
|
|
122
|
+
* - Only works for {@link EResourceType.USER_ANALYTICS}.
|
|
123
|
+
*/
|
|
124
|
+
metrics?: RawAnalyticsMetric[];
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Show the verified follower count and relationship counts in the response.
|
|
128
|
+
*
|
|
129
|
+
* @remarks
|
|
130
|
+
* - Only works for {@link EResourceType.USER_ANALYTICS}.
|
|
131
|
+
*/
|
|
132
|
+
showVerifiedFollowers?: boolean;
|
|
68
133
|
}
|
|
69
134
|
|
|
70
135
|
/**
|
|
@@ -9,13 +9,15 @@ export interface IPostArgs {
|
|
|
9
9
|
*
|
|
10
10
|
* @remarks
|
|
11
11
|
* Required only when posting using the following resources:
|
|
12
|
-
* - {@link
|
|
13
|
-
* - {@link
|
|
14
|
-
* - {@link
|
|
15
|
-
* - {@link
|
|
16
|
-
* - {@link
|
|
17
|
-
* - {@link
|
|
18
|
-
* - {@link
|
|
12
|
+
* - {@link ResourceType.TWEET_BOOKMARK}
|
|
13
|
+
* - {@link ResourceType.TWEET_LIKE}
|
|
14
|
+
* - {@link ResourceType.TWEET_RETWEET}
|
|
15
|
+
* - {@link ResourceType.TWEET_UNBOOKMARK}
|
|
16
|
+
* - {@link ResourceType.TWEET_UNLIKE}
|
|
17
|
+
* - {@link ResourceType.TWEET_UNPOST}
|
|
18
|
+
* - {@link ResourceType.TWEET_UNRETWEET}
|
|
19
|
+
* - {@link ResourceType.USER_FOLLOW}
|
|
20
|
+
* - {@link ResourceType.USER_UNFOLLOW}
|
|
19
21
|
*/
|
|
20
22
|
id?: string;
|
|
21
23
|
|
|
@@ -23,7 +25,7 @@ export interface IPostArgs {
|
|
|
23
25
|
* The tweet that is to be posted.
|
|
24
26
|
*
|
|
25
27
|
* @remarks
|
|
26
|
-
* Required only when posting a tweet using {@link
|
|
28
|
+
* Required only when posting a tweet using {@link ResourceType.TWEET_POST}
|
|
27
29
|
*/
|
|
28
30
|
tweet?: INewTweet;
|
|
29
31
|
|
|
@@ -32,11 +34,29 @@ export interface IPostArgs {
|
|
|
32
34
|
*
|
|
33
35
|
* @remarks
|
|
34
36
|
* Required only when uploading a media using the following resources:
|
|
35
|
-
* - {@link
|
|
36
|
-
* - {@link
|
|
37
|
-
* - {@link
|
|
37
|
+
* - {@link ResourceType.MEDIA_UPLOAD_APPEND}
|
|
38
|
+
* - {@link ResourceType.MEDIA_UPLOAD_FINALIZE}
|
|
39
|
+
* - {@link ResourceType.MEDIA_UPLOAD_INITIALIZE}
|
|
38
40
|
*/
|
|
39
41
|
upload?: IUploadArgs;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The id of the target user.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* Required only for the following resources:
|
|
48
|
+
* - {@link ResourceType.LIST_MEMBER_ADD}
|
|
49
|
+
* - {@link ResourceType.LIST_MEMBER_REMOVE}
|
|
50
|
+
*/
|
|
51
|
+
userId?: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The id of the conversation to delete.
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* Required only when deleting a conversation using {@link ResourceType.DM_DELETE_CONVERSATION}
|
|
58
|
+
*/
|
|
59
|
+
conversationId?: string;
|
|
40
60
|
}
|
|
41
61
|
|
|
42
62
|
/**
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { IAnalyticsMetric } from '../../types/raw/base/Analytic';
|
|
2
|
+
/**
|
|
3
|
+
* The details of the analytic result of the connected User.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface IAnalytics {
|
|
8
|
+
/** The creation date of user's account. */
|
|
9
|
+
createdAt: string;
|
|
10
|
+
|
|
11
|
+
/** Total followers number */
|
|
12
|
+
followers: number;
|
|
13
|
+
|
|
14
|
+
/** Total verified followers */
|
|
15
|
+
verifiedFollowers: number;
|
|
16
|
+
|
|
17
|
+
/** Total impressions on the given period */
|
|
18
|
+
impressions: number;
|
|
19
|
+
|
|
20
|
+
/** Total profile visits on the given period */
|
|
21
|
+
profileVisits: number;
|
|
22
|
+
|
|
23
|
+
/** Total Engagements on the given period */
|
|
24
|
+
engagements: number;
|
|
25
|
+
|
|
26
|
+
/** Total Follows on the given period */
|
|
27
|
+
follows: number;
|
|
28
|
+
|
|
29
|
+
/** Total Replies on the given period */
|
|
30
|
+
replies: number;
|
|
31
|
+
|
|
32
|
+
/** Total Likes on the given period */
|
|
33
|
+
likes: number;
|
|
34
|
+
|
|
35
|
+
/** Total Retweets on the given period */
|
|
36
|
+
retweets: number;
|
|
37
|
+
|
|
38
|
+
/** Total Bookmark on the given period */
|
|
39
|
+
bookmarks: number;
|
|
40
|
+
|
|
41
|
+
/** Total Shares on the given period */
|
|
42
|
+
shares: number;
|
|
43
|
+
|
|
44
|
+
/** Total CreateTweets on the given period */
|
|
45
|
+
createTweets: number;
|
|
46
|
+
|
|
47
|
+
/** Total CreateQuote on the given period */
|
|
48
|
+
createQuote: number;
|
|
49
|
+
|
|
50
|
+
/** Total Unfollows on the given period */
|
|
51
|
+
unfollows: number;
|
|
52
|
+
|
|
53
|
+
/** Total CreateReply on the given period */
|
|
54
|
+
createReply: number;
|
|
55
|
+
|
|
56
|
+
/** Organic metrics times series */
|
|
57
|
+
organicMetricsTimeSeries: IAnalyticsMetric[];
|
|
58
|
+
}
|