glitch-javascript-sdk 0.3.1 → 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,7 @@
1
+ import Route from "./interface";
2
+ declare class PostsRoute {
3
+ static routes: {
4
+ [key: string]: Route;
5
+ };
6
+ }
7
+ export default PostsRoute;
package/dist/index.d.ts CHANGED
@@ -1393,6 +1393,57 @@ declare class Waitlists {
1393
1393
  static delete<T>(waitlist_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
1394
1394
  }
1395
1395
 
1396
+ declare class Posts {
1397
+ /**
1398
+ * List all the Posts.
1399
+ *
1400
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList
1401
+ *
1402
+ * @returns promise
1403
+ */
1404
+ static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
1405
+ /**
1406
+ * Create a new post.
1407
+ *
1408
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/newPostResourceStorage
1409
+ *
1410
+ * @param data The data to be passed when creating a post.
1411
+ *
1412
+ * @returns Promise
1413
+ */
1414
+ static create<T>(data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
1415
+ /**
1416
+ * Update a post.
1417
+ *
1418
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/updatePostStorage
1419
+ *
1420
+ * @param post_id The id of the post to update.
1421
+ * @param data The data to update.
1422
+ *
1423
+ * @returns promise
1424
+ */
1425
+ static update<T>(post_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
1426
+ /**
1427
+ * Retrieve the information for a single post.
1428
+ *
1429
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
1430
+ *
1431
+ * @param post_id The id fo the post to retrieve.
1432
+ *
1433
+ * @returns promise
1434
+ */
1435
+ static view<T>(post_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
1436
+ /**
1437
+ * Deletes a post.
1438
+ *
1439
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage
1440
+ *
1441
+ * @param post_id The id of the post to delete.
1442
+ * @returns promise
1443
+ */
1444
+ static delete<T>(post_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
1445
+ }
1446
+
1396
1447
  declare class Templates {
1397
1448
  /**
1398
1449
  * List all the templates.
@@ -1666,6 +1717,7 @@ declare class Glitch {
1666
1717
  Users: typeof Users;
1667
1718
  Events: typeof Events;
1668
1719
  Teams: typeof Teams;
1720
+ Posts: typeof Posts;
1669
1721
  Templates: typeof Templates;
1670
1722
  Waitlists: typeof Waitlists;
1671
1723
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Javascript SDK for Glitch",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -0,0 +1,77 @@
1
+ import PostsRoute from "../routes/PostsRoute";
2
+ import Requests from "../util/Requests";
3
+ import Response from "../util/Response";
4
+ import { AxiosPromise } from "axios";
5
+
6
+ class Posts {
7
+
8
+ /**
9
+ * List all the Posts.
10
+ *
11
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList
12
+ *
13
+ * @returns promise
14
+ */
15
+ public static list<T>(params?: Record<string, any>) : AxiosPromise<Response<T>> {
16
+ return Requests.processRoute(PostsRoute.routes.list, undefined, undefined, params);
17
+ }
18
+
19
+ /**
20
+ * Create a new post.
21
+ *
22
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/newPostResourceStorage
23
+ *
24
+ * @param data The data to be passed when creating a post.
25
+ *
26
+ * @returns Promise
27
+ */
28
+ public static create<T>(data : object, params?: Record<string, any>) : AxiosPromise<Response<T>> {
29
+
30
+ return Requests.processRoute(PostsRoute.routes.create, data, undefined, params);
31
+ }
32
+
33
+ /**
34
+ * Update a post.
35
+ *
36
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/updatePostStorage
37
+ *
38
+ * @param post_id The id of the post to update.
39
+ * @param data The data to update.
40
+ *
41
+ * @returns promise
42
+ */
43
+ public static update<T>(post_id : string, data : object, params?: Record<string, any>) : AxiosPromise<Response<T>>{
44
+
45
+ return Requests.processRoute(PostsRoute.routes.update, data, {post_id : post_id}, params);
46
+ }
47
+
48
+ /**
49
+ * Retrieve the information for a single post.
50
+ *
51
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
52
+ *
53
+ * @param post_id The id fo the post to retrieve.
54
+ *
55
+ * @returns promise
56
+ */
57
+ public static view<T>(post_id : string, params?: Record<string, any>) : AxiosPromise<Response<T>> {
58
+
59
+ return Requests.processRoute(PostsRoute.routes.view, {}, {post_id : post_id}, params);
60
+ }
61
+
62
+ /**
63
+ * Deletes a post.
64
+ *
65
+ * @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage
66
+ *
67
+ * @param post_id The id of the post to delete.
68
+ * @returns promise
69
+ */
70
+ public static delete<T>(post_id : string, params?: Record<string, any>) : AxiosPromise<Response<T>> {
71
+
72
+ return Requests.processRoute(PostsRoute.routes.delete, {}, {post_id : post_id}, params);
73
+ }
74
+
75
+ }
76
+
77
+ export default Posts;
package/src/api/index.ts CHANGED
@@ -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
 
10
11
 
@@ -15,4 +16,5 @@ export {Users};
15
16
  export {Events};
16
17
  export {Teams};
17
18
  export {Waitlists};
19
+ export {Posts};
18
20
  export {Templates};
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ import {Communities} from "./api";
9
9
  import { Users } from "./api";
10
10
  import { Events } from "./api";
11
11
  import { Teams } from "./api";
12
+ import { Posts } from "./api";
12
13
  import {Templates} from "./api";
13
14
  import { Waitlists } from "./api";
14
15
 
@@ -42,6 +43,7 @@ class Glitch {
42
43
  Users: Users,
43
44
  Events: Events,
44
45
  Teams: Teams,
46
+ Posts: Posts,
45
47
  Templates : Templates,
46
48
  Waitlists: Waitlists
47
49
  }
@@ -0,0 +1,16 @@
1
+ import Route from "./interface";
2
+ import HTTP_METHODS from "../constants/HttpMethods";
3
+
4
+ class PostsRoute {
5
+
6
+ public static routes: { [key: string]: Route } = {
7
+ list: { url: '/posts', method: HTTP_METHODS.GET },
8
+ create: { url: '/posts', method: HTTP_METHODS.POST },
9
+ view : { url: '/posts/{post_id}', method: HTTP_METHODS.GET },
10
+ update :{ url: '/posts/{post_id}', method: HTTP_METHODS.PUT },
11
+ delete : { url: '/posts/{post_id}', method: HTTP_METHODS.DELETE },
12
+ };
13
+
14
+ }
15
+
16
+ export default PostsRoute;