/
Rettiwt.ts
70 lines (65 loc) · 2.08 KB
/
Rettiwt.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// SERVICES
import { AuthService } from './services/public/AuthService';
import { TweetService } from './services/public/TweetService';
import { UserService } from './services/public/UserService';
// TYPES
import { IRettiwtConfig } from './types/RettiwtConfig';
/**
* The class for accessing Twitter API.
*
* The created Rettiwt instance can be configured by passing in a configuration object to the constructor.
*
* For details regarding the available configuration options, refer to {@link IRettiwtConfig}
*
* @example Creating a Rettiwt instance with 'guest' authentication:
* ```
* import { Rettiwt } from 'rettiwt-api';
*
* // Creating a new Rettiwt instance
* const rettiwt = new Rettiwt();
* ```
*
* @example Creating a Rettiwt instance with 'guest' authentication, using a pre-generated guest key:
* ```
* import { Rettiwt } from 'rettiwt-api';
*
* // Creating a new Rettiwt instance
* const rettiwt = new Rettiwt({ guestKey: 'GUEST_KEY' });
* ```
*
* @example Creating a Rettiwt instance with 'user' authentication:
* ```
* import { Rettiwt } from 'rettiwt-api';
*
* // Creating a new Rettiwt instance
* const rettiwt = new Rettiwt({ apiKey: 'API_KEY' });
* ```
*
* @example Creating a Rettiwt instance with 'user'authentication, along with enabling debug logs and using a proxy:
* ```
* import { Rettiwt } from 'rettiwt-api';
*
* // Creating a new Rettiwt instance
* const rettiwt = new Rettiwt({ apiKey: 'API_KEY', logging: true, proxyUrl: 'URL_TO_PROXY_SERVER' });
* ```
*
* @public
*/
export class Rettiwt {
/** The instance used to authenticate. */
public auth: AuthService;
/** The instance used to fetch data related to tweets. */
public tweet: TweetService;
/** The instance used to fetch data related to users. */
public user: UserService;
/**
* Initializes a new Rettiwt instance using the given api key.
*
* @param config - The config object for configuring the Rettiwt instance.
*/
public constructor(config?: IRettiwtConfig) {
this.auth = new AuthService(config);
this.tweet = new TweetService(config);
this.user = new UserService(config);
}
}