glitch-javascript-sdk 0.0.1 → 0.0.3
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/dist/cjs/index.js +55 -186
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Auth.d.ts +34 -2
- package/dist/esm/api/Competitions.d.ts +50 -5
- package/dist/esm/api/Events.d.ts +53 -0
- package/dist/esm/api/Users.d.ts +62 -0
- package/dist/esm/api/index.d.ts +4 -0
- package/dist/esm/index.d.ts +8 -2
- package/dist/esm/index.js +211 -342
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/EventsRoute.d.ts +7 -0
- package/dist/esm/routes/UserRoutes.d.ts +7 -0
- package/dist/esm/util/Requests.d.ts +27 -5
- package/dist/index.d.ts +199 -9
- package/package.json +1 -1
- package/src/api/Auth.ts +38 -3
- package/src/api/Competitions.ts +50 -5
- package/src/api/Events.ts +81 -0
- package/src/api/Users.ts +92 -0
- package/src/api/index.ts +5 -1
- package/src/index.ts +8 -2
- package/src/routes/EventsRoute.ts +33 -0
- package/src/routes/UserRoutes.ts +20 -0
- package/src/util/Requests.ts +46 -31
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
import Config from '../config/Config';
|
|
2
2
|
import Route from '../routes/interface';
|
|
3
3
|
import Response from './Response';
|
|
4
|
+
import { AxiosPromise } from 'axios';
|
|
4
5
|
declare class Requests {
|
|
5
6
|
config: Config;
|
|
6
7
|
private static baseUrl;
|
|
7
8
|
private static authToken;
|
|
8
9
|
constructor(config: Config);
|
|
10
|
+
/**
|
|
11
|
+
* Sets the configuration of the system.
|
|
12
|
+
*
|
|
13
|
+
* @param config Config The config class.
|
|
14
|
+
*/
|
|
9
15
|
static setConfig(config: Config): void;
|
|
16
|
+
/**
|
|
17
|
+
* Sets the base url of the API.
|
|
18
|
+
*
|
|
19
|
+
* @param url The url to of the API.
|
|
20
|
+
*/
|
|
10
21
|
static setBaseUrl(url: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the JSON Web token
|
|
24
|
+
*
|
|
25
|
+
* @param token
|
|
26
|
+
*/
|
|
11
27
|
static setAuthToken(token: string): void;
|
|
12
28
|
private static request;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Calls a GET request to the url endpoint.
|
|
31
|
+
*
|
|
32
|
+
* @param url
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
static get<T>(url: string): AxiosPromise<Response<T>>;
|
|
36
|
+
static post<T>(url: string, data: any): AxiosPromise<Response<T>>;
|
|
37
|
+
static put<T>(url: string, data: any): AxiosPromise<Response<T>>;
|
|
38
|
+
static delete<T>(url: string): AxiosPromise<Response<T>>;
|
|
17
39
|
/**
|
|
18
40
|
* The Route class contains the method and url, thereforce items can be
|
|
19
41
|
* automatically routed depending on the configuration.
|
|
@@ -22,6 +44,6 @@ declare class Requests {
|
|
|
22
44
|
* @param data
|
|
23
45
|
* @returns
|
|
24
46
|
*/
|
|
25
|
-
static processRoute(route: Route, data?: object, routeReplace?: object):
|
|
47
|
+
static processRoute<T>(route: Route, data?: object, routeReplace?: object): AxiosPromise<Response<T>>;
|
|
26
48
|
}
|
|
27
49
|
export default Requests;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AxiosPromise } from 'axios';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Config
|
|
3
5
|
*
|
|
@@ -19,22 +21,210 @@ interface Response<T> {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
declare class Auth {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Attempts to authenticate a user using their email address.
|
|
26
|
+
*
|
|
27
|
+
* @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authLogin
|
|
28
|
+
*
|
|
29
|
+
* @param email The email address of the user
|
|
30
|
+
* @param password The password of the user
|
|
31
|
+
*
|
|
32
|
+
* @returns A promise
|
|
33
|
+
*/
|
|
34
|
+
static loginWithEmail<T>(email: string, password: string): AxiosPromise<Response<T>>;
|
|
35
|
+
/**
|
|
36
|
+
* Attempts to authenticate a user using their username.
|
|
37
|
+
*
|
|
38
|
+
* @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authLogin
|
|
39
|
+
*
|
|
40
|
+
* @param username The username of the user
|
|
41
|
+
* @param password The password of the user
|
|
42
|
+
*
|
|
43
|
+
* @returns A promise
|
|
44
|
+
*/
|
|
45
|
+
static loginWithUsername<T>(username: string, password: string): AxiosPromise<Response<T>>;
|
|
46
|
+
/**
|
|
47
|
+
* Attempts to register a user.
|
|
48
|
+
*
|
|
49
|
+
* @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authRegister
|
|
50
|
+
*
|
|
51
|
+
* @param data The data the user can register with.
|
|
52
|
+
*
|
|
53
|
+
* @returns A promise
|
|
54
|
+
*/
|
|
55
|
+
static register<T>(data: object): AxiosPromise<Response<T>>;
|
|
24
56
|
}
|
|
25
57
|
|
|
26
58
|
declare class Competitions {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
59
|
+
/**
|
|
60
|
+
* List all the competitions
|
|
61
|
+
*
|
|
62
|
+
* @see https://api.glitch.fun/api/documentation#/Competitions%20Route/resourceList
|
|
63
|
+
*
|
|
64
|
+
* @returns promise
|
|
65
|
+
*/
|
|
66
|
+
static list<T>(): AxiosPromise<Response<T>>;
|
|
67
|
+
/**
|
|
68
|
+
* Create a new competition
|
|
69
|
+
*
|
|
70
|
+
* @see https://api.glitch.fun/api/documentation#/Competitions%20Route/newResourceStorage
|
|
71
|
+
*
|
|
72
|
+
* @param data The date to be passed when creating a competiton.
|
|
73
|
+
*
|
|
74
|
+
* @returns Promise
|
|
75
|
+
*/
|
|
76
|
+
static create<T>(data: object): AxiosPromise<Response<T>>;
|
|
77
|
+
/**
|
|
78
|
+
* Update a competition
|
|
79
|
+
*
|
|
80
|
+
* @see https://api.glitch.fun/api/documentation#/Competitions%20Route/updateStorage
|
|
81
|
+
*
|
|
82
|
+
* @param competition_id The id of the competition to update.
|
|
83
|
+
* @param data The data to update.
|
|
84
|
+
*
|
|
85
|
+
* @returns promise
|
|
86
|
+
*/
|
|
87
|
+
static update<T>(competition_id: string, data: object): AxiosPromise<Response<T>>;
|
|
88
|
+
/**
|
|
89
|
+
* Retrieve the information for a single competition.
|
|
90
|
+
*
|
|
91
|
+
* @see https://api.glitch.fun/api/documentation#/Competitions%20Route/showStorage
|
|
92
|
+
*
|
|
93
|
+
* @param competition_id The id fo the competition to retrieve.
|
|
94
|
+
*
|
|
95
|
+
* @returns promise
|
|
96
|
+
*/
|
|
97
|
+
static view<T>(competition_id: string): AxiosPromise<Response<T>>;
|
|
98
|
+
/**
|
|
99
|
+
* Deletes a competition.
|
|
100
|
+
*
|
|
101
|
+
* @see https://api.glitch.fun/api/documentation#/Competitions%20Route/destoryStorage
|
|
102
|
+
*
|
|
103
|
+
* @param competition_id The id of the competition to delete.
|
|
104
|
+
* @returns promise
|
|
105
|
+
*/
|
|
106
|
+
static delete<T>(competition_id: string): AxiosPromise<Response<T>>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
declare class Users {
|
|
110
|
+
/**
|
|
111
|
+
* List all the users.
|
|
112
|
+
*
|
|
113
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/userList
|
|
114
|
+
*
|
|
115
|
+
* @returns promise
|
|
116
|
+
*/
|
|
117
|
+
static list<T>(): AxiosPromise<Response<T>>;
|
|
118
|
+
/**
|
|
119
|
+
* Updates a users information. Requires the users JSON Web Token (JWT) for them to update their profile.
|
|
120
|
+
*
|
|
121
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/updateUser
|
|
122
|
+
*
|
|
123
|
+
* @param data The date to be passed when creating a competiton.
|
|
124
|
+
*
|
|
125
|
+
* @returns Promise
|
|
126
|
+
*/
|
|
127
|
+
static update<T>(data: object): AxiosPromise<Response<T>>;
|
|
128
|
+
/**
|
|
129
|
+
* Gets the current users information based on the current Json Web Token (JWT).
|
|
130
|
+
*
|
|
131
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/showMe
|
|
132
|
+
*
|
|
133
|
+
* @param user_id The id of the user to update.
|
|
134
|
+
* @param data The data to update.
|
|
135
|
+
*
|
|
136
|
+
* @returns promise
|
|
137
|
+
*/
|
|
138
|
+
static me<T>(): AxiosPromise<Response<T>>;
|
|
139
|
+
/**
|
|
140
|
+
* Will follow and unfollow a user. If the user is not being following, it will follow the user. If they are following, it will unfollow the user. The current JWT is used for the follower.
|
|
141
|
+
*
|
|
142
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/userToggleFollow
|
|
143
|
+
*
|
|
144
|
+
* @param user_id The id fo the user to retrieve.
|
|
145
|
+
*
|
|
146
|
+
* @returns promise
|
|
147
|
+
*/
|
|
148
|
+
static followToggle<T>(user_id: string): AxiosPromise<Response<T>>;
|
|
149
|
+
/**
|
|
150
|
+
* Show a users profile.
|
|
151
|
+
*
|
|
152
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/showUser
|
|
153
|
+
*
|
|
154
|
+
* @param user_id The id of the user to delete.
|
|
155
|
+
* @returns promise
|
|
156
|
+
*/
|
|
157
|
+
static profile<T>(user_id: string): AxiosPromise<Response<T>>;
|
|
158
|
+
/**
|
|
159
|
+
* Retrieves a user's one time login token based on a users JWT.
|
|
160
|
+
*
|
|
161
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/userOneTimeLoginToken
|
|
162
|
+
*
|
|
163
|
+
*
|
|
164
|
+
* @returns promise
|
|
165
|
+
*/
|
|
166
|
+
static oneTimeLoginToken<T>(): AxiosPromise<Response<T>>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
declare class Events {
|
|
170
|
+
/**
|
|
171
|
+
* List all the events
|
|
172
|
+
*
|
|
173
|
+
* @see https://api.glitch.fun/api/documentation#/Event%20Route/resourceEventList
|
|
174
|
+
*
|
|
175
|
+
* @returns promise
|
|
176
|
+
*/
|
|
177
|
+
static list<T>(): AxiosPromise<Response<T>>;
|
|
178
|
+
/**
|
|
179
|
+
* Create a new event.
|
|
180
|
+
*
|
|
181
|
+
* @see https://api.glitch.fun/api/documentation#/Event%20Route/newEventResourceStorage
|
|
182
|
+
*
|
|
183
|
+
* @param data The data to be passed when creating an event.
|
|
184
|
+
*
|
|
185
|
+
* @returns Promise
|
|
186
|
+
*/
|
|
187
|
+
static create<T>(data: object): AxiosPromise<Response<T>>;
|
|
188
|
+
/**
|
|
189
|
+
* Update a event
|
|
190
|
+
*
|
|
191
|
+
* @see https://api.glitch.fun/api/documentation#/Event%20Route/updateEventStorage
|
|
192
|
+
*
|
|
193
|
+
* @param event_id The id of the event to update.
|
|
194
|
+
* @param data The data to update.
|
|
195
|
+
*
|
|
196
|
+
* @returns promise
|
|
197
|
+
*/
|
|
198
|
+
static update<T>(event_id: string, data: object): AxiosPromise<Response<T>>;
|
|
199
|
+
/**
|
|
200
|
+
* Retrieve the information for a single event.
|
|
201
|
+
*
|
|
202
|
+
* @see https://api.glitch.fun/api/documentation#/Event%20Route/showEventStorage
|
|
203
|
+
*
|
|
204
|
+
* @param event_id The id fo the event to retrieve.
|
|
205
|
+
*
|
|
206
|
+
* @returns promise
|
|
207
|
+
*/
|
|
208
|
+
static view<T>(event_id: string): AxiosPromise<Response<T>>;
|
|
209
|
+
/**
|
|
210
|
+
* Deletes a event.
|
|
211
|
+
*
|
|
212
|
+
* @see https://api.glitch.fun/api/documentation#/Event%20Route/destoryEventStorage
|
|
213
|
+
*
|
|
214
|
+
* @param event_id The id of the event to delete.
|
|
215
|
+
* @returns promise
|
|
216
|
+
*/
|
|
217
|
+
static delete<T>(event_id: string): AxiosPromise<Response<T>>;
|
|
32
218
|
}
|
|
33
219
|
|
|
34
220
|
declare class Glitch {
|
|
35
221
|
static config: typeof Config;
|
|
36
|
-
static
|
|
37
|
-
|
|
222
|
+
static api: {
|
|
223
|
+
Auth: typeof Auth;
|
|
224
|
+
Competitions: typeof Competitions;
|
|
225
|
+
Users: typeof Users;
|
|
226
|
+
Events: typeof Events;
|
|
227
|
+
};
|
|
38
228
|
}
|
|
39
229
|
|
|
40
230
|
export { Glitch };
|
package/package.json
CHANGED
package/src/api/Auth.ts
CHANGED
|
@@ -1,13 +1,48 @@
|
|
|
1
1
|
import AuthRoutes from "../routes/AuthRoute";
|
|
2
2
|
import Requests from "../util/Requests";
|
|
3
|
+
import Response from "../util/Response";
|
|
4
|
+
import { AxiosPromise } from "axios";
|
|
3
5
|
|
|
4
6
|
class Auth {
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Attempts to authenticate a user using their email address.
|
|
10
|
+
*
|
|
11
|
+
* @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authLogin
|
|
12
|
+
*
|
|
13
|
+
* @param email The email address of the user
|
|
14
|
+
* @param password The password of the user
|
|
15
|
+
*
|
|
16
|
+
* @returns A promise
|
|
17
|
+
*/
|
|
18
|
+
public static loginWithEmail<T>(email: string, password: string) : AxiosPromise<Response<T>> {
|
|
19
|
+
return Requests.post(AuthRoutes.routes.login.url, {email : email, password: password});
|
|
8
20
|
}
|
|
9
21
|
|
|
10
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Attempts to authenticate a user using their username.
|
|
24
|
+
*
|
|
25
|
+
* @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authLogin
|
|
26
|
+
*
|
|
27
|
+
* @param username The username of the user
|
|
28
|
+
* @param password The password of the user
|
|
29
|
+
*
|
|
30
|
+
* @returns A promise
|
|
31
|
+
*/
|
|
32
|
+
public static loginWithUsername<T>(username: string, password: string) : AxiosPromise<Response<T>> {
|
|
33
|
+
return Requests.post(AuthRoutes.routes.login.url, {username : username, password: password});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Attempts to register a user.
|
|
38
|
+
*
|
|
39
|
+
* @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authRegister
|
|
40
|
+
*
|
|
41
|
+
* @param data The data the user can register with.
|
|
42
|
+
*
|
|
43
|
+
* @returns A promise
|
|
44
|
+
*/
|
|
45
|
+
public static register<T>(data : object) : AxiosPromise<Response<T>> {
|
|
11
46
|
return Requests.processRoute(AuthRoutes.routes.register, data);
|
|
12
47
|
}
|
|
13
48
|
}
|
package/src/api/Competitions.ts
CHANGED
|
@@ -1,28 +1,73 @@
|
|
|
1
1
|
import CompetitionRoutes from "../routes/CompetitionRoute";
|
|
2
2
|
import Requests from "../util/Requests";
|
|
3
|
+
import Response from "../util/Response";
|
|
4
|
+
import { AxiosPromise } from "axios";
|
|
3
5
|
|
|
4
6
|
class Competitions {
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
/**
|
|
9
|
+
* List all the competitions
|
|
10
|
+
*
|
|
11
|
+
* @see https://api.glitch.fun/api/documentation#/Competitions%20Route/resourceList
|
|
12
|
+
*
|
|
13
|
+
* @returns promise
|
|
14
|
+
*/
|
|
15
|
+
public static list<T>() : AxiosPromise<Response<T>> {
|
|
7
16
|
return Requests.processRoute(CompetitionRoutes.routes.list);
|
|
8
17
|
}
|
|
9
18
|
|
|
10
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Create a new competition
|
|
21
|
+
*
|
|
22
|
+
* @see https://api.glitch.fun/api/documentation#/Competitions%20Route/newResourceStorage
|
|
23
|
+
*
|
|
24
|
+
* @param data The date to be passed when creating a competiton.
|
|
25
|
+
*
|
|
26
|
+
* @returns Promise
|
|
27
|
+
*/
|
|
28
|
+
public static create<T>(data : object) : AxiosPromise<Response<T>> {
|
|
11
29
|
|
|
12
30
|
return Requests.processRoute(CompetitionRoutes.routes.create, data);
|
|
13
31
|
}
|
|
14
32
|
|
|
15
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Update a competition
|
|
35
|
+
*
|
|
36
|
+
* @see https://api.glitch.fun/api/documentation#/Competitions%20Route/updateStorage
|
|
37
|
+
*
|
|
38
|
+
* @param competition_id The id of the competition to update.
|
|
39
|
+
* @param data The data to update.
|
|
40
|
+
*
|
|
41
|
+
* @returns promise
|
|
42
|
+
*/
|
|
43
|
+
public static update<T>(competition_id : string, data : object) : AxiosPromise<Response<T>>{
|
|
16
44
|
|
|
17
45
|
return Requests.processRoute(CompetitionRoutes.routes.create, data, {competition_id : competition_id});
|
|
18
46
|
}
|
|
19
47
|
|
|
20
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Retrieve the information for a single competition.
|
|
50
|
+
*
|
|
51
|
+
* @see https://api.glitch.fun/api/documentation#/Competitions%20Route/showStorage
|
|
52
|
+
*
|
|
53
|
+
* @param competition_id The id fo the competition to retrieve.
|
|
54
|
+
*
|
|
55
|
+
* @returns promise
|
|
56
|
+
*/
|
|
57
|
+
public static view<T>(competition_id : string) : AxiosPromise<Response<T>> {
|
|
21
58
|
|
|
22
59
|
return Requests.processRoute(CompetitionRoutes.routes.view, {}, {competition_id : competition_id});
|
|
23
60
|
}
|
|
24
61
|
|
|
25
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Deletes a competition.
|
|
64
|
+
*
|
|
65
|
+
* @see https://api.glitch.fun/api/documentation#/Competitions%20Route/destoryStorage
|
|
66
|
+
*
|
|
67
|
+
* @param competition_id The id of the competition to delete.
|
|
68
|
+
* @returns promise
|
|
69
|
+
*/
|
|
70
|
+
public static delete<T>(competition_id : string) : AxiosPromise<Response<T>> {
|
|
26
71
|
|
|
27
72
|
return Requests.processRoute(CompetitionRoutes.routes.delete, {}, {competition_id : competition_id});
|
|
28
73
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import EventsRoutes from "../routes/EventsRoute";
|
|
2
|
+
import Requests from "../util/Requests";
|
|
3
|
+
import Response from "../util/Response";
|
|
4
|
+
import { AxiosPromise } from "axios";
|
|
5
|
+
|
|
6
|
+
class Events {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* List all the events
|
|
10
|
+
*
|
|
11
|
+
* @see https://api.glitch.fun/api/documentation#/Event%20Route/resourceEventList
|
|
12
|
+
*
|
|
13
|
+
* @returns promise
|
|
14
|
+
*/
|
|
15
|
+
public static list<T>() : AxiosPromise<Response<T>> {
|
|
16
|
+
return Requests.processRoute(EventsRoutes.routes.list);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new event.
|
|
21
|
+
*
|
|
22
|
+
* @see https://api.glitch.fun/api/documentation#/Event%20Route/newEventResourceStorage
|
|
23
|
+
*
|
|
24
|
+
* @param data The data to be passed when creating an event.
|
|
25
|
+
*
|
|
26
|
+
* @returns Promise
|
|
27
|
+
*/
|
|
28
|
+
public static create<T>(data : object) : AxiosPromise<Response<T>> {
|
|
29
|
+
|
|
30
|
+
return Requests.processRoute(EventsRoutes.routes.create, data);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Update a event
|
|
35
|
+
*
|
|
36
|
+
* @see https://api.glitch.fun/api/documentation#/Event%20Route/updateEventStorage
|
|
37
|
+
*
|
|
38
|
+
* @param event_id The id of the event to update.
|
|
39
|
+
* @param data The data to update.
|
|
40
|
+
*
|
|
41
|
+
* @returns promise
|
|
42
|
+
*/
|
|
43
|
+
public static update<T>(event_id : string, data : object) : AxiosPromise<Response<T>>{
|
|
44
|
+
|
|
45
|
+
return Requests.processRoute(EventsRoutes.routes.create, data, {event_id : event_id});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Retrieve the information for a single event.
|
|
50
|
+
*
|
|
51
|
+
* @see https://api.glitch.fun/api/documentation#/Event%20Route/showEventStorage
|
|
52
|
+
*
|
|
53
|
+
* @param event_id The id fo the event to retrieve.
|
|
54
|
+
*
|
|
55
|
+
* @returns promise
|
|
56
|
+
*/
|
|
57
|
+
public static view<T>(event_id : string) : AxiosPromise<Response<T>> {
|
|
58
|
+
|
|
59
|
+
return Requests.processRoute(EventsRoutes.routes.view, {}, {event_id : event_id});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Deletes a event.
|
|
64
|
+
*
|
|
65
|
+
* @see https://api.glitch.fun/api/documentation#/Event%20Route/destoryEventStorage
|
|
66
|
+
*
|
|
67
|
+
* @param event_id The id of the event to delete.
|
|
68
|
+
* @returns promise
|
|
69
|
+
*/
|
|
70
|
+
public static delete<T>(event_id : string) : AxiosPromise<Response<T>> {
|
|
71
|
+
|
|
72
|
+
return Requests.processRoute(EventsRoutes.routes.delete, {}, {event_id : event_id});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default Events;
|
package/src/api/Users.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import UserRoutes from "../routes/UserRoutes";
|
|
2
|
+
import Requests from "../util/Requests";
|
|
3
|
+
import Response from "../util/Response";
|
|
4
|
+
import { AxiosPromise } from "axios";
|
|
5
|
+
|
|
6
|
+
class Users {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* List all the users.
|
|
10
|
+
*
|
|
11
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/userList
|
|
12
|
+
*
|
|
13
|
+
* @returns promise
|
|
14
|
+
*/
|
|
15
|
+
public static list<T>(): AxiosPromise<Response<T>> {
|
|
16
|
+
return Requests.processRoute(UserRoutes.routes.list);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Updates a users information. Requires the users JSON Web Token (JWT) for them to update their profile.
|
|
21
|
+
*
|
|
22
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/updateUser
|
|
23
|
+
*
|
|
24
|
+
* @param data The date to be passed when creating a competiton.
|
|
25
|
+
*
|
|
26
|
+
* @returns Promise
|
|
27
|
+
*/
|
|
28
|
+
public static update<T>(data: object): AxiosPromise<Response<T>> {
|
|
29
|
+
|
|
30
|
+
return Requests.processRoute(UserRoutes.routes.update, data);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Gets the current users information based on the current Json Web Token (JWT).
|
|
35
|
+
*
|
|
36
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/showMe
|
|
37
|
+
*
|
|
38
|
+
* @param user_id The id of the user to update.
|
|
39
|
+
* @param data The data to update.
|
|
40
|
+
*
|
|
41
|
+
* @returns promise
|
|
42
|
+
*/
|
|
43
|
+
public static me<T>(): AxiosPromise<Response<T>> {
|
|
44
|
+
|
|
45
|
+
return Requests.processRoute(UserRoutes.routes.me, {});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Will follow and unfollow a user. If the user is not being following, it will follow the user. If they are following, it will unfollow the user. The current JWT is used for the follower.
|
|
50
|
+
*
|
|
51
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/userToggleFollow
|
|
52
|
+
*
|
|
53
|
+
* @param user_id The id fo the user to retrieve.
|
|
54
|
+
*
|
|
55
|
+
* @returns promise
|
|
56
|
+
*/
|
|
57
|
+
public static followToggle<T>(user_id: string): AxiosPromise<Response<T>> {
|
|
58
|
+
|
|
59
|
+
return Requests.processRoute(UserRoutes.routes.follow, {}, { user_id: user_id });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Show a users profile.
|
|
64
|
+
*
|
|
65
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/showUser
|
|
66
|
+
*
|
|
67
|
+
* @param user_id The id of the user to delete.
|
|
68
|
+
* @returns promise
|
|
69
|
+
*/
|
|
70
|
+
public static profile<T>(user_id: string): AxiosPromise<Response<T>> {
|
|
71
|
+
|
|
72
|
+
return Requests.processRoute(UserRoutes.routes.profile, {}, { user_id: user_id });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Retrieves a user's one time login token based on a users JWT.
|
|
77
|
+
*
|
|
78
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/userOneTimeLoginToken
|
|
79
|
+
*
|
|
80
|
+
*
|
|
81
|
+
* @returns promise
|
|
82
|
+
*/
|
|
83
|
+
public static oneTimeLoginToken<T>(): AxiosPromise<Response<T>> {
|
|
84
|
+
|
|
85
|
+
return Requests.processRoute(UserRoutes.routes.oneTimeToken, {});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default Users;
|
package/src/api/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,13 +5,19 @@ import Config from "./config/Config";
|
|
|
5
5
|
//API
|
|
6
6
|
import { Auth } from "./api";
|
|
7
7
|
import { Competitions } from "./api";
|
|
8
|
+
import { Users } from "./api";
|
|
9
|
+
import {Events} from "./api";
|
|
8
10
|
|
|
9
11
|
class Glitch {
|
|
10
12
|
|
|
11
13
|
public static config: typeof Config = Config;
|
|
12
14
|
|
|
13
|
-
public static
|
|
14
|
-
|
|
15
|
+
public static api : {
|
|
16
|
+
Auth : typeof Auth,
|
|
17
|
+
Competitions: typeof Competitions,
|
|
18
|
+
Users: typeof Users
|
|
19
|
+
Events : typeof Events
|
|
20
|
+
}
|
|
15
21
|
|
|
16
22
|
|
|
17
23
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Route from "./interface";
|
|
2
|
+
import HTTP_METHODS from "../constants/HttpMethods";
|
|
3
|
+
|
|
4
|
+
class EventsRoutes {
|
|
5
|
+
|
|
6
|
+
public static routes: { [key: string]: Route } = {
|
|
7
|
+
list: { url: '/events', method: HTTP_METHODS.GET },
|
|
8
|
+
create: { url: '/events', method: HTTP_METHODS.POST },
|
|
9
|
+
view : { url: '/events/{event_id}', method: HTTP_METHODS.GET },
|
|
10
|
+
update :{ url: '/events/{event_id}', method: HTTP_METHODS.PUT },
|
|
11
|
+
delete : { url: '/events/{event_id}', method: HTTP_METHODS.DELETE },
|
|
12
|
+
updateInvirtu : {url : '/events/{uuid}/invirtu', method: HTTP_METHODS.PUT },
|
|
13
|
+
updateRTMPSource : {url : '/events/{uuid}/updateRTMPSource/{subid}', method: HTTP_METHODS.PUT },
|
|
14
|
+
removeRTMPSource : {url : '/events/{uuid}/removeRTMPSource/{subid}', method: HTTP_METHODS.DELETE},
|
|
15
|
+
uploadMainImage : {url : '/events/{uuid}/removeRTMPSource/{subid}', method: HTTP_METHODS.POST},
|
|
16
|
+
uploadBannerImage : {url : '/events/{uuid}/uploadBannerImage', method: HTTP_METHODS.POST},
|
|
17
|
+
enableBroadcastMode : {url : '/events/{uuid}/uploadBannerImage', method: HTTP_METHODS.POST},
|
|
18
|
+
enableLiestreamMode : {url : '/events/{uuid}/enableLivestreamMode', method: HTTP_METHODS.POST},
|
|
19
|
+
sendOnScreenContent : {url : '/events/{uuid}/sendOnScreenContent', method: HTTP_METHODS.POST},
|
|
20
|
+
addOveleray : {url : '/events/{uuid}/addOverlay', method : HTTP_METHODS.POST},
|
|
21
|
+
removeOverlay : {url : '/events/{uuid}/removeOverlay/{subid}', method : HTTP_METHODS.DELETE},
|
|
22
|
+
enableOverlay : {url : '/events/{uuid}/enableOverlay/{subid}', method : HTTP_METHODS.POST},
|
|
23
|
+
disableOverlay : {url : '/events/{uuid}/disableOverlay', method: HTTP_METHODS.POST},
|
|
24
|
+
enableDonations : {url : '/events/{uuid}/enableDonations', method: HTTP_METHODS.POST},
|
|
25
|
+
disableDonations : {url : '/events/{uuid}/disableDonations', method : HTTP_METHODS.POST},
|
|
26
|
+
sendInvite : {url : '/events/{uuid}/sendInvite', method : HTTP_METHODS.POST},
|
|
27
|
+
acceptInvite : {url : '/events/{uuid}/sendInvite', method : HTTP_METHODS.POST}
|
|
28
|
+
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default EventsRoutes;
|