rettiwt-api 5.0.0-alpha.3 → 5.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.
- package/README.md +160 -87
- package/dist/collections/Extractors.d.ts +6 -2
- package/dist/collections/Extractors.js +1 -0
- package/dist/collections/Extractors.js.map +1 -1
- package/dist/collections/Groups.js +1 -0
- package/dist/collections/Groups.js.map +1 -1
- package/dist/collections/Requests.d.ts +1 -1
- package/dist/collections/Requests.js +4 -2
- package/dist/collections/Requests.js.map +1 -1
- package/dist/collections/Tweet.d.ts +10 -0
- package/dist/collections/Tweet.js +17 -0
- package/dist/collections/Tweet.js.map +1 -0
- package/dist/commands/Tweet.js +0 -16
- package/dist/commands/Tweet.js.map +1 -1
- package/dist/commands/User.js +15 -15
- package/dist/commands/User.js.map +1 -1
- package/dist/enums/Api.d.ts +1 -51
- package/dist/enums/Api.js +1 -52
- package/dist/enums/Api.js.map +1 -1
- package/dist/enums/Resource.d.ts +1 -0
- package/dist/enums/Resource.js +1 -0
- package/dist/enums/Resource.js.map +1 -1
- package/dist/enums/Tweet.d.ts +8 -0
- package/dist/enums/Tweet.js +13 -0
- package/dist/enums/Tweet.js.map +1 -0
- package/dist/enums/raw/Tweet.d.ts +11 -1
- package/dist/enums/raw/Tweet.js +13 -2
- package/dist/enums/raw/Tweet.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/models/RettiwtConfig.d.ts +27 -3
- package/dist/models/RettiwtConfig.js +37 -4
- package/dist/models/RettiwtConfig.js.map +1 -1
- package/dist/models/args/FetchArgs.d.ts +3 -3
- package/dist/models/args/FetchArgs.js +3 -2
- package/dist/models/args/FetchArgs.js.map +1 -1
- package/dist/models/args/PostArgs.d.ts +2 -3
- package/dist/models/args/PostArgs.js +3 -3
- package/dist/models/args/PostArgs.js.map +1 -1
- package/dist/models/auth/AuthCookie.d.ts +1 -1
- package/dist/models/auth/AuthCookie.js +1 -1
- package/dist/models/auth/AuthCredential.d.ts +1 -1
- package/dist/models/auth/AuthCredential.js +1 -1
- package/dist/models/data/List.d.ts +4 -0
- package/dist/models/data/List.js +7 -0
- package/dist/models/data/List.js.map +1 -1
- package/dist/models/data/Notification.d.ts +4 -0
- package/dist/models/data/Notification.js +7 -0
- package/dist/models/data/Notification.js.map +1 -1
- package/dist/models/data/Tweet.d.ts +4 -0
- package/dist/models/data/Tweet.js +7 -0
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.d.ts +4 -0
- package/dist/models/data/User.js +7 -0
- package/dist/models/data/User.js.map +1 -1
- package/dist/models/errors/TwitterError.d.ts +37 -0
- package/dist/models/errors/TwitterError.js +60 -0
- package/dist/models/errors/TwitterError.js.map +1 -0
- package/dist/requests/List.js +28 -9
- package/dist/requests/List.js.map +1 -1
- package/dist/requests/Tweet.d.ts +2 -1
- package/dist/requests/Tweet.js +94 -38
- package/dist/requests/Tweet.js.map +1 -1
- package/dist/requests/User.js +231 -111
- package/dist/requests/User.js.map +1 -1
- package/dist/services/internal/AuthService.d.ts +6 -6
- package/dist/services/internal/AuthService.js +7 -8
- package/dist/services/internal/AuthService.js.map +1 -1
- package/dist/services/internal/ErrorService.d.ts +5 -76
- package/dist/services/internal/ErrorService.js +13 -116
- package/dist/services/internal/ErrorService.js.map +1 -1
- package/dist/services/internal/TidService.d.ts +4 -5
- package/dist/services/internal/TidService.js +18 -24
- package/dist/services/internal/TidService.js.map +1 -1
- package/dist/services/public/FetcherService.d.ts +4 -3
- package/dist/services/public/FetcherService.js +8 -7
- package/dist/services/public/FetcherService.js.map +1 -1
- package/dist/services/public/ListService.d.ts +6 -4
- package/dist/services/public/ListService.js +6 -4
- package/dist/services/public/ListService.js.map +1 -1
- package/dist/services/public/TweetService.d.ts +96 -74
- package/dist/services/public/TweetService.js +97 -87
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.d.ts +106 -38
- package/dist/services/public/UserService.js +126 -43
- package/dist/services/public/UserService.js.map +1 -1
- package/dist/types/args/FetchArgs.d.ts +8 -0
- package/dist/types/errors/TwitterError.d.ts +30 -0
- package/dist/types/{raw/generic/Error.js → errors/TwitterError.js} +1 -1
- package/dist/types/errors/TwitterError.js.map +1 -0
- package/dist/types/raw/base/Error.d.ts +32 -0
- package/dist/types/raw/base/Error.js +4 -0
- package/dist/types/raw/base/Error.js.map +1 -0
- package/dist/types/raw/generic/Response.d.ts +0 -2
- package/dist/types/raw/tweet/DetailsBulk.d.ts +288 -0
- package/dist/types/raw/tweet/DetailsBulk.js +4 -0
- package/dist/types/raw/tweet/DetailsBulk.js.map +1 -0
- package/dist/types/raw/user/DetailsBulk.d.ts +91 -0
- package/dist/types/raw/user/DetailsBulk.js +4 -0
- package/dist/types/raw/user/DetailsBulk.js.map +1 -0
- package/package.json +1 -1
- package/src/collections/Extractors.ts +8 -2
- package/src/collections/Groups.ts +1 -0
- package/src/collections/Requests.ts +6 -2
- package/src/collections/Tweet.ts +17 -0
- package/src/commands/Tweet.ts +0 -16
- package/src/commands/User.ts +15 -15
- package/src/enums/Api.ts +0 -51
- package/src/enums/Resource.ts +1 -0
- package/src/enums/Tweet.ts +8 -0
- package/src/enums/raw/Tweet.ts +12 -1
- package/src/index.ts +6 -6
- package/src/models/RettiwtConfig.ts +43 -4
- package/src/models/args/FetchArgs.ts +4 -3
- package/src/models/args/PostArgs.ts +3 -4
- package/src/models/auth/AuthCookie.ts +1 -1
- package/src/models/auth/AuthCredential.ts +1 -1
- package/src/models/data/List.ts +9 -0
- package/src/models/data/Notification.ts +10 -0
- package/src/models/data/Tweet.ts +9 -0
- package/src/models/data/User.ts +9 -0
- package/src/models/errors/TwitterError.ts +65 -0
- package/src/requests/List.ts +28 -9
- package/src/requests/Tweet.ts +95 -39
- package/src/requests/User.ts +231 -111
- package/src/services/internal/AuthService.ts +8 -9
- package/src/services/internal/ErrorService.ts +14 -132
- package/src/services/internal/TidService.ts +21 -28
- package/src/services/public/FetcherService.ts +8 -7
- package/src/services/public/ListService.ts +6 -4
- package/src/services/public/TweetService.ts +104 -95
- package/src/services/public/UserService.ts +143 -51
- package/src/types/args/FetchArgs.ts +10 -0
- package/src/types/errors/TwitterError.ts +37 -0
- package/src/types/raw/base/Error.ts +37 -0
- package/src/types/raw/generic/Response.ts +0 -3
- package/src/types/raw/tweet/DetailsBulk.ts +338 -0
- package/src/types/raw/user/DetailsBulk.ts +104 -0
- package/dist/enums/Http.d.ts +0 -68
- package/dist/enums/Http.js +0 -73
- package/dist/enums/Http.js.map +0 -1
- package/dist/models/errors/ApiError.d.ts +0 -15
- package/dist/models/errors/ApiError.js +0 -23
- package/dist/models/errors/ApiError.js.map +0 -1
- package/dist/models/errors/HttpError.d.ts +0 -15
- package/dist/models/errors/HttpError.js +0 -23
- package/dist/models/errors/HttpError.js.map +0 -1
- package/dist/models/errors/RettiwtError.d.ts +0 -9
- package/dist/models/errors/RettiwtError.js +0 -17
- package/dist/models/errors/RettiwtError.js.map +0 -1
- package/dist/models/errors/TimeoutError.d.ts +0 -12
- package/dist/models/errors/TimeoutError.js +0 -19
- package/dist/models/errors/TimeoutError.js.map +0 -1
- package/dist/types/raw/generic/Error.d.ts +0 -30
- package/dist/types/raw/generic/Error.js.map +0 -1
- package/src/enums/Http.ts +0 -68
- package/src/models/errors/ApiError.ts +0 -21
- package/src/models/errors/HttpError.ts +0 -21
- package/src/models/errors/RettiwtError.ts +0 -13
- package/src/models/errors/TimeoutError.ts +0 -15
- package/src/types/raw/generic/Error.ts +0 -35
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import { Agent } from 'https';
|
|
2
|
-
|
|
3
1
|
import axios from 'axios';
|
|
4
2
|
|
|
5
3
|
import { EApiErrors } from '../../enums/Api';
|
|
6
4
|
import { AuthCredential } from '../../models/auth/AuthCredential';
|
|
5
|
+
import { RettiwtConfig } from '../../models/RettiwtConfig';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* The services that handles authentication.
|
|
10
9
|
*
|
|
11
|
-
* @
|
|
10
|
+
* @internal
|
|
12
11
|
*/
|
|
13
12
|
export class AuthService {
|
|
14
|
-
/** The
|
|
15
|
-
private readonly
|
|
13
|
+
/** The config object. */
|
|
14
|
+
private readonly _config: RettiwtConfig;
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
|
-
* @param
|
|
17
|
+
* @param config - The config for Rettiwt.
|
|
19
18
|
*/
|
|
20
|
-
public constructor(
|
|
21
|
-
this.
|
|
19
|
+
public constructor(config: RettiwtConfig) {
|
|
20
|
+
this._config = config;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
/**
|
|
@@ -107,7 +106,7 @@ export class AuthService {
|
|
|
107
106
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
108
107
|
}>('https://api.twitter.com/1.1/guest/activate.json', undefined, {
|
|
109
108
|
headers: cred.toHeader(),
|
|
110
|
-
httpsAgent: this.
|
|
109
|
+
httpsAgent: this._config.httpsAgent,
|
|
111
110
|
})
|
|
112
111
|
.then((res) => {
|
|
113
112
|
cred.guestToken = res.data.guest_token;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { AxiosError,
|
|
1
|
+
import { AxiosError, isAxiosError } from 'axios';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { EHttpStatus } from '../../enums/Http';
|
|
5
|
-
import { findKeyByValue } from '../../helper/JsonUtils';
|
|
6
|
-
import { ApiError } from '../../models/errors/ApiError';
|
|
7
|
-
import { HttpError } from '../../models/errors/HttpError';
|
|
8
|
-
import { TimeoutError } from '../../models/errors/TimeoutError';
|
|
3
|
+
import { TwitterError } from '../../models/errors/TwitterError';
|
|
9
4
|
import { IErrorHandler } from '../../types/ErrorHandler';
|
|
5
|
+
import { IErrorData as IRawErrorData, IErrorDetails as IRawErrorDetails } from '../../types/raw/base/Error';
|
|
10
6
|
|
|
11
7
|
/**
|
|
12
8
|
* The base service that handles any errors.
|
|
@@ -15,129 +11,19 @@ import { IErrorHandler } from '../../types/ErrorHandler';
|
|
|
15
11
|
*/
|
|
16
12
|
export class ErrorService implements IErrorHandler {
|
|
17
13
|
/**
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
protected static readonly DEFAULT_ERROR_MESSAGE = 'Unknown error';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Creates an API error instance based on the provided error code.
|
|
24
|
-
*
|
|
25
|
-
* @param errorCode - The error code.
|
|
26
|
-
*
|
|
27
|
-
* @returns An API error instance.
|
|
28
|
-
*/
|
|
29
|
-
protected createApiError(errorCode: number): ApiError {
|
|
30
|
-
return new ApiError(errorCode, this.getApiErrorMessage(errorCode));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Creates an HTTP error instance based on the provided HTTP status.
|
|
35
|
-
*
|
|
36
|
-
* @param httpStatus - The HTTP status code.
|
|
37
|
-
*
|
|
38
|
-
* @returns An HTTP error instance.
|
|
39
|
-
*/
|
|
40
|
-
protected createHttpError(httpStatus: number): HttpError {
|
|
41
|
-
return new HttpError(httpStatus, this.getHttpErrorMessage(httpStatus));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Retrieves the API error message based on the provided error code.
|
|
14
|
+
* Handles errors thrown by Twitter.
|
|
46
15
|
*
|
|
47
|
-
* @param
|
|
48
|
-
*
|
|
49
|
-
* @returns The API error message.
|
|
16
|
+
* @param error - The error response received from Twitter.
|
|
50
17
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return !!errorCodeKey && errorCodeKey in EApiErrors
|
|
55
|
-
? EApiErrors[errorCodeKey as keyof typeof EApiErrors]
|
|
56
|
-
: ErrorService.DEFAULT_ERROR_MESSAGE;
|
|
18
|
+
private handleAxiosError(error: AxiosError<IRawErrorData | IRawErrorDetails>): void {
|
|
19
|
+
throw new TwitterError(error);
|
|
57
20
|
}
|
|
58
21
|
|
|
59
22
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @param error - The error object.
|
|
63
|
-
*
|
|
64
|
-
* @returns The response data.
|
|
65
|
-
*
|
|
66
|
-
* @throws The original error if it is not an HTTP error with a response.
|
|
23
|
+
* Handle unknown error.
|
|
67
24
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return error.response;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Retrieves the API error code from the Axios response data.
|
|
78
|
-
*
|
|
79
|
-
* @param response - The response object received.
|
|
80
|
-
*
|
|
81
|
-
* @returns The error code, or undefined if not found.
|
|
82
|
-
*/
|
|
83
|
-
protected getErrorCode(response: AxiosResponse): number | undefined {
|
|
84
|
-
const errors = (response.data as { errors: { code: number }[] }).errors;
|
|
85
|
-
|
|
86
|
-
return !!errors && errors.length ? errors[0].code : undefined;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Retrieves the HTTP error message based on the provided HTTP status.
|
|
91
|
-
*
|
|
92
|
-
* @param httpStatus - The HTTP status code.
|
|
93
|
-
*
|
|
94
|
-
* @returns The HTTP error message.
|
|
95
|
-
*/
|
|
96
|
-
protected getHttpErrorMessage(httpStatus: number): string {
|
|
97
|
-
return Object.values(EHttpStatus).includes(httpStatus)
|
|
98
|
-
? EHttpStatus[httpStatus]
|
|
99
|
-
: ErrorService.DEFAULT_ERROR_MESSAGE;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Handles API error in a response.
|
|
104
|
-
*
|
|
105
|
-
* @param response - The response object received.
|
|
106
|
-
*
|
|
107
|
-
* @throws An error with the corresponding API error message if any API-related error has occurred.
|
|
108
|
-
*/
|
|
109
|
-
protected handleApiError(response: AxiosResponse): void {
|
|
110
|
-
const errorCode = this.getErrorCode(response);
|
|
111
|
-
|
|
112
|
-
if (errorCode === undefined) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
throw this.createApiError(errorCode);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Handles HTTP error in a response.
|
|
121
|
-
*
|
|
122
|
-
* @param response - The response object received.
|
|
123
|
-
*
|
|
124
|
-
* @throws An error with the corresponding HTTP status text if any HTTP-related error has occurred.
|
|
125
|
-
*/
|
|
126
|
-
protected handleHttpError(response: AxiosResponse): void {
|
|
127
|
-
throw this.createHttpError(response.status);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Handles exceeded timeout, configured in RettiwtConfig.
|
|
132
|
-
*
|
|
133
|
-
* @param error - The error object.
|
|
134
|
-
*
|
|
135
|
-
* @throws An error if the configured request timeout has been exceeded.
|
|
136
|
-
*/
|
|
137
|
-
protected handleTimeoutError(error: AxiosError): void {
|
|
138
|
-
if (error.code === 'ECONNABORTED') {
|
|
139
|
-
throw new TimeoutError(error.message);
|
|
140
|
-
}
|
|
25
|
+
private handleUnknownError(): void {
|
|
26
|
+
throw new Error('Unknown error');
|
|
141
27
|
}
|
|
142
28
|
|
|
143
29
|
/**
|
|
@@ -146,14 +32,10 @@ export class ErrorService implements IErrorHandler {
|
|
|
146
32
|
* @param error - The error caught while making HTTP request to Twitter API.
|
|
147
33
|
*/
|
|
148
34
|
public handle(error: unknown): void {
|
|
149
|
-
if (
|
|
150
|
-
|
|
35
|
+
if (isAxiosError(error)) {
|
|
36
|
+
this.handleAxiosError(error as AxiosError<IRawErrorData | IRawErrorDetails>);
|
|
37
|
+
} else {
|
|
38
|
+
this.handleUnknownError();
|
|
151
39
|
}
|
|
152
|
-
|
|
153
|
-
this.handleTimeoutError(error);
|
|
154
|
-
|
|
155
|
-
const axiosResponse = this.getAxiosResponse(error);
|
|
156
|
-
this.handleApiError(axiosResponse);
|
|
157
|
-
this.handleHttpError(axiosResponse);
|
|
158
40
|
}
|
|
159
41
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Agent } from 'http';
|
|
2
|
-
|
|
3
1
|
import axios from 'axios';
|
|
4
2
|
import * as htmlParser from 'node-html-parser';
|
|
5
3
|
|
|
@@ -7,6 +5,7 @@ import { ELogActions } from '../../enums/Logging';
|
|
|
7
5
|
|
|
8
6
|
import { calculateClientTransactionIdHeader } from '../../helper/TidUtils';
|
|
9
7
|
|
|
8
|
+
import { RettiwtConfig } from '../../models/RettiwtConfig';
|
|
10
9
|
import { ITidDynamicArgs } from '../../types/auth/TidDynamicArgs';
|
|
11
10
|
import { ITidProvider } from '../../types/auth/TidProvider';
|
|
12
11
|
|
|
@@ -19,30 +18,15 @@ import { LogService } from './LogService';
|
|
|
19
18
|
*/
|
|
20
19
|
export class TidService implements ITidProvider {
|
|
21
20
|
private readonly _cdnUrl: string;
|
|
22
|
-
private readonly
|
|
23
|
-
private readonly _requestHeaders: NonNullable<unknown>;
|
|
21
|
+
private readonly _config: RettiwtConfig;
|
|
24
22
|
private _dynamicArgs?: ITidDynamicArgs;
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
|
-
* @param
|
|
25
|
+
* @param config - The config for Rettiwt.
|
|
28
26
|
*/
|
|
29
|
-
public constructor(
|
|
27
|
+
public constructor(config: RettiwtConfig) {
|
|
30
28
|
this._cdnUrl = 'https://abs.twimg.com/responsive-web/client-web';
|
|
31
|
-
this.
|
|
32
|
-
this._requestHeaders = {
|
|
33
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
34
|
-
|
|
35
|
-
Authority: 'x.com',
|
|
36
|
-
'Accept-Language': 'en-US,en;q=0.9',
|
|
37
|
-
'Cache-Control': 'no-cache',
|
|
38
|
-
Referer: 'https://x.com',
|
|
39
|
-
'User-Agent':
|
|
40
|
-
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
|
|
41
|
-
'X-Twitter-Active-User': 'yes',
|
|
42
|
-
'X-Twitter-Client-Language': 'en',
|
|
43
|
-
|
|
44
|
-
/* eslint-enable @typescript-eslint/naming-convention */
|
|
45
|
-
};
|
|
29
|
+
this._config = config;
|
|
46
30
|
}
|
|
47
31
|
|
|
48
32
|
/**
|
|
@@ -70,9 +54,9 @@ export class TidService implements ITidProvider {
|
|
|
70
54
|
*/
|
|
71
55
|
private async getHomepageHtml(): Promise<string> {
|
|
72
56
|
const response = await axios.get<string>('https://x.com', {
|
|
73
|
-
headers: this.
|
|
74
|
-
httpAgent: this.
|
|
75
|
-
httpsAgent: this.
|
|
57
|
+
headers: this._config.headers,
|
|
58
|
+
httpAgent: this._config.httpsAgent,
|
|
59
|
+
httpsAgent: this._config.httpsAgent,
|
|
76
60
|
});
|
|
77
61
|
|
|
78
62
|
return response.data;
|
|
@@ -88,8 +72,8 @@ export class TidService implements ITidProvider {
|
|
|
88
72
|
|
|
89
73
|
const onDemandFileHash = ondemandFileMatch ? ondemandFileMatch[1] : '';
|
|
90
74
|
const response = await axios.get<string>(`${this._cdnUrl}/ondemand.s.${onDemandFileHash}a.js`, {
|
|
91
|
-
httpAgent: this.
|
|
92
|
-
httpsAgent: this.
|
|
75
|
+
httpAgent: this._config.httpsAgent,
|
|
76
|
+
httpsAgent: this._config.httpsAgent,
|
|
93
77
|
});
|
|
94
78
|
const match = response.data.matchAll(/(\(\w\[(\d{1,2})],\s*16\))+?/gm);
|
|
95
79
|
|
|
@@ -118,8 +102,12 @@ export class TidService implements ITidProvider {
|
|
|
118
102
|
*/
|
|
119
103
|
public async generate(method: string, path: string): Promise<string | undefined> {
|
|
120
104
|
try {
|
|
105
|
+
// Refreshing dynamic args
|
|
106
|
+
await this.refreshDynamicArgs();
|
|
107
|
+
|
|
108
|
+
// If dynamic args weren't obtained, skip with error
|
|
121
109
|
if (!this._dynamicArgs) {
|
|
122
|
-
|
|
110
|
+
throw new Error('Dynamic args failed to generate');
|
|
123
111
|
}
|
|
124
112
|
|
|
125
113
|
const { verificationKey, frames, indices } = this._dynamicArgs;
|
|
@@ -133,7 +121,12 @@ export class TidService implements ITidProvider {
|
|
|
133
121
|
indices: indices,
|
|
134
122
|
extraByte: 3,
|
|
135
123
|
});
|
|
136
|
-
} catch {
|
|
124
|
+
} catch (err) {
|
|
125
|
+
LogService.log(ELogActions.WARNING, {
|
|
126
|
+
message: 'Failed to generated transaction token. Request may or may not work',
|
|
127
|
+
error: err,
|
|
128
|
+
});
|
|
129
|
+
|
|
137
130
|
return;
|
|
138
131
|
}
|
|
139
132
|
}
|
|
@@ -53,9 +53,9 @@ export class FetcherService {
|
|
|
53
53
|
this.config = config;
|
|
54
54
|
this._delay = config.delay;
|
|
55
55
|
this._errorHandler = config.errorHandler ?? new ErrorService();
|
|
56
|
-
this._tidProvider = config.tidProvider ?? new TidService(config
|
|
56
|
+
this._tidProvider = config.tidProvider ?? new TidService(config);
|
|
57
57
|
this._timeout = config.timeout ?? 0;
|
|
58
|
-
this._auth = new AuthService(config
|
|
58
|
+
this._auth = new AuthService(config);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -137,12 +137,12 @@ export class FetcherService {
|
|
|
137
137
|
// Logging
|
|
138
138
|
LogService.log(ELogActions.VALIDATE, { target: 'FETCH_ARGS' });
|
|
139
139
|
|
|
140
|
-
return new FetchArgs(
|
|
140
|
+
return new FetchArgs(args);
|
|
141
141
|
} else if (postResources.includes(resource)) {
|
|
142
142
|
// Logging
|
|
143
143
|
LogService.log(ELogActions.VALIDATE, { target: 'POST_ARGS' });
|
|
144
144
|
|
|
145
|
-
return new PostArgs(
|
|
145
|
+
return new PostArgs(args);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
@@ -180,8 +180,9 @@ export class FetcherService {
|
|
|
180
180
|
* @returns The raw data response received.
|
|
181
181
|
*
|
|
182
182
|
* @example
|
|
183
|
-
*
|
|
184
|
-
*
|
|
183
|
+
*
|
|
184
|
+
* #### Fetching the raw details of a single user, using their username
|
|
185
|
+
* ```ts
|
|
185
186
|
* import { FetcherService, EResourceType } from 'rettiwt-api';
|
|
186
187
|
*
|
|
187
188
|
* // Creating a new FetcherService instance using the given 'API_KEY'
|
|
@@ -194,7 +195,7 @@ export class FetcherService {
|
|
|
194
195
|
* })
|
|
195
196
|
* .catch(err => {
|
|
196
197
|
* console.log(err);
|
|
197
|
-
* })
|
|
198
|
+
* });
|
|
198
199
|
* ```
|
|
199
200
|
*/
|
|
200
201
|
public async request<T = unknown>(resource: EResourceType, args: IFetchArgs | IPostArgs): Promise<T> {
|
|
@@ -22,14 +22,15 @@ export class ListService extends FetcherService {
|
|
|
22
22
|
/**
|
|
23
23
|
* Get the list of members of a tweet list.
|
|
24
24
|
*
|
|
25
|
-
* @param id - The
|
|
25
|
+
* @param id - The ID of target list.
|
|
26
26
|
* @param count - The number of members to fetch, must be \<= 100.
|
|
27
27
|
* @param cursor - The cursor to the batch of members to fetch.
|
|
28
28
|
*
|
|
29
29
|
* @returns The list tweets in the given list.
|
|
30
30
|
*
|
|
31
31
|
* @example
|
|
32
|
-
*
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
33
34
|
* import { Rettiwt } from 'rettiwt-api';
|
|
34
35
|
*
|
|
35
36
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|
|
@@ -66,14 +67,15 @@ export class ListService extends FetcherService {
|
|
|
66
67
|
/**
|
|
67
68
|
* Get the list of tweets from a tweet list.
|
|
68
69
|
*
|
|
69
|
-
* @param id - The
|
|
70
|
+
* @param id - The ID of target list.
|
|
70
71
|
* @param count - The number of tweets to fetch, must be \<= 100.
|
|
71
72
|
* @param cursor - The cursor to the batch of tweets to fetch.
|
|
72
73
|
*
|
|
73
74
|
* @returns The list tweets in the given list.
|
|
74
75
|
*
|
|
75
76
|
* @example
|
|
76
|
-
*
|
|
77
|
+
*
|
|
78
|
+
* ```ts
|
|
77
79
|
* import { Rettiwt } from 'rettiwt-api';
|
|
78
80
|
*
|
|
79
81
|
* // Creating a new Rettiwt instance using the given 'API_KEY'
|