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 CHANGED
@@ -15625,10 +15625,10 @@ var Requests = /** @class */ (function () {
15625
15625
  headers['Content-Type'] = 'multipart/form-data';
15626
15626
  }
15627
15627
  var uri = "".concat(this.baseUrl).concat(url);
15628
- var validUri = uri.replace(/\/\//g, '/');
15629
15628
  var axiosPromise = axios({
15630
15629
  method: method,
15631
- url: validUri,
15630
+ url: uri,
15631
+ baseURL: this.baseUrl,
15632
15632
  data: fileData || data,
15633
15633
  headers: headers,
15634
15634
  });
@@ -16475,6 +16475,276 @@ var Competitions = /** @class */ (function () {
16475
16475
  return Competitions;
16476
16476
  }());
16477
16477
 
16478
+ var CommunitiesRoute = /** @class */ (function () {
16479
+ function CommunitiesRoute() {
16480
+ }
16481
+ CommunitiesRoute.routes = {
16482
+ list: { url: '/communities', method: HTTP_METHODS.GET },
16483
+ create: { url: '/communities', method: HTTP_METHODS.POST },
16484
+ view: { url: '/communities/{community_id}', method: HTTP_METHODS.GET },
16485
+ update: { url: '/communities/{community_id}', method: HTTP_METHODS.PUT },
16486
+ delete: { url: '/communities/{community_id}', method: HTTP_METHODS.DELETE },
16487
+ uploadLogo: { url: '/communities/{community_id}/uploadLogo', method: HTTP_METHODS.POST },
16488
+ uploadBannerImage: { url: '/communities/{community_id}/uploadBannerImage', method: HTTP_METHODS.POST },
16489
+ uploadVideoLogo: { url: '/communities/{community_id}/uploadVideoLogo', method: HTTP_METHODS.POST },
16490
+ listInvites: { url: '/communities/{community_id}/invites', method: HTTP_METHODS.GET },
16491
+ sendInvite: { url: '/communities/{community_id}/sendInvite', method: HTTP_METHODS.POST },
16492
+ acceptInvite: { url: '/communities/{community_id}/acceptInvite', method: HTTP_METHODS.POST },
16493
+ listUsers: { url: '/communities/{community_id}/users', method: HTTP_METHODS.GET },
16494
+ addUser: { url: '/communities/{community_id}/users', method: HTTP_METHODS.POST },
16495
+ showUser: { url: '/communities/{community_id}/users/{user_id}', method: HTTP_METHODS.GET },
16496
+ updateUser: { url: '/communities/{community_id}/users/{user_id}', method: HTTP_METHODS.PUT },
16497
+ removeUser: { url: '/communities/{community_id}/users/{user_id}', method: HTTP_METHODS.DELETE }
16498
+ };
16499
+ return CommunitiesRoute;
16500
+ }());
16501
+
16502
+ var Communities = /** @class */ (function () {
16503
+ function Communities() {
16504
+ }
16505
+ /**
16506
+ * List all the communities.
16507
+ *
16508
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/resourceCommunityList
16509
+ *
16510
+ * @returns promise
16511
+ */
16512
+ Communities.list = function () {
16513
+ return Requests.processRoute(CommunitiesRoute.routes.list);
16514
+ };
16515
+ /**
16516
+ * Create a new community.
16517
+ *
16518
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/newCommunityResourceStorage
16519
+ *
16520
+ * @param data The data to be passed when creating a community.
16521
+ *
16522
+ * @returns Promise
16523
+ */
16524
+ Communities.create = function (data) {
16525
+ return Requests.processRoute(CommunitiesRoute.routes.create, data);
16526
+ };
16527
+ /**
16528
+ * Update a community.
16529
+ *
16530
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/updateCommunityStorage
16531
+ *
16532
+ * @param community_id The id of the community to update.
16533
+ * @param data The data to update.
16534
+ *
16535
+ * @returns promise
16536
+ */
16537
+ Communities.update = function (community_id, data) {
16538
+ return Requests.processRoute(CommunitiesRoute.routes.create, data, { community_id: community_id });
16539
+ };
16540
+ /**
16541
+ * Retrieve the information for a single community.
16542
+ *
16543
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/showCommunityStorage
16544
+ *
16545
+ * @param community_id The id fo the community to retrieve.
16546
+ *
16547
+ * @returns promise
16548
+ */
16549
+ Communities.view = function (community_id) {
16550
+ return Requests.processRoute(CommunitiesRoute.routes.view, {}, { community_id: community_id });
16551
+ };
16552
+ /**
16553
+ * Deletes a community.
16554
+ *
16555
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/destoryCommunityStorage
16556
+ *
16557
+ * @param community_id The id of the community to delete.
16558
+ * @returns promise
16559
+ */
16560
+ Communities.delete = function (community_id) {
16561
+ return Requests.processRoute(CommunitiesRoute.routes.delete, {}, { community_id: community_id });
16562
+ };
16563
+ /**
16564
+ * Updates the main image for the community using a File object.
16565
+ *
16566
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/uploadLogoCommunityImage
16567
+ *
16568
+ * @param file The file object to upload.
16569
+ * @param data Any additional data to pass along to the upload.
16570
+ *
16571
+ * @returns promise
16572
+ */
16573
+ Communities.uploadLogoFile = function (community_id, file, data) {
16574
+ var url = CommunitiesRoute.routes.uploadLogo.url.replace('{community_id}', community_id);
16575
+ return Requests.uploadFile(url, 'image', file, data);
16576
+ };
16577
+ /**
16578
+ * Updates the main image for the community using a Blob.
16579
+ *
16580
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/uploadLogoCommunityImage
16581
+ *
16582
+ * @param blob The blob to upload.
16583
+ * @param data Any additional data to pass along to the upload
16584
+ *
16585
+ * @returns promise
16586
+ */
16587
+ Communities.uploadLogoBlob = function (community_id, blob, data) {
16588
+ var url = CommunitiesRoute.routes.uploadLogo.url.replace('{community_id}', community_id);
16589
+ return Requests.uploadBlob(url, 'image', blob, data);
16590
+ };
16591
+ /**
16592
+ * Updates the banner image for the community using a File object.
16593
+ *
16594
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/uploadBannerCommunityImage
16595
+ *
16596
+ * @param file The file object to upload.
16597
+ * @param data Any additional data to pass along to the upload.
16598
+ *
16599
+ * @returns promise
16600
+ */
16601
+ Communities.uploadBannerImageFile = function (community_id, file, data) {
16602
+ var url = CommunitiesRoute.routes.uploadBannerImage.url.replace('{community_id}', community_id);
16603
+ return Requests.uploadFile(url, 'image', file, data);
16604
+ };
16605
+ /**
16606
+ * Updates the banner image for the community using a Blob.
16607
+ *
16608
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/uploadBannerCommunityImage
16609
+ *
16610
+ * @param blob The blob to upload.
16611
+ * @param data Any additional data to pass along to the upload
16612
+ *
16613
+ * @returns promise
16614
+ */
16615
+ Communities.uploadBannerImageBlob = function (community_id, blob, data) {
16616
+ var url = CommunitiesRoute.routes.uploadBannerImage.url.replace('{community_id}', community_id);
16617
+ return Requests.uploadBlob(url, 'image', blob, data);
16618
+ };
16619
+ /**
16620
+ * Updates the banner image for the community using a File object.
16621
+ *
16622
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/uploadBannerCommunityImage
16623
+ *
16624
+ * @param file The file object to upload.
16625
+ * @param data Any additional data to pass along to the upload.
16626
+ *
16627
+ * @returns promise
16628
+ */
16629
+ Communities.uploadVideoLogoFile = function (community_id, file, data) {
16630
+ var url = CommunitiesRoute.routes.uploadVideoLogo.url.replace('{community_id}', community_id);
16631
+ return Requests.uploadFile(url, 'image', file, data);
16632
+ };
16633
+ /**
16634
+ * Updates the banner image for the community using a Blob.
16635
+ *
16636
+ * @see https://api.glitch.fun/api/documentation#/Community%20Route/uploadBannerCommunityImage
16637
+ *
16638
+ * @param blob The blob to upload.
16639
+ * @param data Any additional data to pass along to the upload
16640
+ *
16641
+ * @returns promise
16642
+ */
16643
+ Communities.uploadVideoLogoBlob = function (community_id, blob, data) {
16644
+ var url = CommunitiesRoute.routes.uploadVideoLogo.url.replace('{community_id}', community_id);
16645
+ return Requests.uploadBlob(url, 'image', blob, data);
16646
+ };
16647
+ /**
16648
+ * List the invites that have been sent for the community to users.
16649
+ *
16650
+ * @see https://api.glitch.fun/api/documentation#/communitys%20Route/communitysUserInviteList
16651
+ *
16652
+ * @param community_id The id of the community
16653
+ *
16654
+ * @returns promise
16655
+ */
16656
+ Communities.listInvites = function (community_id) {
16657
+ return Requests.processRoute(CommunitiesRoute.routes.listInvites, {}, { community_id: community_id });
16658
+ };
16659
+ /**
16660
+ * Send an invitation to a user to join the community.
16661
+ *
16662
+ * @see https://api.glitch.fun/api/documentation#/communitys%20Route/communitySendInvite
16663
+ *
16664
+ * @param community_id The id of the community.
16665
+ * @param data The data that will be passed into sending an invite.
16666
+ *
16667
+ * @returns promise
16668
+ */
16669
+ Communities.sendInvite = function (community_id, data) {
16670
+ return Requests.processRoute(CommunitiesRoute.routes.sendInvite, data, { community_id: community_id });
16671
+ };
16672
+ /**
16673
+ * Accept an invite to a community. The JSON Web Token (JWT) must be related to the token.
16674
+ *
16675
+ * @see https://api.glitch.fun/api/documentation#/communitys%20Route/communityAcceptInvite
16676
+ *
16677
+ * @param community_id The id of the community
16678
+ * @param token The token required to accept the user.
16679
+ *
16680
+ * @returns promise
16681
+ */
16682
+ Communities.acceptInvite = function (community_id, token) {
16683
+ return Requests.processRoute(CommunitiesRoute.routes.acceptInvite, {}, { community_id: community_id });
16684
+ };
16685
+ /**
16686
+ * List the users who are currently associated with the community.
16687
+ *
16688
+ * @see https://api.glitch.fun/api/documentation#/communitys%20Route/communityUserList
16689
+ *
16690
+ * @param community_id The id of the community.
16691
+ *
16692
+ * @returns promise
16693
+ */
16694
+ Communities.listUsers = function (community_id) {
16695
+ return Requests.processRoute(CommunitiesRoute.routes.listUsers, {}, { community_id: community_id });
16696
+ };
16697
+ /**
16698
+ * Add a user to a community.
16699
+ *
16700
+ * @see https://api.glitch.fun/api/documentation#/communitys%20Route/createcommunityUser
16701
+ *
16702
+ * @param community_id The id of the community.
16703
+ * @param data The data to be passed when adding a user.
16704
+ *
16705
+ * @returns promise
16706
+ */
16707
+ Communities.addUser = function (community_id, data) {
16708
+ return Requests.processRoute(CommunitiesRoute.routes.addUser, data, { community_id: community_id });
16709
+ };
16710
+ /**
16711
+ * Retrieves a single user and their information that is associated with a community.
16712
+ *
16713
+ * @see https://api.glitch.fun/api/documentation#/communitys%20Route/showcommunityUser
16714
+ *
16715
+ * @param community_id The id of the community.
16716
+ * @param user_id The id of the user.
16717
+ *
16718
+ * @returns promise
16719
+ */
16720
+ Communities.getUser = function (community_id, user_id) {
16721
+ return Requests.processRoute(CommunitiesRoute.routes.showUser, {}, { community_id: community_id, user_id: user_id });
16722
+ };
16723
+ /**
16724
+ * Updates the users information associated with the community.
16725
+ *
16726
+ * @param community_id The id of the community.
16727
+ * @param user_id The id of the user.
16728
+ *
16729
+ * @returns promise
16730
+ */
16731
+ Communities.updatetUser = function (community_id, user_id, data) {
16732
+ return Requests.processRoute(CommunitiesRoute.routes.updateUser, data, { community_id: community_id, user_id: user_id });
16733
+ };
16734
+ /**
16735
+ * Removes a user from a community.
16736
+ *
16737
+ * @param community_id The id of community.
16738
+ * @param user_id The id of the user.
16739
+ *
16740
+ * @returns promise
16741
+ */
16742
+ Communities.removetUser = function (community_id, user_id) {
16743
+ return Requests.processRoute(CommunitiesRoute.routes.removeUser, {}, { community_id: community_id, user_id: user_id });
16744
+ };
16745
+ return Communities;
16746
+ }());
16747
+
16478
16748
  var UserRoutes = /** @class */ (function () {
16479
16749
  function UserRoutes() {
16480
16750
  }
@@ -17296,6 +17566,141 @@ var Waitlists = /** @class */ (function () {
17296
17566
  return Waitlists;
17297
17567
  }());
17298
17568
 
17569
+ var TemplatesRoute = /** @class */ (function () {
17570
+ function TemplatesRoute() {
17571
+ }
17572
+ TemplatesRoute.routes = {
17573
+ list: { url: '/templates', method: HTTP_METHODS.GET },
17574
+ create: { url: '/templates', method: HTTP_METHODS.POST },
17575
+ view: { url: '/templates/{template_id}', method: HTTP_METHODS.GET },
17576
+ update: { url: '/templates/{template_id}', method: HTTP_METHODS.PUT },
17577
+ delete: { url: '/templates/{template_id}', method: HTTP_METHODS.DELETE },
17578
+ uploadLogo: { url: '/templates/{template_id}/uploadLogo', method: HTTP_METHODS.POST },
17579
+ uploadMainImage: { url: '/templates/{template_id}/uploadMainImage', method: HTTP_METHODS.POST },
17580
+ };
17581
+ return TemplatesRoute;
17582
+ }());
17583
+
17584
+ var Templates = /** @class */ (function () {
17585
+ function Templates() {
17586
+ }
17587
+ /**
17588
+ * List all the templates.
17589
+ *
17590
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/resourceTemplateList
17591
+ *
17592
+ * @returns promise
17593
+ */
17594
+ Templates.list = function () {
17595
+ return Requests.processRoute(TemplatesRoute.routes.list);
17596
+ };
17597
+ /**
17598
+ * Create a new template.
17599
+ *
17600
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/newTemplateResourceStorage
17601
+ *
17602
+ * @param data The data to be passed when creating a template.
17603
+ *
17604
+ * @returns Promise
17605
+ */
17606
+ Templates.create = function (data) {
17607
+ return Requests.processRoute(TemplatesRoute.routes.create, data);
17608
+ };
17609
+ /**
17610
+ * Update a template.
17611
+ *
17612
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/updateTemplateStorage
17613
+ *
17614
+ * @param template_id The id of the template to update.
17615
+ * @param data The data to update.
17616
+ *
17617
+ * @returns promise
17618
+ */
17619
+ Templates.update = function (template_id, data) {
17620
+ return Requests.processRoute(TemplatesRoute.routes.create, data, { template_id: template_id });
17621
+ };
17622
+ /**
17623
+ * Retrieve the information for a single template.
17624
+ *
17625
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/showTemplateStorage
17626
+ *
17627
+ * @param template_id The id fo the template to retrieve.
17628
+ *
17629
+ * @returns promise
17630
+ */
17631
+ Templates.view = function (template_id) {
17632
+ return Requests.processRoute(TemplatesRoute.routes.view, {}, { template_id: template_id });
17633
+ };
17634
+ /**
17635
+ * Deletes a template.
17636
+ *
17637
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/destoryTemplateStorage
17638
+ *
17639
+ * @param template_id The id of the template to delete.
17640
+ * @returns promise
17641
+ */
17642
+ Templates.delete = function (template_id) {
17643
+ return Requests.processRoute(TemplatesRoute.routes.delete, {}, { template_id: template_id });
17644
+ };
17645
+ /**
17646
+ * Updates the logo for the template using a File object.
17647
+ *
17648
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/uploadLogoTemplateImage
17649
+ *
17650
+ * @param file The file object to upload.
17651
+ * @param data Any additional data to pass along to the upload.
17652
+ *
17653
+ * @returns promise
17654
+ */
17655
+ Templates.uploadLogoFile = function (template_id, file, data) {
17656
+ var url = TemplatesRoute.routes.uploadLogo.url.replace('{template_id}', template_id);
17657
+ return Requests.uploadFile(url, 'image', file, data);
17658
+ };
17659
+ /**
17660
+ * Updates the logo for the template using a Blob.
17661
+ *
17662
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/uploadLogoTemplateImage
17663
+ *
17664
+ * @param blob The blob to upload.
17665
+ * @param data Any additional data to pass along to the upload
17666
+ *
17667
+ * @returns promise
17668
+ */
17669
+ Templates.uploadLogoBlob = function (template_id, blob, data) {
17670
+ var url = TemplatesRoute.routes.uploadLogo.url.replace('{template_id}', template_id);
17671
+ return Requests.uploadBlob(url, 'image', blob, data);
17672
+ };
17673
+ /**
17674
+ * Updates the main image for the template using a File object.
17675
+ *
17676
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/uploadMainTemplateImage
17677
+ *
17678
+ * @param file The file object to upload.
17679
+ * @param data Any additional data to pass along to the upload.
17680
+ *
17681
+ * @returns promise
17682
+ */
17683
+ Templates.uploadMainImageFile = function (template_id, file, data) {
17684
+ var url = TemplatesRoute.routes.uploadMainImage.url.replace('{template_id}', template_id);
17685
+ return Requests.uploadFile(url, 'image', file, data);
17686
+ };
17687
+ /**
17688
+ * Updates the main image for the template using a Blob.
17689
+ *
17690
+ * @see https://api.glitch.fun/api/documentation#/Template%20Route/uploadMainTemplateImage
17691
+ *
17692
+ * @param blob The blob to upload.
17693
+ * @param data Any additional data to pass along to the upload
17694
+ *
17695
+ * @returns promise
17696
+ */
17697
+ Templates.uploadMainImageBlob = function (template_id, blob, data) {
17698
+ var url = TemplatesRoute.routes.uploadMainImage.url.replace('{template_id}', template_id);
17699
+ return Requests.uploadBlob(url, 'image', blob, data);
17700
+ };
17701
+ return Templates;
17702
+ }());
17703
+
17299
17704
  var Parser = /** @class */ (function () {
17300
17705
  function Parser() {
17301
17706
  }
@@ -17586,9 +17991,11 @@ var Glitch = /** @class */ (function () {
17586
17991
  Glitch.api = {
17587
17992
  Auth: Auth,
17588
17993
  Competitions: Competitions,
17994
+ Communities: Communities,
17589
17995
  Users: Users,
17590
17996
  Events: Events,
17591
17997
  Teams: Teams,
17998
+ Templates: Templates,
17592
17999
  Waitlists: Waitlists
17593
18000
  };
17594
18001
  Glitch.util = {