rettiwt-api 2.7.0 → 3.0.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.
Files changed (139) hide show
  1. package/.eslintrc.js +73 -5
  2. package/.tool-versions +1 -0
  3. package/README.md +87 -20
  4. package/dist/Rettiwt.js +0 -1
  5. package/dist/Rettiwt.js.map +1 -1
  6. package/dist/cli.js +2 -4
  7. package/dist/cli.js.map +1 -1
  8. package/dist/collections/Extractors.d.ts +10 -0
  9. package/dist/collections/Extractors.js +43 -0
  10. package/dist/collections/Extractors.js.map +1 -0
  11. package/dist/collections/Groups.d.ts +19 -0
  12. package/dist/collections/Groups.js +55 -0
  13. package/dist/collections/Groups.js.map +1 -0
  14. package/dist/collections/Requests.d.ts +12 -0
  15. package/dist/collections/Requests.js +46 -0
  16. package/dist/collections/Requests.js.map +1 -0
  17. package/dist/commands/Auth.d.ts +6 -0
  18. package/dist/commands/Auth.js +26 -8
  19. package/dist/commands/Auth.js.map +1 -1
  20. package/dist/commands/Tweet.js +237 -82
  21. package/dist/commands/Tweet.js.map +1 -1
  22. package/dist/commands/User.js +197 -36
  23. package/dist/commands/User.js.map +1 -1
  24. package/dist/enums/Api.d.ts +30 -0
  25. package/dist/enums/Api.js +32 -1
  26. package/dist/enums/Api.js.map +1 -1
  27. package/dist/enums/Data.d.ts +9 -0
  28. package/dist/enums/Data.js +14 -0
  29. package/dist/enums/Data.js.map +1 -0
  30. package/dist/enums/Http.d.ts +1 -1
  31. package/dist/enums/Http.js +1 -1
  32. package/dist/enums/Logging.d.ts +6 -5
  33. package/dist/enums/Logging.js +6 -5
  34. package/dist/enums/Logging.js.map +1 -1
  35. package/dist/enums/Resource.d.ts +33 -0
  36. package/dist/enums/Resource.js +42 -0
  37. package/dist/enums/Resource.js.map +1 -0
  38. package/dist/helper/CliUtils.d.ts +1 -1
  39. package/dist/helper/CliUtils.js.map +1 -1
  40. package/dist/index.d.ts +11 -9
  41. package/dist/index.js +11 -14
  42. package/dist/index.js.map +1 -1
  43. package/dist/models/args/FetchArgs.d.ts +129 -0
  44. package/dist/models/args/FetchArgs.js +263 -0
  45. package/dist/models/args/FetchArgs.js.map +1 -0
  46. package/dist/models/args/PostArgs.d.ts +116 -0
  47. package/dist/models/args/PostArgs.js +232 -0
  48. package/dist/models/args/PostArgs.js.map +1 -0
  49. package/dist/models/data/CursoredData.d.ts +11 -11
  50. package/dist/models/data/CursoredData.js +21 -16
  51. package/dist/models/data/CursoredData.js.map +1 -1
  52. package/dist/models/data/List.d.ts +8 -10
  53. package/dist/models/data/List.js +2 -4
  54. package/dist/models/data/List.js.map +1 -1
  55. package/dist/models/data/Tweet.d.ts +41 -29
  56. package/dist/models/data/Tweet.js +71 -15
  57. package/dist/models/data/Tweet.js.map +1 -1
  58. package/dist/models/data/User.d.ts +36 -20
  59. package/dist/models/data/User.js +69 -7
  60. package/dist/models/data/User.js.map +1 -1
  61. package/dist/models/errors/ApiError.d.ts +1 -3
  62. package/dist/models/errors/ApiError.js +1 -4
  63. package/dist/models/errors/ApiError.js.map +1 -1
  64. package/dist/models/errors/DataValidationError.d.ts +30 -0
  65. package/dist/models/errors/DataValidationError.js +34 -0
  66. package/dist/models/errors/DataValidationError.js.map +1 -0
  67. package/dist/models/errors/HttpError.d.ts +1 -3
  68. package/dist/models/errors/HttpError.js +1 -4
  69. package/dist/models/errors/HttpError.js.map +1 -1
  70. package/dist/models/errors/TimeoutError.d.ts +2 -4
  71. package/dist/models/errors/TimeoutError.js +2 -5
  72. package/dist/models/errors/TimeoutError.js.map +1 -1
  73. package/dist/services/internal/ErrorService.d.ts +45 -35
  74. package/dist/services/internal/ErrorService.js +70 -68
  75. package/dist/services/internal/ErrorService.js.map +1 -1
  76. package/dist/services/internal/LogService.d.ts +7 -5
  77. package/dist/services/internal/LogService.js +28 -9
  78. package/dist/services/internal/LogService.js.map +1 -1
  79. package/dist/services/public/AuthService.d.ts +24 -20
  80. package/dist/services/public/AuthService.js +38 -36
  81. package/dist/services/public/AuthService.js.map +1 -1
  82. package/dist/services/public/FetcherService.d.ts +99 -0
  83. package/dist/services/public/FetcherService.js +254 -0
  84. package/dist/services/public/FetcherService.js.map +1 -0
  85. package/dist/services/public/TweetService.d.ts +213 -94
  86. package/dist/services/public/TweetService.js +405 -208
  87. package/dist/services/public/TweetService.js.map +1 -1
  88. package/dist/services/public/UserService.d.ts +185 -52
  89. package/dist/services/public/UserService.js +333 -103
  90. package/dist/services/public/UserService.js.map +1 -1
  91. package/dist/types/ReturnTypes.d.ts +21 -0
  92. package/dist/types/ReturnTypes.js +3 -0
  93. package/dist/types/ReturnTypes.js.map +1 -0
  94. package/package.json +4 -2
  95. package/src/Rettiwt.ts +0 -3
  96. package/src/cli.ts +2 -4
  97. package/src/collections/Extractors.ts +63 -0
  98. package/src/collections/Groups.ts +54 -0
  99. package/src/collections/Requests.ts +52 -0
  100. package/src/commands/Auth.ts +19 -7
  101. package/src/commands/Tweet.ts +179 -91
  102. package/src/commands/User.ts +118 -25
  103. package/src/enums/Api.ts +31 -0
  104. package/src/enums/Data.ts +9 -0
  105. package/src/enums/Http.ts +1 -1
  106. package/src/enums/Logging.ts +6 -5
  107. package/src/enums/Resource.ts +40 -0
  108. package/src/helper/CliUtils.ts +1 -1
  109. package/src/index.ts +41 -14
  110. package/src/models/args/FetchArgs.ts +296 -0
  111. package/src/models/args/PostArgs.ts +263 -0
  112. package/src/models/data/CursoredData.ts +23 -15
  113. package/src/models/data/List.ts +12 -15
  114. package/src/models/data/Tweet.ts +105 -39
  115. package/src/models/data/User.ts +97 -30
  116. package/src/models/errors/ApiError.ts +1 -4
  117. package/src/models/errors/DataValidationError.ts +44 -0
  118. package/src/models/errors/HttpError.ts +1 -4
  119. package/src/models/errors/TimeoutError.ts +2 -5
  120. package/src/services/internal/ErrorService.ts +76 -75
  121. package/src/services/internal/LogService.ts +20 -10
  122. package/src/services/public/AuthService.ts +39 -38
  123. package/src/services/public/FetcherService.ts +230 -0
  124. package/src/services/public/TweetService.ts +381 -179
  125. package/src/services/public/UserService.ts +314 -86
  126. package/src/types/RettiwtConfig.ts +0 -1
  127. package/src/types/ReturnTypes.ts +24 -0
  128. package/dist/models/args/TweetArgs.d.ts +0 -44
  129. package/dist/models/args/TweetArgs.js +0 -82
  130. package/dist/models/args/TweetArgs.js.map +0 -1
  131. package/dist/models/data/Media.d.ts +0 -14
  132. package/dist/models/data/Media.js +0 -19
  133. package/dist/models/data/Media.js.map +0 -1
  134. package/dist/services/internal/FetcherService.d.ts +0 -106
  135. package/dist/services/internal/FetcherService.js +0 -365
  136. package/dist/services/internal/FetcherService.js.map +0 -1
  137. package/src/models/args/TweetArgs.ts +0 -98
  138. package/src/models/data/Media.ts +0 -19
  139. package/src/services/internal/FetcherService.ts +0 -365
@@ -1,12 +1,12 @@
1
1
  import { TweetFilter } from 'rettiwt-core';
2
- import { FetcherService } from '../internal/FetcherService';
3
- import { IRettiwtConfig } from '../../types/RettiwtConfig';
2
+ import { TweetArgs } from '../../models/args/PostArgs';
3
+ import { CursoredData } from '../../models/data/CursoredData';
4
4
  import { Tweet } from '../../models/data/Tweet';
5
5
  import { User } from '../../models/data/User';
6
- import { CursoredData } from '../../models/data/CursoredData';
7
- import { TweetMediaArgs } from '../../models/args/TweetArgs';
6
+ import { IRettiwtConfig } from '../../types/RettiwtConfig';
7
+ import { FetcherService } from './FetcherService';
8
8
  /**
9
- * Handles fetching of data related to tweets.
9
+ * Handles interacting with resources related to tweets.
10
10
  *
11
11
  * @public
12
12
  */
@@ -21,7 +21,10 @@ export declare class TweetService extends FetcherService {
21
21
  * Get the details of a tweet.
22
22
  *
23
23
  * @param id - The id of the target tweet.
24
- * @returns The details of a single tweet with the given tweet id.
24
+ *
25
+ * @returns
26
+ * The details of the tweet with the given id.
27
+ * If no tweet matches the given id, returns `undefined`.
25
28
  *
26
29
  * @example
27
30
  * ```
@@ -30,8 +33,8 @@ export declare class TweetService extends FetcherService {
30
33
  * // Creating a new Rettiwt instance using the given 'API_KEY'
31
34
  * const rettiwt = new Rettiwt({ apiKey: API_KEY });
32
35
  *
33
- * // Fetching the details of the tweet with the id '12345678'
34
- * rettiwt.tweet.details('12345678')
36
+ * // Fetching the details of the tweet with the id '1234567890'
37
+ * rettiwt.tweet.details('1234567890')
35
38
  * .then(res => {
36
39
  * console.log(res);
37
40
  * })
@@ -39,17 +42,14 @@ export declare class TweetService extends FetcherService {
39
42
  * console.log(err);
40
43
  * });
41
44
  * ```
42
- *
43
- * @public
44
45
  */
45
- details(id: string): Promise<Tweet>;
46
+ details(id: string): Promise<Tweet | undefined>;
46
47
  /**
47
- * Search for tweets using a query.
48
+ * Like a tweet.
48
49
  *
49
- * @param query - The query be used for searching the tweets.
50
- * @param count - The number of tweets to fetch, must be \<= 20.
51
- * @param cursor - The cursor to the batch of tweets to fetch.
52
- * @returns The list of tweets that match the given filter.
50
+ * @param id - The id of the tweet to be liked.
51
+ *
52
+ * @returns Whether liking was successful or not.
53
53
  *
54
54
  * @example
55
55
  * ```
@@ -58,8 +58,8 @@ export declare class TweetService extends FetcherService {
58
58
  * // Creating a new Rettiwt instance using the given 'API_KEY'
59
59
  * const rettiwt = new Rettiwt({ apiKey: API_KEY });
60
60
  *
61
- * // Fetching the most recent 5 tweets from user 'user1'
62
- * rettiwt.tweet.search({ fromUsers: ['user1'] }, 5)
61
+ * // Liking the Tweet with id '1234567890'
62
+ * rettiwt.tweet.like('1234567890')
63
63
  * .then(res => {
64
64
  * console.log(res);
65
65
  * })
@@ -67,18 +67,16 @@ export declare class TweetService extends FetcherService {
67
67
  * console.log(err);
68
68
  * });
69
69
  * ```
70
- *
71
- * @remarks For details about available filters, refer to {@link TweetFilter}
72
- *
73
- * @public
74
70
  */
75
- search(query: TweetFilter, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
71
+ like(id: string): Promise<boolean>;
76
72
  /**
77
- * Stream tweets in pseudo real-time using a filter.
73
+ * Get the list of users who liked a tweet.
78
74
  *
79
- * @param filter - The filter to be used for searching the tweets.
80
- * @param pollingInterval - The interval in milliseconds to poll for new tweets. Default interval is 60000 ms.
81
- * @returns An async generator that yields matching tweets as they are found.
75
+ * @param id - The id of the target tweet.
76
+ * @param count - The number of likers to fetch, must be \<= 100.
77
+ * @param cursor - The cursor to the batch of likers to fetch.
78
+ *
79
+ * @returns The list of users who liked the given tweet.
82
80
  *
83
81
  * @example
84
82
  * ```
@@ -87,29 +85,25 @@ export declare class TweetService extends FetcherService {
87
85
  * // Creating a new Rettiwt instance using the given 'API_KEY'
88
86
  * const rettiwt = new Rettiwt({ apiKey: API_KEY });
89
87
  *
90
- * // Streaming all upcoming tweets from user 'user1'
91
- * (async () => {
92
- * try {
93
- * for await (const tweet of rettiwt.tweet.stream({ fromUsers: ['user1'] }, 1000)) {
94
- * console.log(tweet.fullText);
95
- * }
96
- * }
97
- * catch (err) {
98
- * console.log(err);
99
- * }
100
- * })();
88
+ * // Fetching the most recent 100 likers of the Tweet with id '1234567890'
89
+ * rettiwt.tweet.likers('1234567890')
90
+ * .then(res => {
91
+ * console.log(res);
92
+ * })
93
+ * .catch(err => {
94
+ * console.log(err);
95
+ * });
101
96
  * ```
102
- *
103
- * @public
104
97
  */
105
- stream(filter: TweetFilter, pollingInterval?: number): AsyncGenerator<Tweet>;
98
+ likers(id: string, count?: number, cursor?: string): Promise<CursoredData<User>>;
106
99
  /**
107
- * Get the tweets from the tweet list with the given id.
100
+ * Get the list of tweets from a tweet list.
108
101
  *
109
- * @param listId - The id of list from where the tweets are to be fetched.
102
+ * @param id - The id of target list.
110
103
  * @param count - The number of tweets to fetch, must be \<= 100.
111
104
  * @param cursor - The cursor to the batch of tweets to fetch.
112
- * @returns The list tweets present in the given list.
105
+ *
106
+ * @returns The list tweets in the given list.
113
107
  *
114
108
  * @example
115
109
  * ```
@@ -118,8 +112,8 @@ export declare class TweetService extends FetcherService {
118
112
  * // Creating a new Rettiwt instance using the given 'API_KEY'
119
113
  * const rettiwt = new Rettiwt({ apiKey: API_KEY });
120
114
  *
121
- * // Fetching the most recent 100 tweets of the Twitter list with id '12345678'
122
- * rettiwt.tweet.list('12345678')
115
+ * // Fetching the most recent 100 tweets of the Twitter list with id '1234567890'
116
+ * rettiwt.tweet.list('1234567890')
123
117
  * .then(res => {
124
118
  * console.log(res);
125
119
  * })
@@ -130,24 +124,78 @@ export declare class TweetService extends FetcherService {
130
124
  *
131
125
  * @remarks Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.
132
126
  */
133
- list(listId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
127
+ list(id: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
134
128
  /**
135
- * Get the list of users who liked a tweet.
129
+ * Post a tweet.
136
130
  *
137
- * @param tweetId - The rest id of the target tweet.
138
- * @param count - The number of favoriters to fetch, must be \<= 100.
139
- * @param cursor - The cursor to the batch of favoriters to fetch.
140
- * @returns The list of users who liked the given tweet.
131
+ * @param options - The options describing the tweet to be posted. Check {@link TweetArgs} for available options.
132
+ *
133
+ * @returns Whether posting was successful or not.
141
134
  *
142
135
  * @example
136
+ * Posting a simple text
137
+ * ```
138
+ * import { Rettiwt } from 'rettiwt-api';
139
+ *
140
+ * // Creating a new Rettiwt instance using the given 'API_KEY'
141
+ * const rettiwt = new Rettiwt({ apiKey: API_KEY });
142
+ *
143
+ * // Posting a tweet to twitter
144
+ * rettiwt.tweet.post({ text: 'Hello World!' })
145
+ * .then(res => {
146
+ * console.log(res);
147
+ * })
148
+ * .catch(err => {
149
+ * console.log(err);
150
+ * });
151
+ * ```
152
+ *
153
+ * @example
154
+ * Posting a tweet with an image that has been already uploaded
155
+ * ```
156
+ * import { Rettiwt } from 'rettiwt-api';
157
+ *
158
+ * // Creating a new Rettiwt instance using the given 'API_KEY'
159
+ * const rettiwt = new Rettiwt({ apiKey: API_KEY });
160
+ *
161
+ * // Posting a tweet, containing an image called 'mountains.jpg', to twitter
162
+ * rettiwt.tweet.post({ text: 'What a nice view!', media: [{ id: '1234567890' }] })
163
+ * .then(res => {
164
+ * console.log(res);
165
+ * })
166
+ * .catch(err => {
167
+ * console.log(err);
168
+ * });
169
+ * ```
170
+ *
171
+ * @example
172
+ * Posting a reply to a tweet
173
+ * ```
174
+ * import { Rettiwt } from 'rettiwt-api';
175
+ *
176
+ * // Creating a new Rettiwt instance using the given 'API_KEY'
177
+ * const rettiwt = new Rettiwt({ apiKey: API_KEY });
178
+ *
179
+ * // Posting a simple text reply, to a tweet with id "1234567890"
180
+ * rettiwt.tweet.post({ text: 'Hello!', replyTo: "1234567890" })
181
+ * .then(res => {
182
+ * console.log(res);
183
+ * })
184
+ * .catch(err => {
185
+ * console.log(err);
186
+ * });
187
+ * ```
188
+ *
189
+ * * @example
190
+ * Posting a tweet that quotes another tweet
143
191
  * ```
144
192
  * import { Rettiwt } from 'rettiwt-api';
145
193
  *
146
194
  * // Creating a new Rettiwt instance using the given 'API_KEY'
147
195
  * const rettiwt = new Rettiwt({ apiKey: API_KEY });
148
196
  *
149
- * // Fetching the most recent 100 likers of the Tweet with id '12345678'
150
- * rettiwt.tweet.favoriters('12345678')
197
+ * // Posting a simple text tweet, quoting a tweet with id "1234567890"
198
+ * rettiwt.tweet.post({ text: 'Hello!', quote: "1234567890" })
151
199
  * .then(res => {
152
200
  * console.log(res);
153
201
  * })
@@ -155,16 +203,40 @@ export declare class TweetService extends FetcherService {
155
203
  * console.log(err);
156
204
  * });
157
205
  * ```
206
+ */
207
+ post(options: TweetArgs): Promise<string | undefined>;
208
+ /**
209
+ * Retweet a tweet.
210
+ *
211
+ * @param id - The id of the target tweet.
158
212
  *
159
- * @public
213
+ * @returns Whether retweeting was successful or not.
214
+ *
215
+ * @example
216
+ * ```
217
+ * import { Rettiwt } from 'rettiwt-api';
218
+ *
219
+ * // Creating a new Rettiwt instance using the given 'API_KEY'
220
+ * const rettiwt = new Rettiwt({ apiKey: API_KEY });
221
+ *
222
+ * // Retweeting the Tweet with id '1234567890'
223
+ * rettiwt.tweet.retweet('1234567890')
224
+ * .then(res => {
225
+ * console.log(res);
226
+ * })
227
+ * .catch(err => {
228
+ * console.log(err);
229
+ * });
230
+ * ```
160
231
  */
161
- favoriters(tweetId: string, count?: number, cursor?: string): Promise<CursoredData<User>>;
232
+ retweet(id: string): Promise<boolean>;
162
233
  /**
163
234
  * Get the list of users who retweeted a tweet.
164
235
  *
165
- * @param tweetId - The rest id of the target tweet.
236
+ * @param id - The id of the target tweet.
166
237
  * @param count - The number of retweeters to fetch, must be \<= 100.
167
238
  * @param cursor - The cursor to the batch of retweeters to fetch.
239
+ *
168
240
  * @returns The list of users who retweeted the given tweet.
169
241
  *
170
242
  * @example
@@ -174,8 +246,8 @@ export declare class TweetService extends FetcherService {
174
246
  * // Creating a new Rettiwt instance using the given 'API_KEY'
175
247
  * const rettiwt = new Rettiwt({ apiKey: API_KEY });
176
248
  *
177
- * // Fetching the most recent 100 retweeters of the Tweet with id '12345678'
178
- * rettiwt.tweet.retweeters('12345678')
249
+ * // Fetching the most recent 100 retweeters of the Tweet with id '1234567890'
250
+ * rettiwt.tweet.retweeters('1234567890')
179
251
  * .then(res => {
180
252
  * console.log(res);
181
253
  * })
@@ -183,27 +255,26 @@ export declare class TweetService extends FetcherService {
183
255
  * console.log(err);
184
256
  * });
185
257
  * ```
186
- *
187
- * @public
188
258
  */
189
- retweeters(tweetId: string, count?: number, cursor?: string): Promise<CursoredData<User>>;
259
+ retweeters(id: string, count?: number, cursor?: string): Promise<CursoredData<User>>;
190
260
  /**
191
- * Post a tweet.
261
+ * Search for tweets using a filter.
192
262
  *
193
- * @param text - The text to be posted, length must be \<= 280 characters.
194
- * @param media - The list of media to post in the tweet, max number of media must be \<= 4.
195
- * @param replyTo - The id of the tweet to which the reply is to be made.
196
- * @returns Whether posting was successful or not.
263
+ * @param filter - The filter to be used for searching the tweets.
264
+ * @param count - The number of tweets to fetch, must be \<= 20.
265
+ * @param cursor - The cursor to the batch of tweets to fetch.
266
+ *
267
+ * @returns The list of tweets that match the given filter.
197
268
  *
198
- * @example Posting a simple text
269
+ * @example
199
270
  * ```
200
271
  * import { Rettiwt } from 'rettiwt-api';
201
272
  *
202
273
  * // Creating a new Rettiwt instance using the given 'API_KEY'
203
274
  * const rettiwt = new Rettiwt({ apiKey: API_KEY });
204
275
  *
205
- * // Posting a tweet to twitter
206
- * rettiwt.tweet.tweet('Hello World!')
276
+ * // Fetching the most recent 5 tweets from user 'user1'
277
+ * rettiwt.tweet.search({ fromUsers: ['user1'] }, 5)
207
278
  * .then(res => {
208
279
  * console.log(res);
209
280
  * })
@@ -212,15 +283,54 @@ export declare class TweetService extends FetcherService {
212
283
  * });
213
284
  * ```
214
285
  *
215
- * @example Posting a tweet with an image
286
+ * @remarks For details about available filters, refer to {@link TweetFilter}
287
+ */
288
+ search(filter: TweetFilter, count?: number, cursor?: string): Promise<CursoredData<Tweet>>;
289
+ /**
290
+ * Stream tweets in pseudo real-time using a filter.
291
+ *
292
+ * @param filter - The filter to be used for searching the tweets.
293
+ * @param pollingInterval - The interval in milliseconds to poll for new tweets. Default interval is 60000 ms.
294
+ *
295
+ * @returns An async generator that yields matching tweets as they are found.
296
+ *
297
+ * @example
298
+ * ```
299
+ * import { Rettiwt } from 'rettiwt-api';
300
+ *
301
+ * // Creating a new Rettiwt instance using the given 'API_KEY'
302
+ * const rettiwt = new Rettiwt({ apiKey: API_KEY });
303
+ *
304
+ * // Streaming all upcoming tweets from user 'user1'
305
+ * (async () => {
306
+ * try {
307
+ * for await (const tweet of rettiwt.tweet.stream({ fromUsers: ['user1'] }, 1000)) {
308
+ * console.log(tweet.fullText);
309
+ * }
310
+ * }
311
+ * catch (err) {
312
+ * console.log(err);
313
+ * }
314
+ * })();
315
+ * ```
316
+ */
317
+ stream(filter: TweetFilter, pollingInterval?: number): AsyncGenerator<Tweet>;
318
+ /**
319
+ * Unlike a tweet.
320
+ *
321
+ * @param id - The id of the target tweet.
322
+ *
323
+ * @returns Whether unliking was successful or not.
324
+ *
325
+ * @example
216
326
  * ```
217
327
  * import { Rettiwt } from 'rettiwt-api';
218
328
  *
219
329
  * // Creating a new Rettiwt instance using the given 'API_KEY'
220
330
  * const rettiwt = new Rettiwt({ apiKey: API_KEY });
221
331
  *
222
- * // Posting a tweet, containing an image called 'mountains.jpg', to twitter
223
- * rettiwt.tweet.tweet('What a nice view!', [{ path: 'mountains.jpg' }])
332
+ * // Unliking the Tweet with id '1234567890'
333
+ * rettiwt.tweet.unlike('1234567890')
224
334
  * .then(res => {
225
335
  * console.log(res);
226
336
  * })
@@ -228,16 +338,24 @@ export declare class TweetService extends FetcherService {
228
338
  * console.log(err);
229
339
  * });
230
340
  * ```
341
+ */
342
+ unlike(id: string): Promise<boolean>;
343
+ /**
344
+ * Unpost a tweet.
231
345
  *
232
- * @example Posting a reply to a tweet
346
+ * @param id - The id of the target tweet.
347
+ *
348
+ * @returns Whether unposting was successful or not.
349
+ *
350
+ * @example
233
351
  * ```
234
352
  * import { Rettiwt } from 'rettiwt-api';
235
353
  *
236
354
  * // Creating a new Rettiwt instance using the given 'API_KEY'
237
355
  * const rettiwt = new Rettiwt({ apiKey: API_KEY });
238
356
  *
239
- * // Posting a simple text reply, to a tweet with id "1234567890"
240
- * rettiwt.tweet.tweet('Hello!', undefined, "1234567890")
357
+ * // Unposting the Tweet with id '1234567890'
358
+ * rettiwt.tweet.unpost('1234567890')
241
359
  * .then(res => {
242
360
  * console.log(res);
243
361
  * })
@@ -245,15 +363,14 @@ export declare class TweetService extends FetcherService {
245
363
  * console.log(err);
246
364
  * });
247
365
  * ```
248
- *
249
- * @public
250
366
  */
251
- tweet(text: string, media?: TweetMediaArgs[], replyTo?: string): Promise<boolean>;
367
+ unpost(id: string): Promise<boolean>;
252
368
  /**
253
- * Favorite the tweet with the given id.
369
+ * Unretweet a tweet.
254
370
  *
255
- * @param tweetId - The id of the tweet to be favorited.
256
- * @returns Whether favoriting was successful or not.
371
+ * @param id - The id of the target tweet.
372
+ *
373
+ * @returns Whether unretweeting was successful or not.
257
374
  *
258
375
  * @example
259
376
  * ```
@@ -262,8 +379,8 @@ export declare class TweetService extends FetcherService {
262
379
  * // Creating a new Rettiwt instance using the given 'API_KEY'
263
380
  * const rettiwt = new Rettiwt({ apiKey: API_KEY });
264
381
  *
265
- * // Liking the Tweet with id '12345678'
266
- * rettiwt.tweet.favorite('12345678')
382
+ * // Unretweeting the Tweet with id '1234567890'
383
+ * rettiwt.tweet.unretweet('1234567890')
267
384
  * .then(res => {
268
385
  * console.log(res);
269
386
  * })
@@ -271,15 +388,14 @@ export declare class TweetService extends FetcherService {
271
388
  * console.log(err);
272
389
  * });
273
390
  * ```
274
- *
275
- * @public
276
391
  */
277
- favorite(tweetId: string): Promise<boolean>;
392
+ unretweet(id: string): Promise<boolean>;
278
393
  /**
279
- * Retweet the tweet with the given id.
394
+ * Upload a media file to Twitter.
280
395
  *
281
- * @param tweetId - The id of the tweet with the given id.
282
- * @returns Whether retweeting was successful or not.
396
+ * @param media - The path or ArrayBuffer to the media file to upload.
397
+ *
398
+ * @returns The id of the uploaded media.
283
399
  *
284
400
  * @example
285
401
  * ```
@@ -288,8 +404,8 @@ export declare class TweetService extends FetcherService {
288
404
  * // Creating a new Rettiwt instance using the given 'API_KEY'
289
405
  * const rettiwt = new Rettiwt({ apiKey: API_KEY });
290
406
  *
291
- * // Retweeting the Tweet with id '12345678'
292
- * rettiwt.tweet.retweet('12345678')
407
+ * // Uploading a file called mountains.jpg
408
+ * rettiwt.tweet.upload('mountains.jpg')
293
409
  * .then(res => {
294
410
  * console.log(res);
295
411
  * })
@@ -298,7 +414,10 @@ export declare class TweetService extends FetcherService {
298
414
  * });
299
415
  * ```
300
416
  *
301
- * @public
417
+ * @remarks
418
+ * - The uploaded media exists for 24 hrs within which it can be included in a tweet to be posted.
419
+ * If not posted in a tweet within this period, the uploaded media is removed.
420
+ * - Instead of a path to the media, an ArrayBuffer containing the media can also be uploaded.
302
421
  */
303
- retweet(tweetId: string): Promise<boolean>;
422
+ upload(media: string | ArrayBuffer): Promise<string>;
304
423
  }