@smartico/public-api 0.0.4 → 0.0.5
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/README.md +23 -44
- package/dist/Core/GetLabelInfoRequest.d.ts +3 -0
- package/dist/Core/GetLabelInfoResponse.d.ts +7 -0
- package/dist/Core/GetTranslationsRequest.d.ts +7 -0
- package/dist/Core/GetTranslationsResponse.d.ts +7 -0
- package/dist/Core/PublicLabelSettings.d.ts +28 -0
- package/dist/Core/PublicProperties.d.ts +11 -0
- package/dist/Core/ResponseIdentify.d.ts +12 -0
- package/dist/Core/TranslationArea.d.ts +9 -0
- package/dist/Core/index.d.ts +8 -0
- package/dist/MiniGames/SAWAskForUsername.d.ts +4 -0
- package/dist/MiniGames/SAWDoSpinResponse.d.ts +1 -7
- package/dist/MiniGames/SAWSpinErrorCode.d.ts +7 -0
- package/dist/MiniGames/SAWTemplateUI.d.ts +2 -5
- package/dist/MiniGames/SAWUtils.d.ts +5 -0
- package/dist/MiniGames/index.d.ts +5 -2
- package/dist/OCache.d.ts +11 -0
- package/dist/SmarticoAPI.d.ts +14 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +312 -36
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +217 -19
- package/dist/index.modern.mjs.map +1 -1
- package/package.json +9 -3
- package/src/Core/GetLabelInfoRequest.ts +5 -0
- package/src/Core/GetLabelInfoResponse.ts +6 -0
- package/src/Core/GetTranslationsRequest.ts +10 -0
- package/src/Core/GetTranslationsResponse.ts +8 -0
- package/src/Core/PublicLabelSettings.ts +34 -0
- package/src/Core/PublicProperties.ts +11 -0
- package/src/Core/ResponseIdentify.ts +14 -0
- package/src/Core/TranslationArea.ts +11 -0
- package/src/Core/index.ts +18 -0
- package/src/MiniGames/SAWAskForUsername.ts +5 -0
- package/src/MiniGames/SAWDoSpinResponse.ts +1 -8
- package/src/MiniGames/SAWSpinErrorCode.ts +8 -0
- package/src/MiniGames/SAWTemplateUI.ts +3 -5
- package/src/MiniGames/SAWUtils.ts +31 -0
- package/src/MiniGames/index.ts +8 -3
- package/src/OCache.ts +54 -0
- package/src/SmarticoAPI.ts +128 -9
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
- Describes data types
|
|
1
|
+
# Smartico Public API
|
|
2
|
+
API allows you to build and manage Smartico Gamification context on behalf of the user. It can be used in the JS/TS based frontend or in NodeJS backend
|
|
4
3
|
|
|
5
|
-
#
|
|
4
|
+
# Installation
|
|
6
5
|
|
|
7
6
|
```bash
|
|
8
7
|
npm install --save @smartico/public-api
|
|
@@ -11,65 +10,45 @@ npm install --save @smartico/public-api
|
|
|
11
10
|
## Usage
|
|
12
11
|
|
|
13
12
|
```typescript
|
|
14
|
-
import {
|
|
13
|
+
import { SmarticoAPI } from '@smartico/public-api';
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const message: ProtocolRequest = {
|
|
21
|
-
api_key: rq.label_api_key,
|
|
22
|
-
brand_key: rq.brand_key,
|
|
23
|
-
ext_user_id: rq.smartico_ext_user_id,
|
|
24
|
-
uuid: Util.uuid(),
|
|
25
|
-
ts: new Date().getTime(),
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return message as any
|
|
29
|
-
}
|
|
15
|
+
const SAPI = new SmarticoAPI( 'your-label-api-key', 'your-brand-key', { logger: console });
|
|
16
|
+
|
|
17
|
+
const response = await SAPI.miniGamesGetTemplates(rsUser.user_ext_id);
|
|
30
18
|
|
|
19
|
+
response.templates.forEach( t => {
|
|
20
|
+
console.log(t.saw_template_ui_definition.name)
|
|
31
21
|
}
|
|
32
|
-
```
|
|
33
22
|
|
|
34
|
-
|
|
23
|
+
```
|
|
35
24
|
|
|
36
|
-
### Set new package version
|
|
37
25
|
|
|
38
|
-
|
|
39
|
-
npm run build
|
|
40
|
-
npm version [<newversion> | major | minor | patch ]
|
|
41
|
-
```
|
|
26
|
+
## Development and publishing process
|
|
42
27
|
|
|
43
|
-
###
|
|
28
|
+
### Publishing process
|
|
44
29
|
|
|
45
30
|
```sh
|
|
31
|
+
git commit
|
|
32
|
+
npm run build
|
|
33
|
+
npm version patch
|
|
46
34
|
npm run pub
|
|
47
35
|
```
|
|
48
36
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
### Enable Debug changes locally
|
|
52
|
-
|
|
53
|
-
(reference article: https://terodox.tech/using-npm-link-for-package-development/)
|
|
37
|
+
### Debug locally
|
|
54
38
|
|
|
55
39
|
In the public-api project console:
|
|
56
40
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
This will create a symlink from the global `node_modules/@smartico/public-api` to your current folder - `<your-local-git-folder-for-this-project>/public-api`
|
|
41
|
+
```sh
|
|
42
|
+
npm link
|
|
43
|
+
# when you are done
|
|
44
|
+
npm unlink
|
|
45
|
+
```
|
|
63
46
|
|
|
64
47
|
Consumer project console:
|
|
65
48
|
```bash
|
|
66
49
|
npm link @smartico/public-api
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Now you are ready to debug locally the library!
|
|
70
50
|
|
|
71
|
-
|
|
72
|
-
```bash
|
|
51
|
+
# when you are done
|
|
73
52
|
npm unlink npm link @smartico/public-api
|
|
74
53
|
npm install npm link @smartico/public-api
|
|
75
|
-
```
|
|
54
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum PublicLabelSettings {
|
|
2
|
+
FCM_SENDER_ID = "FCM_SENDER_ID",
|
|
3
|
+
PUBLIC_API_URL = "PUBLIC_API_URL",
|
|
4
|
+
FCM_SW_URL = "FCM_SW_URL",
|
|
5
|
+
RECORDING_ENABLED_FOR_ALL_USERS = "RECORDING_ENABLED_FOR_ALL_USERS",
|
|
6
|
+
JS_INJECTION = "JS_INJECTION",
|
|
7
|
+
GAMIFICATION_UI_MAIN = "GAMIFICATION_UI_MAIN",
|
|
8
|
+
GAMIFICATION_UI_WIDGET = "GAMIFICATION_UI_WIDGET",
|
|
9
|
+
GAMIFICATION_UI_MINI_GAME = "GAMIFICATION_UI_MINI_GAME",
|
|
10
|
+
GAMIFICATION_UI_SETTINGS = "GAMIFICATION_UI_SETTINGS",
|
|
11
|
+
GAMIFICATION_UI_MAIN_TEST = "GAMIFICATION_UI_MAIN_TEST",
|
|
12
|
+
GAMIFICATION_UI_WIDGET_TEST = "GAMIFICATION_UI_WIDGET_TEST",
|
|
13
|
+
GAMIFICATION_UI_SETTINGS_TEST = "GAMIFICATION_UI_SETTINGS_TEST",
|
|
14
|
+
FRONT_END_ALLOWED_LANGUAGES = "FRONT_END_ALLOWED_LANGUAGES",
|
|
15
|
+
FRONT_END_ALLOW_DOMAINS = "FRONT_END_ALLOW_DOMAINS",
|
|
16
|
+
DELAY_ENGAGEMENT_EXECUTION_ON_LOGIN_MS = "DELAY_ENGAGEMENT_EXECUTION_ON_LOGIN_MS",
|
|
17
|
+
SHADOW_LABEL_PUBLIC_KEY = "SHADOW_LABEL_PUBLIC_KEY",
|
|
18
|
+
DYNAMIC_IMAGE_DOMAIN = "DYNAMIC_IMAGE_DOMAIN",
|
|
19
|
+
GAMIFICATION_UI_LEVEL_ENABLED = "GAMIFICATION_UI_LEVEL_ENABLED",
|
|
20
|
+
GAMIFICATION_UI_LEVEL_IMAGE_MOB = "GAMIFICATION_UI_LEVEL_IMAGE_MOB",
|
|
21
|
+
GAMIFICATION_UI_LEVEL_IMAGE_DESK = "GAMIFICATION_UI_LEVEL_IMAGE_DESK",
|
|
22
|
+
GAMIFICATION_LEVELS_LOGIC2 = "GAMIFICATION_LEVELS_LOGIC2",
|
|
23
|
+
AVATAR_CUSTOM_IMAGE_MAX_ID = "AVATAR_CUSTOM_IMAGE_MAX_ID",
|
|
24
|
+
AVATAR_CUSTOM_IMAGE_FOLDER = "AVATAR_CUSTOM_IMAGE_FOLDER",
|
|
25
|
+
RETENTION_GAMES_CUSTOMER_ID = "RETENTION_GAMES_CUSTOMER_ID",
|
|
26
|
+
GAMIFICATION_SHOW_POWERED_BY = "GAMIFICATION_SHOW_POWERED_BY",
|
|
27
|
+
_system_leader_board_mask_username = "_system_leader_board_mask_username"
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface PublicProperties {
|
|
2
|
+
core_user_language?: string;
|
|
3
|
+
ach_points_balance?: number;
|
|
4
|
+
ach_points_ever?: number;
|
|
5
|
+
ach_points_board_period_type_1?: number;
|
|
6
|
+
ach_points_board_period_type_2?: number;
|
|
7
|
+
ach_level_current_id?: number;
|
|
8
|
+
ach_level_current?: string;
|
|
9
|
+
core_is_test_account?: boolean;
|
|
10
|
+
ach_gamification_in_control_group?: boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ProtocolResponse } from "../Base/ProtocolResponse";
|
|
2
|
+
import { PublicProperties } from "./PublicProperties";
|
|
3
|
+
interface ResponseIdentify extends ProtocolResponse {
|
|
4
|
+
user_id: number;
|
|
5
|
+
ext_user_id: string;
|
|
6
|
+
public_username: string;
|
|
7
|
+
avatar_id: string;
|
|
8
|
+
job: boolean;
|
|
9
|
+
props?: PublicProperties;
|
|
10
|
+
pubic_username_set: boolean;
|
|
11
|
+
}
|
|
12
|
+
export { ResponseIdentify };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GetLabelInfoRequest } from './GetLabelInfoRequest';
|
|
2
|
+
import { GetLabelInfoResponse } from './GetLabelInfoResponse';
|
|
3
|
+
import { GetTranslationsRequest } from './GetTranslationsRequest';
|
|
4
|
+
import { GetTranslationsResponse } from './GetTranslationsResponse';
|
|
5
|
+
import { PublicLabelSettings } from './PublicLabelSettings';
|
|
6
|
+
import { ResponseIdentify } from './ResponseIdentify';
|
|
7
|
+
import { TranslationArea } from './TranslationArea';
|
|
8
|
+
export { GetTranslationsRequest, GetTranslationsResponse, GetLabelInfoRequest, GetLabelInfoResponse, TranslationArea, PublicLabelSettings, ResponseIdentify };
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { ProtocolResponse } from "./../Base/ProtocolResponse";
|
|
2
|
-
|
|
3
|
-
SAW_OK = 0,
|
|
4
|
-
SAW_NO_SPINS = 40001,
|
|
5
|
-
SAW_PRIZE_POOL_EMPTY = 40002,
|
|
6
|
-
SAW_NOT_ENOUGH_POINTS = 40003,
|
|
7
|
-
SAW_FAILED_MAX_SPINS_REACHED = 40004
|
|
8
|
-
}
|
|
2
|
+
import { SAWSpinErrorCode } from "./SAWSpinErrorCode";
|
|
9
3
|
export interface SAWDoSpinResponse extends ProtocolResponse {
|
|
10
4
|
errCode: SAWSpinErrorCode;
|
|
11
5
|
errMsg?: string;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
NOASK = "no-ask",
|
|
3
|
-
ONSUMBIT = "on-submit"
|
|
4
|
-
}
|
|
1
|
+
import { SAWAskForUsername } from "./SAWAskForUsername";
|
|
5
2
|
export interface SAWTemplateUI {
|
|
6
3
|
skin: string;
|
|
7
4
|
name: string;
|
|
@@ -25,7 +22,7 @@ export interface SAWTemplateUI {
|
|
|
25
22
|
jackpot_symbol?: string;
|
|
26
23
|
promo_image?: string;
|
|
27
24
|
promo_text?: string;
|
|
28
|
-
ask_for_username?:
|
|
25
|
+
ask_for_username?: SAWAskForUsername;
|
|
29
26
|
show_prize_board?: boolean;
|
|
30
27
|
max_spins_period_ms?: number;
|
|
31
28
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { SAWUtils } from "./SAWUtils";
|
|
1
2
|
import { SAWAcknowledgeType } from "./SAWAcknowledgeType";
|
|
3
|
+
import { SAWAskForUsername } from "./SAWAskForUsername";
|
|
2
4
|
import { SAWBuyInType, SAWBuyInTypeName } from "./SAWBuyInType";
|
|
3
5
|
import { SAWDoSpinRequest } from "./SAWDoSpinRequest";
|
|
4
|
-
import { SAWDoSpinResponse
|
|
6
|
+
import { SAWDoSpinResponse } from "./SAWDoSpinResponse";
|
|
5
7
|
import { SAWGameType, SAWGameTypeName } from "./SAWGameType";
|
|
6
8
|
import { SAWGetTemplatesRequest } from "./SAWGetTemplatesRequest";
|
|
7
9
|
import { SAWGetTemplatesResponse } from "./SAWGetTemplatesResponse";
|
|
8
10
|
import { SAWPrize } from "./SAWPrize";
|
|
9
11
|
import { SAWPrizeType } from "./SAWPrizeType";
|
|
10
12
|
import { SAWPrizeUI } from "./SAWPrizeUI";
|
|
13
|
+
import { SAWSpinErrorCode } from "./SAWSpinErrorCode";
|
|
11
14
|
import { SAWTemplate } from "./SAWTemplate";
|
|
12
15
|
import { SAWTemplateUI } from "./SAWTemplateUI";
|
|
13
16
|
import { SAWWinSoundType, SAWWinSoundFiles } from "./SAWWinSoundType";
|
|
14
|
-
export { SAWAcknowledgeType, SAWBuyInType, SAWBuyInTypeName, SAWDoSpinRequest, SAWDoSpinResponse,
|
|
17
|
+
export { SAWUtils, SAWAcknowledgeType, SAWBuyInType, SAWBuyInTypeName, SAWDoSpinRequest, SAWDoSpinResponse, SAWGameType, SAWGameTypeName, SAWGetTemplatesRequest, SAWGetTemplatesResponse, SAWPrize, SAWPrizeType, SAWPrizeUI, SAWTemplate, SAWTemplateUI, SAWWinSoundType, SAWWinSoundFiles, SAWAskForUsername, SAWSpinErrorCode };
|
package/dist/OCache.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum ECacheContext {
|
|
2
|
+
Translations = 0,
|
|
3
|
+
LabelInfo = 1
|
|
4
|
+
}
|
|
5
|
+
export declare class OCache {
|
|
6
|
+
private static cache;
|
|
7
|
+
static get<T>(oKey: any, cacheContext: ECacheContext): T | undefined;
|
|
8
|
+
static set(oKey: any, o: any, cacheContext: ECacheContext, ttlSeconds?: number): void;
|
|
9
|
+
static use<T>(oKey: any, cacheContext: ECacheContext, f: () => Promise<T>, ttlSeconds?: number): Promise<T>;
|
|
10
|
+
static clear(cacheContext: ECacheContext): Promise<void>;
|
|
11
|
+
}
|
package/dist/SmarticoAPI.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { ClassId } from "./Base/ClassId";
|
|
|
2
2
|
import { SAWGetTemplatesResponse } from './MiniGames/SAWGetTemplatesResponse';
|
|
3
3
|
import { SAWTemplate } from './MiniGames/SAWTemplate';
|
|
4
4
|
import { ILogger } from './ILogger';
|
|
5
|
+
import { SAWDoSpinResponse } from './MiniGames';
|
|
6
|
+
import { GetTranslationsResponse, ResponseIdentify, TranslationArea } from './Core';
|
|
7
|
+
import { GetLabelInfoResponse } from './Core/GetLabelInfoResponse';
|
|
5
8
|
interface IOptions {
|
|
6
9
|
logger?: ILogger;
|
|
7
10
|
logCIDs?: ClassId[];
|
|
@@ -11,13 +14,22 @@ declare class SmarticoAPI {
|
|
|
11
14
|
private label_api_key;
|
|
12
15
|
private brand_api_key;
|
|
13
16
|
private publicUrl;
|
|
17
|
+
private avatarDomain;
|
|
14
18
|
private logger;
|
|
15
19
|
private logCIDs;
|
|
16
20
|
private logHTTPTiming;
|
|
17
21
|
constructor(label_api_key: string, brand_api_key: string, options?: IOptions);
|
|
18
22
|
private send;
|
|
19
23
|
private buildMessage;
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
coreReportCustomEvent(user_ext_id: string, eventType: string, payload?: any): Promise<any>;
|
|
25
|
+
coreGetTranslations(user_ext_id: string, lang_code: string, areas: TranslationArea[], cacheSec?: number): Promise<GetTranslationsResponse>;
|
|
26
|
+
coreIdentifyLabel(user_ext_id: string, cacheSec?: number): Promise<GetLabelInfoResponse>;
|
|
27
|
+
coreIdentifyUser(user_ext_id: string): Promise<ResponseIdentify>;
|
|
28
|
+
coreChangeUsername(user_ext_id: string, public_username_custom: string): Promise<{
|
|
29
|
+
public_username_custom: string;
|
|
30
|
+
}>;
|
|
31
|
+
sawGetTemplates(user_ext_id: string): Promise<SAWGetTemplatesResponse>;
|
|
32
|
+
sawFormatTemplatesForWidget(templates: SAWTemplate[], pointsBalance: number): Promise<any[]>;
|
|
33
|
+
sawSpinRequest(user_ext_id: string, saw_template_id: number, round_id: number): Promise<SAWDoSpinResponse>;
|
|
22
34
|
}
|
|
23
35
|
export { SmarticoAPI };
|