@smartico/public-api 0.0.132 → 0.0.133
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 +0 -2
- package/dist/IntUtils.d.ts +1 -0
- package/dist/Jackpots/JackpotPublicMeta.d.ts +2 -0
- package/dist/MiniGames/SAWGameType.d.ts +3 -1
- package/dist/Missions/UserAchievement.d.ts +4 -0
- package/dist/SmarticoLib/index.d.ts +0 -2
- package/dist/Store/StoreItemPurchased.d.ts +3 -0
- package/dist/WSAPI/WSAPI.d.ts +1 -1
- package/dist/WSAPI/WSAPITypes.d.ts +19 -0
- package/dist/index.js +37 -5
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +38 -5
- package/dist/index.modern.mjs.map +1 -1
- package/docs/interfaces/TMissionOrBadge.md +24 -0
- package/docs/interfaces/TStoreItem.md +24 -0
- package/package.json +1 -1
- package/src/Base/ClassId.ts +0 -2
- package/src/IntUtils.ts +31 -1
- package/src/Jackpots/JackPotWinner.ts +5 -5
- package/src/Jackpots/JackpotDetails.ts +0 -1
- package/src/Jackpots/JackpotPublicMeta.ts +2 -1
- package/src/MiniGames/SAWGameType.ts +5 -2
- package/src/Missions/UserAchievement.ts +15 -2
- package/src/SmarticoLib/index.ts +0 -2
- package/src/Store/StoreItemPurchased.ts +12 -1
- package/src/WSAPI/WSAPI.ts +1 -1
- package/src/WSAPI/WSAPITypes.ts +23 -3
|
@@ -229,3 +229,27 @@ ___
|
|
|
229
229
|
• `Optional` **prize\_claimed\_date\_ts**: `number`
|
|
230
230
|
|
|
231
231
|
The date/timestamp indicating when the prize was claimed by the user
|
|
232
|
+
|
|
233
|
+
___
|
|
234
|
+
|
|
235
|
+
### completed\_today
|
|
236
|
+
|
|
237
|
+
• `Optional` **completed\_today**: `boolean`
|
|
238
|
+
|
|
239
|
+
Flag for mission/badge indicating that mission/badge completed today
|
|
240
|
+
|
|
241
|
+
___
|
|
242
|
+
|
|
243
|
+
### completed\_this\_week
|
|
244
|
+
|
|
245
|
+
• `Optional` **completed\_this\_week**: `boolean`
|
|
246
|
+
|
|
247
|
+
Flag for mission/badge indicating that mission/badge completed this week
|
|
248
|
+
|
|
249
|
+
___
|
|
250
|
+
|
|
251
|
+
### completed\_this\_month
|
|
252
|
+
|
|
253
|
+
• `Optional` **completed\_this\_month**: `boolean`
|
|
254
|
+
|
|
255
|
+
Flag for mission/badge indicating that mission/badge completed this month
|
|
@@ -132,3 +132,27 @@ ___
|
|
|
132
132
|
• `Optional` **purchase\_points\_amount**: `number`
|
|
133
133
|
|
|
134
134
|
The amount of points you can purchase an item
|
|
135
|
+
|
|
136
|
+
___
|
|
137
|
+
|
|
138
|
+
### purchased\_today
|
|
139
|
+
|
|
140
|
+
• `Optional` **purchased\_today**: `boolean`
|
|
141
|
+
|
|
142
|
+
Flag for store item indicating that it was purchased today
|
|
143
|
+
|
|
144
|
+
___
|
|
145
|
+
|
|
146
|
+
### purchased\_this\_week
|
|
147
|
+
|
|
148
|
+
• `Optional` **purchased\_this\_week**: `boolean`
|
|
149
|
+
|
|
150
|
+
Flag for store item indicating that it was purchased this week
|
|
151
|
+
|
|
152
|
+
___
|
|
153
|
+
|
|
154
|
+
### purchased\_this\_month
|
|
155
|
+
|
|
156
|
+
• `Optional` **purchased\_this\_month**: `boolean`
|
|
157
|
+
|
|
158
|
+
Flag for store item indicating that it was purchased this month
|
package/package.json
CHANGED
package/src/Base/ClassId.ts
CHANGED
|
@@ -44,8 +44,6 @@ export enum ClassId {
|
|
|
44
44
|
RELOAD_ACHIEVEMENTS_EVENT = 504,
|
|
45
45
|
GET_LEADERS_BOARD_REQUEST = 505,
|
|
46
46
|
GET_LEADERS_BOARD_RESPONSE = 506,
|
|
47
|
-
GET_ACTIVITY_LOG_REQUEST = 507,
|
|
48
|
-
GET_ACTIVITY_LOG_RESPONSE = 508,
|
|
49
47
|
GET_SHOP_ITEMS_REQUEST = 509,
|
|
50
48
|
GET_SHOP_ITEMS_RESPONSE = 510,
|
|
51
49
|
BUY_SHOP_ITEM_REQUEST = 511,
|
package/src/IntUtils.ts
CHANGED
|
@@ -49,8 +49,38 @@ class IntUtils {
|
|
|
49
49
|
// } else {
|
|
50
50
|
// return null
|
|
51
51
|
// }
|
|
52
|
-
// }
|
|
52
|
+
// }
|
|
53
53
|
|
|
54
|
+
public static isWithinPeriod = (timestamp: number, period: 'today' | 'thisWeek' | 'thisMonth'): boolean => {
|
|
55
|
+
const now = new Date();
|
|
56
|
+
const completedDate = new Date(timestamp * 1000);
|
|
57
|
+
|
|
58
|
+
switch(period) {
|
|
59
|
+
case 'today':
|
|
60
|
+
return (
|
|
61
|
+
now.getFullYear() === completedDate.getFullYear() &&
|
|
62
|
+
now.getMonth() === completedDate.getMonth() &&
|
|
63
|
+
now.getDate() === completedDate.getDate()
|
|
64
|
+
);
|
|
65
|
+
case "thisWeek":
|
|
66
|
+
const startOfWeek = new Date(now);
|
|
67
|
+
startOfWeek.setDate(now.getDate() - now.getDay());
|
|
68
|
+
startOfWeek.setHours(0, 0, 0, 0);
|
|
69
|
+
|
|
70
|
+
const endOfWeek = new Date(startOfWeek);
|
|
71
|
+
endOfWeek.setDate(startOfWeek.getDate() + 6);
|
|
72
|
+
endOfWeek.setHours(23, 59, 59, 999);
|
|
73
|
+
|
|
74
|
+
return completedDate >= startOfWeek && completedDate <= endOfWeek;
|
|
75
|
+
case "thisMonth":
|
|
76
|
+
return (
|
|
77
|
+
now.getFullYear() === completedDate.getFullYear() &&
|
|
78
|
+
now.getMonth() === completedDate.getMonth()
|
|
79
|
+
);
|
|
80
|
+
default:
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
54
84
|
}
|
|
55
85
|
|
|
56
86
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
interface JackPotWinner {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
is_me: boolean;
|
|
4
|
+
public_username: string; // masked for all except "is_me"
|
|
5
|
+
winning_amount_jp_currency: number;
|
|
6
|
+
winning_amount_wallet_currency: number;
|
|
7
|
+
winning_position: number
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export { JackPotWinner }
|
|
@@ -5,7 +5,8 @@ export enum SAWGameType {
|
|
|
5
5
|
ScratchCard = 2,
|
|
6
6
|
MatchX = 3,
|
|
7
7
|
GiftBox = 4,
|
|
8
|
-
PrizeDrop = 5
|
|
8
|
+
PrizeDrop = 5,
|
|
9
|
+
Quiz = 6
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export enum SAWGameTypeName {
|
|
@@ -14,6 +15,7 @@ export enum SAWGameTypeName {
|
|
|
14
15
|
MatchX = "matchx",
|
|
15
16
|
GiftBox = "giftbox",
|
|
16
17
|
PrizeDrop = "prizedrop",
|
|
18
|
+
Quiz = 'quiz',
|
|
17
19
|
Unknown = "unknown"
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -24,6 +26,7 @@ export const SAWGameTypeNamed = (type: SAWGameType): SAWGameTypeName => {
|
|
|
24
26
|
[SAWGameType.ScratchCard]: SAWGameTypeName.ScratchCard,
|
|
25
27
|
[SAWGameType.MatchX]: SAWGameTypeName.MatchX,
|
|
26
28
|
[SAWGameType.GiftBox]: SAWGameTypeName.GiftBox,
|
|
27
|
-
[SAWGameType.PrizeDrop]: SAWGameTypeName.PrizeDrop
|
|
29
|
+
[SAWGameType.PrizeDrop]: SAWGameTypeName.PrizeDrop,
|
|
30
|
+
[SAWGameType.Quiz]: SAWGameTypeName.Quiz
|
|
28
31
|
}[type] || SAWGameTypeName.Unknown;
|
|
29
32
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { AchRelatedGame } from "../Base/AchRelatedGame";
|
|
3
3
|
import { IntUtils } from "../IntUtils";
|
|
4
4
|
import { TMissionOrBadge } from "../WSAPI/WSAPITypes";
|
|
5
|
-
import { AchCategory } from "./AchievementCategory";
|
|
6
5
|
import { AchievementPublicMeta } from "./AchievementPublicMeta";
|
|
7
6
|
import { AchievementStatus } from "./AchievementStatus";
|
|
8
7
|
import { AchievementTaskType } from "./AchievementTaskType";
|
|
@@ -24,6 +23,7 @@ export interface UserAchievement {
|
|
|
24
23
|
time_limit_ms?: number;
|
|
25
24
|
progress?: number;
|
|
26
25
|
complete_date?: string;
|
|
26
|
+
complete_date_ts?: number;
|
|
27
27
|
unlock_date?: string;
|
|
28
28
|
milliseconds_till_available?: number;
|
|
29
29
|
completed_tasks?: number;
|
|
@@ -37,11 +37,21 @@ export interface UserAchievement {
|
|
|
37
37
|
ach_completed_id?: number; // ID of the completion fact from ach_completed or ach_completed_recurring tables
|
|
38
38
|
requires_prize_claim?: boolean; // flag from achievement if the mission prize will be given only after user claims it
|
|
39
39
|
prize_claimed_date_ts?: number; // the date/timestamp indicating when the prize was claimed by the user
|
|
40
|
+
|
|
41
|
+
completed_today?: boolean;
|
|
42
|
+
completed_this_week?: boolean;
|
|
43
|
+
completed_this_month?: boolean;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
export const UserAchievementTransform = (items: UserAchievement[]): TMissionOrBadge[] => {
|
|
43
46
|
|
|
47
|
+
|
|
48
|
+
export const UserAchievementTransform = (items: UserAchievement[]): TMissionOrBadge[] => {
|
|
49
|
+
|
|
44
50
|
return items.filter( r => r.ach_id >= 1).map( r => {
|
|
51
|
+
const completedToday = r.complete_date_ts ? IntUtils.isWithinPeriod(r.complete_date_ts, 'today') : false;
|
|
52
|
+
const completedThisWeek = r.complete_date_ts ? IntUtils.isWithinPeriod(r.complete_date_ts, 'thisWeek') : false;
|
|
53
|
+
const completedThisMonth = r.complete_date_ts ? IntUtils.isWithinPeriod(r.complete_date_ts, 'thisMonth') : false;
|
|
54
|
+
|
|
45
55
|
const x: TMissionOrBadge = {
|
|
46
56
|
id: r.ach_id,
|
|
47
57
|
name: r.ach_public_meta.name,
|
|
@@ -89,6 +99,9 @@ export const UserAchievementTransform = (items: UserAchievement[]): TMissionOrBa
|
|
|
89
99
|
ach_completed_id: r.ach_completed_id,
|
|
90
100
|
requires_prize_claim: r.requires_prize_claim,
|
|
91
101
|
prize_claimed_date_ts: r.prize_claimed_date_ts,
|
|
102
|
+
completed_today: completedToday,
|
|
103
|
+
completed_this_week: completedThisWeek,
|
|
104
|
+
completed_this_month: completedThisMonth
|
|
92
105
|
}
|
|
93
106
|
return x;
|
|
94
107
|
});
|
package/src/SmarticoLib/index.ts
CHANGED
|
@@ -152,8 +152,6 @@ declare enum ClassId {
|
|
|
152
152
|
RELOAD_ACHIEVEMENTS_EVENT = 504,
|
|
153
153
|
GET_LEADERS_BOARD_REQUEST = 505,
|
|
154
154
|
GET_LEADERS_BOARD_RESPONSE = 506,
|
|
155
|
-
GET_ACTIVITY_LOG_REQUEST = 507,
|
|
156
|
-
GET_ACTIVITY_LOG_RESPONSE = 508,
|
|
157
155
|
GET_SHOP_ITEMS_REQUEST = 509,
|
|
158
156
|
GET_SHOP_ITEMS_RESPONSE = 510,
|
|
159
157
|
BUY_SHOP_ITEM_REQUEST = 511,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IntUtils } from "../IntUtils";
|
|
1
2
|
import { TStoreItem } from "../WSAPI/WSAPITypes";
|
|
2
3
|
import { StoreItem } from "./StoreItem";
|
|
3
4
|
import { StoreItemType } from "./StoreItemType";
|
|
@@ -5,10 +6,17 @@ import { StoreItemType } from "./StoreItemType";
|
|
|
5
6
|
interface StoreItemPurchased extends StoreItem {
|
|
6
7
|
purchase_ts: number;
|
|
7
8
|
purchase_points_amount: number;
|
|
9
|
+
purchased_today?: boolean;
|
|
10
|
+
purchased_this_week?: boolean;
|
|
11
|
+
purchased_this_month?: boolean;
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
export const StoreItemPurchasedTransform = (items: StoreItemPurchased[]): TStoreItem[] => {
|
|
11
15
|
return items.filter( r => r.id >= 1).map( r => {
|
|
16
|
+
const purchasedToday = r.purchase_ts ? IntUtils.isWithinPeriod(r.purchase_ts, 'today') : false;
|
|
17
|
+
const purchasedThisWeek = r.purchase_ts ? IntUtils.isWithinPeriod(r.purchase_ts, 'thisWeek') : false;
|
|
18
|
+
const purchasedThisMonth = r.purchase_ts ? IntUtils.isWithinPeriod(r.purchase_ts, 'thisMonth') : false;
|
|
19
|
+
|
|
12
20
|
const x: TStoreItem =
|
|
13
21
|
{
|
|
14
22
|
id: r.id,
|
|
@@ -31,7 +39,10 @@ export const StoreItemPurchasedTransform = (items: StoreItemPurchased[]): TStore
|
|
|
31
39
|
category_ids: r.categoryIds ?? [],
|
|
32
40
|
pool: r.shopPool,
|
|
33
41
|
purchase_ts: r.purchase_ts,
|
|
34
|
-
purchase_points_amount: r.purchase_points_amount
|
|
42
|
+
purchase_points_amount: r.purchase_points_amount,
|
|
43
|
+
purchased_today: purchasedToday,
|
|
44
|
+
purchased_this_week: purchasedThisWeek,
|
|
45
|
+
purchased_this_month: purchasedThisMonth,
|
|
35
46
|
}
|
|
36
47
|
return x;
|
|
37
48
|
});
|
package/src/WSAPI/WSAPI.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { ECacheContext, OCache } from "../OCache";
|
|
|
5
5
|
import { SmarticoAPI } from "../SmarticoAPI";
|
|
6
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
|
-
import { JackpotDetails, JackpotPot, JackpotWinPush, JackpotsOptinResponse, JackpotsOptoutResponse } from "
|
|
8
|
+
import { JackpotDetails, JackpotPot, JackpotWinPush, JackpotsOptinResponse, JackpotsOptoutResponse } from "../Jackpots";
|
|
9
9
|
import { AchRelatedGame } from "src/Base/AchRelatedGame";
|
|
10
10
|
|
|
11
11
|
/** @hidden */
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -94,9 +94,8 @@ export interface TMiniGameTemplate {
|
|
|
94
94
|
/** The custom data of the mini-game defined by operator in the BackOffice. Can be a JSON object, string or number */
|
|
95
95
|
custom_data: any;
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
/** List of prizes for mini-games */
|
|
98
98
|
prizes: TMiniGamePrize[];
|
|
99
|
-
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
|
|
@@ -334,8 +333,11 @@ export interface TTournamentDetailed extends TTournament {
|
|
|
334
333
|
* TStoreCategory describes the store category item. Each store item can be assigned to 1 or more categories
|
|
335
334
|
*/
|
|
336
335
|
export interface TStoreCategory {
|
|
336
|
+
/**ID of the store category */
|
|
337
337
|
id: number;
|
|
338
|
+
/**Name of the store category */
|
|
338
339
|
name: string;
|
|
340
|
+
/**Order of the store category among other categories. Default value is 1 */
|
|
339
341
|
order: number
|
|
340
342
|
}
|
|
341
343
|
|
|
@@ -381,15 +383,24 @@ export interface TStoreItem {
|
|
|
381
383
|
purchase_ts?: number;
|
|
382
384
|
/** The amount of points you can purchase an item */
|
|
383
385
|
purchase_points_amount?: number;
|
|
386
|
+
/** Flag for store item indicating that it was purchased today */
|
|
387
|
+
purchased_today?: boolean;
|
|
388
|
+
/** Flag for store item indicating that it was purchased this week */
|
|
389
|
+
purchased_this_week?: boolean;
|
|
390
|
+
/** Flag for store item indicating that it was purchased this month */
|
|
391
|
+
purchased_this_month?: boolean;
|
|
384
392
|
}
|
|
385
393
|
|
|
386
394
|
/**
|
|
387
395
|
* TAchCategory describes the badge category item. Each badge item can be assigned to 1 or more categories
|
|
388
396
|
*/
|
|
389
397
|
export interface TAchCategory {
|
|
398
|
+
/**ID of the badge category */
|
|
390
399
|
id: number;
|
|
400
|
+
/**Name of the badge category */
|
|
391
401
|
name: string;
|
|
392
|
-
|
|
402
|
+
/**Order of the badge category among other categories. Default value is 1 */
|
|
403
|
+
order: number
|
|
393
404
|
}
|
|
394
405
|
|
|
395
406
|
/**
|
|
@@ -470,6 +481,15 @@ export interface TMissionOrBadge {
|
|
|
470
481
|
|
|
471
482
|
/** The date/timestamp indicating when the prize was claimed by the user */
|
|
472
483
|
prize_claimed_date_ts?: number;
|
|
484
|
+
|
|
485
|
+
/** Flag for mission/badge indicating that mission/badge completed today */
|
|
486
|
+
completed_today?: boolean;
|
|
487
|
+
|
|
488
|
+
/** Flag for mission/badge indicating that mission/badge completed this week */
|
|
489
|
+
completed_this_week?: boolean;
|
|
490
|
+
|
|
491
|
+
/** Flag for mission/badge indicating that mission/badge completed this month */
|
|
492
|
+
completed_this_month?: boolean;
|
|
473
493
|
}
|
|
474
494
|
|
|
475
495
|
export interface AchRelatedGame {
|