rettiwt-api 1.1.1 → 1.1.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 +32 -7
- package/dist/endpoints/Endpoints.d.ts +14 -0
- package/dist/endpoints/Endpoints.js +20 -0
- package/dist/endpoints/Endpoints.js.map +1 -0
- package/dist/endpoints/Url.d.ts +5 -0
- package/dist/endpoints/Url.js +12 -0
- package/dist/endpoints/Url.js.map +1 -0
- package/dist/enums/Endpoints.d.ts +25 -0
- package/dist/enums/Endpoints.js +31 -0
- package/dist/enums/Endpoints.js.map +1 -0
- package/dist/enums/Errors.d.ts +20 -0
- package/dist/enums/Errors.js +28 -0
- package/dist/enums/Errors.js.map +1 -0
- package/dist/enums/HTTP.d.ts +17 -0
- package/dist/enums/HTTP.js +23 -0
- package/dist/enums/HTTP.js.map +1 -0
- package/dist/graphql/enums/Errors.d.ts +20 -0
- package/dist/graphql/enums/Errors.js +28 -0
- package/dist/graphql/enums/Errors.js.map +1 -0
- package/dist/graphql/queries/RootQuery.js +10 -3
- package/dist/graphql/queries/RootQuery.js.map +1 -1
- package/dist/graphql/resolvers/AccountResolver.d.ts +3 -3
- package/dist/graphql/resolvers/AccountResolver.js.map +1 -1
- package/dist/graphql/resolvers/ResolverBase.d.ts +14 -3
- package/dist/graphql/resolvers/ResolverBase.js +13 -1
- package/dist/graphql/resolvers/ResolverBase.js.map +1 -1
- package/dist/graphql/resolvers/TweetResolver.d.ts +3 -3
- package/dist/graphql/resolvers/TweetResolver.js +30 -18
- package/dist/graphql/resolvers/TweetResolver.js.map +1 -1
- package/dist/graphql/resolvers/UserResolver.d.ts +4 -4
- package/dist/graphql/resolvers/UserResolver.js +23 -19
- package/dist/graphql/resolvers/UserResolver.js.map +1 -1
- package/dist/graphql/types/Errors.d.ts +20 -0
- package/dist/graphql/types/Errors.js +28 -0
- package/dist/graphql/types/Errors.js.map +1 -0
- package/dist/graphql/types/TweetTypes.js +2 -2
- package/dist/graphql/types/TweetTypes.js.map +1 -1
- package/dist/index.d.ts +31 -15
- package/dist/index.js +32 -17
- package/dist/index.js.map +1 -1
- package/dist/middlewares/Authentication.d.ts +0 -0
- package/dist/middlewares/Authentication.js +2 -0
- package/dist/middlewares/Authentication.js.map +1 -0
- package/dist/models/args/TweetFilter.d.ts +59 -0
- package/dist/models/args/TweetFilter.js +101 -0
- package/dist/models/args/TweetFilter.js.map +1 -0
- package/dist/models/args/TweetListArgs.d.ts +21 -0
- package/dist/models/args/TweetListArgs.js +54 -0
- package/dist/models/args/TweetListArgs.js.map +1 -0
- package/dist/models/args/UserListArgs.d.ts +21 -0
- package/dist/models/args/UserListArgs.js +54 -0
- package/dist/models/args/UserListArgs.js.map +1 -0
- package/dist/models/auth/AuthCookie.d.ts +21 -0
- package/dist/models/auth/AuthCookie.js +33 -0
- package/dist/models/auth/AuthCookie.js.map +1 -0
- package/dist/models/data/CursoredData.d.ts +34 -0
- package/dist/models/data/CursoredData.js +42 -0
- package/dist/models/data/CursoredData.js.map +1 -0
- package/dist/models/data/DataValidationError.d.ts +18 -0
- package/dist/models/data/DataValidationError.js +21 -0
- package/dist/models/data/DataValidationError.js.map +1 -0
- package/dist/models/data/Errors.d.ts +18 -0
- package/dist/models/data/Errors.js +21 -0
- package/dist/models/data/Errors.js.map +1 -0
- package/dist/models/data/Service.d.ts +33 -0
- package/dist/models/data/Service.js +41 -0
- package/dist/models/data/Service.js.map +1 -0
- package/dist/models/data/Tweet.d.ts +53 -0
- package/dist/models/data/Tweet.js +104 -0
- package/dist/models/data/Tweet.js.map +1 -0
- package/dist/models/data/User.d.ts +41 -0
- package/dist/models/data/User.js +32 -0
- package/dist/models/data/User.js.map +1 -0
- package/dist/models/errors/DataValidationError.d.ts +20 -0
- package/dist/models/errors/DataValidationError.js +23 -0
- package/dist/models/errors/DataValidationError.js.map +1 -0
- package/dist/models/query/Variables.d.ts +2 -0
- package/dist/models/query/Variables.js +10 -0
- package/dist/models/query/Variables.js.map +1 -0
- package/dist/requests/Url.d.ts +5 -0
- package/dist/requests/Url.js +12 -0
- package/dist/requests/Url.js.map +1 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.js +9 -10
- package/dist/server.js.map +1 -1
- package/dist/services/accounts/AccountService.d.ts +6 -0
- package/dist/services/accounts/AccountService.js +20 -0
- package/dist/services/accounts/AccountService.js.map +1 -1
- package/dist/services/auth/AccountService.d.ts +88 -0
- package/dist/services/auth/AccountService.js +392 -0
- package/dist/services/auth/AccountService.js.map +1 -0
- package/dist/services/auth/AuthService.d.ts +31 -0
- package/dist/services/auth/AuthService.js +118 -0
- package/dist/services/auth/AuthService.js.map +1 -0
- package/dist/services/auth/LoginFlows.d.ts +77 -0
- package/dist/services/auth/LoginFlows.js +92 -0
- package/dist/services/auth/LoginFlows.js.map +1 -0
- package/dist/services/data/TweetService.d.ts +46 -16
- package/dist/services/data/TweetService.js +71 -54
- package/dist/services/data/TweetService.js.map +1 -1
- package/dist/services/data/UserService.d.ts +45 -21
- package/dist/services/data/UserService.js +78 -75
- package/dist/services/data/UserService.js.map +1 -1
- package/dist/services/helper/Headers.d.ts +4 -4
- package/dist/services/helper/Headers.js.map +1 -1
- package/dist/services/helper/Parser.d.ts +2 -2
- package/dist/services/helper/Parser.js.map +1 -1
- package/dist/services/helper/extractors/Tweets.d.ts +6 -6
- package/dist/services/helper/extractors/Tweets.js +1 -1
- package/dist/services/helper/extractors/Tweets.js.map +1 -1
- package/dist/services/helper/extractors/Users.d.ts +4 -4
- package/dist/services/helper/extractors/Users.js +1 -1
- package/dist/services/helper/extractors/Users.js.map +1 -1
- package/dist/services/helper/payloads/LoginFlows.d.ts +77 -0
- package/dist/services/helper/payloads/LoginFlows.js +92 -0
- package/dist/services/helper/payloads/LoginFlows.js.map +1 -0
- package/dist/services/util/CacheService.d.ts +33 -0
- package/dist/services/util/CacheService.js +96 -0
- package/dist/services/util/CacheService.js.map +1 -0
- package/dist/services/util/FetcherService.d.ts +65 -0
- package/dist/services/util/FetcherService.js +214 -0
- package/dist/services/util/FetcherService.js.map +1 -0
- package/dist/types/Args.d.ts +38 -0
- package/dist/types/Args.js +5 -0
- package/dist/types/Args.js.map +1 -0
- package/dist/types/Authentication.d.ts +17 -2
- package/dist/types/Authentication.js +1 -0
- package/dist/types/Authentication.js.map +1 -1
- package/dist/types/Resolvers.d.ts +5 -4
- package/dist/types/Rettiwt.d.ts +16 -0
- package/dist/types/Rettiwt.js +3 -0
- package/dist/types/Rettiwt.js.map +1 -0
- package/dist/types/Service.d.ts +15 -23
- package/dist/types/Service.js +2 -16
- package/dist/types/Service.js.map +1 -1
- package/dist/types/Tweet.d.ts +25 -19
- package/dist/types/Tweet.js +0 -2
- package/dist/types/Tweet.js.map +1 -1
- package/dist/types/User.d.ts +35 -0
- package/dist/types/User.js +3 -0
- package/dist/types/User.js.map +1 -0
- package/dist/types/args/TweetFilter.d.ts +54 -0
- package/dist/types/args/TweetFilter.js +96 -0
- package/dist/types/args/TweetFilter.js.map +1 -0
- package/dist/types/args/TweetListArg.d.ts +10 -0
- package/dist/types/args/TweetListArg.js +42 -0
- package/dist/types/args/TweetListArg.js.map +1 -0
- package/dist/types/args/TweetListArgs.d.ts +20 -0
- package/dist/types/args/TweetListArgs.js +52 -0
- package/dist/types/args/TweetListArgs.js.map +1 -0
- package/dist/types/args/UserListArgs.d.ts +16 -0
- package/dist/types/args/UserListArgs.js +48 -0
- package/dist/types/args/UserListArgs.js.map +1 -0
- package/dist/types/data/Errors.d.ts +4 -1
- package/dist/types/data/Errors.js +3 -0
- package/dist/types/data/Errors.js.map +1 -1
- package/dist/types/data/TweetFilter.d.ts +49 -0
- package/dist/types/data/TweetFilter.js +63 -0
- package/dist/types/data/TweetFilter.js.map +1 -0
- package/dist/types/interfaces/Args.d.ts +38 -0
- package/dist/types/interfaces/Args.js +5 -0
- package/dist/types/interfaces/Args.js.map +1 -0
- package/dist/types/interfaces/Authentication.d.ts +40 -0
- package/dist/types/interfaces/Authentication.js +5 -0
- package/dist/types/interfaces/Authentication.js.map +1 -0
- package/dist/types/interfaces/Resolvers.d.ts +14 -0
- package/dist/types/interfaces/Resolvers.js +3 -0
- package/dist/types/interfaces/Resolvers.js.map +1 -0
- package/dist/types/interfaces/Rettiwt.d.ts +16 -0
- package/dist/types/interfaces/Rettiwt.js +3 -0
- package/dist/types/interfaces/Rettiwt.js.map +1 -0
- package/dist/types/interfaces/Service.d.ts +13 -0
- package/dist/types/interfaces/Service.js +3 -0
- package/dist/types/interfaces/Service.js.map +1 -0
- package/dist/types/interfaces/Services.d.ts +13 -0
- package/dist/types/interfaces/Services.js +3 -0
- package/dist/types/interfaces/Services.js.map +1 -0
- package/dist/types/interfaces/Tweet.d.ts +46 -0
- package/dist/types/interfaces/Tweet.js +3 -0
- package/dist/types/interfaces/Tweet.js.map +1 -0
- package/dist/types/interfaces/TweetFilter.d.ts +0 -0
- package/dist/types/interfaces/TweetFilter.js +2 -0
- package/dist/types/interfaces/TweetFilter.js.map +1 -0
- package/{src/types/data/User.ts → dist/types/interfaces/User.d.ts} +35 -51
- package/dist/types/interfaces/User.js +3 -0
- package/dist/types/interfaces/User.js.map +1 -0
- package/dist/types/raw/query/tweet/TweetDetails.d.ts +34 -0
- package/dist/types/raw/query/tweet/TweetDetails.js +5 -0
- package/dist/types/raw/query/tweet/TweetDetails.js.map +1 -0
- package/dist/types/raw/user/User.js.map +1 -1
- package/dist/types/services/args/TweetFilter.d.ts +50 -0
- package/dist/types/services/args/TweetFilter.js +76 -0
- package/dist/types/services/args/TweetFilter.js.map +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +64 -0
- package/docs/assets/main.js +58 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1280 -0
- package/docs/classes/AccountService.html +303 -0
- package/docs/classes/AuthCookie.html +146 -0
- package/docs/classes/AuthService.html +147 -0
- package/docs/classes/CacheService.html +157 -0
- package/docs/classes/Cursor.html +102 -0
- package/docs/classes/CursoredData.html +126 -0
- package/docs/classes/DataValidationError.html +119 -0
- package/docs/classes/FetcherService.html +225 -0
- package/docs/classes/Tweet.html +210 -0
- package/docs/classes/TweetEntities.html +128 -0
- package/docs/classes/TweetFilter.html +204 -0
- package/docs/classes/TweetListArgs.html +118 -0
- package/docs/classes/TweetService.html +313 -0
- package/docs/classes/User.html +230 -0
- package/docs/classes/UserListArgs.html +118 -0
- package/docs/classes/UserService.html +315 -0
- package/docs/enums/HttpMethods.html +74 -0
- package/docs/functions/Rettiwt.html +99 -0
- package/docs/index.html +161 -0
- package/docs/interfaces/IAuthCookie.html +104 -0
- package/docs/interfaces/ICursor.html +77 -0
- package/docs/interfaces/ICursoredData.html +93 -0
- package/docs/interfaces/IDataContext.html +91 -0
- package/docs/interfaces/IListArgs.html +87 -0
- package/docs/interfaces/ITweet.html +176 -0
- package/docs/interfaces/ITweetEntities.html +104 -0
- package/docs/interfaces/ITweetFilter.html +158 -0
- package/docs/interfaces/IUser.html +194 -0
- package/docs/modules.html +109 -0
- package/package.json +5 -2
- package/src/enums/Errors.ts +21 -0
- package/src/graphql/enums/Errors.ts +21 -0
- package/src/graphql/queries/RootQuery.ts +11 -4
- package/src/graphql/resolvers/AccountResolver.ts +3 -3
- package/src/graphql/resolvers/ResolverBase.ts +19 -5
- package/src/graphql/resolvers/TweetResolver.ts +26 -17
- package/src/graphql/resolvers/UserResolver.ts +18 -20
- package/src/graphql/types/TweetTypes.ts +2 -2
- package/src/graphql/types/UserTypes.ts +1 -1
- package/src/index.ts +39 -17
- package/src/models/args/TweetFilter.ts +119 -0
- package/src/models/args/TweetListArgs.ts +47 -0
- package/src/models/args/UserListArgs.ts +47 -0
- package/src/models/auth/AuthCookie.ts +43 -0
- package/src/models/data/CursoredData.ts +45 -0
- package/src/models/data/Tweet.ts +118 -0
- package/src/models/data/User.ts +72 -0
- package/src/models/errors/DataValidationError.ts +29 -0
- package/src/server.ts +9 -10
- package/src/services/{accounts → auth}/AccountService.ts +92 -17
- package/src/services/auth/AuthService.ts +81 -0
- package/src/services/data/TweetService.ts +77 -58
- package/src/services/data/UserService.ts +93 -89
- package/src/services/helper/Headers.ts +4 -4
- package/src/services/helper/Parser.ts +2 -2
- package/src/services/helper/extractors/Tweets.ts +7 -7
- package/src/services/helper/extractors/Users.ts +5 -5
- package/src/services/{CacheService.ts → util/CacheService.ts} +4 -1
- package/src/services/{FetcherService.ts → util/FetcherService.ts} +19 -11
- package/src/types/Args.ts +49 -0
- package/src/types/Authentication.ts +29 -7
- package/src/types/Resolvers.ts +5 -4
- package/src/types/Rettiwt.ts +20 -0
- package/src/types/Service.ts +24 -0
- package/src/types/Tweet.ts +61 -0
- package/src/types/User.ts +48 -0
- package/tsconfig.json +2 -2
- package/src/services/AuthService.ts +0 -68
- package/src/services/helper/deserializers/Tweets.ts +0 -70
- package/src/services/helper/deserializers/Users.ts +0 -26
- package/src/types/data/Errors.ts +0 -34
- package/src/types/data/Service.ts +0 -55
- package/src/types/data/Tweet.ts +0 -123
- package/src/types/raw/auth/Cookie.ts +0 -16
- /package/src/{types → enums}/HTTP.ts +0 -0
- /package/src/services/{accounts → helper/payloads}/LoginFlows.ts +0 -0
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
// SERVICES
|
|
2
|
-
import { FetcherService } from "../FetcherService";
|
|
3
|
-
import { AuthService } from "../AuthService";
|
|
2
|
+
import { FetcherService } from "../util/FetcherService";
|
|
3
|
+
import { AuthService } from "../auth/AuthService";
|
|
4
|
+
|
|
5
|
+
// MODELS
|
|
6
|
+
import { Tweet } from "../../models/data/Tweet";
|
|
7
|
+
import { User } from "../../models/data/User";
|
|
8
|
+
import { TweetListArgs } from "../../models/args/TweetListArgs";
|
|
9
|
+
import { TweetFilter } from "../../models/args/TweetFilter";
|
|
10
|
+
import { CursoredData } from '../../models/data/CursoredData';
|
|
4
11
|
|
|
5
12
|
// TYPES
|
|
6
|
-
import { TweetFilter, Tweet } from "../../types/data/Tweet";
|
|
7
|
-
import { User } from "../../types/data/User";
|
|
8
|
-
import { CursoredData } from '../../types/data/Service';
|
|
9
13
|
import RawTweet, { Result as TweetData } from '../../types/raw/tweet/Tweet';
|
|
10
14
|
import { Result as UserData } from "../../types/raw/user/User";
|
|
11
15
|
import RawTweets from '../../types/raw/tweet/Tweets';
|
|
12
16
|
import RawLikers from '../../types/raw/tweet/Favouriters';
|
|
13
17
|
import RawRetweeters from '../../types/raw/tweet/Retweeters';
|
|
14
|
-
|
|
18
|
+
|
|
19
|
+
// ENUMS
|
|
20
|
+
import { AuthenticationErrors } from '../../enums/Errors';
|
|
15
21
|
|
|
16
22
|
// URLS
|
|
17
23
|
import * as TweetUrls from '../helper/urls/Tweets';
|
|
@@ -19,10 +25,6 @@ import * as TweetUrls from '../helper/urls/Tweets';
|
|
|
19
25
|
// EXTRACTORS
|
|
20
26
|
import * as TweetExtractors from "../helper/extractors/Tweets";
|
|
21
27
|
|
|
22
|
-
// DESERIALIZERS
|
|
23
|
-
import * as UserDeserializers from '../helper/deserializers/Users';
|
|
24
|
-
import * as TweetDeserializers from '../helper/deserializers/Tweets';
|
|
25
|
-
|
|
26
28
|
// PARSERS
|
|
27
29
|
import { toQueryString } from '../helper/Parser';
|
|
28
30
|
|
|
@@ -31,7 +33,6 @@ import { toQueryString } from '../helper/Parser';
|
|
|
31
33
|
* @public
|
|
32
34
|
*/
|
|
33
35
|
export class TweetService extends FetcherService {
|
|
34
|
-
// MEMBER METHODS
|
|
35
36
|
/**
|
|
36
37
|
* @param auth The AuthService instance to use for authentication.
|
|
37
38
|
*/
|
|
@@ -41,19 +42,24 @@ export class TweetService extends FetcherService {
|
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* @param filter The filter be used for searching the tweets.
|
|
44
|
-
* @param count The number of tweets to fetch
|
|
45
|
+
* @param count The number of tweets to fetch, must be >= 10 and <= 20
|
|
45
46
|
* @param cursor The cursor to the next batch of tweets. If blank, first batch is fetched.
|
|
47
|
+
*
|
|
46
48
|
* @returns The list of tweets that match the given filter.
|
|
47
|
-
*
|
|
49
|
+
*
|
|
50
|
+
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if an invalid count has been provided.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
*
|
|
54
|
+
* If cookies have been provided, then authenticated requests are made. Else, guest requests are made.
|
|
48
55
|
*/
|
|
49
|
-
async getTweets(
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
56
|
+
async getTweets(query: TweetFilter, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
57
|
+
// Objectifying parameters
|
|
58
|
+
let filter: TweetFilter = new TweetFilter(query);
|
|
59
|
+
let args: TweetListArgs = new TweetListArgs(count, cursor);
|
|
54
60
|
|
|
55
61
|
// Getting the raw data
|
|
56
|
-
let res = await this.request<RawTweets>(TweetUrls.tweetsUrl(toQueryString(filter), count, cursor),
|
|
62
|
+
let res = await this.request<RawTweets>(TweetUrls.tweetsUrl(toQueryString(filter), args.count, args.cursor), this.isAuthenticated).then(res => res.data);
|
|
57
63
|
|
|
58
64
|
// Extracting data
|
|
59
65
|
let data = TweetExtractors.extractTweets(res);
|
|
@@ -62,21 +68,28 @@ export class TweetService extends FetcherService {
|
|
|
62
68
|
this.cacheData(data);
|
|
63
69
|
|
|
64
70
|
// Parsing data
|
|
65
|
-
let tweets = data.required.map((item: TweetData) =>
|
|
71
|
+
let tweets = data.required.map((item: TweetData) => new Tweet(item));
|
|
66
72
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
// Sorting the tweets by date, from recent to oldest
|
|
74
|
+
tweets.sort((a, b) => new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf());
|
|
75
|
+
|
|
76
|
+
return new CursoredData<Tweet>(tweets, data.cursor);
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
/**
|
|
74
|
-
* @param
|
|
80
|
+
* @param id The id of the target tweet.
|
|
81
|
+
*
|
|
75
82
|
* @returns The details of a single tweet with the given tweet id.
|
|
83
|
+
*
|
|
84
|
+
* @throws {@link Errors.DataErrors.TweetNotFound} error, if no tweet with the given id was found.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
*
|
|
88
|
+
* No cookies are required to use this method.
|
|
76
89
|
*/
|
|
77
|
-
async
|
|
90
|
+
async getTweetDetails(id: string): Promise<Tweet> {
|
|
78
91
|
// Getting data from cache
|
|
79
|
-
let cachedData = await this.readData(
|
|
92
|
+
let cachedData = await this.readData(id);
|
|
80
93
|
|
|
81
94
|
// If data exists in cache
|
|
82
95
|
if (cachedData) {
|
|
@@ -84,40 +97,46 @@ export class TweetService extends FetcherService {
|
|
|
84
97
|
}
|
|
85
98
|
|
|
86
99
|
// Fetching the raw data
|
|
87
|
-
let res = await this.request<RawTweet>(TweetUrls.tweetDetailsUrl(
|
|
100
|
+
let res = await this.request<RawTweet>(TweetUrls.tweetDetailsUrl(id), false).then(res => res.data);
|
|
88
101
|
|
|
89
102
|
// Extracting data
|
|
90
|
-
let data = TweetExtractors.extractTweet(res,
|
|
103
|
+
let data = TweetExtractors.extractTweet(res, id);
|
|
91
104
|
|
|
92
105
|
// Caching data
|
|
93
106
|
this.cacheData(data);
|
|
94
107
|
|
|
95
108
|
// Parsing data
|
|
96
|
-
let tweet =
|
|
109
|
+
let tweet = new Tweet(data.required[0]);
|
|
97
110
|
|
|
98
111
|
return tweet;
|
|
99
112
|
}
|
|
100
113
|
|
|
101
114
|
/**
|
|
102
115
|
* @param tweetId The rest id of the target tweet.
|
|
103
|
-
* @param count The batch size of the list.
|
|
116
|
+
* @param count The batch size of the list, must be >= 10 (when no cursor is provided) and <= 20.
|
|
104
117
|
* @param cursor The cursor to the next batch of users. If blank, first batch is fetched.
|
|
118
|
+
*
|
|
105
119
|
* @returns The list of users who liked the given tweet.
|
|
106
|
-
*
|
|
120
|
+
*
|
|
121
|
+
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
122
|
+
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count is provided.
|
|
123
|
+
* @throws {@link Errors.DataErrors.TweetNotFound} error, if no tweet with the given id was found.
|
|
124
|
+
*
|
|
125
|
+
* @remarks
|
|
126
|
+
*
|
|
127
|
+
* Cookies are required to use this method!
|
|
107
128
|
*/
|
|
108
|
-
async getTweetLikers(tweetId: string, count
|
|
129
|
+
async getTweetLikers(tweetId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
109
130
|
// If user is not authenticated, abort
|
|
110
131
|
if(!this.isAuthenticated) {
|
|
111
|
-
throw new Error(
|
|
132
|
+
throw new Error(AuthenticationErrors.NotAuthenticated);
|
|
112
133
|
}
|
|
113
134
|
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
throw new Error(Errors.ValidationErrors.InvalidCount);
|
|
117
|
-
}
|
|
135
|
+
// Objectifying parameters
|
|
136
|
+
let args: TweetListArgs = new TweetListArgs(count, cursor);
|
|
118
137
|
|
|
119
138
|
// Fetching the raw data
|
|
120
|
-
let res = await this.request<RawLikers>(TweetUrls.tweetLikesUrl(tweetId, count, cursor)).then(res => res.data);
|
|
139
|
+
let res = await this.request<RawLikers>(TweetUrls.tweetLikesUrl(tweetId, args.count, args.cursor)).then(res => res.data);
|
|
121
140
|
|
|
122
141
|
// Extracting data
|
|
123
142
|
let data = TweetExtractors.extractTweetLikers(res);
|
|
@@ -126,34 +145,37 @@ export class TweetService extends FetcherService {
|
|
|
126
145
|
this.cacheData(data);
|
|
127
146
|
|
|
128
147
|
// Parsing data
|
|
129
|
-
let users = data.required.map((item: UserData) =>
|
|
148
|
+
let users = data.required.map((item: UserData) => new User(item));
|
|
130
149
|
|
|
131
|
-
return
|
|
132
|
-
list: users,
|
|
133
|
-
next: { value: data.cursor }
|
|
134
|
-
};
|
|
150
|
+
return new CursoredData<User>(users, data.cursor);
|
|
135
151
|
}
|
|
136
152
|
|
|
137
153
|
/**
|
|
138
154
|
* @param tweetId The rest id of the target tweet.
|
|
139
|
-
* @param count The batch size of the list.
|
|
155
|
+
* @param count The batch size of the list, must be >= 10 (when no cursor is provided) and <= 100.
|
|
140
156
|
* @param cursor The cursor to the next batch of users. If blank, first batch is fetched.
|
|
157
|
+
*
|
|
141
158
|
* @returns The list of users who retweeted the given tweet.
|
|
142
|
-
*
|
|
159
|
+
*
|
|
160
|
+
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
161
|
+
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count is provided.
|
|
162
|
+
* @throws {@link Errors.DataErrors.TweetNotFound} error, if no tweet with the given id was found.
|
|
163
|
+
*
|
|
164
|
+
* @remarks
|
|
165
|
+
*
|
|
166
|
+
* Cookies are required to use this method!
|
|
143
167
|
*/
|
|
144
|
-
async getTweetRetweeters(tweetId: string, count
|
|
168
|
+
async getTweetRetweeters(tweetId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
145
169
|
// If user is not authenticated, abort
|
|
146
170
|
if(!this.isAuthenticated) {
|
|
147
|
-
throw new Error(
|
|
171
|
+
throw new Error(AuthenticationErrors.NotAuthenticated);
|
|
148
172
|
}
|
|
149
173
|
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
throw new Error(Errors.ValidationErrors.InvalidCount);
|
|
153
|
-
}
|
|
174
|
+
// Objectifying parameters
|
|
175
|
+
let args: TweetListArgs = new TweetListArgs(count, cursor);
|
|
154
176
|
|
|
155
177
|
// Fetching the raw data
|
|
156
|
-
let res = await this.request<RawRetweeters>(TweetUrls.tweetRetweetUrl(tweetId, count, cursor)).then(res => res.data);
|
|
178
|
+
let res = await this.request<RawRetweeters>(TweetUrls.tweetRetweetUrl(tweetId, args.count, args.cursor)).then(res => res.data);
|
|
157
179
|
|
|
158
180
|
// Extracting data
|
|
159
181
|
let data = TweetExtractors.extractTweetRetweeters(res);
|
|
@@ -162,12 +184,9 @@ export class TweetService extends FetcherService {
|
|
|
162
184
|
this.cacheData(data);
|
|
163
185
|
|
|
164
186
|
// Parsing data
|
|
165
|
-
let users = data.required.map((item: UserData) =>
|
|
187
|
+
let users = data.required.map((item: UserData) => new User(item));
|
|
166
188
|
|
|
167
|
-
return
|
|
168
|
-
list: users,
|
|
169
|
-
next: { value: data.cursor }
|
|
170
|
-
};
|
|
189
|
+
return new CursoredData<User>(users, data.cursor);
|
|
171
190
|
}
|
|
172
191
|
|
|
173
192
|
/**
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
// SERVICES
|
|
2
|
-
import { FetcherService } from '../FetcherService';
|
|
3
|
-
import { AuthService } from '../AuthService';
|
|
2
|
+
import { FetcherService } from '../util/FetcherService';
|
|
3
|
+
import { AuthService } from '../auth/AuthService';
|
|
4
|
+
|
|
5
|
+
// MODELS
|
|
6
|
+
import { User } from '../../models/data/User';
|
|
7
|
+
import { UserListArgs } from '../../models/args/UserListArgs';
|
|
8
|
+
import { Tweet } from '../../models/data/Tweet';
|
|
4
9
|
|
|
5
10
|
// TYPES
|
|
6
|
-
import {
|
|
7
|
-
import { Tweet } from '../../types/data/Tweet';
|
|
8
|
-
import { CursoredData } from '../../types/data/Service';
|
|
11
|
+
import { CursoredData } from '../../models/data/CursoredData';
|
|
9
12
|
import { Result as TweetData } from '../../types/raw/tweet/Tweet';
|
|
10
13
|
import RawUser, { Result as UserData } from '../../types/raw/user/User';
|
|
11
14
|
import RawUserFollowers from '../../types/raw/user/Followers';
|
|
12
15
|
import RawUserFollowing from '../../types/raw/user/Following';
|
|
13
16
|
import RawUserLikes from '../../types/raw/user/Likes';
|
|
14
|
-
|
|
17
|
+
|
|
18
|
+
// ENUMS
|
|
19
|
+
import { AuthenticationErrors } from '../../enums/Errors';
|
|
15
20
|
|
|
16
21
|
// URLS
|
|
17
22
|
import * as UserUrls from '../helper/urls/Users';
|
|
@@ -19,15 +24,10 @@ import * as UserUrls from '../helper/urls/Users';
|
|
|
19
24
|
// EXTRACTORS
|
|
20
25
|
import * as UserExtractors from '../helper/extractors/Users';
|
|
21
26
|
|
|
22
|
-
// DESERIALIZERS
|
|
23
|
-
import * as UserDeserializers from '../helper/deserializers/Users';
|
|
24
|
-
import * as TweetDeserializers from '../helper/deserializers/Tweets';
|
|
25
|
-
|
|
26
27
|
/**
|
|
27
28
|
* Handles fetching of data related to user account
|
|
28
29
|
*/
|
|
29
30
|
export class UserService extends FetcherService {
|
|
30
|
-
// MEMBER METHODS
|
|
31
31
|
/**
|
|
32
32
|
* @param auth The AuthService instance to use for authentication.
|
|
33
33
|
*/
|
|
@@ -36,40 +36,37 @@ export class UserService extends FetcherService {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* @param
|
|
39
|
+
* @param id The id/username of the target user.
|
|
40
|
+
*
|
|
40
41
|
* @returns The details of the given user.
|
|
42
|
+
*
|
|
43
|
+
* @throws {@link Errors.DataErrors.UserNotFound} error, if no user with the given username was found.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
*
|
|
47
|
+
* No cookies are required to use this method.
|
|
41
48
|
*/
|
|
42
|
-
async getUserDetails(
|
|
43
|
-
|
|
44
|
-
let res: RawUser = await this.request<RawUser>(UserUrls.userDetailsUrl(screenName), false).then(res => res.data);
|
|
45
|
-
|
|
46
|
-
// Extracting data
|
|
47
|
-
let data = UserExtractors.extractUserDetails(res);
|
|
48
|
-
|
|
49
|
-
// Caching data
|
|
50
|
-
this.cacheData(data);
|
|
49
|
+
async getUserDetails(id: string): Promise<User> {
|
|
50
|
+
let res: RawUser;
|
|
51
51
|
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
// If id is not a numeric string => username is supplied
|
|
53
|
+
if (isNaN(Number(id))) {
|
|
54
|
+
// Fetching the raw data
|
|
55
|
+
res = await this.request<RawUser>(UserUrls.userDetailsUrl(id), false).then(res => res.data);
|
|
56
|
+
}
|
|
57
|
+
// If id is a numeric string => id is supplied
|
|
58
|
+
else {
|
|
59
|
+
// Getting data from cache
|
|
60
|
+
let cachedData = await this.readData(id);
|
|
61
|
+
|
|
62
|
+
// If data exists in cache
|
|
63
|
+
if (cachedData) {
|
|
64
|
+
return cachedData;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Fetching the raw data
|
|
68
|
+
res = await this.request<RawUser>(UserUrls.userDetailsByIdUrl(id), false).then(res => res.data);
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
// Fetchin the raw data
|
|
72
|
-
let res = await this.request<RawUser>(UserUrls.userDetailsByIdUrl(restId), false).then(res => res.data);
|
|
73
70
|
|
|
74
71
|
// Extracting data
|
|
75
72
|
let data = UserExtractors.extractUserDetails(res);
|
|
@@ -78,32 +75,38 @@ export class UserService extends FetcherService {
|
|
|
78
75
|
this.cacheData(data);
|
|
79
76
|
|
|
80
77
|
// Parsing data
|
|
81
|
-
let user =
|
|
82
|
-
|
|
78
|
+
let user = new User(data.required[0]);
|
|
79
|
+
|
|
83
80
|
return user;
|
|
84
81
|
}
|
|
85
82
|
|
|
86
83
|
/**
|
|
87
84
|
* @param userId The rest id of the target user.
|
|
88
|
-
* @param count The number of following to fetch.
|
|
85
|
+
* @param count The number of following to fetch, must be >= 40 (when no cursor is provided) and <=100.
|
|
89
86
|
* @param cursor The cursor to next batch. If blank, first batch is fetched.
|
|
87
|
+
*
|
|
90
88
|
* @returns The list of users followed by the target user.
|
|
91
|
-
*
|
|
89
|
+
*
|
|
90
|
+
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
91
|
+
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count has been provided.
|
|
92
|
+
* @throws {@link Errors.DataErrors.UserNotFound} error, if invalid count has been provided.
|
|
93
|
+
*
|
|
94
|
+
* @remarks
|
|
95
|
+
*
|
|
96
|
+
* Cookies are required to use this method!
|
|
92
97
|
*/
|
|
93
|
-
async getUserFollowing(userId: string, count
|
|
98
|
+
async getUserFollowing(userId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
94
99
|
// If user is not authenticated, abort
|
|
95
|
-
if(!this.isAuthenticated) {
|
|
96
|
-
throw new Error(
|
|
100
|
+
if (!this.isAuthenticated) {
|
|
101
|
+
throw new Error(AuthenticationErrors.NotAuthenticated);
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
throw new Error(Errors.ValidationErrors.InvalidCount);
|
|
102
|
-
}
|
|
104
|
+
// Objectifying parameters
|
|
105
|
+
let args: UserListArgs = new UserListArgs(count, cursor);
|
|
103
106
|
|
|
104
107
|
// Fetchin the raw data
|
|
105
|
-
let res = await this.request<RawUserFollowing>(UserUrls.userFollowingUrl(userId, count, cursor)).then(res => res.data);
|
|
106
|
-
|
|
108
|
+
let res = await this.request<RawUserFollowing>(UserUrls.userFollowingUrl(userId, args.count, args.cursor)).then(res => res.data);
|
|
109
|
+
|
|
107
110
|
// Extracting data
|
|
108
111
|
let data = UserExtractors.extractUserFollow(res);
|
|
109
112
|
|
|
@@ -111,35 +114,38 @@ export class UserService extends FetcherService {
|
|
|
111
114
|
this.cacheData(data);
|
|
112
115
|
|
|
113
116
|
// Parsing data
|
|
114
|
-
let users = data.required.map((item: UserData) =>
|
|
117
|
+
let users = data.required.map((item: UserData) => new User(item));
|
|
115
118
|
|
|
116
|
-
return
|
|
117
|
-
list: users,
|
|
118
|
-
next: { value: data.cursor }
|
|
119
|
-
};
|
|
119
|
+
return new CursoredData<User>(users, data.cursor);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* @param userId The rest id of the target user.
|
|
124
|
-
* @param count The number of followers to fetch.
|
|
124
|
+
* @param count The number of followers to fetch, must be >= 40 (when no cursor is provided) and <=100.
|
|
125
125
|
* @param cursor The cursor to next batch. If blank, first batch is fetched.
|
|
126
|
+
*
|
|
126
127
|
* @returns The list of users following the target user.
|
|
127
|
-
*
|
|
128
|
+
*
|
|
129
|
+
* @throws {@link Errors.AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
130
|
+
* @throws {@link Errors.ValidationErrors.InvalidCount} error, if invalid count has been provided.
|
|
131
|
+
* @throws {@link Errors.DataErrors.UserNotFound} error, if invalid count has been provided.
|
|
132
|
+
*
|
|
133
|
+
* @remarks
|
|
134
|
+
*
|
|
135
|
+
* Cookies are required to use this method!
|
|
128
136
|
*/
|
|
129
|
-
async getUserFollowers(userId: string, count
|
|
137
|
+
async getUserFollowers(userId: string, count?: number, cursor?: string): Promise<CursoredData<User>> {
|
|
130
138
|
// If user is not authenticated, abort
|
|
131
139
|
if (!this.isAuthenticated) {
|
|
132
|
-
throw new Error(
|
|
140
|
+
throw new Error(AuthenticationErrors.NotAuthenticated);
|
|
133
141
|
}
|
|
134
142
|
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
throw new Error(Errors.ValidationErrors.InvalidCount);
|
|
138
|
-
}
|
|
143
|
+
// Objectifying parameters
|
|
144
|
+
let args: UserListArgs = new UserListArgs(count, cursor);
|
|
139
145
|
|
|
140
146
|
// Fetching the raw data
|
|
141
|
-
let res = await this.request<RawUserFollowers>(UserUrls.userFollowersUrl(userId, count, cursor)).then(res => res.data);
|
|
142
|
-
|
|
147
|
+
let res = await this.request<RawUserFollowers>(UserUrls.userFollowersUrl(userId, args.count, args.cursor)).then(res => res.data);
|
|
148
|
+
|
|
143
149
|
// Extracting data
|
|
144
150
|
let data = UserExtractors.extractUserFollow(res);
|
|
145
151
|
|
|
@@ -147,35 +153,36 @@ export class UserService extends FetcherService {
|
|
|
147
153
|
this.cacheData(data);
|
|
148
154
|
|
|
149
155
|
// Parsing data
|
|
150
|
-
let users = data.required.map((item: UserData) =>
|
|
156
|
+
let users = data.required.map((item: UserData) => new User(item));
|
|
151
157
|
|
|
152
|
-
return
|
|
153
|
-
list: users,
|
|
154
|
-
next: { value: data.cursor }
|
|
155
|
-
};
|
|
158
|
+
return new CursoredData<User>(users, data.cursor);
|
|
156
159
|
}
|
|
157
160
|
|
|
158
161
|
/**
|
|
159
162
|
* @param userId The rest id of the target user.
|
|
160
163
|
* @param count The number of likes to fetch.
|
|
161
|
-
* @param cursor The cursor to next batch. If blank, first batch is fetched.
|
|
164
|
+
* @param cursor The cursor to next batch. If blank, first batch is fetched, must be >= 40 (when no cursor is provided) and <=100.
|
|
165
|
+
*
|
|
162
166
|
* @returns The list of tweets liked by the target user.
|
|
163
|
-
*
|
|
167
|
+
*
|
|
168
|
+
* @throws {@link AuthenticationErrors.NotAuthenticated} error, if no cookies have been provided.
|
|
169
|
+
*
|
|
170
|
+
* @remarks
|
|
171
|
+
*
|
|
172
|
+
* Cookies are required to use this method!
|
|
164
173
|
*/
|
|
165
|
-
async getUserLikes(userId: string, count
|
|
174
|
+
async getUserLikes(userId: string, count?: number, cursor?: string): Promise<CursoredData<Tweet>> {
|
|
166
175
|
// If user is not authenticated, abort
|
|
167
176
|
if (!this.isAuthenticated) {
|
|
168
|
-
throw new Error(
|
|
177
|
+
throw new Error(AuthenticationErrors.NotAuthenticated);
|
|
169
178
|
}
|
|
170
179
|
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
throw new Error(Errors.ValidationErrors.InvalidCount);
|
|
174
|
-
}
|
|
180
|
+
// Objectifying parameters
|
|
181
|
+
let args: UserListArgs = new UserListArgs(count, cursor);
|
|
175
182
|
|
|
176
183
|
// Fetching the raw data
|
|
177
|
-
let res = await this.request<RawUserLikes>(UserUrls.userLikesUrl(userId, count, cursor)).then(res => res.data);
|
|
178
|
-
|
|
184
|
+
let res = await this.request<RawUserLikes>(UserUrls.userLikesUrl(userId, args.count, args.cursor)).then(res => res.data);
|
|
185
|
+
|
|
179
186
|
// Extracting data
|
|
180
187
|
let data = UserExtractors.extractUserLikes(res);
|
|
181
188
|
|
|
@@ -183,11 +190,8 @@ export class UserService extends FetcherService {
|
|
|
183
190
|
this.cacheData(data);
|
|
184
191
|
|
|
185
192
|
// Parsing data
|
|
186
|
-
let tweets = data.required.map((item: TweetData) =>
|
|
193
|
+
let tweets = data.required.map((item: TweetData) => new Tweet(item));
|
|
187
194
|
|
|
188
|
-
return
|
|
189
|
-
list: tweets,
|
|
190
|
-
next: { value: data.cursor }
|
|
191
|
-
};
|
|
195
|
+
return new CursoredData<Tweet>(tweets, data.cursor);
|
|
192
196
|
}
|
|
193
197
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// TYPES
|
|
2
|
-
import {
|
|
2
|
+
import { IGuestCredentials, IAuthCredentials } from '../../types/Authentication';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @param authToken The authentication token received from Twitter
|
|
@@ -7,7 +7,7 @@ import { GuestCredentials, AuthCredentials } from '../../types/Authentication';
|
|
|
7
7
|
* @param cookie The cookie associated with the logged in account
|
|
8
8
|
* @returns The header required for making authorized HTTP requests
|
|
9
9
|
*/
|
|
10
|
-
export function authorizedHeader(authCred:
|
|
10
|
+
export function authorizedHeader(authCred: IAuthCredentials): any {
|
|
11
11
|
return [
|
|
12
12
|
`sec-ch-ua: "Not_A Brand";v="99", "Microsoft Edge";v="109", "Chromium";v="109"`,
|
|
13
13
|
`x-twitter-client-language: en`,
|
|
@@ -28,7 +28,7 @@ export function authorizedHeader(authCred: AuthCredentials): any {
|
|
|
28
28
|
* @param guestCred The guest credentials to use
|
|
29
29
|
* @returns The header requred for making guest HTTP requests
|
|
30
30
|
*/
|
|
31
|
-
export function guestHeader(guestCred:
|
|
31
|
+
export function guestHeader(guestCred: IGuestCredentials): any {
|
|
32
32
|
return [
|
|
33
33
|
'Accept: */*',
|
|
34
34
|
`authorization: ${guestCred.authToken}`,
|
|
@@ -42,7 +42,7 @@ export function guestHeader(guestCred: GuestCredentials): any {
|
|
|
42
42
|
* @param cookie The cookie to be used
|
|
43
43
|
* @returns The header for making HTTP request for logging in
|
|
44
44
|
*/
|
|
45
|
-
export function loginHeader(guestCred:
|
|
45
|
+
export function loginHeader(guestCred: IGuestCredentials, cookie: string): any {
|
|
46
46
|
return [
|
|
47
47
|
`sec-ch-ua: "Not_A Brand";v="99", "Microsoft Edge";v="109", "Chromium";v="109"`,
|
|
48
48
|
`x-twitter-client-language: en`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// TYPES
|
|
2
|
-
import {
|
|
2
|
+
import { ITweetFilter } from '../../types/Args';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @returns Whether the given json object is empty or not
|
|
@@ -92,7 +92,7 @@ export function normalizeText(text: string): string {
|
|
|
92
92
|
* @param filter The tweet filter to use for getting filtered tweets
|
|
93
93
|
* @returns The same tweet filter, in a URL query format string
|
|
94
94
|
*/
|
|
95
|
-
export function toQueryString(filter:
|
|
95
|
+
export function toQueryString(filter: ITweetFilter): string {
|
|
96
96
|
// Concatenating the input filter arguments to a URL query formatted string
|
|
97
97
|
return [
|
|
98
98
|
filter.words ? filter.words.join(' ') : '',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// TYPES
|
|
2
|
-
import {
|
|
3
|
-
import { DataErrors } from '../../../
|
|
2
|
+
import { IDataExtract } from '../../../types/Resolvers';
|
|
3
|
+
import { DataErrors } from '../../../enums/Errors';
|
|
4
4
|
import RawTweet from '../../../types/raw/tweet/Tweet';
|
|
5
5
|
import RawTweets from '../../../types/raw/tweet/Tweets';
|
|
6
6
|
import RawRetweeters from '../../../types/raw/tweet/Retweeters';
|
|
@@ -13,7 +13,7 @@ import * as Parsers from '../Parser';
|
|
|
13
13
|
* @returns The raw tweets data formatted and sorted into required and additional data
|
|
14
14
|
* @param res The raw response received from TwitterAPI
|
|
15
15
|
*/
|
|
16
|
-
export function extractTweets(res: RawTweets):
|
|
16
|
+
export function extractTweets(res: RawTweets): IDataExtract {
|
|
17
17
|
let required: any[] = []; // To store the reqruied raw data
|
|
18
18
|
let cursor: string = ''; // To store the cursor to next batch
|
|
19
19
|
let users: any[] = []; // To store additional user data
|
|
@@ -63,7 +63,7 @@ export function extractTweets(res: RawTweets): DataExtract {
|
|
|
63
63
|
* @param res The raw response received from TwitterAPI
|
|
64
64
|
* @param tweetId The rest id of the tweet to fetch
|
|
65
65
|
*/
|
|
66
|
-
export function extractTweet(res: RawTweet, tweetId: string):
|
|
66
|
+
export function extractTweet(res: RawTweet, tweetId: string): IDataExtract {
|
|
67
67
|
let required: any[] = []; // To store the reqruied raw data
|
|
68
68
|
let cursor: string = ''; // To store the cursor to next batch
|
|
69
69
|
let users: any[] = []; // To store additional user data
|
|
@@ -112,7 +112,7 @@ export function extractTweet(res: RawTweet, tweetId: string): DataExtract {
|
|
|
112
112
|
* @returns The raw tweet likers data formatted and sorted into required and additional data
|
|
113
113
|
* @param res The raw response received from TwitterAPI
|
|
114
114
|
*/
|
|
115
|
-
export function extractTweetLikers(res: RawLikers):
|
|
115
|
+
export function extractTweetLikers(res: RawLikers): IDataExtract {
|
|
116
116
|
let required: any[] = []; // To store the reqruied raw data
|
|
117
117
|
let cursor: string = ''; // To store the cursor to next batch
|
|
118
118
|
let users: any[] = []; // To store additional user data
|
|
@@ -152,7 +152,7 @@ export function extractTweetLikers(res: RawLikers): DataExtract {
|
|
|
152
152
|
* @returns The raw tweet retweeters data formatted and sorted into required and additional data
|
|
153
153
|
* @param res The raw response received from TwitterAPI
|
|
154
154
|
*/
|
|
155
|
-
export function extractTweetRetweeters(res: RawRetweeters):
|
|
155
|
+
export function extractTweetRetweeters(res: RawRetweeters): IDataExtract {
|
|
156
156
|
let required: any[] = []; // To store the reqruied raw data
|
|
157
157
|
let cursor: string = ''; // To store the cursor to next batch
|
|
158
158
|
let users: any[] = []; // To store additional user data
|
|
@@ -193,7 +193,7 @@ export function extractTweetRetweeters(res: RawRetweeters): DataExtract {
|
|
|
193
193
|
* @param res The raw response received from TwitterAPI
|
|
194
194
|
* @param tweetId The id of the tweet whose replies must be extracted
|
|
195
195
|
*/
|
|
196
|
-
export function extractTweetReplies(res: RawTweet, tweetId: string):
|
|
196
|
+
export function extractTweetReplies(res: RawTweet, tweetId: string): IDataExtract {
|
|
197
197
|
let required: any[] = []; // To store the reqruied raw data
|
|
198
198
|
let cursor: string = ''; // To store the cursor to next batch
|
|
199
199
|
let users: any[] = []; // To store additional user data
|