@smartico/public-api 0.0.138 → 0.0.140
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/Jackpots/JackPotWinner.d.ts +5 -0
- package/dist/Missions/AchievementStatus.d.ts +2 -1
- package/dist/Store/StoreItemType.d.ts +13 -1
- package/dist/WSAPI/WSAPITypes.d.ts +2 -2
- package/dist/index.js +35 -15
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +34 -16
- package/dist/index.modern.mjs.map +1 -1
- package/docs/classes/WSAPI.md +11 -2
- package/docs/interfaces/JackPotWinner.md +10 -0
- package/docs/interfaces/TStoreItem.md +2 -2
- package/package.json +1 -1
- package/src/Jackpots/JackPotWinner.ts +6 -1
- package/src/Missions/AchievementStatus.ts +2 -1
- package/src/SmarticoAPI.ts +3 -1
- package/src/Store/StoreItem.ts +3 -8
- package/src/Store/StoreItemPurchased.ts +4 -8
- package/src/Store/StoreItemType.ts +23 -1
- package/src/WSAPI/WSAPI.ts +3 -5
- package/src/WSAPI/WSAPITypes.ts +2 -2
package/docs/classes/WSAPI.md
CHANGED
|
@@ -201,7 +201,7 @@ ___
|
|
|
201
201
|
|
|
202
202
|
### getStorePurchasedItems
|
|
203
203
|
|
|
204
|
-
▸ **getStorePurchasedItems**(): `Promise`<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
|
|
204
|
+
▸ **getStorePurchasedItems**(`«destructured»?`): `Promise`<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
|
|
205
205
|
|
|
206
206
|
Returns purchased items based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
|
|
207
207
|
The maximum number of items per request is limited to 20.
|
|
@@ -210,9 +210,18 @@ Example usage:
|
|
|
210
210
|
```
|
|
211
211
|
_smartico.api.getStorePurchasedItems().then((result) => {
|
|
212
212
|
console.log(result);
|
|
213
|
-
|
|
213
|
+
});
|
|
214
214
|
```
|
|
215
215
|
|
|
216
|
+
#### Parameters
|
|
217
|
+
|
|
218
|
+
| Name | Type |
|
|
219
|
+
| :------ | :------ |
|
|
220
|
+
| `«destructured»` | `Object` |
|
|
221
|
+
| › `limit?` | `number` |
|
|
222
|
+
| › `offset?` | `number` |
|
|
223
|
+
| › `onUpdate?` | (`data`: [`TStoreItem`](../interfaces/TStoreItem.md)[]) => `void` |
|
|
224
|
+
|
|
216
225
|
#### Returns
|
|
217
226
|
|
|
218
227
|
`Promise`<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
|
|
@@ -6,26 +6,36 @@
|
|
|
6
6
|
|
|
7
7
|
• **is\_me**: `boolean`
|
|
8
8
|
|
|
9
|
+
Flag indicating that this winner is the currently logged in user
|
|
10
|
+
|
|
9
11
|
___
|
|
10
12
|
|
|
11
13
|
### public\_username
|
|
12
14
|
|
|
13
15
|
• **public\_username**: `string`
|
|
14
16
|
|
|
17
|
+
Name of the winner, note that for all users except is_me, the name is masked by default, but masking can be disabled by request to Smartico AM team
|
|
18
|
+
|
|
15
19
|
___
|
|
16
20
|
|
|
17
21
|
### winning\_amount\_jp\_currency
|
|
18
22
|
|
|
19
23
|
• **winning\_amount\_jp\_currency**: `number`
|
|
20
24
|
|
|
25
|
+
Won amount in the Jackpot currency
|
|
26
|
+
|
|
21
27
|
___
|
|
22
28
|
|
|
23
29
|
### winning\_amount\_wallet\_currency
|
|
24
30
|
|
|
25
31
|
• **winning\_amount\_wallet\_currency**: `number`
|
|
26
32
|
|
|
33
|
+
Won amount in the user Wallet currency
|
|
34
|
+
|
|
27
35
|
___
|
|
28
36
|
|
|
29
37
|
### winning\_position
|
|
30
38
|
|
|
31
39
|
• **winning\_position**: `number`
|
|
40
|
+
|
|
41
|
+
Position of the winner. Relevant for jackpots where there could be multiple winners
|
|
@@ -38,9 +38,9 @@ ___
|
|
|
38
38
|
|
|
39
39
|
### type
|
|
40
40
|
|
|
41
|
-
• **type**: ``"
|
|
41
|
+
• **type**: ``"unknown"`` \| ``"bonus"`` \| ``"tangible"`` \| ``"minigamespin"`` \| ``"changelevel"`` \| ``"prizedrop"``
|
|
42
42
|
|
|
43
|
-
Type of the store item. Can be 'bonus' or '
|
|
43
|
+
Type of the store item. Can be 'bonus' or 'tangible' or different others.
|
|
44
44
|
|
|
45
45
|
___
|
|
46
46
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
interface JackPotWinner {
|
|
3
|
+
/** Flag indicating that this winner is the currently logged in user */
|
|
3
4
|
is_me: boolean;
|
|
5
|
+
/** Name of the winner, note that for all users except is_me, the name is masked by default, but masking can be disabled by request to Smartico AM team */
|
|
4
6
|
public_username: string; // masked for all except "is_me"
|
|
7
|
+
/** Won amount in the Jackpot currency */
|
|
5
8
|
winning_amount_jp_currency: number;
|
|
9
|
+
/** Won amount in the user Wallet currency */
|
|
6
10
|
winning_amount_wallet_currency: number;
|
|
7
|
-
|
|
11
|
+
/** Position of the winner. Relevant for jackpots where there could be multiple winners */
|
|
12
|
+
winning_position: number;
|
|
8
13
|
}
|
|
9
14
|
|
|
10
15
|
export { JackPotWinner }
|
package/src/SmarticoAPI.ts
CHANGED
|
@@ -173,7 +173,9 @@ class SmarticoAPI {
|
|
|
173
173
|
private buildMessage<TRequest,TResponse>(user_ext_id: string, cid: ClassId, payload: Partial<TRequest> = {}): TResponse {
|
|
174
174
|
|
|
175
175
|
const message: ProtocolRequest = {
|
|
176
|
-
|
|
176
|
+
// AA: in fact we need api and brand keys and ext_user_id only in the context of HTTP
|
|
177
|
+
// its not needed in WebSocket and can be deleted
|
|
178
|
+
api_key: this.label_api_key,
|
|
177
179
|
brand_key: this.brand_api_key,
|
|
178
180
|
ext_user_id: user_ext_id,
|
|
179
181
|
cid,
|
package/src/Store/StoreItem.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TStoreItem } from "../WSAPI/WSAPITypes";
|
|
2
2
|
import { StoreItemPublicMeta } from "./StoreItemPublicMeta";
|
|
3
|
-
import { StoreItemType } from "./StoreItemType";
|
|
3
|
+
import { StoreItemType, StoreItemTypeNamed } from "./StoreItemType";
|
|
4
4
|
|
|
5
5
|
export interface StoreItem {
|
|
6
6
|
id: number;
|
|
@@ -23,15 +23,10 @@ export const StoreItemTransform = (items: StoreItem[]): TStoreItem[] => {
|
|
|
23
23
|
description: r.itemPublicMeta.description,
|
|
24
24
|
ribbon: r.itemPublicMeta.label_tag === 'custom' ? r.itemPublicMeta.custom_label_tag : r.itemPublicMeta.label_tag,
|
|
25
25
|
limit_message: r.itemPublicMeta.limit_message,
|
|
26
|
-
priority: r.itemPublicMeta.priority,
|
|
26
|
+
priority: r.itemPublicMeta.priority ?? 0,
|
|
27
27
|
related_item_ids: r.itemPublicMeta.related_items,
|
|
28
28
|
hint_text: r.itemPublicMeta.hint_text,
|
|
29
|
-
|
|
30
|
-
type: {
|
|
31
|
-
[StoreItemType.Bonus]: 'bonus',
|
|
32
|
-
[StoreItemType.Manual]: 'manual'
|
|
33
|
-
}[r.itemTypeId] as 'bonus' | 'manual',
|
|
34
|
-
|
|
29
|
+
type: StoreItemTypeNamed(r.itemTypeId),
|
|
35
30
|
can_buy: r.canBuy,
|
|
36
31
|
category_ids: r.categoryIds ?? [],
|
|
37
32
|
pool: r.shopPool,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IntUtils } from "../IntUtils";
|
|
2
2
|
import { TStoreItem } from "../WSAPI/WSAPITypes";
|
|
3
3
|
import { StoreItem } from "./StoreItem";
|
|
4
|
-
import {
|
|
4
|
+
import { StoreItemTypeNamed } from "./StoreItemType";
|
|
5
5
|
|
|
6
6
|
interface StoreItemPurchased extends StoreItem {
|
|
7
7
|
purchase_ts: number;
|
|
@@ -26,15 +26,10 @@ export const StoreItemPurchasedTransform = (items: StoreItemPurchased[]): TStore
|
|
|
26
26
|
description: r.itemPublicMeta.description,
|
|
27
27
|
ribbon: r.itemPublicMeta.label_tag === 'custom' ? r.itemPublicMeta.custom_label_tag : r.itemPublicMeta.label_tag,
|
|
28
28
|
limit_message: r.itemPublicMeta.limit_message,
|
|
29
|
-
priority: r.itemPublicMeta.priority,
|
|
29
|
+
priority: r.itemPublicMeta.priority ?? 0,
|
|
30
30
|
related_item_ids: r.itemPublicMeta.related_items,
|
|
31
31
|
hint_text: r.itemPublicMeta.hint_text,
|
|
32
|
-
|
|
33
|
-
type: {
|
|
34
|
-
[StoreItemType.Bonus]: 'bonus',
|
|
35
|
-
[StoreItemType.Manual]: 'manual'
|
|
36
|
-
}[r.itemTypeId] as 'bonus' | 'manual',
|
|
37
|
-
|
|
32
|
+
type: StoreItemTypeNamed(r.itemTypeId),
|
|
38
33
|
can_buy: r.canBuy,
|
|
39
34
|
category_ids: r.categoryIds ?? [],
|
|
40
35
|
pool: r.shopPool,
|
|
@@ -44,6 +39,7 @@ export const StoreItemPurchasedTransform = (items: StoreItemPurchased[]): TStore
|
|
|
44
39
|
purchased_this_week: purchasedThisWeek,
|
|
45
40
|
purchased_this_month: purchasedThisMonth,
|
|
46
41
|
}
|
|
42
|
+
|
|
47
43
|
return x;
|
|
48
44
|
});
|
|
49
45
|
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
export enum StoreItemType {
|
|
2
2
|
Bonus = 1,
|
|
3
|
-
|
|
3
|
+
Tangible = 2,
|
|
4
|
+
MiniGameSpin = 3,
|
|
5
|
+
ChangeLevel = 4,
|
|
6
|
+
PrizeDrop = 5,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export enum StoreItemTypeName {
|
|
10
|
+
Bonus = "bonus",
|
|
11
|
+
Tangible = "tangible",
|
|
12
|
+
MiniGameSpin = "minigamespin",
|
|
13
|
+
ChangeLevel = "changelevel",
|
|
14
|
+
PrizeDrop = "prizedrop",
|
|
15
|
+
Unknown = "unknown"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const StoreItemTypeNamed = (type: StoreItemType): StoreItemTypeName => {
|
|
19
|
+
return {
|
|
20
|
+
[StoreItemType.Bonus]: StoreItemTypeName.Bonus,
|
|
21
|
+
[StoreItemType.Tangible]: StoreItemTypeName.Bonus,
|
|
22
|
+
[StoreItemType.MiniGameSpin]: StoreItemTypeName.MiniGameSpin,
|
|
23
|
+
[StoreItemType.ChangeLevel]: StoreItemTypeName.ChangeLevel,
|
|
24
|
+
[StoreItemType.PrizeDrop]: StoreItemTypeName.PrizeDrop,
|
|
25
|
+
}[type] || StoreItemTypeName.Unknown;
|
|
4
26
|
}
|
|
5
27
|
|
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 "../Jackpots";
|
|
8
|
+
import { JackpotDetails, JackpotPot, JackpotWinPush, JackpotsOptinResponse, JackpotsOptoutRequest, JackpotsOptoutResponse } from "../Jackpots";
|
|
9
9
|
|
|
10
10
|
/** @hidden */
|
|
11
11
|
const CACHE_DATA_SEC = 30;
|
|
@@ -51,6 +51,8 @@ export class WSAPI {
|
|
|
51
51
|
on(ClassId.LOGOUT_RESPONSE, () => OCache.clearContext(ECacheContext.WSAPI));
|
|
52
52
|
on(ClassId.IDENTIFY_RESPONSE, () => OCache.clearContext(ECacheContext.WSAPI));
|
|
53
53
|
on(ClassId.JP_WIN_PUSH, (data: JackpotWinPush) => this.jackpotClearCache());
|
|
54
|
+
on(ClassId.JP_OPTOUT_RESPONSE, (data: JackpotsOptoutRequest) => this.jackpotClearCache());
|
|
55
|
+
on(ClassId.JP_OPTIN_RESPONSE, (data: JackpotsOptinResponse) => this.jackpotClearCache());
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
/** Returns information about current user
|
|
@@ -513,8 +515,6 @@ export class WSAPI {
|
|
|
513
515
|
|
|
514
516
|
const result = await this.api.jackpotOptIn(null, filter);
|
|
515
517
|
|
|
516
|
-
this.jackpotClearCache();
|
|
517
|
-
|
|
518
518
|
return result;
|
|
519
519
|
}
|
|
520
520
|
|
|
@@ -535,8 +535,6 @@ export class WSAPI {
|
|
|
535
535
|
|
|
536
536
|
const result = await this.api.jackpotOptOut(null, filter);
|
|
537
537
|
|
|
538
|
-
this.jackpotClearCache();
|
|
539
|
-
|
|
540
538
|
return result;
|
|
541
539
|
}
|
|
542
540
|
}
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -355,8 +355,8 @@ export interface TStoreItem {
|
|
|
355
355
|
description: string;
|
|
356
356
|
/** URL of the image of the store item */
|
|
357
357
|
image: string;
|
|
358
|
-
/** Type of the store item. Can be 'bonus' or '
|
|
359
|
-
type: 'bonus' | '
|
|
358
|
+
/** Type of the store item. Can be 'bonus' or 'tangible' or different others. */
|
|
359
|
+
type: 'bonus' | 'tangible' | 'minigamespin' | 'changelevel' | 'prizedrop' | "unknown";
|
|
360
360
|
/** The price of the store item in the gamification points */
|
|
361
361
|
price: number;
|
|
362
362
|
/** The ribbon of the store item. Can be 'sale', 'hot', 'new', 'vip' or URL to the image in case of custom ribbon */
|