@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.244",
3
+ "version": "0.0.245",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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,9 @@
1
+ import { StoreItemPurchaseType } from "./StoreItemPurchaseType";
2
+
1
3
  export interface StoreItemPublicMeta {
2
4
  price: string;
3
5
  image_url: string;
6
+ purchase_type: StoreItemPurchaseType;
4
7
  name: string;
5
8
  description: string;
6
9
  label_tag: string;
@@ -0,0 +1,5 @@
1
+ export enum StoreItemPurchaseType {
2
+ Points = 0,
3
+ Gems = 1,
4
+ Diamonds = 2,
5
+ }
@@ -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,
@@ -11,3 +11,4 @@ export * from './StoreItemType';
11
11
  export * from './StoreItemPurchased';
12
12
  export * from './GetStoreHistoryRequest';
13
13
  export * from './GetStoreHistoryResponse';
14
+ export * from './StoreItemPurchaseType';
@@ -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
  /**