@smartico/public-api 0.0.244 → 0.0.245
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/Store/StoreItemPublicMeta.d.ts +2 -0
- package/dist/Store/StoreItemPurchaseType.d.ts +5 -0
- package/dist/Store/index.d.ts +1 -0
- package/dist/WSAPI/WSAPITypes.d.ts +2 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +30 -1
- package/dist/index.modern.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Store/StoreItem.ts +15 -0
- package/src/Store/StoreItemPublicMeta.ts +3 -0
- package/src/Store/StoreItemPurchaseType.ts +5 -0
- package/src/Store/StoreItemPurchased.ts +14 -0
- package/src/Store/index.ts +1 -0
- package/src/WSAPI/WSAPITypes.ts +2 -0
package/package.json
CHANGED
package/src/Store/StoreItem.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IntUtils } from '../IntUtils';
|
|
2
2
|
import { TStoreItem } from '../WSAPI/WSAPITypes';
|
|
3
3
|
import { StoreItemPublicMeta } from './StoreItemPublicMeta';
|
|
4
|
+
import { StoreItemPurchaseType } from './StoreItemPurchaseType';
|
|
4
5
|
import { StoreItemType, StoreItemTypeNamed } from './StoreItemType';
|
|
5
6
|
|
|
6
7
|
export interface StoreItem {
|
|
@@ -12,13 +13,27 @@ export interface StoreItem {
|
|
|
12
13
|
shopPool: number;
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
const mapPurchaseType = (purchaseType: StoreItemPurchaseType) => {
|
|
17
|
+
if (purchaseType === StoreItemPurchaseType.Points) {
|
|
18
|
+
return 'points';
|
|
19
|
+
} else if (purchaseType === StoreItemPurchaseType.Gems) {
|
|
20
|
+
return 'gems';
|
|
21
|
+
} else if (purchaseType === StoreItemPurchaseType.Diamonds) {
|
|
22
|
+
return 'diamonds';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return 'points';
|
|
26
|
+
};
|
|
27
|
+
|
|
15
28
|
export const StoreItemTransform = (items: StoreItem[]): TStoreItem[] => {
|
|
29
|
+
|
|
16
30
|
return items
|
|
17
31
|
.filter((r) => r.id >= 1)
|
|
18
32
|
.map((r) => {
|
|
19
33
|
const x: TStoreItem = {
|
|
20
34
|
id: r.id,
|
|
21
35
|
name: r.itemPublicMeta.name,
|
|
36
|
+
purchase_type: mapPurchaseType(r.itemPublicMeta.purchase_type),
|
|
22
37
|
price: r.itemPublicMeta.price as any as number, // AA: strange why it's string
|
|
23
38
|
image: r.itemPublicMeta.image_url,
|
|
24
39
|
description: r.itemPublicMeta.description,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IntUtils } from '../IntUtils';
|
|
2
2
|
import { TStoreItem } from '../WSAPI/WSAPITypes';
|
|
3
3
|
import { StoreItem } from './StoreItem';
|
|
4
|
+
import { StoreItemPurchaseType } from './StoreItemPurchaseType';
|
|
4
5
|
import { StoreItemTypeNamed } from './StoreItemType';
|
|
5
6
|
|
|
6
7
|
interface StoreItemPurchased extends StoreItem {
|
|
@@ -11,6 +12,18 @@ interface StoreItemPurchased extends StoreItem {
|
|
|
11
12
|
purchased_this_month?: boolean;
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
const mapPurchaseType = (purchaseType: StoreItemPurchaseType) => {
|
|
16
|
+
if (purchaseType === StoreItemPurchaseType.Points) {
|
|
17
|
+
return 'points';
|
|
18
|
+
} else if (purchaseType === StoreItemPurchaseType.Gems) {
|
|
19
|
+
return 'gems';
|
|
20
|
+
} else if (purchaseType === StoreItemPurchaseType.Diamonds) {
|
|
21
|
+
return 'diamonds';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return 'points';
|
|
25
|
+
};
|
|
26
|
+
|
|
14
27
|
export const StoreItemPurchasedTransform = (items: StoreItemPurchased[]): TStoreItem[] => {
|
|
15
28
|
return items
|
|
16
29
|
.filter((r) => r.id >= 1)
|
|
@@ -23,6 +36,7 @@ export const StoreItemPurchasedTransform = (items: StoreItemPurchased[]): TStore
|
|
|
23
36
|
id: r.id,
|
|
24
37
|
name: r.itemPublicMeta.name,
|
|
25
38
|
price: r.itemPublicMeta.price as any as number, // AA: strange why it's string
|
|
39
|
+
purchase_type: mapPurchaseType(r.itemPublicMeta.purchase_type),
|
|
26
40
|
image: r.itemPublicMeta.image_url,
|
|
27
41
|
description: r.itemPublicMeta.description,
|
|
28
42
|
ribbon: r.itemPublicMeta.label_tag === 'custom' ? r.itemPublicMeta.custom_label_tag : r.itemPublicMeta.label_tag,
|
package/src/Store/index.ts
CHANGED
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -470,6 +470,8 @@ export interface TStoreItem {
|
|
|
470
470
|
purchased_this_week?: boolean;
|
|
471
471
|
/** Flag for store item indicating that it was purchased this month */
|
|
472
472
|
purchased_this_month?: boolean;
|
|
473
|
+
/** The type of the purchase */
|
|
474
|
+
purchase_type: 'points' | 'gems' | 'diamonds';
|
|
473
475
|
}
|
|
474
476
|
|
|
475
477
|
/**
|