@smartico/public-api 0.0.122 → 0.0.124
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/Base/ClassId.d.ts +3 -0
- package/dist/Core/CheckSegmentMatchRequest.d.ts +4 -0
- package/dist/Core/CheckSegmentMatchResponse.d.ts +7 -0
- package/dist/Jackpots/GetJackpotsPotsRequest.d.ts +1 -1
- package/dist/Jackpots/GetJackpotsPotsResponse.d.ts +1 -1
- package/dist/Jackpots/GetJackpotsRequest.d.ts +1 -1
- package/dist/Jackpots/JackPotWinner.d.ts +8 -0
- package/dist/Jackpots/JackpotWinPush.d.ts +7 -0
- package/dist/MiniGames/SAWPrizeDropWinPush.d.ts +2 -0
- package/dist/MiniGames/SAWTemplateUI.d.ts +6 -0
- package/dist/MiniGames/index.d.ts +1 -0
- package/dist/Missions/AchClaimPrizeResponse.d.ts +2 -2
- package/dist/Missions/index.d.ts +2 -0
- package/dist/SmarticoAPI.d.ts +4 -2
- package/dist/WSAPI/WSAPI.d.ts +7 -1
- package/dist/WSAPI/WSAPITypes.d.ts +19 -0
- package/dist/index.js +260 -188
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +48 -2
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +2 -0
- package/docs/classes/WSAPI.md +55 -0
- package/docs/enums/SAWGameTypeName.md +6 -0
- package/docs/interfaces/TMiniGamePrize.md +9 -1
- package/docs/interfaces/TMiniGameTemplate.md +1 -1
- package/docs/interfaces/TMissionClaimRewardResult.md +19 -0
- package/docs/interfaces/TMissionOrBadge.md +32 -0
- package/docs/interfaces/TSegmentCheckResult.md +13 -0
- package/package.json +1 -1
- package/src/Base/ClassId.ts +4 -1
- package/src/Core/CheckSegmentMatchRequest.ts +6 -0
- package/src/Core/CheckSegmentMatchResponse.ts +8 -0
- package/src/Jackpots/GetJackpotsPotsRequest.ts +1 -1
- package/src/Jackpots/GetJackpotsPotsResponse.ts +1 -1
- package/src/Jackpots/GetJackpotsRequest.ts +1 -1
- package/src/Jackpots/JackPotWinner.ts +10 -0
- package/src/Jackpots/JackpotWinPush.ts +8 -0
- package/src/MiniGames/SAWPrizeDropWinPush.ts +2 -0
- package/src/MiniGames/SAWTemplateUI.ts +10 -0
- package/src/MiniGames/index.ts +2 -1
- package/src/Missions/AchClaimPrizeResponse.ts +2 -3
- package/src/Missions/UserAchievement.ts +3 -0
- package/src/Missions/index.ts +3 -1
- package/src/SmarticoAPI.ts +32 -2
- package/src/WSAPI/WSAPI.ts +30 -1
- package/src/WSAPI/WSAPITypes.ts +24 -0
- package/src/Jackpots/jackpotsWSApi.zip +0 -0
package/docs/README.md
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
- [AchRelatedGame](interfaces/AchRelatedGame.md)
|
|
27
27
|
- [TMissionOrBadgeTask](interfaces/TMissionOrBadgeTask.md)
|
|
28
28
|
- [TMissionOptInResult](interfaces/TMissionOptInResult.md)
|
|
29
|
+
- [TMissionClaimRewardResult](interfaces/TMissionClaimRewardResult.md)
|
|
29
30
|
- [TTournamentRegistrationResult](interfaces/TTournamentRegistrationResult.md)
|
|
30
31
|
- [TBuyStoreItemResult](interfaces/TBuyStoreItemResult.md)
|
|
31
32
|
- [TGetTranslations](interfaces/TGetTranslations.md)
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
- [LeaderBoardsRewardsT](interfaces/LeaderBoardsRewardsT.md)
|
|
37
38
|
- [LeaderBoardUserT](interfaces/LeaderBoardUserT.md)
|
|
38
39
|
- [UserLevelExtraCountersT](interfaces/UserLevelExtraCountersT.md)
|
|
40
|
+
- [TSegmentCheckResult](interfaces/TSegmentCheckResult.md)
|
|
39
41
|
|
|
40
42
|
## General API
|
|
41
43
|
|
package/docs/classes/WSAPI.md
CHANGED
|
@@ -14,6 +14,42 @@ Returns information about current user
|
|
|
14
14
|
|
|
15
15
|
___
|
|
16
16
|
|
|
17
|
+
### checkSegmentMatch
|
|
18
|
+
|
|
19
|
+
▸ **checkSegmentMatch**(`segment_id`): `Promise`<`boolean`\>
|
|
20
|
+
|
|
21
|
+
Check if user belongs to specific segments
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
| Name | Type |
|
|
26
|
+
| :------ | :------ |
|
|
27
|
+
| `segment_id` | `number` |
|
|
28
|
+
|
|
29
|
+
#### Returns
|
|
30
|
+
|
|
31
|
+
`Promise`<`boolean`\>
|
|
32
|
+
|
|
33
|
+
___
|
|
34
|
+
|
|
35
|
+
### checkSegmentListMatch
|
|
36
|
+
|
|
37
|
+
▸ **checkSegmentListMatch**(`segment_ids`): `Promise`<[`TSegmentCheckResult`](../interfaces/TSegmentCheckResult.md)[]\>
|
|
38
|
+
|
|
39
|
+
Check if user belongs to specific list of segments
|
|
40
|
+
|
|
41
|
+
#### Parameters
|
|
42
|
+
|
|
43
|
+
| Name | Type |
|
|
44
|
+
| :------ | :------ |
|
|
45
|
+
| `segment_ids` | `number`[] |
|
|
46
|
+
|
|
47
|
+
#### Returns
|
|
48
|
+
|
|
49
|
+
`Promise`<[`TSegmentCheckResult`](../interfaces/TSegmentCheckResult.md)[]\>
|
|
50
|
+
|
|
51
|
+
___
|
|
52
|
+
|
|
17
53
|
### getLevels
|
|
18
54
|
|
|
19
55
|
▸ **getLevels**(): `Promise`<[`TLevel`](../interfaces/TLevel.md)[]\>
|
|
@@ -177,6 +213,25 @@ Requests an opt-in for the specified mission_id. Returns the err_code.
|
|
|
177
213
|
|
|
178
214
|
___
|
|
179
215
|
|
|
216
|
+
### requestMissionClaimReward
|
|
217
|
+
|
|
218
|
+
▸ **requestMissionClaimReward**(`mission_id`, `ach_completed_id`): `Promise`<[`TMissionClaimRewardResult`](../interfaces/TMissionClaimRewardResult.md)\>
|
|
219
|
+
|
|
220
|
+
Request for claim reward for the specified mission id. Returns the err_code.
|
|
221
|
+
|
|
222
|
+
#### Parameters
|
|
223
|
+
|
|
224
|
+
| Name | Type |
|
|
225
|
+
| :------ | :------ |
|
|
226
|
+
| `mission_id` | `number` |
|
|
227
|
+
| `ach_completed_id` | `number` |
|
|
228
|
+
|
|
229
|
+
#### Returns
|
|
230
|
+
|
|
231
|
+
`Promise`<[`TMissionClaimRewardResult`](../interfaces/TMissionClaimRewardResult.md)\>
|
|
232
|
+
|
|
233
|
+
___
|
|
234
|
+
|
|
180
235
|
### getTournamentsList
|
|
181
236
|
|
|
182
237
|
▸ **getTournamentsList**(`params?`): `Promise`<[`TTournament`](../interfaces/TTournament.md)[]\>
|
|
@@ -40,7 +40,15 @@ ___
|
|
|
40
40
|
|
|
41
41
|
• `Optional` **font\_size**: `number`
|
|
42
42
|
|
|
43
|
-
Custom font size for the prize
|
|
43
|
+
Custom font size for the prize (desktop)
|
|
44
|
+
|
|
45
|
+
___
|
|
46
|
+
|
|
47
|
+
### font\_size\_mobile
|
|
48
|
+
|
|
49
|
+
• `Optional` **font\_size\_mobile**: `number`
|
|
50
|
+
|
|
51
|
+
Custom font size for the prize (mobile)
|
|
44
52
|
|
|
45
53
|
___
|
|
46
54
|
|
|
@@ -136,7 +136,7 @@ ___
|
|
|
136
136
|
|
|
137
137
|
• **custom\_data**: `any`
|
|
138
138
|
|
|
139
|
-
The custom data of the mini-game defined by operator. Can be a JSON object, string or number
|
|
139
|
+
The custom data of the mini-game defined by operator in the BackOffice. Can be a JSON object, string or number
|
|
140
140
|
|
|
141
141
|
___
|
|
142
142
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Interface: TMissionClaimRewardResult
|
|
2
|
+
|
|
3
|
+
TMissionClaimRewardResult describes the response of call to _smartico.api.requestMissionClaimReward(mission_id, ach_completed_id) method
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### err\_code
|
|
8
|
+
|
|
9
|
+
• **err\_code**: `number`
|
|
10
|
+
|
|
11
|
+
Error code that represents outcome of the claim request. Successful claim reward in case err_code is 0
|
|
12
|
+
|
|
13
|
+
___
|
|
14
|
+
|
|
15
|
+
### err\_message
|
|
16
|
+
|
|
17
|
+
• **err\_message**: `string`
|
|
18
|
+
|
|
19
|
+
Optional error message
|
|
@@ -197,3 +197,35 @@ ___
|
|
|
197
197
|
• `Optional` **position**: `number`
|
|
198
198
|
|
|
199
199
|
Priority (or position) of the mission in the UI. Low value indicates higher position in the UI
|
|
200
|
+
|
|
201
|
+
___
|
|
202
|
+
|
|
203
|
+
### ribbon
|
|
204
|
+
|
|
205
|
+
• `Optional` **ribbon**: `string`
|
|
206
|
+
|
|
207
|
+
The ribbon of the mission/badge item. Can be 'sale', 'hot', 'new', 'vip' or URL to the image in case of custom ribbon
|
|
208
|
+
|
|
209
|
+
___
|
|
210
|
+
|
|
211
|
+
### ach\_completed\_id
|
|
212
|
+
|
|
213
|
+
• `Optional` **ach\_completed\_id**: `number`
|
|
214
|
+
|
|
215
|
+
ID of the completion fact from ach_completed or ach_completed_recurring tables
|
|
216
|
+
|
|
217
|
+
___
|
|
218
|
+
|
|
219
|
+
### requires\_prize\_claim
|
|
220
|
+
|
|
221
|
+
• `Optional` **requires\_prize\_claim**: `boolean`
|
|
222
|
+
|
|
223
|
+
Flag from achievement if the mission prize will be given only after user claims it
|
|
224
|
+
|
|
225
|
+
___
|
|
226
|
+
|
|
227
|
+
### prize\_claimed\_date\_ts
|
|
228
|
+
|
|
229
|
+
• `Optional` **prize\_claimed\_date\_ts**: `number`
|
|
230
|
+
|
|
231
|
+
The date/timestamp indicating when the prize was claimed by the user
|
package/package.json
CHANGED
package/src/Base/ClassId.ts
CHANGED
|
@@ -33,6 +33,9 @@ export enum ClassId {
|
|
|
33
33
|
CLIENT_SET_CUSTOM_USERNAME_REQUEST = 159,
|
|
34
34
|
CLIENT_SET_CUSTOM_USERNAME_RESPONSE = 160,
|
|
35
35
|
|
|
36
|
+
CHECK_SEGMENT_MATCH_REQUEST = 161,
|
|
37
|
+
CHECK_SEGMENT_MATCH_RESPONSE = 162,
|
|
38
|
+
|
|
36
39
|
// 500-1000 - Achievements
|
|
37
40
|
GET_LEVEL_MAP_REQUEST = 500,
|
|
38
41
|
GET_LEVEL_MAP_RESPONSE = 501,
|
|
@@ -111,7 +114,7 @@ export enum ClassId {
|
|
|
111
114
|
JP_OPTOUT_REQUEST = 806,
|
|
112
115
|
JP_OPTOUT_RESPONSE = 807,
|
|
113
116
|
|
|
114
|
-
|
|
117
|
+
JP_WIN_PUSH = 808,
|
|
115
118
|
|
|
116
119
|
REGISTER_PUSH_NOTIFICATIONS_TOKEN_REQ = 1003,
|
|
117
120
|
REGISTER_PUSH_NOTIFICATIONS_TOKEN_RESP = 2003,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ProtocolMessage } from "../Base/ProtocolMessage";
|
|
2
|
+
import { JackPotWinner } from "./JackPotWinner";
|
|
3
|
+
import { JackpotDetails } from "./JackpotDetails";
|
|
4
|
+
|
|
5
|
+
export interface JackpotWinPush extends ProtocolMessage {
|
|
6
|
+
jackpot: JackpotDetails;
|
|
7
|
+
winners: JackPotWinner[];
|
|
8
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ProtocolMessage } from ".././Base/ProtocolMessage";
|
|
2
2
|
import { SAWPrize } from "./SAWPrize";
|
|
3
|
+
import { SAWTemplate } from "./SAWTemplate";
|
|
3
4
|
|
|
4
5
|
export interface SAWPrizeDropWinPush extends ProtocolMessage {
|
|
5
6
|
request_id: string; // guid
|
|
6
7
|
saw_template_id: number;
|
|
7
8
|
saw_prize: SAWPrize;
|
|
9
|
+
saw_template: SAWTemplate;
|
|
8
10
|
}
|
|
@@ -40,4 +40,14 @@ export interface SAWTemplateUI {
|
|
|
40
40
|
only_in_custom_section?: boolean;
|
|
41
41
|
|
|
42
42
|
custom_data: any;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// prize drop specific
|
|
46
|
+
placeholder_1?: string;
|
|
47
|
+
placeholder_2?: string;
|
|
48
|
+
prize_drop_template?: {
|
|
49
|
+
id: string;
|
|
50
|
+
content: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
43
53
|
}
|
package/src/MiniGames/index.ts
CHANGED
|
@@ -16,4 +16,5 @@ export * from "./SAWTemplateUI";
|
|
|
16
16
|
export * from "./SAWWinSoundType";
|
|
17
17
|
export * from "./SAWDoAknowledgeRequest";
|
|
18
18
|
export * from "./SAWDoAknowledgeResponse";
|
|
19
|
-
export * from "./SAWSpinsCountPush";
|
|
19
|
+
export * from "./SAWSpinsCountPush";
|
|
20
|
+
export * from "./SAWPrizeDropWinPush";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export interface AchClaimPrizeRequest extends ProtocolMessage {
|
|
1
|
+
import { ProtocolResponse } from "../Base/ProtocolResponse";
|
|
2
|
+
export interface AchClaimPrizeResponse extends ProtocolResponse {
|
|
4
3
|
|
|
5
4
|
// no details here, just check for errCode and reload list of missions
|
|
6
5
|
}
|
|
@@ -86,6 +86,9 @@ export const UserAchievementTransform = (items: UserAchievement[]): TMissionOrBa
|
|
|
86
86
|
},
|
|
87
87
|
})),
|
|
88
88
|
category_ids: r.ach_categories ?? [],
|
|
89
|
+
ach_completed_id: r.ach_completed_id,
|
|
90
|
+
requires_prize_claim: r.requires_prize_claim,
|
|
91
|
+
prize_claimed_date_ts: r.prize_claimed_date_ts,
|
|
89
92
|
}
|
|
90
93
|
return x;
|
|
91
94
|
});
|
package/src/Missions/index.ts
CHANGED
|
@@ -14,4 +14,6 @@ export * from "./ScheduledMissionType";
|
|
|
14
14
|
export * from './AchCategoryPublicMeta';
|
|
15
15
|
export * from './AchievementCategory';
|
|
16
16
|
export * from './GetAchCategoriesResponse';
|
|
17
|
-
export * from './GetAchCategoriesRequest';
|
|
17
|
+
export * from './GetAchCategoriesRequest';
|
|
18
|
+
export * from './AchClaimPrizeRequest';
|
|
19
|
+
export * from './AchClaimPrizeResponse'
|
package/src/SmarticoAPI.ts
CHANGED
|
@@ -12,14 +12,16 @@ import { GetLabelInfoResponse } from './Core/GetLabelInfoResponse';
|
|
|
12
12
|
import { GetLabelInfoRequest } from './Core/GetLabelInfoRequest';
|
|
13
13
|
import { GetInboxMessagesRequest, GetInboxMessagesResponse, InboxMessageBody, InboxMessageBodyTransform, InboxMessagesTransform, MarkInboxMessageDeletedRequest, MarkInboxMessageDeletedResponse, MarkInboxMessageReadRequest, MarkInboxMessageReadResponse, MarkInboxMessageStarredRequest, MarkInboxMessageStarredResponse } from './Inbox';
|
|
14
14
|
import { BuyStoreItemRequest, BuyStoreItemResponse, GetCategoriesStoreResponse, GetStoreItemsResponse, StoreCategoryTransform, StoreItemTransform } from './Store';
|
|
15
|
-
import { AchCategoryTransform, AchievementOptinRequest, AchievementOptinResponse, AchievementType, GetAchCategoriesResponse, GetAchievementMapRequest, GetAchievementMapResponse, UserAchievementTransform } from './Missions';
|
|
15
|
+
import { AchCategoryTransform, AchClaimPrizeRequest, AchClaimPrizeResponse, AchievementOptinRequest, AchievementOptinResponse, AchievementType, GetAchCategoriesResponse, GetAchievementMapRequest, GetAchievementMapResponse, UserAchievementTransform } from './Missions';
|
|
16
16
|
import { GetTournamentInfoRequest, GetTournamentInfoResponse, GetTournamentsRequest, GetTournamentsResponse, TournamentItemsTransform, TournamentRegisterRequest, TournamentRegisterResponse, tournamentInfoItemTransform } from './Tournaments';
|
|
17
17
|
import { GetLeaderBoardsRequest, GetLeaderBoardsResponse, LeaderBoardDetails, LeaderBoardPeriodType } from "./Leaderboard";
|
|
18
18
|
import { GetLevelMapResponse, GetLevelMapResponseTransform } from "./Level";
|
|
19
19
|
import { WSAPI } from "./WSAPI/WSAPI";
|
|
20
|
-
import { TInboxMessage, TInboxMessageBody, TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreCategory, TAchCategory, TStoreItem, TTournament, TTournamentDetailed, LeaderBoardDetailsT, UserLevelExtraCountersT } from "./WSAPI/WSAPITypes";
|
|
20
|
+
import { TInboxMessage, TInboxMessageBody, TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreCategory, TAchCategory, TStoreItem, TTournament, TTournamentDetailed, LeaderBoardDetailsT, UserLevelExtraCountersT, TSegmentCheckResult } from "./WSAPI/WSAPITypes";
|
|
21
21
|
import { getLeaderBoardTransform } from "./Leaderboard/LeaderBoards";
|
|
22
22
|
import { GetAchievementsUserInfoResponse } from "./Core/GetAchievementsUserInfoResponse";
|
|
23
|
+
import { CheckSegmentMatchResponse } from "./Core/CheckSegmentMatchResponse";
|
|
24
|
+
import { CheckSegmentMatchRequest } from "./Core/CheckSegmentMatchRequest";
|
|
23
25
|
|
|
24
26
|
const PUBLIC_API_URL = 'https://papi{ENV_ID}.smartico.ai/services/public';
|
|
25
27
|
const C_SOCKET_PROD = 'wss://api{ENV_ID}.smartico.ai/websocket/services';
|
|
@@ -271,6 +273,19 @@ class SmarticoAPI {
|
|
|
271
273
|
return await this.send(message, ClassId.CLIENT_SET_CUSTOM_USERNAME_RESPONSE);
|
|
272
274
|
}
|
|
273
275
|
|
|
276
|
+
public async coreCheckSegments(user_ext_id: string, segment_id: number[]): Promise<TSegmentCheckResult[]> {
|
|
277
|
+
|
|
278
|
+
const message = this.buildMessage<CheckSegmentMatchRequest, any>(user_ext_id, ClassId.CHECK_SEGMENT_MATCH_REQUEST, {
|
|
279
|
+
segment_id
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
const results = await this.send<CheckSegmentMatchResponse>(message, ClassId.CHECK_SEGMENT_MATCH_RESPONSE);
|
|
283
|
+
|
|
284
|
+
return results.segments || [];
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
274
289
|
public async sawGetTemplates(user_ext_id: string, lang?: string, is_visitor_mode: boolean = false): Promise<SAWGetTemplatesResponse> {
|
|
275
290
|
|
|
276
291
|
const message = this.buildMessage<SAWGetTemplatesRequest, SAWGetTemplatesResponse>(user_ext_id, ClassId.SAW_GET_SPINS_REQUEST, lang ? { force_language: lang, is_visitor_mode } : { is_visitor_mode });
|
|
@@ -355,6 +370,21 @@ class SmarticoAPI {
|
|
|
355
370
|
return res;
|
|
356
371
|
}
|
|
357
372
|
|
|
373
|
+
public async missionClaimPrize(user_ext_id: string, mission_id: number, ach_completed_id: number) {
|
|
374
|
+
if (!mission_id) {
|
|
375
|
+
throw new Error('Missing mission id');
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const message = this.buildMessage<AchClaimPrizeRequest, AchClaimPrizeResponse>(user_ext_id, ClassId.ACHIEVEMENT_CLAIM_PRIZE_REQUEST, {
|
|
379
|
+
ach_id: mission_id,
|
|
380
|
+
ach_completed_id: ach_completed_id
|
|
381
|
+
})
|
|
382
|
+
|
|
383
|
+
const res = await this.send<AchClaimPrizeResponse>(message, ClassId.ACHIEVEMENT_CLAIM_PRIZE_RESPONSE);
|
|
384
|
+
|
|
385
|
+
return res;
|
|
386
|
+
}
|
|
387
|
+
|
|
358
388
|
public async registerInTournament(user_ext_id: string, tournamentInstanceId: number) {
|
|
359
389
|
if (!tournamentInstanceId) {
|
|
360
390
|
throw new Error('Missing tournament instance id');
|
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 { InboxMarkMessageAction, LeaderBoardDetailsT, TAchCategory, TBuyStoreItemResult, TGetTranslations, TInboxMessage, TInboxMessageBody, TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionOptInResult, TMissionOrBadge, TStoreCategory, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUserProfile, UserLevelExtraCountersT } from "./WSAPITypes";
|
|
6
|
+
import { InboxMarkMessageAction, LeaderBoardDetailsT, TAchCategory, TBuyStoreItemResult, TGetTranslations, TInboxMessage, TInboxMessageBody, TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionClaimRewardResult, TMissionOptInResult, TMissionOrBadge, TSegmentCheckResult, TStoreCategory, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUserProfile, UserLevelExtraCountersT } from "./WSAPITypes";
|
|
7
7
|
import { LeaderBoardPeriodType } from "../Leaderboard";
|
|
8
8
|
|
|
9
9
|
/** @hidden */
|
|
@@ -21,6 +21,7 @@ enum onUpdateContextKey {
|
|
|
21
21
|
AchCategories = 'achCategories',
|
|
22
22
|
LeaderBoards = 'leaderBoards',
|
|
23
23
|
LevelExtraCounters = 'levelExtraCounters',
|
|
24
|
+
Segments = 'segments',
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
|
|
@@ -53,6 +54,22 @@ export class WSAPI {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
/** Check if user belongs to specific segments */
|
|
58
|
+
|
|
59
|
+
public async checkSegmentMatch(segment_id: number): Promise<boolean> {
|
|
60
|
+
const r = await this.api.coreCheckSegments(null, [segment_id]);
|
|
61
|
+
if (r && r.find(s => s.segment_id === segment_id && s.is_matching)) {
|
|
62
|
+
return true;
|
|
63
|
+
} else {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Check if user belongs to specific list of segments */
|
|
69
|
+
public async checkSegmentListMatch(segment_ids: number[]): Promise<TSegmentCheckResult[]> {
|
|
70
|
+
return await this.api.coreCheckSegments(null, segment_ids)
|
|
71
|
+
}
|
|
72
|
+
|
|
56
73
|
/** Returns all the levels available the current user */
|
|
57
74
|
public async getLevels(): Promise<TLevel[]> {
|
|
58
75
|
return OCache.use(onUpdateContextKey.Levels, ECacheContext.WSAPI, () => this.api.levelsGetT(null), CACHE_DATA_SEC);
|
|
@@ -150,6 +167,18 @@ export class WSAPI {
|
|
|
150
167
|
return o;
|
|
151
168
|
}
|
|
152
169
|
|
|
170
|
+
/** Request for claim reward for the specified mission id. Returns the err_code. */
|
|
171
|
+
public async requestMissionClaimReward(mission_id: number, ach_completed_id: number): Promise<TMissionClaimRewardResult> {
|
|
172
|
+
const r = await this.api.missionClaimPrize(null, mission_id, ach_completed_id);
|
|
173
|
+
|
|
174
|
+
const o: TMissionClaimRewardResult = {
|
|
175
|
+
err_code: r.errCode,
|
|
176
|
+
err_message: r.errMsg,
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return o;
|
|
180
|
+
}
|
|
181
|
+
|
|
153
182
|
/** Returns all the active instances of tournaments
|
|
154
183
|
* 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.
|
|
155
184
|
* The onUpdate callback will be called when the user has registered in a tournament. Updated list will be passed to onUpdate callback.*/
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -457,6 +457,15 @@ export interface TMissionOrBadge {
|
|
|
457
457
|
|
|
458
458
|
/** The ribbon of the mission/badge item. Can be 'sale', 'hot', 'new', 'vip' or URL to the image in case of custom ribbon */
|
|
459
459
|
ribbon?: TRibbon;
|
|
460
|
+
|
|
461
|
+
/** ID of the completion fact from ach_completed or ach_completed_recurring tables */
|
|
462
|
+
ach_completed_id?: number;
|
|
463
|
+
|
|
464
|
+
/** Flag from achievement if the mission prize will be given only after user claims it */
|
|
465
|
+
requires_prize_claim?: boolean;
|
|
466
|
+
|
|
467
|
+
/** The date/timestamp indicating when the prize was claimed by the user */
|
|
468
|
+
prize_claimed_date_ts?: number;
|
|
460
469
|
}
|
|
461
470
|
|
|
462
471
|
export interface AchRelatedGame {
|
|
@@ -505,6 +514,16 @@ export interface TMissionOptInResult {
|
|
|
505
514
|
err_message: string;
|
|
506
515
|
}
|
|
507
516
|
|
|
517
|
+
/**
|
|
518
|
+
* TMissionClaimRewardResult describes the response of call to _smartico.api.requestMissionClaimReward(mission_id, ach_completed_id) method
|
|
519
|
+
*/
|
|
520
|
+
export interface TMissionClaimRewardResult {
|
|
521
|
+
/** Error code that represents outcome of the claim request. Successful claim reward in case err_code is 0 */
|
|
522
|
+
err_code: number;
|
|
523
|
+
/** Optional error message */
|
|
524
|
+
err_message: string;
|
|
525
|
+
}
|
|
526
|
+
|
|
508
527
|
export interface TTournamentRegistrationResult {
|
|
509
528
|
/** Error code that represents outcome of the tournament registration request. Successful registration in case err_code is 0 */
|
|
510
529
|
err_code: TournamentRegistrationError;
|
|
@@ -608,3 +627,8 @@ export interface UserLevelExtraCountersT {
|
|
|
608
627
|
level_counter_2?: number,
|
|
609
628
|
}
|
|
610
629
|
|
|
630
|
+
|
|
631
|
+
export interface TSegmentCheckResult {
|
|
632
|
+
segment_id: number;
|
|
633
|
+
is_matching: boolean;
|
|
634
|
+
}
|
|
Binary file
|