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/esm/index.js CHANGED
@@ -29847,10 +29847,10 @@ var Requests = /** @class */ (function () {
29847
29847
  headers['Content-Type'] = 'multipart/form-data';
29848
29848
  }
29849
29849
  var uri = "".concat(this.baseUrl).concat(url);
29850
- var validUri = uri.replace(/\/\//g, '/');
29851
29850
  var axiosPromise = axios({
29852
29851
  method: method,
29853
- url: validUri,
29852
+ url: uri,
29853
+ baseURL: this.baseUrl,
29854
29854
  data: fileData || data,
29855
29855
  headers: headers,
29856
29856
  });
@@ -30697,6 +30697,276 @@ var Competitions = /** @class */ (function () {
30697
30697
  return Competitions;
30698
30698
  }());
30699
30699
 
30700
+ var CommunitiesRoute = /** @class */ (function () {
30701
+ function CommunitiesRoute() {
30702
+ }
30703
+ CommunitiesRoute.routes = {
30704
+ list: { url: '/communities', method: HTTP_METHODS.GET },
30705
+ create: { url: '/communities', method: HTTP_METHODS.POST },
30706
+ view: { url: '/communities/{community_id}', method: HTTP_METHODS.GET },
30707
+ update: { url: '/communities/{community_id}', method: HTTP_METHODS.PUT },
30708
+ delete: { url: '/communities/{community_id}', method: HTTP_METHODS.DELETE },
30709
+ uploadLogo: { url: '/communities/{community_id}/uploadLogo', method: HTTP_METHODS.POST },
30710
+ uploadBannerImage: { url: '/communities/{community_id}/uploadBannerImage', method: HTTP_METHODS.POST },
30711
+ uploadVideoLogo: { url: '/communities/{community_id}/uploadVideoLogo', method: HTTP_METHODS.POST },
30712
+ listInvites: { url: '/communities/{community_id}/invites', method: HTTP_METHODS.GET },
30713
+ sendInvite: { url: '/communities/{community_id}/sendInvite', method: HTTP_METHODS.POST },
30714
+ acceptInvite: { url: '/communities/{community_id}/acceptInvite', method: HTTP_METHODS.POST },
30715
+ listUsers: { url: '/communities/{community_id}/users', method: HTTP_METHODS.GET },
30716
+ addUser: { url: '/communities/{community_id}/users', method: HTTP_METHODS.POST },
30717
+ showUser: { url: '/communities/{community_id}/users/{user_id}', method: HTTP_METHODS.GET },
30718
+ updateUser: { url: '/communities/{community_id}/users/{user_id}', method: HTTP_METHODS.PUT },
30719
+ removeUser: { url: '/communities/{community_id}/users/{user_id}', method: HTTP_METHODS.DELETE }
30720
+ };
30721
+ return CommunitiesRoute;
30722
+ }());
30723
+
30724
+ var Communities = /** @class */ (function () {
30725
+ function Communities() {
30726
+ }
30727
+ /**
30728
+ * List all the communities.
30729
+ *
30730
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/resourceCommunityList
30731
+ *
30732
+ * @returns promise
30733
+ */
30734
+ Communities.list = function () {
30735
+ return Requests.processRoute(CommunitiesRoute.routes.list);
30736
+ };
30737
+ /**
30738
+ * Create a new community.
30739
+ *
30740
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/newCommunityResourceStorage
30741
+ *
30742
+ * @param data The data to be passed when creating a community.
30743
+ *
30744
+ * @returns Promise
30745
+ */
30746
+ Communities.create = function (data) {
30747
+ return Requests.processRoute(CommunitiesRoute.routes.create, data);
30748
+ };
30749
+ /**
30750
+ * Update a community.
30751
+ *
30752
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/updateCommunityStorage
30753
+ *
30754
+ * @param community_id The id of the community to update.
30755
+ * @param data The data to update.
30756
+ *
30757
+ * @returns promise
30758
+ */
30759
+ Communities.update = function (community_id, data) {
30760
+ return Requests.processRoute(CommunitiesRoute.routes.create, data, { community_id: community_id });
30761
+ };
30762
+ /**
30763
+ * Retrieve the information for a single community.
30764
+ *
30765
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/showCommunityStorage
30766
+ *
30767
+ * @param community_id The id fo the community to retrieve.
30768
+ *
30769
+ * @returns promise
30770
+ */
30771
+ Communities.view = function (community_id) {
30772
+ return Requests.processRoute(CommunitiesRoute.routes.view, {}, { community_id: community_id });
30773
+ };
30774
+ /**
30775
+ * Deletes a community.
30776
+ *
30777
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/destoryCommunityStorage
30778
+ *
30779
+ * @param community_id The id of the community to delete.
30780
+ * @returns promise
30781
+ */
30782
+ Communities.delete = function (community_id) {
30783
+ return Requests.processRoute(CommunitiesRoute.routes.delete, {}, { community_id: community_id });
30784
+ };
30785
+ /**
30786
+ * Updates the main image for the community using a File object.
30787
+ *
30788
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/uploadLogoCommunityImage
30789
+ *
30790
+ * @param file The file object to upload.
30791
+ * @param data Any additional data to pass along to the upload.
30792
+ *
30793
+ * @returns promise
30794
+ */
30795
+ Communities.uploadLogoFile = function (community_id, file, data) {
30796
+ var url = CommunitiesRoute.routes.uploadLogo.url.replace('{community_id}', community_id);
30797
+ return Requests.uploadFile(url, 'image', file, data);
30798
+ };
30799
+ /**
30800
+ * Updates the main image for the community using a Blob.
30801
+ *
30802
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/uploadLogoCommunityImage
30803
+ *
30804
+ * @param blob The blob to upload.
30805
+ * @param data Any additional data to pass along to the upload
30806
+ *
30807
+ * @returns promise
30808
+ */
30809
+ Communities.uploadLogoBlob = function (community_id, blob, data) {
30810
+ var url = CommunitiesRoute.routes.uploadLogo.url.replace('{community_id}', community_id);
30811
+ return Requests.uploadBlob(url, 'image', blob, data);
30812
+ };
30813
+ /**
30814
+ * Updates the banner image for the community using a File object.
30815
+ *
30816
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/uploadBannerCommunityImage
30817
+ *
30818
+ * @param file The file object to upload.
30819
+ * @param data Any additional data to pass along to the upload.
30820
+ *
30821
+ * @returns promise
30822
+ */
30823
+ Communities.uploadBannerImageFile = function (community_id, file, data) {
30824
+ var url = CommunitiesRoute.routes.uploadBannerImage.url.replace('{community_id}', community_id);
30825
+ return Requests.uploadFile(url, 'image', file, data);
30826
+ };
30827
+ /**
30828
+ * Updates the banner image for the community using a Blob.
30829
+ *
30830
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/uploadBannerCommunityImage
30831
+ *
30832
+ * @param blob The blob to upload.
30833
+ * @param data Any additional data to pass along to the upload
30834
+ *
30835
+ * @returns promise
30836
+ */
30837
+ Communities.uploadBannerImageBlob = function (community_id, blob, data) {
30838
+ var url = CommunitiesRoute.routes.uploadBannerImage.url.replace('{community_id}', community_id);
30839
+ return Requests.uploadBlob(url, 'image', blob, data);
30840
+ };
30841
+ /**
30842
+ * Updates the banner image for the community using a File object.
30843
+ *
30844
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/uploadBannerCommunityImage
30845
+ *
30846
+ * @param file The file object to upload.
30847
+ * @param data Any additional data to pass along to the upload.
30848
+ *
30849
+ * @returns promise
30850
+ */
30851
+ Communities.uploadVideoLogoFile = function (community_id, file, data) {
30852
+ var url = CommunitiesRoute.routes.uploadVideoLogo.url.replace('{community_id}', community_id);
30853
+ return Requests.uploadFile(url, 'image', file, data);
30854
+ };
30855
+ /**
30856
+ * Updates the banner image for the community using a Blob.
30857
+ *
30858
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/uploadBannerCommunityImage
30859
+ *
30860
+ * @param blob The blob to upload.
30861
+ * @param data Any additional data to pass along to the upload
30862
+ *
30863
+ * @returns promise
30864
+ */
30865
+ Communities.uploadVideoLogoBlob = function (community_id, blob, data) {
30866
+ var url = CommunitiesRoute.routes.uploadVideoLogo.url.replace('{community_id}', community_id);
30867
+ return Requests.uploadBlob(url, 'image', blob, data);
30868
+ };
30869
+ /**
30870
+ * List the invites that have been sent for the community to users.
30871
+ *
30872
+ * @see https://api.glitch.fun/api/documentation#/communitys%20Route/communitysUserInviteList
30873
+ *
30874
+ * @param community_id The id of the community
30875
+ *
30876
+ * @returns promise
30877
+ */
30878
+ Communities.listInvites = function (community_id) {
30879
+ return Requests.processRoute(CommunitiesRoute.routes.listInvites, {}, { community_id: community_id });
30880
+ };
30881
+ /**
30882
+ * Send an invitation to a user to join the community.
30883
+ *
30884
+ * @see https://api.glitch.fun/api/documentation#/communitys%20Route/communitySendInvite
30885
+ *
30886
+ * @param community_id The id of the community.
30887
+ * @param data The data that will be passed into sending an invite.
30888
+ *
30889
+ * @returns promise
30890
+ */
30891
+ Communities.sendInvite = function (community_id, data) {
30892
+ return Requests.processRoute(CommunitiesRoute.routes.sendInvite, data, { community_id: community_id });
30893
+ };
30894
+ /**
30895
+ * Accept an invite to a community. The JSON Web Token (JWT) must be related to the token.
30896
+ *
30897
+ * @see https://api.glitch.fun/api/documentation#/communitys%20Route/communityAcceptInvite
30898
+ *
30899
+ * @param community_id The id of the community
30900
+ * @param token The token required to accept the user.
30901
+ *
30902
+ * @returns promise
30903
+ */
30904
+ Communities.acceptInvite = function (community_id, token) {
30905
+ return Requests.processRoute(CommunitiesRoute.routes.acceptInvite, {}, { community_id: community_id });
30906
+ };
30907
+ /**
30908
+ * List the users who are currently associated with the community.
30909
+ *
30910
+ * @see https://api.glitch.fun/api/documentation#/communitys%20Route/communityUserList
30911
+ *
30912
+ * @param community_id The id of the community.
30913
+ *
30914
+ * @returns promise
30915
+ */
30916
+ Communities.listUsers = function (community_id) {
30917
+ return Requests.processRoute(CommunitiesRoute.routes.listUsers, {}, { community_id: community_id });
30918
+ };
30919
+ /**
30920
+ * Add a user to a community.
30921
+ *
30922
+ * @see https://api.glitch.fun/api/documentation#/communitys%20Route/createcommunityUser
30923
+ *
30924
+ * @param community_id The id of the community.
30925
+ * @param data The data to be passed when adding a user.
30926
+ *
30927
+ * @returns promise
30928
+ */
30929
+ Communities.addUser = function (community_id, data) {
30930
+ return Requests.processRoute(CommunitiesRoute.routes.addUser, data, { community_id: community_id });
30931
+ };
30932
+ /**
30933
+ * Retrieves a single user and their information that is associated with a community.
30934
+ *
30935
+ * @see https://api.glitch.fun/api/documentation#/communitys%20Route/showcommunityUser
30936
+ *
30937
+ * @param community_id The id of the community.
30938
+ * @param user_id The id of the user.
30939
+ *
30940
+ * @returns promise
30941
+ */
30942
+ Communities.getUser = function (community_id, user_id) {
30943
+ return Requests.processRoute(CommunitiesRoute.routes.showUser, {}, { community_id: community_id, user_id: user_id });
30944
+ };
30945
+ /**
30946
+ * Updates the users information associated with the community.
30947
+ *
30948
+ * @param community_id The id of the community.
30949
+ * @param user_id The id of the user.
30950
+ *
30951
+ * @returns promise
30952
+ */
30953
+ Communities.updatetUser = function (community_id, user_id, data) {
30954
+ return Requests.processRoute(CommunitiesRoute.routes.updateUser, data, { community_id: community_id, user_id: user_id });
30955
+ };
30956
+ /**
30957
+ * Removes a user from a community.
30958
+ *
30959
+ * @param community_id The id of community.
30960
+ * @param user_id The id of the user.
30961
+ *
30962
+ * @returns promise
30963
+ */
30964
+ Communities.removetUser = function (community_id, user_id) {
30965
+ return Requests.processRoute(CommunitiesRoute.routes.removeUser, {}, { community_id: community_id, user_id: user_id });
30966
+ };
30967
+ return Communities;
30968
+ }());
30969
+
30700
30970
  var UserRoutes = /** @class */ (function () {
30701
30971
  function UserRoutes() {
30702
30972
  }
@@ -31518,6 +31788,141 @@ var Waitlists = /** @class */ (function () {
31518
31788
  return Waitlists;
31519
31789
  }());
31520
31790
 
31791
+ var TemplatesRoute = /** @class */ (function () {
31792
+ function TemplatesRoute() {
31793
+ }
31794
+ TemplatesRoute.routes = {
31795
+ list: { url: '/templates', method: HTTP_METHODS.GET },
31796
+ create: { url: '/templates', method: HTTP_METHODS.POST },
31797
+ view: { url: '/templates/{template_id}', method: HTTP_METHODS.GET },
31798
+ update: { url: '/templates/{template_id}', method: HTTP_METHODS.PUT },
31799
+ delete: { url: '/templates/{template_id}', method: HTTP_METHODS.DELETE },
31800
+ uploadLogo: { url: '/templates/{template_id}/uploadLogo', method: HTTP_METHODS.POST },
31801
+ uploadMainImage: { url: '/templates/{template_id}/uploadMainImage', method: HTTP_METHODS.POST },
31802
+ };
31803
+ return TemplatesRoute;
31804
+ }());
31805
+
31806
+ var Templates = /** @class */ (function () {
31807
+ function Templates() {
31808
+ }
31809
+ /**
31810
+ * List all the templates.
31811
+ *
31812
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/resourceTemplateList
31813
+ *
31814
+ * @returns promise
31815
+ */
31816
+ Templates.list = function () {
31817
+ return Requests.processRoute(TemplatesRoute.routes.list);
31818
+ };
31819
+ /**
31820
+ * Create a new template.
31821
+ *
31822
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/newTemplateResourceStorage
31823
+ *
31824
+ * @param data The data to be passed when creating a template.
31825
+ *
31826
+ * @returns Promise
31827
+ */
31828
+ Templates.create = function (data) {
31829
+ return Requests.processRoute(TemplatesRoute.routes.create, data);
31830
+ };
31831
+ /**
31832
+ * Update a template.
31833
+ *
31834
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/updateTemplateStorage
31835
+ *
31836
+ * @param template_id The id of the template to update.
31837
+ * @param data The data to update.
31838
+ *
31839
+ * @returns promise
31840
+ */
31841
+ Templates.update = function (template_id, data) {
31842
+ return Requests.processRoute(TemplatesRoute.routes.create, data, { template_id: template_id });
31843
+ };
31844
+ /**
31845
+ * Retrieve the information for a single template.
31846
+ *
31847
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/showTemplateStorage
31848
+ *
31849
+ * @param template_id The id fo the template to retrieve.
31850
+ *
31851
+ * @returns promise
31852
+ */
31853
+ Templates.view = function (template_id) {
31854
+ return Requests.processRoute(TemplatesRoute.routes.view, {}, { template_id: template_id });
31855
+ };
31856
+ /**
31857
+ * Deletes a template.
31858
+ *
31859
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/destoryTemplateStorage
31860
+ *
31861
+ * @param template_id The id of the template to delete.
31862
+ * @returns promise
31863
+ */
31864
+ Templates.delete = function (template_id) {
31865
+ return Requests.processRoute(TemplatesRoute.routes.delete, {}, { template_id: template_id });
31866
+ };
31867
+ /**
31868
+ * Updates the logo for the template using a File object.
31869
+ *
31870
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/uploadLogoTemplateImage
31871
+ *
31872
+ * @param file The file object to upload.
31873
+ * @param data Any additional data to pass along to the upload.
31874
+ *
31875
+ * @returns promise
31876
+ */
31877
+ Templates.uploadLogoFile = function (template_id, file, data) {
31878
+ var url = TemplatesRoute.routes.uploadLogo.url.replace('{template_id}', template_id);
31879
+ return Requests.uploadFile(url, 'image', file, data);
31880
+ };
31881
+ /**
31882
+ * Updates the logo for the template using a Blob.
31883
+ *
31884
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/uploadLogoTemplateImage
31885
+ *
31886
+ * @param blob The blob to upload.
31887
+ * @param data Any additional data to pass along to the upload
31888
+ *
31889
+ * @returns promise
31890
+ */
31891
+ Templates.uploadLogoBlob = function (template_id, blob, data) {
31892
+ var url = TemplatesRoute.routes.uploadLogo.url.replace('{template_id}', template_id);
31893
+ return Requests.uploadBlob(url, 'image', blob, data);
31894
+ };
31895
+ /**
31896
+ * Updates the main image for the template using a File object.
31897
+ *
31898
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/uploadMainTemplateImage
31899
+ *
31900
+ * @param file The file object to upload.
31901
+ * @param data Any additional data to pass along to the upload.
31902
+ *
31903
+ * @returns promise
31904
+ */
31905
+ Templates.uploadMainImageFile = function (template_id, file, data) {
31906
+ var url = TemplatesRoute.routes.uploadMainImage.url.replace('{template_id}', template_id);
31907
+ return Requests.uploadFile(url, 'image', file, data);
31908
+ };
31909
+ /**
31910
+ * Updates the main image for the template using a Blob.
31911
+ *
31912
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/uploadMainTemplateImage
31913
+ *
31914
+ * @param blob The blob to upload.
31915
+ * @param data Any additional data to pass along to the upload
31916
+ *
31917
+ * @returns promise
31918
+ */
31919
+ Templates.uploadMainImageBlob = function (template_id, blob, data) {
31920
+ var url = TemplatesRoute.routes.uploadMainImage.url.replace('{template_id}', template_id);
31921
+ return Requests.uploadBlob(url, 'image', blob, data);
31922
+ };
31923
+ return Templates;
31924
+ }());
31925
+
31521
31926
  var Parser = /** @class */ (function () {
31522
31927
  function Parser() {
31523
31928
  }
@@ -31808,9 +32213,11 @@ var Glitch = /** @class */ (function () {
31808
32213
  Glitch.api = {
31809
32214
  Auth: Auth,
31810
32215
  Competitions: Competitions,
32216
+ Communities: Communities,
31811
32217
  Users: Users,
31812
32218
  Events: Events,
31813
32219
  Teams: Teams,
32220
+ Templates: Templates,
31814
32221
  Waitlists: Waitlists
31815
32222
  };
31816
32223
  Glitch.util = {