glitch-javascript-sdk 1.0.1 → 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.
- package/dist/cjs/index.js +53 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Games.d.ts +29 -0
- package/dist/esm/api/index.d.ts +2 -0
- package/dist/esm/config/Config.d.ts +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +53 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/GamesRoutes.d.ts +7 -0
- package/dist/index.d.ts +29 -1
- package/package.json +1 -1
- package/src/api/Games.ts +43 -0
- package/src/api/index.ts +3 -1
- package/src/config/Config.ts +5 -1
- package/src/index.ts +2 -0
- package/src/routes/GamesRoutes.ts +14 -0
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ declare class Config {
|
|
|
39
39
|
*/
|
|
40
40
|
static setCommunity(community: Record<string, any>): void;
|
|
41
41
|
/**
|
|
42
|
-
* Sets the root level domain so data can accessed across
|
|
42
|
+
* Sets the root level domain so data can be accessed across
|
|
43
43
|
* multiple subdomains
|
|
44
44
|
*
|
|
45
45
|
* @param domain The domain ie: example.com
|
|
@@ -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
package/src/api/Games.ts
ADDED
|
@@ -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/config/Config.ts
CHANGED
|
@@ -78,12 +78,16 @@ class Config {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* Sets the root level domain so data can accessed across
|
|
81
|
+
* Sets the root level domain so data can be accessed across
|
|
82
82
|
* multiple subdomains
|
|
83
83
|
*
|
|
84
84
|
* @param domain The domain ie: example.com
|
|
85
85
|
*/
|
|
86
86
|
public static setRootDomain(domain: string) {
|
|
87
|
+
if (!domain) {
|
|
88
|
+
console.error("setRootDomain: domain is undefined or null");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
87
91
|
|
|
88
92
|
const parts = domain.split('.');
|
|
89
93
|
|
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;
|