glitch-javascript-sdk 0.0.2 → 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 +0 -136
- package/dist/cjs/index.js.map +1 -1
- 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 +164 -318
- 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/index.d.ts +117 -2
- package/package.json +1 -1
- 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/dist/index.d.ts
CHANGED
|
@@ -106,10 +106,125 @@ declare class Competitions {
|
|
|
106
106
|
static delete<T>(competition_id: string): AxiosPromise<Response<T>>;
|
|
107
107
|
}
|
|
108
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>>;
|
|
218
|
+
}
|
|
219
|
+
|
|
109
220
|
declare class Glitch {
|
|
110
221
|
static config: typeof Config;
|
|
111
|
-
static
|
|
112
|
-
|
|
222
|
+
static api: {
|
|
223
|
+
Auth: typeof Auth;
|
|
224
|
+
Competitions: typeof Competitions;
|
|
225
|
+
Users: typeof Users;
|
|
226
|
+
Events: typeof Events;
|
|
227
|
+
};
|
|
113
228
|
}
|
|
114
229
|
|
|
115
230
|
export { Glitch };
|
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Route from "./interface";
|
|
2
|
+
import HTTP_METHODS from "../constants/HttpMethods";
|
|
3
|
+
|
|
4
|
+
class UserRoutes {
|
|
5
|
+
|
|
6
|
+
public static routes: { [key: string]: Route } = {
|
|
7
|
+
list: { url: '/users', method: HTTP_METHODS.GET },
|
|
8
|
+
update: { url: '/users', method: HTTP_METHODS.PUT },
|
|
9
|
+
follow : { url: '/users/{user_id}/follow', method: HTTP_METHODS.POST },
|
|
10
|
+
profile :{ url: '/users/{uuid}/profile', method: HTTP_METHODS.GET },
|
|
11
|
+
me : { url: '/users/me', method: HTTP_METHODS.GET },
|
|
12
|
+
oneTimeToken : { url: '/users/oneTimeToken', method: HTTP_METHODS.GET },
|
|
13
|
+
uploadAvatar : { url: '/users/uploadAvatarImage', method: HTTP_METHODS.POST },
|
|
14
|
+
uploadBanner : { url: '/users/uploadBannerImage', method: HTTP_METHODS.POST },
|
|
15
|
+
createDonationPage : { url: '/users/createDonationPage', method: HTTP_METHODS.POST },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default UserRoutes;
|