@smartico/public-api 0.0.47 → 0.0.49
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 +36 -11
- package/dist/IntUtils.d.ts +1 -0
- package/dist/Level/GetLevelMapResponse.d.ts +2 -0
- package/dist/Missions/UserAchievement.d.ts +3 -0
- package/dist/SmarticoAPI.d.ts +10 -1
- package/dist/WSAPI/WSAPI.d.ts +8 -3
- package/dist/WSAPI/WSAPITypes.d.ts +124 -5
- package/dist/index.js +128 -32
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +85 -19
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +12 -0
- package/docs/classes/WSAPI.md +37 -0
- package/docs/interfaces/TLevel.md +74 -0
- package/docs/interfaces/TMissionOrBadge.md +167 -0
- package/docs/interfaces/TMissionOrBadgeTask.md +35 -0
- package/docs/interfaces/TUserProfile.md +81 -0
- package/package.json +1 -1
- package/src/IntUtils.ts +19 -0
- package/src/Level/GetLevelMapResponse.ts +16 -0
- package/src/Missions/UserAchievement.ts +39 -0
- package/src/SmarticoAPI.ts +32 -17
- package/src/WSAPI/WSAPI.ts +24 -8
- package/src/WSAPI/WSAPITypes.ts +126 -16
- package/tsconfig.json +7 -2
- package/docs_test/README_TWO.md +0 -57
- package/docs_test/classes/WSAPI.md +0 -19
- package/docs_test/interfaces/GetLevelMapClearedResponse.md +0 -57
- package/docs_test/modules.md +0 -13
- /package/{docs_test → docs}/.nojekyll +0 -0
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -1,29 +1,139 @@
|
|
|
1
|
-
import { GetLevelMapResponse } from "../Level"
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* TUser interface describes the information of the user
|
|
4
|
+
* The user object is returned by _smartico.api.getUserProfile() method.
|
|
5
|
+
* If you want to track the changes of the user profile, you can subscribe to the callback in the following way
|
|
6
|
+
* _smartico.on('props_change', () => console.log(_smartico.api.getUserProfile()) );
|
|
7
|
+
*/
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
export interface TUserProfile {
|
|
10
|
+
/** The language of the user */
|
|
11
|
+
core_user_language: string;
|
|
12
|
+
/** The current points balance that user can use in the Store, Mini-games, Tournaments, etc.. */
|
|
13
|
+
ach_points_balance: number;
|
|
14
|
+
/** The amount of points that user collected in total */
|
|
15
|
+
ach_points_ever: number;
|
|
16
|
+
/**
|
|
17
|
+
* The array of the public tags set on the user object.
|
|
18
|
+
* They can be treated as server-based cookies.
|
|
19
|
+
* You can set tags using following method _smartico.event('core_public_tags_update', { core_public_tags: ['A', 'B'] } );
|
|
20
|
+
* And then you can check for the tags
|
|
21
|
+
*/
|
|
22
|
+
core_public_tags: string[];
|
|
23
|
+
/** The ID of the current level of the user */
|
|
24
|
+
ach_level_current_id?: number;
|
|
25
|
+
/** The indicator if user is marked as test user */
|
|
26
|
+
core_is_test_account?: boolean;
|
|
27
|
+
/** The URL to the user avatar */
|
|
28
|
+
avatar_url?: string;
|
|
29
|
+
/** The username of current user */
|
|
30
|
+
public_username?: string;
|
|
31
|
+
/** THe number of unread inbox messages */
|
|
32
|
+
core_inbox_unread_count?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* TLevel interface describes the information of each level defined in the system
|
|
37
|
+
* There is no order of the levels, but it can be calculated using required_points property
|
|
38
|
+
* The current level of user can be taken from the user object using ach_level_current_id property
|
|
39
|
+
* The progress to the next level can be calculated using ach_points_ever and required_points properties of next level
|
|
40
|
+
*/
|
|
41
|
+
export interface TLevel {
|
|
7
42
|
|
|
43
|
+
/** The ID of the Level */
|
|
8
44
|
id: number,
|
|
45
|
+
/** The name of the Level, translated to the user language */
|
|
9
46
|
name: string,
|
|
47
|
+
/** The description of the Level, translated to the user language */
|
|
10
48
|
description: string,
|
|
49
|
+
/** The URL of the image of the Level */
|
|
11
50
|
image: string,
|
|
51
|
+
/** The amount of points required to reach the Level */
|
|
12
52
|
required_points: number,
|
|
53
|
+
/** Number of points that user should collect in order to see this level */
|
|
54
|
+
visibility_points: number;
|
|
55
|
+
/**
|
|
56
|
+
* The counter of 1st metric used to reach the Level.
|
|
57
|
+
* Relevant in case of using advanced leveling logic
|
|
58
|
+
* https://help.smartico.ai/welcome/more/release-notes/september-2022#new-logic-for-leveling-users
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
13
61
|
required_level_counter_1: number,
|
|
62
|
+
/**
|
|
63
|
+
* The counter of 2nd metric used to reach the Level.
|
|
64
|
+
* Relevant in case of using advanced leveling logic
|
|
65
|
+
* https://help.smartico.ai/welcome/more/release-notes/september-2022#new-logic-for-leveling-users
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
14
68
|
required_level_counter_2: number,
|
|
15
69
|
}
|
|
16
70
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
71
|
+
/**
|
|
72
|
+
* TMissionOrBadge interface describes the information of mission or badge defined in the system
|
|
73
|
+
*/
|
|
74
|
+
export interface TMissionOrBadge {
|
|
75
|
+
/** ID of the mission or badge */
|
|
76
|
+
id: number;
|
|
77
|
+
/** Type of entity. Can be 'mission' or 'badge' */
|
|
78
|
+
type: 'mission' | 'badge',
|
|
79
|
+
/** Name of the mission or badge, translated to the user language */
|
|
80
|
+
name: string;
|
|
81
|
+
/** Description of the mission or badge, translated to the user language */
|
|
82
|
+
desription: string;
|
|
83
|
+
/** Description of the mission reward if defined */
|
|
84
|
+
reward: string;
|
|
85
|
+
/** URL of the image of the mission or badge */
|
|
86
|
+
image: string;
|
|
87
|
+
/** Indicator if the mission is completed or badge is granted */
|
|
88
|
+
is_completed: boolean;
|
|
89
|
+
/** Indicator if the mission is locked. Means that it's visible to the user, but he cannot progress in it until it's unlocked.
|
|
90
|
+
* Mission may optionally contain the explanation of what should be done to unlock it in the unlock_mission_description property
|
|
91
|
+
*/
|
|
92
|
+
is_locked: boolean;
|
|
93
|
+
/** Optional explaination of what should be done to unlock the mission */
|
|
94
|
+
unlock_mission_description: string;
|
|
95
|
+
/** Indicator if the mission requires opt-in. Means that user should explicitly opt-in to the mission in order to start progressing in it */
|
|
96
|
+
is_requires_optin: boolean;
|
|
97
|
+
/** Indicator if the user opted-in to the mission */
|
|
98
|
+
is_opted_in: boolean;
|
|
99
|
+
/** The amount of time in milliseconds that user has to complete the mission */
|
|
100
|
+
time_limit_ms: number
|
|
101
|
+
/** The date when the mission was started, relevant for the time limited missions */
|
|
102
|
+
dt_start: number;
|
|
103
|
+
/** The progress of the mission in percents calculated as the aggregated relative percentage of all tasks */
|
|
104
|
+
progress: number;
|
|
105
|
+
/**
|
|
106
|
+
* The action that should be performed when user clicks on the mission or badge
|
|
107
|
+
* Can be URL or deep link, e.g. 'dp:deposit'. The most safe to execute CTA is to pass it to _smartico.do(cta_action);
|
|
108
|
+
* The 'dp' function will handle the CTA and will execute it in the most safe way
|
|
109
|
+
*/
|
|
110
|
+
cta_action: string,
|
|
111
|
+
/** The text of the CTA button, e.g. 'Make a deposit' */
|
|
112
|
+
cta_text: string,
|
|
113
|
+
/**
|
|
114
|
+
* The ID of the custom section where the mission or badge is assigned
|
|
115
|
+
* The list of custom sections can be retrieved using _smartico.api.getCustomSections() method (TODO-API)
|
|
116
|
+
*/
|
|
117
|
+
custom_section_id: number,
|
|
118
|
+
/** The indicator if the mission or badge is visible only in the custom section and should be hidden from the main overview of missions/badges */
|
|
119
|
+
only_in_custom_section: boolean,
|
|
120
|
+
/** The custom data of the mission or badge defined by operator. Can be a JSON object, string or number */
|
|
121
|
+
custom_data: any,
|
|
122
|
+
|
|
123
|
+
/** The list of tasks of the mission or badge */
|
|
124
|
+
tasks: TMissionOrBadgeTask[]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* TMissionOrBadgeTask interface describes the information of tasks that belings to mission or badge. See also TMissionOrBadge
|
|
129
|
+
*/
|
|
130
|
+
export interface TMissionOrBadgeTask {
|
|
131
|
+
/** ID of the task */
|
|
132
|
+
id: number,
|
|
133
|
+
/** Name of the task, translated to the user language */
|
|
134
|
+
name: string,
|
|
135
|
+
/** Indicator if the task is completed */
|
|
136
|
+
is_completed: boolean,
|
|
137
|
+
/** The progress of the task in percents */
|
|
138
|
+
progress: number
|
|
29
139
|
}
|
package/tsconfig.json
CHANGED
|
@@ -16,11 +16,16 @@
|
|
|
16
16
|
"typedocOptions": {
|
|
17
17
|
"name": "Smartico API documentation",
|
|
18
18
|
"entryPoints": ["src/WSAPI/WSAPI.ts", "src/WSAPI/WSAPITypes.ts"],
|
|
19
|
-
"out": "
|
|
19
|
+
"out": "docs",
|
|
20
20
|
"plugin": ["typedoc-plugin-markdown", "typedoc-plugin-merge-modules"],
|
|
21
|
-
"entryDocument": "
|
|
21
|
+
"entryDocument": "README.md",
|
|
22
22
|
"disableSources": true,
|
|
23
23
|
"excludePrivate": true,
|
|
24
|
+
"readme": "none",
|
|
25
|
+
"cleanOutputDir": true,
|
|
26
|
+
"hideBreadcrumbs": true,
|
|
27
|
+
"hideInPageTOC": true,
|
|
28
|
+
"sort": "source-order"
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
|
package/docs_test/README_TWO.md
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
Smartico API documentation / [Modules](modules.md)
|
|
2
|
-
|
|
3
|
-
# Smartico Public API
|
|
4
|
-
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
|
|
5
|
-
|
|
6
|
-
# Installation
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
npm install --save @smartico/public-api
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Usage
|
|
13
|
-
|
|
14
|
-
```typescript
|
|
15
|
-
import { SmarticoAPI } from '@smartico/public-api';
|
|
16
|
-
|
|
17
|
-
const SAPI = new SmarticoAPI( 'your-label-api-key', 'your-brand-key', 'your-message-sender', { logger: console });
|
|
18
|
-
|
|
19
|
-
const response = await SAPI.miniGamesGetTemplates(rsUser.user_ext_id);
|
|
20
|
-
|
|
21
|
-
response.templates.forEach( t => {
|
|
22
|
-
console.log(t.saw_template_ui_definition.name)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## API
|
|
28
|
-
### To learn more about the capabilities of our API, go to the [API documentation](docs_test/modules.md)
|
|
29
|
-
|
|
30
|
-
## Development and publishing process
|
|
31
|
-
|
|
32
|
-
### Publishing process
|
|
33
|
-
|
|
34
|
-
```sh
|
|
35
|
-
git commit
|
|
36
|
-
npm run build
|
|
37
|
-
npm version patch
|
|
38
|
-
npm run pub
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Debug locally
|
|
42
|
-
|
|
43
|
-
In the public-api project console:
|
|
44
|
-
|
|
45
|
-
```sh
|
|
46
|
-
npm link
|
|
47
|
-
# when you are done
|
|
48
|
-
npm unlink
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Consumer project console:
|
|
52
|
-
```bash
|
|
53
|
-
npm link @smartico/public-api --legacy-peer-deps
|
|
54
|
-
|
|
55
|
-
# when you are done
|
|
56
|
-
npm unlink @smartico/public-api --legacy-peer-deps && npm install @smartico/public-api --legacy-peer-deps
|
|
57
|
-
```
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
[Smartico API documentation](../README_TWO.md) / [Modules](../modules.md) / WSAPI
|
|
2
|
-
|
|
3
|
-
# Class: WSAPI
|
|
4
|
-
|
|
5
|
-
## Table of contents
|
|
6
|
-
|
|
7
|
-
### Methods
|
|
8
|
-
|
|
9
|
-
- [getLevelsTransformed](WSAPI.md#getlevelstransformed)
|
|
10
|
-
|
|
11
|
-
## Methods
|
|
12
|
-
|
|
13
|
-
### getLevelsTransformed
|
|
14
|
-
|
|
15
|
-
▸ **getLevelsTransformed**(): `Promise`<[`GetLevelMapClearedResponse`](../interfaces/GetLevelMapClearedResponse.md)[]\>
|
|
16
|
-
|
|
17
|
-
#### Returns
|
|
18
|
-
|
|
19
|
-
`Promise`<[`GetLevelMapClearedResponse`](../interfaces/GetLevelMapClearedResponse.md)[]\>
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
[Smartico API documentation](../README_TWO.md) / [Modules](../modules.md) / GetLevelMapClearedResponse
|
|
2
|
-
|
|
3
|
-
# Interface: GetLevelMapClearedResponse
|
|
4
|
-
|
|
5
|
-
## Table of contents
|
|
6
|
-
|
|
7
|
-
### Properties
|
|
8
|
-
|
|
9
|
-
- [description](GetLevelMapClearedResponse.md#description)
|
|
10
|
-
- [id](GetLevelMapClearedResponse.md#id)
|
|
11
|
-
- [image](GetLevelMapClearedResponse.md#image)
|
|
12
|
-
- [name](GetLevelMapClearedResponse.md#name)
|
|
13
|
-
- [required\_level\_counter\_1](GetLevelMapClearedResponse.md#required_level_counter_1)
|
|
14
|
-
- [required\_level\_counter\_2](GetLevelMapClearedResponse.md#required_level_counter_2)
|
|
15
|
-
- [required\_points](GetLevelMapClearedResponse.md#required_points)
|
|
16
|
-
|
|
17
|
-
## Properties
|
|
18
|
-
|
|
19
|
-
### description
|
|
20
|
-
|
|
21
|
-
• **description**: `string`
|
|
22
|
-
|
|
23
|
-
___
|
|
24
|
-
|
|
25
|
-
### id
|
|
26
|
-
|
|
27
|
-
• **id**: `number`
|
|
28
|
-
|
|
29
|
-
___
|
|
30
|
-
|
|
31
|
-
### image
|
|
32
|
-
|
|
33
|
-
• **image**: `string`
|
|
34
|
-
|
|
35
|
-
___
|
|
36
|
-
|
|
37
|
-
### name
|
|
38
|
-
|
|
39
|
-
• **name**: `string`
|
|
40
|
-
|
|
41
|
-
___
|
|
42
|
-
|
|
43
|
-
### required\_level\_counter\_1
|
|
44
|
-
|
|
45
|
-
• **required\_level\_counter\_1**: `number`
|
|
46
|
-
|
|
47
|
-
___
|
|
48
|
-
|
|
49
|
-
### required\_level\_counter\_2
|
|
50
|
-
|
|
51
|
-
• **required\_level\_counter\_2**: `number`
|
|
52
|
-
|
|
53
|
-
___
|
|
54
|
-
|
|
55
|
-
### required\_points
|
|
56
|
-
|
|
57
|
-
• **required\_points**: `number`
|
package/docs_test/modules.md
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
[Smartico API documentation](README_TWO.md) / Modules
|
|
2
|
-
|
|
3
|
-
# Smartico API documentation
|
|
4
|
-
|
|
5
|
-
## Table of contents
|
|
6
|
-
|
|
7
|
-
### General API
|
|
8
|
-
|
|
9
|
-
- [WSAPI](classes/WSAPI.md)
|
|
10
|
-
|
|
11
|
-
### Levels response
|
|
12
|
-
|
|
13
|
-
- [GetLevelMapClearedResponse](interfaces/GetLevelMapClearedResponse.md)
|
|
File without changes
|