glitch-javascript-sdk 1.0.2 → 1.0.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.
@@ -0,0 +1,7 @@
1
+ import Route from "./interface";
2
+ declare class GamesRoutes {
3
+ static routes: {
4
+ [key: string]: Route;
5
+ };
6
+ }
7
+ export default GamesRoutes;
package/dist/index.d.ts CHANGED
@@ -2968,6 +2968,33 @@ declare class Influencers {
2968
2968
  static viewInfluencer<T>(influencer_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
2969
2969
  }
2970
2970
 
2971
+ declare class Games {
2972
+ /**
2973
+ * Get a list of Games available on he platform.
2974
+ *
2975
+ * @see https://api.glitch.fun/api/documentation#/ExternalGames/getExternalGames
2976
+ *
2977
+ * @returns promise
2978
+ */
2979
+ static listGames<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
2980
+ /**
2981
+ * Retrieve information on a single game.
2982
+ *
2983
+ * @see https://api.glitch.fun/api/documentation#/ExternalGames/getExternalGameById
2984
+ *
2985
+ * @returns promise
2986
+ */
2987
+ static viewGame<T>(game_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
2988
+ /**
2989
+ * Generates campaign data for this game.
2990
+ *
2991
+ * @see https://api.glitch.fun/api/documentation#/ExternalGames/generateCampaign
2992
+ *
2993
+ * @returns promise
2994
+ */
2995
+ static createCampaignData<T>(game_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
2996
+ }
2997
+
2971
2998
  interface Route {
2972
2999
  url: string;
2973
3000
  method: string;
@@ -3273,6 +3300,7 @@ declare class Glitch {
3273
3300
  Communities: typeof Communities;
3274
3301
  Users: typeof Users;
3275
3302
  Events: typeof Events;
3303
+ Games: typeof Games;
3276
3304
  Feedback: typeof Feedback;
3277
3305
  Influencers: typeof Influencers;
3278
3306
  Teams: typeof Teams;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Javascript SDK for Glitch",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -0,0 +1,43 @@
1
+ import GamesRoutes from "../routes/GamesRoutes";
2
+ import Requests from "../util/Requests";
3
+ import Response from "../util/Response";
4
+ import { AxiosPromise } from "axios";
5
+
6
+ class Games {
7
+
8
+ /**
9
+ * Get a list of Games available on he platform.
10
+ *
11
+ * @see https://api.glitch.fun/api/documentation#/ExternalGames/getExternalGames
12
+ *
13
+ * @returns promise
14
+ */
15
+ public static listGames<T>(params?: Record<string, any>) : AxiosPromise<Response<T>> {
16
+ return Requests.processRoute(GamesRoutes.routes.listGames, undefined, undefined, params);
17
+ }
18
+
19
+ /**
20
+ * Retrieve information on a single game.
21
+ *
22
+ * @see https://api.glitch.fun/api/documentation#/ExternalGames/getExternalGameById
23
+ *
24
+ * @returns promise
25
+ */
26
+ public static viewGame<T>(game_id : string, params?: Record<string, any>) : AxiosPromise<Response<T>> {
27
+ return Requests.processRoute(GamesRoutes.routes.viewGame, undefined, {game_id : game_id}, params);
28
+ }
29
+
30
+ /**
31
+ * Generates campaign data for this game.
32
+ *
33
+ * @see https://api.glitch.fun/api/documentation#/ExternalGames/generateCampaign
34
+ *
35
+ * @returns promise
36
+ */
37
+ public static createCampaignData<T>(game_id : string, data?: object, params?: Record<string, any>) : AxiosPromise<Response<T>> {
38
+ return Requests.processRoute(GamesRoutes.routes.createCampaignData, data, {game_id : game_id}, params);
39
+ }
40
+
41
+ }
42
+
43
+ export default Games;
package/src/api/index.ts CHANGED
@@ -20,6 +20,7 @@ import Subscriptions from "./Subscriptions";
20
20
  import Messages from "./Messages";
21
21
  import Feedback from "./Feedback";
22
22
  import Influencers from "./Influencers";
23
+ import Games from "./Games";
23
24
 
24
25
  export {Auth};
25
26
  export {Competitions};
@@ -42,4 +43,5 @@ export {Campaigns};
42
43
  export {Subscriptions};
43
44
  export {Messages};
44
45
  export {Feedback};
45
- export {Influencers};
46
+ export {Influencers};
47
+ export {Games};
package/src/index.ts CHANGED
@@ -24,6 +24,7 @@ import {Subscriptions} from "./api";
24
24
  import {Messages} from "./api";
25
25
  import {Feedback} from "./api";
26
26
  import {Influencers} from "./api";
27
+ import {Games} from "./api";
27
28
 
28
29
 
29
30
 
@@ -63,6 +64,7 @@ class Glitch {
63
64
  Communities : Communities,
64
65
  Users: Users,
65
66
  Events: Events,
67
+ Games : Games,
66
68
  Feedback : Feedback,
67
69
  Influencers : Influencers,
68
70
  Teams: Teams,
@@ -0,0 +1,14 @@
1
+ import Route from "./interface";
2
+ import HTTP_METHODS from "../constants/HttpMethods";
3
+
4
+ class GamesRoutes {
5
+
6
+ public static routes: { [key: string]: Route } = {
7
+ listGames: { url: '/games', method: HTTP_METHODS.GET },
8
+ viewGame: { url: '/games/{game_id}', method: HTTP_METHODS.GET },
9
+ createCampaignData: { url: '/games/{game_id}/generateCampaign', method: HTTP_METHODS.POST },
10
+ };
11
+
12
+ }
13
+
14
+ export default GamesRoutes;