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