glitch-javascript-sdk 0.2.0 → 0.2.2
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 +409 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Communities.d.ts +201 -0
- package/dist/esm/api/Templates.d.ts +97 -0
- package/dist/esm/api/index.d.ts +4 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +409 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/CommunitiesRoute.d.ts +7 -0
- package/dist/esm/routes/TemplatesRoute.d.ts +7 -0
- package/dist/index.d.ts +296 -0
- package/package.json +1 -1
- package/src/api/Communities.ts +290 -0
- package/src/api/Templates.ts +145 -0
- package/src/api/index.ts +5 -1
- package/src/index.ts +4 -0
- package/src/routes/CommunitiesRoute.ts +27 -0
- package/src/routes/TemplatesRoute.ts +18 -0
- package/src/util/Requests.ts +2 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import TemplatesRoute from "../routes/TemplatesRoute";
|
|
2
|
+
import Requests from "../util/Requests";
|
|
3
|
+
import Response from "../util/Response";
|
|
4
|
+
import { AxiosPromise } from "axios";
|
|
5
|
+
|
|
6
|
+
class Templates {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* List all the templates.
|
|
10
|
+
*
|
|
11
|
+
* @see https://api.glitch.fun/api/documentation#/Template%20Route/resourceTemplateList
|
|
12
|
+
*
|
|
13
|
+
* @returns promise
|
|
14
|
+
*/
|
|
15
|
+
public static list<T>() : AxiosPromise<Response<T>> {
|
|
16
|
+
return Requests.processRoute(TemplatesRoute.routes.list);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new template.
|
|
21
|
+
*
|
|
22
|
+
* @see https://api.glitch.fun/api/documentation#/Template%20Route/newTemplateResourceStorage
|
|
23
|
+
*
|
|
24
|
+
* @param data The data to be passed when creating a template.
|
|
25
|
+
*
|
|
26
|
+
* @returns Promise
|
|
27
|
+
*/
|
|
28
|
+
public static create<T>(data : object) : AxiosPromise<Response<T>> {
|
|
29
|
+
|
|
30
|
+
return Requests.processRoute(TemplatesRoute.routes.create, data);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Update a template.
|
|
35
|
+
*
|
|
36
|
+
* @see https://api.glitch.fun/api/documentation#/Template%20Route/updateTemplateStorage
|
|
37
|
+
*
|
|
38
|
+
* @param template_id The id of the template to update.
|
|
39
|
+
* @param data The data to update.
|
|
40
|
+
*
|
|
41
|
+
* @returns promise
|
|
42
|
+
*/
|
|
43
|
+
public static update<T>(template_id : string, data : object) : AxiosPromise<Response<T>>{
|
|
44
|
+
|
|
45
|
+
return Requests.processRoute(TemplatesRoute.routes.create, data, {template_id : template_id});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Retrieve the information for a single template.
|
|
50
|
+
*
|
|
51
|
+
* @see https://api.glitch.fun/api/documentation#/Template%20Route/showTemplateStorage
|
|
52
|
+
*
|
|
53
|
+
* @param template_id The id fo the template to retrieve.
|
|
54
|
+
*
|
|
55
|
+
* @returns promise
|
|
56
|
+
*/
|
|
57
|
+
public static view<T>(template_id : string) : AxiosPromise<Response<T>> {
|
|
58
|
+
|
|
59
|
+
return Requests.processRoute(TemplatesRoute.routes.view, {}, {template_id : template_id});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Deletes a template.
|
|
64
|
+
*
|
|
65
|
+
* @see https://api.glitch.fun/api/documentation#/Template%20Route/destoryTemplateStorage
|
|
66
|
+
*
|
|
67
|
+
* @param template_id The id of the template to delete.
|
|
68
|
+
* @returns promise
|
|
69
|
+
*/
|
|
70
|
+
public static delete<T>(template_id : string) : AxiosPromise<Response<T>> {
|
|
71
|
+
|
|
72
|
+
return Requests.processRoute(TemplatesRoute.routes.delete, {}, {template_id : template_id});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Updates the logo for the template using a File object.
|
|
77
|
+
*
|
|
78
|
+
* @see https://api.glitch.fun/api/documentation#/Template%20Route/uploadLogoTemplateImage
|
|
79
|
+
*
|
|
80
|
+
* @param file The file object to upload.
|
|
81
|
+
* @param data Any additional data to pass along to the upload.
|
|
82
|
+
*
|
|
83
|
+
* @returns promise
|
|
84
|
+
*/
|
|
85
|
+
public static uploadLogoFile<T>(template_id: string, file : File, data? : object): AxiosPromise<Response<T>> {
|
|
86
|
+
|
|
87
|
+
let url = TemplatesRoute.routes.uploadLogo.url.replace('{template_id}', template_id);
|
|
88
|
+
|
|
89
|
+
return Requests.uploadFile(url, 'image', file, data);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Updates the logo for the template using a Blob.
|
|
94
|
+
*
|
|
95
|
+
* @see https://api.glitch.fun/api/documentation#/Template%20Route/uploadLogoTemplateImage
|
|
96
|
+
*
|
|
97
|
+
* @param blob The blob to upload.
|
|
98
|
+
* @param data Any additional data to pass along to the upload
|
|
99
|
+
*
|
|
100
|
+
* @returns promise
|
|
101
|
+
*/
|
|
102
|
+
public static uploadLogoBlob<T>(template_id: string, blob : Blob, data? : object): AxiosPromise<Response<T>> {
|
|
103
|
+
|
|
104
|
+
let url = TemplatesRoute.routes.uploadLogo.url.replace('{template_id}', template_id);
|
|
105
|
+
|
|
106
|
+
return Requests.uploadBlob(url, 'image', blob, data);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Updates the main image for the template using a File object.
|
|
111
|
+
*
|
|
112
|
+
* @see https://api.glitch.fun/api/documentation#/Template%20Route/uploadMainTemplateImage
|
|
113
|
+
*
|
|
114
|
+
* @param file The file object to upload.
|
|
115
|
+
* @param data Any additional data to pass along to the upload.
|
|
116
|
+
*
|
|
117
|
+
* @returns promise
|
|
118
|
+
*/
|
|
119
|
+
public static uploadMainImageFile<T>(template_id: string, file : File, data? : object): AxiosPromise<Response<T>> {
|
|
120
|
+
|
|
121
|
+
let url = TemplatesRoute.routes.uploadMainImage.url.replace('{template_id}', template_id);
|
|
122
|
+
|
|
123
|
+
return Requests.uploadFile(url, 'image', file, data);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Updates the main image for the template using a Blob.
|
|
128
|
+
*
|
|
129
|
+
* @see https://api.glitch.fun/api/documentation#/Template%20Route/uploadMainTemplateImage
|
|
130
|
+
*
|
|
131
|
+
* @param blob The blob to upload.
|
|
132
|
+
* @param data Any additional data to pass along to the upload
|
|
133
|
+
*
|
|
134
|
+
* @returns promise
|
|
135
|
+
*/
|
|
136
|
+
public static uploadMainImageBlob<T>(template_id: string, blob : Blob, data? : object): AxiosPromise<Response<T>> {
|
|
137
|
+
|
|
138
|
+
let url = TemplatesRoute.routes.uploadMainImage.url.replace('{template_id}', template_id);
|
|
139
|
+
|
|
140
|
+
return Requests.uploadBlob(url, 'image', blob, data);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export default Templates;
|
package/src/api/index.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import Auth from "./Auth";
|
|
2
2
|
import Competitions from "./Competitions";
|
|
3
|
+
import Communities from "./Communities";
|
|
3
4
|
import Users from "./Users";
|
|
4
5
|
import Events from "./Events";
|
|
5
6
|
import Teams from "./Teams";
|
|
6
7
|
import Waitlists from "./Waitlist";
|
|
8
|
+
import Templates from "./Templates";
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
export {Auth};
|
|
10
12
|
export {Competitions};
|
|
13
|
+
export {Communities};
|
|
11
14
|
export {Users};
|
|
12
15
|
export {Events};
|
|
13
16
|
export {Teams};
|
|
14
|
-
export {Waitlists}
|
|
17
|
+
export {Waitlists};
|
|
18
|
+
export {Templates};
|
package/src/index.ts
CHANGED
|
@@ -5,9 +5,11 @@ import { Config } from "./config";
|
|
|
5
5
|
//API
|
|
6
6
|
import Auth from "./api/Auth";
|
|
7
7
|
import Competitions from "./api/Competitions";
|
|
8
|
+
import {Communities} from "./api";
|
|
8
9
|
import { Users } from "./api";
|
|
9
10
|
import { Events } from "./api";
|
|
10
11
|
import { Teams } from "./api";
|
|
12
|
+
import {Templates} from "./api";
|
|
11
13
|
import { Waitlists } from "./api";
|
|
12
14
|
|
|
13
15
|
import Requests from "./util/Requests";
|
|
@@ -36,9 +38,11 @@ class Glitch {
|
|
|
36
38
|
public static api = {
|
|
37
39
|
Auth: Auth,
|
|
38
40
|
Competitions: Competitions,
|
|
41
|
+
Communities : Communities,
|
|
39
42
|
Users: Users,
|
|
40
43
|
Events: Events,
|
|
41
44
|
Teams: Teams,
|
|
45
|
+
Templates : Templates,
|
|
42
46
|
Waitlists: Waitlists
|
|
43
47
|
}
|
|
44
48
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Route from "./interface";
|
|
2
|
+
import HTTP_METHODS from "../constants/HttpMethods";
|
|
3
|
+
|
|
4
|
+
class CommunitiesRoute {
|
|
5
|
+
|
|
6
|
+
public static routes: { [key: string]: Route } = {
|
|
7
|
+
list: { url: '/communities', method: HTTP_METHODS.GET },
|
|
8
|
+
create: { url: '/communities', method: HTTP_METHODS.POST },
|
|
9
|
+
view : { url: '/communities/{community_id}', method: HTTP_METHODS.GET },
|
|
10
|
+
update :{ url: '/communities/{community_id}', method: HTTP_METHODS.PUT },
|
|
11
|
+
delete : { url: '/communities/{community_id}', method: HTTP_METHODS.DELETE },
|
|
12
|
+
uploadLogo : {url: '/communities/{community_id}/uploadLogo', method : HTTP_METHODS.POST },
|
|
13
|
+
uploadBannerImage : {url : '/communities/{community_id}/uploadBannerImage', method : HTTP_METHODS.POST },
|
|
14
|
+
uploadVideoLogo : {url : '/communities/{community_id}/uploadVideoLogo', method : HTTP_METHODS.POST },
|
|
15
|
+
listInvites : {url : '/communities/{community_id}/invites', method : HTTP_METHODS.GET },
|
|
16
|
+
sendInvite : {url: '/communities/{community_id}/sendInvite', method : HTTP_METHODS.POST},
|
|
17
|
+
acceptInvite : {url : '/communities/{community_id}/acceptInvite', method: HTTP_METHODS.POST},
|
|
18
|
+
listUsers : {url : '/communities/{community_id}/users', method : HTTP_METHODS.GET},
|
|
19
|
+
addUser : {url : '/communities/{community_id}/users', method : HTTP_METHODS.POST},
|
|
20
|
+
showUser : {url : '/communities/{community_id}/users/{user_id}', method : HTTP_METHODS.GET},
|
|
21
|
+
updateUser : {url : '/communities/{community_id}/users/{user_id}', method : HTTP_METHODS.PUT},
|
|
22
|
+
removeUser : {url : '/communities/{community_id}/users/{user_id}', method : HTTP_METHODS.DELETE}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default CommunitiesRoute;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Route from "./interface";
|
|
2
|
+
import HTTP_METHODS from "../constants/HttpMethods";
|
|
3
|
+
|
|
4
|
+
class TemplatesRoute {
|
|
5
|
+
|
|
6
|
+
public static routes: { [key: string]: Route } = {
|
|
7
|
+
list: { url: '/templates', method: HTTP_METHODS.GET },
|
|
8
|
+
create: { url: '/templates', method: HTTP_METHODS.POST },
|
|
9
|
+
view : { url: '/templates/{template_id}', method: HTTP_METHODS.GET },
|
|
10
|
+
update :{ url: '/templates/{template_id}', method: HTTP_METHODS.PUT },
|
|
11
|
+
delete : { url: '/templates/{template_id}', method: HTTP_METHODS.DELETE },
|
|
12
|
+
uploadLogo : {url: '/templates/{template_id}/uploadLogo', method : HTTP_METHODS.POST },
|
|
13
|
+
uploadMainImage : {url : '/templates/{template_id}/uploadMainImage', method : HTTP_METHODS.POST },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default TemplatesRoute;
|