@smartico/public-api 0.0.57 → 0.0.59
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/MiniGames/SAWPrizeUI.d.ts +1 -0
- package/dist/MiniGames/SAWSpinErrorCode.d.ts +6 -0
- package/dist/SmarticoAPI.d.ts +1 -1
- package/dist/WSAPI/WSAPI.d.ts +3 -1
- package/dist/WSAPI/WSAPITypes.d.ts +22 -11
- package/dist/index.js +29 -5
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +20 -1
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +2 -0
- package/docs/classes/WSAPI.md +20 -2
- package/docs/enums/SAWSpinErrorCode.md +49 -0
- package/docs/interfaces/TLevel.md +1 -1
- package/docs/interfaces/TMiniGamePlayResult.md +27 -0
- package/docs/interfaces/TMiniGamePrize.md +1 -1
- package/docs/interfaces/TMiniGameTemplate.md +1 -1
- package/docs/interfaces/TMissionOrBadge.md +1 -1
- package/docs/interfaces/TMissionOrBadgeTask.md +1 -1
- package/docs/interfaces/TStoreCategory.md +1 -1
- package/docs/interfaces/TStoreItem.md +1 -1
- package/docs/interfaces/TTournament.md +1 -1
- package/docs/interfaces/TTournamentDetailed.md +1 -1
- package/docs/interfaces/TUserProfile.md +1 -1
- package/package.json +1 -1
- package/src/MiniGames/SAWPrizeUI.ts +1 -0
- package/src/MiniGames/SAWSpinErrorCode.ts +10 -2
- package/src/SmarticoAPI.ts +1 -1
- package/src/WSAPI/WSAPI.ts +16 -2
- package/src/WSAPI/WSAPITypes.ts +23 -11
- package/tsconfig.json +1 -0
package/docs/README.md
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
- [SAWBuyInTypeName](enums/SAWBuyInTypeName.md)
|
|
6
6
|
- [SAWGameTypeName](enums/SAWGameTypeName.md)
|
|
7
7
|
- [MiniGamePrizeTypeName](enums/MiniGamePrizeTypeName.md)
|
|
8
|
+
- [SAWSpinErrorCode](enums/SAWSpinErrorCode.md)
|
|
8
9
|
- [TournamentRegistrationStatusName](enums/TournamentRegistrationStatusName.md)
|
|
9
10
|
|
|
10
11
|
## Interfaces
|
|
11
12
|
|
|
12
13
|
- [TMiniGamePrize](interfaces/TMiniGamePrize.md)
|
|
14
|
+
- [TMiniGamePlayResult](interfaces/TMiniGamePlayResult.md)
|
|
13
15
|
- [TMiniGameTemplate](interfaces/TMiniGameTemplate.md)
|
|
14
16
|
- [TUserProfile](interfaces/TUserProfile.md)
|
|
15
17
|
- [TLevel](interfaces/TLevel.md)
|
package/docs/classes/WSAPI.md
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
### getUserProfile
|
|
6
6
|
|
|
7
|
-
▸ **getUserProfile**():
|
|
7
|
+
▸ **getUserProfile**(): [`TUserProfile`](../interfaces/TUserProfile.md)
|
|
8
8
|
|
|
9
9
|
Returns information about current user
|
|
10
10
|
|
|
11
11
|
#### Returns
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
[`TUserProfile`](../interfaces/TUserProfile.md)
|
|
14
14
|
|
|
15
15
|
___
|
|
16
16
|
|
|
@@ -86,6 +86,24 @@ Returns the list of mini-games available for user
|
|
|
86
86
|
|
|
87
87
|
___
|
|
88
88
|
|
|
89
|
+
### playMiniGame
|
|
90
|
+
|
|
91
|
+
▸ **playMiniGame**(`template_id`): `Promise`<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
|
|
92
|
+
|
|
93
|
+
Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
|
|
94
|
+
|
|
95
|
+
#### Parameters
|
|
96
|
+
|
|
97
|
+
| Name | Type |
|
|
98
|
+
| :------ | :------ |
|
|
99
|
+
| `template_id` | `number` |
|
|
100
|
+
|
|
101
|
+
#### Returns
|
|
102
|
+
|
|
103
|
+
`Promise`<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
|
|
104
|
+
|
|
105
|
+
___
|
|
106
|
+
|
|
89
107
|
### getTournamentsList
|
|
90
108
|
|
|
91
109
|
▸ **getTournamentsList**(): `Promise`<[`TTournament`](../interfaces/TTournament.md)[]\>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Enumeration: SAWSpinErrorCode
|
|
2
|
+
|
|
3
|
+
## Enumeration Members
|
|
4
|
+
|
|
5
|
+
### SAW\_OK
|
|
6
|
+
|
|
7
|
+
• **SAW\_OK** = ``0``
|
|
8
|
+
|
|
9
|
+
No error
|
|
10
|
+
|
|
11
|
+
___
|
|
12
|
+
|
|
13
|
+
### SAW\_NO\_SPINS
|
|
14
|
+
|
|
15
|
+
• **SAW\_NO\_SPINS** = ``40001``
|
|
16
|
+
|
|
17
|
+
User doesn't have 'spin attempts' to play. In case buy in type for the game is 'spins' based
|
|
18
|
+
|
|
19
|
+
___
|
|
20
|
+
|
|
21
|
+
### SAW\_PRIZE\_POOL\_EMPTY
|
|
22
|
+
|
|
23
|
+
• **SAW\_PRIZE\_POOL\_EMPTY** = ``40002``
|
|
24
|
+
|
|
25
|
+
The are no prizes left to play the game
|
|
26
|
+
|
|
27
|
+
___
|
|
28
|
+
|
|
29
|
+
### SAW\_NOT\_ENOUGH\_POINTS
|
|
30
|
+
|
|
31
|
+
• **SAW\_NOT\_ENOUGH\_POINTS** = ``40003``
|
|
32
|
+
|
|
33
|
+
User doesn't have enough points to play. In case buy in type for the game is 'points' based
|
|
34
|
+
|
|
35
|
+
___
|
|
36
|
+
|
|
37
|
+
### SAW\_FAILED\_MAX\_SPINS\_REACHED
|
|
38
|
+
|
|
39
|
+
• **SAW\_FAILED\_MAX\_SPINS\_REACHED** = ``40004``
|
|
40
|
+
|
|
41
|
+
User reached max number of game attempts defined in the BackOffice
|
|
42
|
+
|
|
43
|
+
___
|
|
44
|
+
|
|
45
|
+
### SAW\_VISITOR\_STOP\_SPIN\_REQUEST
|
|
46
|
+
|
|
47
|
+
• **SAW\_VISITOR\_STOP\_SPIN\_REQUEST** = ``-40001``
|
|
48
|
+
|
|
49
|
+
Special code for the 'visitor' mode
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Interface: TLevel
|
|
2
2
|
|
|
3
|
-
TLevel
|
|
3
|
+
TLevel describes the information of each level defined in the system
|
|
4
4
|
There is no order of the levels, but it can be calculated using required_points property
|
|
5
5
|
The current level of user can be taken from the user object using ach_level_current_id property
|
|
6
6
|
The progress to the next level can be calculated using ach_points_ever and required_points properties of next level
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Interface: TMiniGamePlayResult
|
|
2
|
+
|
|
3
|
+
TMiniGamePlayResult describes the response of call to _smartico.api.playMiniGame(template_id) method
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### err\_code
|
|
8
|
+
|
|
9
|
+
• **err\_code**: [`SAWSpinErrorCode`](../enums/SAWSpinErrorCode.md)
|
|
10
|
+
|
|
11
|
+
Error code that represents outcome of the game play attempt. Game succeed to be played in case err_code is 0
|
|
12
|
+
|
|
13
|
+
___
|
|
14
|
+
|
|
15
|
+
### err\_message
|
|
16
|
+
|
|
17
|
+
• **err\_message**: `string`
|
|
18
|
+
|
|
19
|
+
Optional error message
|
|
20
|
+
|
|
21
|
+
___
|
|
22
|
+
|
|
23
|
+
### prize\_id
|
|
24
|
+
|
|
25
|
+
• **prize\_id**: `number`
|
|
26
|
+
|
|
27
|
+
The prize_id that user won, details of the prize can be found in the mini-game definition
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Interface: TMissionOrBadgeTask
|
|
2
2
|
|
|
3
|
-
TMissionOrBadgeTask
|
|
3
|
+
TMissionOrBadgeTask describes the information of tasks that belings to mission or badge. See also TMissionOrBadge
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Interface: TStoreCategory
|
|
2
2
|
|
|
3
|
-
TStoreCategory
|
|
3
|
+
TStoreCategory describes the store category item. Each store item can be assigned to 1 or more categories
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Interface: TTournamentDetailed
|
|
2
2
|
|
|
3
|
-
TTournamentDetailed
|
|
3
|
+
TTournamentDetailed describes the information of the tournament item and includes list of participants, their scores and position in the tournament leaderboard
|
|
4
4
|
|
|
5
5
|
## Hierarchy
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Interface: TUserProfile
|
|
2
2
|
|
|
3
|
-
TUser
|
|
3
|
+
TUser describes the information of the user
|
|
4
4
|
The user object is returned by _smartico.api.getUserProfile() method.
|
|
5
5
|
If you want to track the changes of the user profile, you can subscribe to the callback in the following way
|
|
6
6
|
_smartico.on('props_change', () => console.log(_smartico.api.getUserProfile()) );
|
package/package.json
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
/*
|
|
3
|
+
* Possible error codes for the mini-games attempts
|
|
4
|
+
*/
|
|
2
5
|
export enum SAWSpinErrorCode {
|
|
6
|
+
/** No error */
|
|
3
7
|
SAW_OK = 0,
|
|
8
|
+
/** User doesn't have 'spin attempts' to play. In case buy in type for the game is 'spins' based */
|
|
4
9
|
SAW_NO_SPINS = 40001,
|
|
10
|
+
/** The are no prizes left to play the game */
|
|
5
11
|
SAW_PRIZE_POOL_EMPTY = 40002,
|
|
12
|
+
/** User doesn't have enough points to play. In case buy in type for the game is 'points' based */
|
|
6
13
|
SAW_NOT_ENOUGH_POINTS = 40003,
|
|
14
|
+
/** User reached max number of game attempts defined in the BackOffice */
|
|
7
15
|
SAW_FAILED_MAX_SPINS_REACHED = 40004,
|
|
8
|
-
|
|
9
|
-
SAW_VISITOR_STOP_SPIN_REQUEST = -40001
|
|
16
|
+
/** Special code for the 'visitor' mode */
|
|
17
|
+
SAW_VISITOR_STOP_SPIN_REQUEST = -40001
|
|
10
18
|
}
|
package/src/SmarticoAPI.ts
CHANGED
|
@@ -295,7 +295,7 @@ class SmarticoAPI {
|
|
|
295
295
|
return SAWTemplatesTransform((await this.sawGetTemplates(user_ext_id)).templates);
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
public async sawSpinRequest(user_ext_id: string, saw_template_id: number, round_id
|
|
298
|
+
public async sawSpinRequest(user_ext_id: string, saw_template_id: number, round_id?: number): Promise<SAWDoSpinResponse> {
|
|
299
299
|
|
|
300
300
|
const message = this.buildMessage<SAWDoSpinRequest, SAWDoSpinResponse>(user_ext_id, ClassId.SAW_DO_SPIN_REQUEST, {
|
|
301
301
|
saw_template_id,
|
package/src/WSAPI/WSAPI.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CoreUtils } from "../Core";
|
|
2
2
|
import { SmarticoAPI } from "../SmarticoAPI";
|
|
3
3
|
|
|
4
|
-
import { TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TUserProfile } from "./WSAPITypes";
|
|
4
|
+
import { TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TUserProfile } from "./WSAPITypes";
|
|
5
5
|
|
|
6
6
|
/** @group General API */
|
|
7
7
|
export class WSAPI {
|
|
@@ -49,7 +49,21 @@ export class WSAPI {
|
|
|
49
49
|
/** Returns the list of mini-games available for user */
|
|
50
50
|
public async getMiniGames(): Promise<TMiniGameTemplate[]> {
|
|
51
51
|
return this.api.sawGetTemplatesT(null);
|
|
52
|
-
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code */
|
|
55
|
+
public async playMiniGame(template_id: number): Promise<TMiniGamePlayResult> {
|
|
56
|
+
|
|
57
|
+
const r = await this.api.sawSpinRequest(null, template_id);
|
|
58
|
+
|
|
59
|
+
const o: TMiniGamePlayResult = {
|
|
60
|
+
err_code: r.errCode,
|
|
61
|
+
err_message: r.errMsg,
|
|
62
|
+
prize_id: r.saw_prize_id,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return o;
|
|
66
|
+
}
|
|
53
67
|
|
|
54
68
|
/** Returns all the active instances of tournaments */
|
|
55
69
|
public async getTournamentsList(): Promise<TTournament[]> {
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { MiniGamePrizeTypeName, SAWBuyInTypeName, SAWGameTypeName, SAWPrizeType, SAWPrizeUI } from "../MiniGames";
|
|
1
|
+
import { MiniGamePrizeTypeName, SAWBuyInTypeName, SAWGameTypeName, SAWPrizeType, SAWPrizeUI, SAWSpinErrorCode } from "../MiniGames";
|
|
2
2
|
import { TournamentRegistrationStatusName, TournamentRegistrationTypeName } from "../Tournaments";
|
|
3
3
|
|
|
4
4
|
type TRibbon = 'sale' | 'hot' | 'new' | 'vip' | string
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* TMiniGamePrize
|
|
8
|
+
* TMiniGamePrize describes the information of prize in the array of prizes in the TMiniGameTemplate
|
|
9
9
|
*/
|
|
10
10
|
export interface TMiniGamePrize {
|
|
11
11
|
/** ID of the prize */
|
|
@@ -23,9 +23,21 @@ export interface TMiniGamePrize {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* TMiniGamePlayResult describes the response of call to _smartico.api.playMiniGame(template_id) method
|
|
28
|
+
*/
|
|
29
|
+
export interface TMiniGamePlayResult {
|
|
30
|
+
/** Error code that represents outcome of the game play attempt. Game succeed to be played in case err_code is 0 */
|
|
31
|
+
err_code: SAWSpinErrorCode;
|
|
32
|
+
/** Optional error message */
|
|
33
|
+
err_message: string;
|
|
34
|
+
/** The prize_id that user won, details of the prize can be found in the mini-game definition */
|
|
35
|
+
prize_id: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
26
38
|
|
|
27
39
|
/**
|
|
28
|
-
* TMiniGameTemplate
|
|
40
|
+
* TMiniGameTemplate describes the information of mini-games available for the user
|
|
29
41
|
*/
|
|
30
42
|
export interface TMiniGameTemplate {
|
|
31
43
|
/** ID of the mini-game template */
|
|
@@ -69,7 +81,7 @@ export interface TMiniGameTemplate {
|
|
|
69
81
|
|
|
70
82
|
|
|
71
83
|
/**
|
|
72
|
-
* TUser
|
|
84
|
+
* TUser describes the information of the user
|
|
73
85
|
* The user object is returned by _smartico.api.getUserProfile() method.
|
|
74
86
|
* If you want to track the changes of the user profile, you can subscribe to the callback in the following way
|
|
75
87
|
* _smartico.on('props_change', () => console.log(_smartico.api.getUserProfile()) );
|
|
@@ -102,7 +114,7 @@ export interface TUserProfile {
|
|
|
102
114
|
}
|
|
103
115
|
|
|
104
116
|
/**
|
|
105
|
-
* TLevel
|
|
117
|
+
* TLevel describes the information of each level defined in the system
|
|
106
118
|
* There is no order of the levels, but it can be calculated using required_points property
|
|
107
119
|
* The current level of user can be taken from the user object using ach_level_current_id property
|
|
108
120
|
* The progress to the next level can be calculated using ach_points_ever and required_points properties of next level
|
|
@@ -138,7 +150,7 @@ export interface TLevel {
|
|
|
138
150
|
}
|
|
139
151
|
|
|
140
152
|
/**
|
|
141
|
-
* TTournament
|
|
153
|
+
* TTournament describes the general information of the tournament item
|
|
142
154
|
*/
|
|
143
155
|
|
|
144
156
|
export interface TTournament {
|
|
@@ -213,7 +225,7 @@ export interface TTournament {
|
|
|
213
225
|
}
|
|
214
226
|
|
|
215
227
|
/**
|
|
216
|
-
* TTournamentDetailed
|
|
228
|
+
* TTournamentDetailed describes the information of the tournament item and includes list of participants, their scores and position in the tournament leaderboard
|
|
217
229
|
*/
|
|
218
230
|
export interface TTournamentDetailed extends TTournament {
|
|
219
231
|
|
|
@@ -245,7 +257,7 @@ export interface TTournamentDetailed extends TTournament {
|
|
|
245
257
|
};
|
|
246
258
|
|
|
247
259
|
/**
|
|
248
|
-
* TStoreCategory
|
|
260
|
+
* TStoreCategory describes the store category item. Each store item can be assigned to 1 or more categories
|
|
249
261
|
*/
|
|
250
262
|
export interface TStoreCategory {
|
|
251
263
|
id: number;
|
|
@@ -254,7 +266,7 @@ export interface TStoreCategory {
|
|
|
254
266
|
}
|
|
255
267
|
|
|
256
268
|
/**
|
|
257
|
-
* TStoreItem
|
|
269
|
+
* TStoreItem describes the information of the store item defined in the system
|
|
258
270
|
*/
|
|
259
271
|
export interface TStoreItem {
|
|
260
272
|
/** ID of the store item */
|
|
@@ -290,7 +302,7 @@ export interface TStoreItem {
|
|
|
290
302
|
}
|
|
291
303
|
|
|
292
304
|
/**
|
|
293
|
-
* TMissionOrBadge
|
|
305
|
+
* TMissionOrBadge describes the information of mission or badge defined in the system
|
|
294
306
|
*/
|
|
295
307
|
export interface TMissionOrBadge {
|
|
296
308
|
/** ID of the mission or badge */
|
|
@@ -346,7 +358,7 @@ export interface TMissionOrBadge {
|
|
|
346
358
|
}
|
|
347
359
|
|
|
348
360
|
/**
|
|
349
|
-
* TMissionOrBadgeTask
|
|
361
|
+
* TMissionOrBadgeTask describes the information of tasks that belings to mission or badge. See also TMissionOrBadge
|
|
350
362
|
*/
|
|
351
363
|
export interface TMissionOrBadgeTask {
|
|
352
364
|
/** ID of the task */
|
package/tsconfig.json
CHANGED