glitch-javascript-sdk 0.3.0 → 0.3.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.
@@ -0,0 +1,53 @@
1
+ import Response from "../util/Response";
2
+ import { AxiosPromise } from "axios";
3
+ declare class Posts {
4
+ /**
5
+ * List all the Posts.
6
+ *
7
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList
8
+ *
9
+ * @returns promise
10
+ */
11
+ static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
12
+ /**
13
+ * Create a new post.
14
+ *
15
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/newPostResourceStorage
16
+ *
17
+ * @param data The data to be passed when creating a post.
18
+ *
19
+ * @returns Promise
20
+ */
21
+ static create<T>(data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
22
+ /**
23
+ * Update a post.
24
+ *
25
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/updatePostStorage
26
+ *
27
+ * @param post_id The id of the post to update.
28
+ * @param data The data to update.
29
+ *
30
+ * @returns promise
31
+ */
32
+ static update<T>(post_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
33
+ /**
34
+ * Retrieve the information for a single post.
35
+ *
36
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
37
+ *
38
+ * @param post_id The id fo the post to retrieve.
39
+ *
40
+ * @returns promise
41
+ */
42
+ static view<T>(post_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
43
+ /**
44
+ * Deletes a post.
45
+ *
46
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage
47
+ *
48
+ * @param post_id The id of the post to delete.
49
+ * @returns promise
50
+ */
51
+ static delete<T>(post_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
52
+ }
53
+ export default Posts;
@@ -5,6 +5,7 @@ import Users from "./Users";
5
5
  import Events from "./Events";
6
6
  import Teams from "./Teams";
7
7
  import Waitlists from "./Waitlist";
8
+ import Posts from "./Posts";
8
9
  import Templates from "./Templates";
9
10
  export { Auth };
10
11
  export { Competitions };
@@ -13,4 +14,5 @@ export { Users };
13
14
  export { Events };
14
15
  export { Teams };
15
16
  export { Waitlists };
17
+ export { Posts };
16
18
  export { Templates };
@@ -5,6 +5,7 @@ import { Communities } from "./api";
5
5
  import { Users } from "./api";
6
6
  import { Events } from "./api";
7
7
  import { Teams } from "./api";
8
+ import { Posts } from "./api";
8
9
  import { Templates } from "./api";
9
10
  import { Waitlists } from "./api";
10
11
  import Requests from "./util/Requests";
@@ -30,6 +31,7 @@ declare class Glitch {
30
31
  Users: typeof Users;
31
32
  Events: typeof Events;
32
33
  Teams: typeof Teams;
34
+ Posts: typeof Posts;
33
35
  Templates: typeof Templates;
34
36
  Waitlists: typeof Waitlists;
35
37
  };
package/dist/esm/index.js CHANGED
@@ -29903,6 +29903,9 @@ var Requests = /** @class */ (function () {
29903
29903
  var queryString = Object.entries(params)
29904
29904
  .map(function (_a) {
29905
29905
  var key = _a[0], value = _a[1];
29906
+ if (Array.isArray(value)) {
29907
+ return value.map(function (item) { return "".concat(key, "[]=").concat(encodeURIComponent(item)); }).join('&');
29908
+ }
29906
29909
  return "".concat(key, "=").concat(encodeURIComponent(value));
29907
29910
  })
29908
29911
  .join('&');
@@ -31943,6 +31946,83 @@ var Waitlists = /** @class */ (function () {
31943
31946
  return Waitlists;
31944
31947
  }());
31945
31948
 
31949
+ var PostsRoute = /** @class */ (function () {
31950
+ function PostsRoute() {
31951
+ }
31952
+ PostsRoute.routes = {
31953
+ list: { url: '/posts', method: HTTP_METHODS.GET },
31954
+ create: { url: '/posts', method: HTTP_METHODS.POST },
31955
+ view: { url: '/posts/{post_id}', method: HTTP_METHODS.GET },
31956
+ update: { url: '/posts/{post_id}', method: HTTP_METHODS.PUT },
31957
+ delete: { url: '/posts/{post_id}', method: HTTP_METHODS.DELETE },
31958
+ };
31959
+ return PostsRoute;
31960
+ }());
31961
+
31962
+ var Posts = /** @class */ (function () {
31963
+ function Posts() {
31964
+ }
31965
+ /**
31966
+ * List all the Posts.
31967
+ *
31968
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList
31969
+ *
31970
+ * @returns promise
31971
+ */
31972
+ Posts.list = function (params) {
31973
+ return Requests.processRoute(PostsRoute.routes.list, undefined, undefined, params);
31974
+ };
31975
+ /**
31976
+ * Create a new post.
31977
+ *
31978
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/newPostResourceStorage
31979
+ *
31980
+ * @param data The data to be passed when creating a post.
31981
+ *
31982
+ * @returns Promise
31983
+ */
31984
+ Posts.create = function (data, params) {
31985
+ return Requests.processRoute(PostsRoute.routes.create, data, undefined, params);
31986
+ };
31987
+ /**
31988
+ * Update a post.
31989
+ *
31990
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/updatePostStorage
31991
+ *
31992
+ * @param post_id The id of the post to update.
31993
+ * @param data The data to update.
31994
+ *
31995
+ * @returns promise
31996
+ */
31997
+ Posts.update = function (post_id, data, params) {
31998
+ return Requests.processRoute(PostsRoute.routes.update, data, { post_id: post_id }, params);
31999
+ };
32000
+ /**
32001
+ * Retrieve the information for a single post.
32002
+ *
32003
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
32004
+ *
32005
+ * @param post_id The id fo the post to retrieve.
32006
+ *
32007
+ * @returns promise
32008
+ */
32009
+ Posts.view = function (post_id, params) {
32010
+ return Requests.processRoute(PostsRoute.routes.view, {}, { post_id: post_id }, params);
32011
+ };
32012
+ /**
32013
+ * Deletes a post.
32014
+ *
32015
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage
32016
+ *
32017
+ * @param post_id The id of the post to delete.
32018
+ * @returns promise
32019
+ */
32020
+ Posts.delete = function (post_id, params) {
32021
+ return Requests.processRoute(PostsRoute.routes.delete, {}, { post_id: post_id }, params);
32022
+ };
32023
+ return Posts;
32024
+ }());
32025
+
31946
32026
  var TemplatesRoute = /** @class */ (function () {
31947
32027
  function TemplatesRoute() {
31948
32028
  }
@@ -32380,6 +32460,7 @@ var Glitch = /** @class */ (function () {
32380
32460
  Users: Users,
32381
32461
  Events: Events,
32382
32462
  Teams: Teams,
32463
+ Posts: Posts,
32383
32464
  Templates: Templates,
32384
32465
  Waitlists: Waitlists
32385
32466
  };