@smartico/public-api 0.0.72 → 0.0.74
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/SmarticoAPI.d.ts +2 -1
- package/dist/WSAPI/WSAPI.d.ts +15 -2
- package/dist/WSAPI/WSAPITypes.d.ts +9 -0
- package/dist/index.js +119 -71
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +32 -1
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +1 -0
- package/docs/classes/WSAPI.md +29 -20
- package/docs/interfaces/TMissionOptInResult.md +19 -0
- package/package.json +1 -1
- package/src/SmarticoAPI.ts +11 -1
- package/src/WSAPI/WSAPI.ts +32 -4
- package/src/WSAPI/WSAPITypes.ts +10 -0
package/docs/README.md
CHANGED
package/docs/classes/WSAPI.md
CHANGED
|
@@ -28,18 +28,14 @@ ___
|
|
|
28
28
|
|
|
29
29
|
### getMissions
|
|
30
30
|
|
|
31
|
-
▸ **getMissions**(
|
|
32
|
-
|
|
33
|
-
Returns all the missions available the current user.
|
|
34
|
-
The returned missions is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
35
|
-
The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it.
|
|
31
|
+
▸ **getMissions**(`params?`): `Promise`<[`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]\>
|
|
36
32
|
|
|
37
33
|
#### Parameters
|
|
38
34
|
|
|
39
35
|
| Name | Type |
|
|
40
36
|
| :------ | :------ |
|
|
41
|
-
|
|
|
42
|
-
|
|
|
37
|
+
| `params` | `Object` |
|
|
38
|
+
| `params.onUpdate?` | (`data`: [`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]) => `void` |
|
|
43
39
|
|
|
44
40
|
#### Returns
|
|
45
41
|
|
|
@@ -85,18 +81,17 @@ ___
|
|
|
85
81
|
|
|
86
82
|
### getMiniGames
|
|
87
83
|
|
|
88
|
-
▸ **getMiniGames**(
|
|
84
|
+
▸ **getMiniGames**(`params?`): `Promise`<[`TMiniGameTemplate`](../interfaces/TMiniGameTemplate.md)[]\>
|
|
89
85
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one. Updated templates will be passed to onUpdate callback.
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
93
88
|
|
|
94
89
|
#### Parameters
|
|
95
90
|
|
|
96
91
|
| Name | Type |
|
|
97
92
|
| :------ | :------ |
|
|
98
|
-
|
|
|
99
|
-
|
|
|
93
|
+
| `params` | `Object` |
|
|
94
|
+
| `params.onUpdate?` | (`data`: [`TMiniGameTemplate`](../interfaces/TMiniGameTemplate.md)[]) => `void` |
|
|
100
95
|
|
|
101
96
|
#### Returns
|
|
102
97
|
|
|
@@ -122,20 +117,34 @@ Plays the specified by template_id mini-game on behalf of user and returns prize
|
|
|
122
117
|
|
|
123
118
|
___
|
|
124
119
|
|
|
125
|
-
###
|
|
120
|
+
### requestMissionOptIn
|
|
121
|
+
|
|
122
|
+
▸ **requestMissionOptIn**(`mission_id`): `Promise`<[`TMissionOptInResult`](../interfaces/TMissionOptInResult.md)\>
|
|
123
|
+
|
|
124
|
+
Requests an opt-in for the specified mission_id. Returns the err_code.
|
|
126
125
|
|
|
127
|
-
|
|
126
|
+
#### Parameters
|
|
127
|
+
|
|
128
|
+
| Name | Type |
|
|
129
|
+
| :------ | :------ |
|
|
130
|
+
| `mission_id` | `number` |
|
|
131
|
+
|
|
132
|
+
#### Returns
|
|
133
|
+
|
|
134
|
+
`Promise`<[`TMissionOptInResult`](../interfaces/TMissionOptInResult.md)\>
|
|
135
|
+
|
|
136
|
+
___
|
|
137
|
+
|
|
138
|
+
### getTournamentsList
|
|
128
139
|
|
|
129
|
-
|
|
130
|
-
The returned list is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getTournamentsList with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
131
|
-
The onUpdate callback will be called when the user has registered in a tournament. Updated list will be passed to onUpdate callback.
|
|
140
|
+
▸ **getTournamentsList**(`params?`): `Promise`<[`TTournament`](../interfaces/TTournament.md)[]\>
|
|
132
141
|
|
|
133
142
|
#### Parameters
|
|
134
143
|
|
|
135
144
|
| Name | Type |
|
|
136
145
|
| :------ | :------ |
|
|
137
|
-
|
|
|
138
|
-
|
|
|
146
|
+
| `params` | `Object` |
|
|
147
|
+
| `params.onUpdate?` | (`data`: [`TTournament`](../interfaces/TTournament.md)[]) => `void` |
|
|
139
148
|
|
|
140
149
|
#### Returns
|
|
141
150
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Interface: TMissionOptInResult
|
|
2
|
+
|
|
3
|
+
TMissionOptInResult describes the response of call to _smartico.api.requestMissionOptIn(mission_id) method
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### err\_code
|
|
8
|
+
|
|
9
|
+
• **err\_code**: `number`
|
|
10
|
+
|
|
11
|
+
Error code that represents outcome of the opt-in request. Successful opt-in in case err_code is 0
|
|
12
|
+
|
|
13
|
+
___
|
|
14
|
+
|
|
15
|
+
### err\_message
|
|
16
|
+
|
|
17
|
+
• **err\_message**: `string`
|
|
18
|
+
|
|
19
|
+
Optional error message
|
package/package.json
CHANGED
package/src/SmarticoAPI.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { GetLabelInfoResponse } from './Core/GetLabelInfoResponse';
|
|
|
12
12
|
import { GetLabelInfoRequest } from './Core/GetLabelInfoRequest';
|
|
13
13
|
import { GetInboxMessagesRequest, GetInboxMessagesResponse } from './Inbox';
|
|
14
14
|
import { GetCategoriesStoreResponse, GetStoreItemsResponse, StoreCategoryTransform, StoreItemTransform } from './Store';
|
|
15
|
-
import { AchievementType, GetAchievementMapRequest, GetAchievementMapResponse, UserAchievementTransform } from './Missions';
|
|
15
|
+
import { AchievementOptinRequest, AchievementOptinResponse, AchievementType, GetAchievementMapRequest, GetAchievementMapResponse, UserAchievementTransform } from './Missions';
|
|
16
16
|
import { GetTournamentInfoRequest, GetTournamentInfoResponse, GetTournamentsRequest, GetTournamentsResponse, TournamentItemsTransform, tournamentInfoItemTransform } from './Tournaments';
|
|
17
17
|
import { GetLeaderBoardsRequest, GetLeaderBoardsResponse, LeaderBoardDetails, LeaderBoardPeriodType } from "./Leaderboard";
|
|
18
18
|
import { GetLevelMapResponse, GetLevelMapResponseTransform } from "./Level";
|
|
@@ -334,6 +334,16 @@ class SmarticoAPI {
|
|
|
334
334
|
return {...spinAttemptResponse, request_id };
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
public async missionOptIn(user_ext_id: string, mission_id: number) {
|
|
338
|
+
const message = this.buildMessage<AchievementOptinRequest, AchievementOptinResponse>(user_ext_id, ClassId.MISSION_OPTIN_REQUEST, {
|
|
339
|
+
achievementId: mission_id
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
const res = await this.send<AchievementOptinResponse>(message, ClassId.MISSION_OPTIN_RESPONSE);
|
|
343
|
+
|
|
344
|
+
return res;
|
|
345
|
+
}
|
|
346
|
+
|
|
337
347
|
public async inboxGetMessages(user_ext_id: string, limit: number = 10, offset: number = 0): Promise<GetInboxMessagesResponse> {
|
|
338
348
|
|
|
339
349
|
const message = this.buildMessage<GetInboxMessagesRequest, GetInboxMessagesResponse>(user_ext_id, ClassId.GET_INBOX_MESSAGES_REQUEST, {
|
package/src/WSAPI/WSAPI.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { CoreUtils } from "../Core";
|
|
|
3
3
|
import { MiniGamePrizeTypeName, SAWDoSpinResponse, SAWSpinErrorCode, SAWSpinsCountPush } from "../MiniGames";
|
|
4
4
|
import { ECacheContext, OCache } from "../OCache";
|
|
5
5
|
import { SmarticoAPI } from "../SmarticoAPI";
|
|
6
|
-
import { TLevel, TMiniGamePlayResult, TMiniGamePrize, TMiniGameTemplate, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TUserProfile } from "./WSAPITypes";
|
|
6
|
+
import { TLevel, TMiniGamePlayResult, TMiniGamePrize, TMiniGameTemplate, TMissionOptInResult, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TUserProfile } from "./WSAPITypes";
|
|
7
7
|
|
|
8
8
|
/** @hidden */
|
|
9
9
|
const CACHE_DATA_SEC = 30;
|
|
@@ -24,6 +24,7 @@ export class WSAPI {
|
|
|
24
24
|
constructor(private api: SmarticoAPI) {
|
|
25
25
|
const on = this.api.tracker.on;
|
|
26
26
|
on(ClassId.SAW_SPINS_COUNT_PUSH, (data: SAWSpinsCountPush) => this.updateOnSpin(data));
|
|
27
|
+
on(ClassId.SAW_SHOW_SPIN_PUSH, () => this.updateOnAddSpin());
|
|
27
28
|
on(ClassId.SAW_DO_SPIN_RESPONSE, (data: SAWDoSpinResponse) => on(ClassId.SAW_AKNOWLEDGE_RESPONSE, () => this.updateOnPrizeWin(data)));
|
|
28
29
|
on(ClassId.MISSION_OPTIN_RESPONSE, () => this.updateMissionsOnOptIn());
|
|
29
30
|
on(ClassId.TOURNAMENT_REGISTER_RESPONSE, () => this.updateTournamentsOnRegistration());
|
|
@@ -47,7 +48,10 @@ export class WSAPI {
|
|
|
47
48
|
|
|
48
49
|
/** Returns all the missions available the current user.
|
|
49
50
|
* The returned missions is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
50
|
-
* The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it. */
|
|
51
|
+
* The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it. */
|
|
52
|
+
/**
|
|
53
|
+
* @param params
|
|
54
|
+
*/
|
|
51
55
|
public async getMissions({ onUpdate }: { onUpdate?: (data: TMissionOrBadge[]) => void } = {}): Promise<TMissionOrBadge[]> {
|
|
52
56
|
if (onUpdate) {
|
|
53
57
|
this.onUpdateCallback.set(onUpdateContextKey.Missions, onUpdate);
|
|
@@ -73,7 +77,11 @@ export class WSAPI {
|
|
|
73
77
|
|
|
74
78
|
/** Returns the list of mini-games available for user
|
|
75
79
|
* The returned list of mini-games is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMiniGames with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
76
|
-
* The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one. Updated templates will be passed to onUpdate callback. */
|
|
80
|
+
* The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback. */
|
|
81
|
+
/**
|
|
82
|
+
/**
|
|
83
|
+
* @param params
|
|
84
|
+
*/
|
|
77
85
|
public async getMiniGames({ onUpdate }: { onUpdate?: (data: TMiniGameTemplate[]) => void } = {}): Promise<TMiniGameTemplate[]> {
|
|
78
86
|
if (onUpdate) {
|
|
79
87
|
this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
|
|
@@ -94,11 +102,26 @@ export class WSAPI {
|
|
|
94
102
|
}
|
|
95
103
|
|
|
96
104
|
return o;
|
|
97
|
-
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Requests an opt-in for the specified mission_id. Returns the err_code. */
|
|
108
|
+
public async requestMissionOptIn(mission_id: number): Promise<TMissionOptInResult>{
|
|
109
|
+
const r = await this.api.missionOptIn(null, mission_id);
|
|
110
|
+
|
|
111
|
+
const o: TMissionOptInResult = {
|
|
112
|
+
err_code: r.errCode,
|
|
113
|
+
err_message: r.errMsg,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return o;
|
|
117
|
+
}
|
|
98
118
|
|
|
99
119
|
/** Returns all the active instances of tournaments
|
|
100
120
|
* The returned list is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getTournamentsList with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
101
121
|
* The onUpdate callback will be called when the user has registered in a tournament. Updated list will be passed to onUpdate callback.*/
|
|
122
|
+
/**
|
|
123
|
+
* @param params
|
|
124
|
+
*/
|
|
102
125
|
public async getTournamentsList({ onUpdate }: { onUpdate?: (data: TTournament[]) => void } = {}): Promise<TTournament[]> {
|
|
103
126
|
if (onUpdate) {
|
|
104
127
|
this.onUpdateCallback.set(onUpdateContextKey.TournamentList, onUpdate);
|
|
@@ -119,6 +142,11 @@ export class WSAPI {
|
|
|
119
142
|
this.updateEntity(onUpdateContextKey.Saw, templates)
|
|
120
143
|
}
|
|
121
144
|
|
|
145
|
+
private async updateOnAddSpin() {
|
|
146
|
+
const payload = await this.api.sawGetTemplatesT(null);
|
|
147
|
+
this.updateEntity(onUpdateContextKey.Saw, payload)
|
|
148
|
+
}
|
|
149
|
+
|
|
122
150
|
private async updateOnPrizeWin(data: SAWDoSpinResponse) {
|
|
123
151
|
if (data.errCode === SAWSpinErrorCode.SAW_OK) {
|
|
124
152
|
const templates: TMiniGameTemplate[] = await OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC);
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -372,4 +372,14 @@ export interface TMissionOrBadgeTask {
|
|
|
372
372
|
is_completed: boolean,
|
|
373
373
|
/** The progress of the task in percents */
|
|
374
374
|
progress: number
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* TMissionOptInResult describes the response of call to _smartico.api.requestMissionOptIn(mission_id) method
|
|
379
|
+
*/
|
|
380
|
+
export interface TMissionOptInResult {
|
|
381
|
+
/** Error code that represents outcome of the opt-in request. Successful opt-in in case err_code is 0 */
|
|
382
|
+
err_code: number;
|
|
383
|
+
/** Optional error message */
|
|
384
|
+
err_message: string;
|
|
375
385
|
}
|