@smartico/public-api 0.0.124 → 0.0.126

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.
@@ -7,6 +7,12 @@
7
7
  ▸ **getUserProfile**(): [`TUserProfile`](../interfaces/TUserProfile.md)
8
8
 
9
9
  Returns information about current user
10
+ Example usage:
11
+ ```
12
+ _smartico.api.getUserProfile().then((result) => {
13
+ console.log(result);
14
+ });
15
+ ```
10
16
 
11
17
  #### Returns
12
18
 
@@ -19,6 +25,12 @@ ___
19
25
  ▸ **checkSegmentMatch**(`segment_id`): `Promise`<`boolean`\>
20
26
 
21
27
  Check if user belongs to specific segments
28
+ Example usage:
29
+ ```
30
+ _smartico.api.checkSegmentMatch(1).then((result) => {
31
+ console.log(result);
32
+ });
33
+ ```
22
34
 
23
35
  #### Parameters
24
36
 
@@ -37,6 +49,12 @@ ___
37
49
  ▸ **checkSegmentListMatch**(`segment_ids`): `Promise`<[`TSegmentCheckResult`](../interfaces/TSegmentCheckResult.md)[]\>
38
50
 
39
51
  Check if user belongs to specific list of segments
52
+ Example usage:
53
+ ```
54
+ _smartico.api.checkSegmentListMatch([1, 2, 3]).then((result) => {
55
+ console.log(result);
56
+ });
57
+ ```
40
58
 
41
59
  #### Parameters
42
60
 
@@ -55,6 +73,12 @@ ___
55
73
  ▸ **getLevels**(): `Promise`<[`TLevel`](../interfaces/TLevel.md)[]\>
56
74
 
57
75
  Returns all the levels available the current user
76
+ Example usage:
77
+ ```
78
+ _smartico.api.getLevels().then((result) => {
79
+ console.log(result);
80
+ });
81
+ ```
58
82
 
59
83
  #### Returns
60
84
 
@@ -66,6 +90,18 @@ ___
66
90
 
67
91
  ▸ **getMissions**(`params?`): `Promise`<[`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]\>
68
92
 
93
+ Returns all the missions available the current user.
94
+ The returned missions are cached for 30 seconds. But you can pass the onUpdate callback as a parameter.
95
+ Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
96
+ The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it.
97
+ Example usage:
98
+ ```
99
+ _smartico.api.getMissions().then((result) => {
100
+ console.log(result);
101
+ });
102
+ ```
103
+ /**
104
+
69
105
  #### Parameters
70
106
 
71
107
  | Name | Type |
@@ -95,7 +131,15 @@ ___
95
131
 
96
132
  ▸ **getUserLevelExtraCounters**(): `Promise`<[`UserLevelExtraCountersT`](../interfaces/UserLevelExtraCountersT.md)\>
97
133
 
98
- Returns the extra counters for the current user level
134
+ Returns the extra counters for the current user level.
135
+ These are counters that are configured for each Smartico client separatly by request.
136
+ For example 1st counter could be total wagering amount, 2nd counter could be total deposit amount, etc.
137
+ Example usage:
138
+ ```
139
+ _smartico.api.getUserLevelExtraCounters().then((result) => {
140
+ console.log(result);
141
+ });
142
+ ```
99
143
 
100
144
  #### Returns
101
145
 
@@ -108,6 +152,11 @@ ___
108
152
  ▸ **getStoreItems**(): `Promise`<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
109
153
 
110
154
  Returns all the store items available the current user
155
+ Example usage:
156
+ ```
157
+ _smartico.api.getStoreItems().then((result) => {
158
+ console.log(result);
159
+ });
111
160
 
112
161
  #### Returns
113
162
 
@@ -119,7 +168,12 @@ ___
119
168
 
120
169
  ▸ **buyStoreItem**(`item_id`): `Promise`<[`TBuyStoreItemResult`](../interfaces/TBuyStoreItemResult.md)\>
121
170
 
122
- Buy the specific shop item by item_id. Returns the err_code.
171
+ Buy the specific shop item by item_id. Returns the err_code in case of success or error.
172
+ Example usage:
173
+ ```
174
+ _smartico.api.buyStoreItem(1).then((result) => {
175
+ console.log(result);
176
+ });
123
177
 
124
178
  #### Parameters
125
179
 
@@ -145,11 +199,30 @@ Returns store categories
145
199
 
146
200
  ___
147
201
 
202
+ ### storeGetPurchasedItems
203
+
204
+ ▸ **storeGetPurchasedItems**(`params?`): `Promise`<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
205
+
206
+ #### Parameters
207
+
208
+ | Name | Type |
209
+ | :------ | :------ |
210
+ | `params` | `Object` |
211
+ | `params.from?` | `number` |
212
+ | `params.to?` | `number` |
213
+ | `params.onUpdate?` | (`data`: [`TStoreItem`](../interfaces/TStoreItem.md)[]) => `void` |
214
+
215
+ #### Returns
216
+
217
+ `Promise`<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
218
+
219
+ ___
220
+
148
221
  ### getAchCategories
149
222
 
150
223
  ▸ **getAchCategories**(): `Promise`<[`TAchCategory`](../interfaces/TAchCategory.md)[]\>
151
224
 
152
- Returns ach categories
225
+ Returns missions & badges categories
153
226
 
154
227
  #### Returns
155
228
 
@@ -116,3 +116,19 @@ ___
116
116
  • `Optional` **hint\_text**: `string`
117
117
 
118
118
  The T&C text for the store item
119
+
120
+ ___
121
+
122
+ ### purchase\_ts
123
+
124
+ • `Optional` **purchase\_ts**: `number`
125
+
126
+ Purchase time to show in purchase history screen
127
+
128
+ ___
129
+
130
+ ### purchase\_points\_amount
131
+
132
+ • `Optional` **purchase\_points\_amount**: `number`
133
+
134
+ The amount of points you can purchase an item
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.124",
3
+ "version": "0.0.126",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,15 @@
1
+ export * from './GetJackpotsPotsRequest';
2
+ export * from './GetJackpotsPotsResponse';
3
+ export * from './GetJackpotsRequest';
4
+ export * from './GetJackpotsResponse';
5
+ export * from './JackPotWinner';
6
+ export * from './JackpotContributionType';
7
+ export * from './JackpotDetails';
8
+ export * from './JackpotPot';
9
+ export * from './JackpotPublicMeta';
10
+ export * from './JackpotType';
11
+ export * from './JackpotWinPush';
12
+ export * from './JackpotsOptinRequest';
13
+ export * from './JackpotsOptinResponse';
14
+ export * from './JackpotsOptoutRequest';
15
+ export * from './JackpotsOptoutResponse';
@@ -11,7 +11,7 @@ import { CoreUtils, GetTranslationsRequest, GetTranslationsResponse, PublicLabel
11
11
  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
- import { BuyStoreItemRequest, BuyStoreItemResponse, GetCategoriesStoreResponse, GetStoreItemsResponse, StoreCategoryTransform, StoreItemTransform } from './Store';
14
+ import { BuyStoreItemRequest, BuyStoreItemResponse, GetCategoriesStoreResponse, GetStoreHistoryRequest, GetStoreHistoryResponse, GetStoreItemsResponse, StoreCategoryTransform, StoreItemPurchasedTransform, StoreItemTransform } from './Store';
15
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";
@@ -440,7 +440,22 @@ class SmarticoAPI {
440
440
 
441
441
  public async storeGetCategoriesT(user_ext_id: string): Promise<TStoreCategory[]> {
442
442
  return StoreCategoryTransform((await this.storeGetCategories(user_ext_id)).categories);
443
- }
443
+ }
444
+
445
+ public async storeGetPurchasedItems(user_ext_id: string, limit: number = 20, offset: number = 0): Promise<GetStoreHistoryResponse> {
446
+ const message = this.buildMessage<GetStoreHistoryRequest, GetStoreHistoryResponse>(user_ext_id, ClassId.ACH_SHOP_ITEM_HISTORY_REQUEST, {
447
+ limit,
448
+ offset,
449
+ });
450
+ return await this.send<GetStoreHistoryResponse>(message, ClassId.ACH_SHOP_ITEM_HISTORY_RESPONSE);
451
+ }
452
+
453
+ public async storeGetPurchasedItemsT(user_ext_id: string, from: number = 0, to: number = 20): Promise<TStoreItem[]> {
454
+ const limit = (to - from) > 20 ? 20 : to - from;
455
+ const offset = from;
456
+
457
+ return StoreItemPurchasedTransform((await this.storeGetPurchasedItems(user_ext_id, limit, offset)).items);
458
+ }
444
459
 
445
460
  public async missionsGetItems(user_ext_id: string): Promise<GetAchievementMapResponse> {
446
461
 
@@ -1,6 +1,6 @@
1
1
  import { ProtocolMessage } from "../Base/ProtocolMessage";
2
2
 
3
3
  export interface GetStoreHistoryRequest extends ProtocolMessage {
4
- offset: number;
5
- limit: number;
4
+ offset?: number;
5
+ limit?: number;
6
6
  }
@@ -1,7 +1,7 @@
1
- import { ProtocolMessage } from "../Base/ProtocolMessage";
2
- import { StorItemPruchased } from "./StorItemPruchased";
1
+ import { ProtocolResponse } from "../Base/ProtocolResponse";
2
+ import { StoreItemPurchased } from "./StoreItemPurchased";
3
3
 
4
- export interface GetStoreHistoryResponse extends ProtocolMessage {
5
- items: StorItemPruchased[];
4
+ export interface GetStoreHistoryResponse extends ProtocolResponse {
5
+ items: StoreItemPurchased[];
6
6
  hasMore: boolean;
7
7
  }
@@ -0,0 +1,41 @@
1
+ import { TStoreItem } from "../WSAPI/WSAPITypes";
2
+ import { StoreItem } from "./StoreItem";
3
+ import { StoreItemType } from "./StoreItemType";
4
+
5
+ interface StoreItemPurchased extends StoreItem {
6
+ purchase_ts: number;
7
+ purchase_points_amount: number;
8
+ }
9
+
10
+ export const StoreItemPurchasedTransform = (items: StoreItemPurchased[]): TStoreItem[] => {
11
+ return items.filter( r => r.id >= 1).map( r => {
12
+ const x: TStoreItem =
13
+ {
14
+ id: r.id,
15
+ name: r.itemPublicMeta.name,
16
+ price: r.itemPublicMeta.price as any as number, // AA: strange why it's string
17
+ image: r.itemPublicMeta.image_url,
18
+ description: r.itemPublicMeta.description,
19
+ ribbon: r.itemPublicMeta.label_tag === 'custom' ? r.itemPublicMeta.custom_label_tag : r.itemPublicMeta.label_tag,
20
+ limit_message: r.itemPublicMeta.limit_message,
21
+ priority: r.itemPublicMeta.priority,
22
+ related_item_ids: r.itemPublicMeta.related_items,
23
+ hint_text: r.itemPublicMeta.hint_text,
24
+
25
+ type: {
26
+ [StoreItemType.Bonus]: 'bonus',
27
+ [StoreItemType.Manual]: 'manual'
28
+ }[r.itemTypeId] as 'bonus' | 'manual',
29
+
30
+ can_buy: r.canBuy,
31
+ category_ids: r.categoryIds ?? [],
32
+ pool: r.shopPool,
33
+ purchase_ts: r.purchase_ts,
34
+ purchase_points_amount: r.purchase_points_amount
35
+ }
36
+ return x;
37
+ });
38
+
39
+ }
40
+
41
+ export { StoreItemPurchased }
@@ -7,4 +7,7 @@ export * from "./StoreCategory";
7
7
  export * from "./StoreCategoryPublicMeta";
8
8
  export * from "./StoreItem";
9
9
  export * from "./StoreItemPublicMeta";
10
- export * from "./StoreItemType";
10
+ export * from "./StoreItemType";
11
+ export * from './StoreItemPurchased';
12
+ export * from './GetStoreHistoryRequest';
13
+ export * from './GetStoreHistoryResponse';
@@ -22,6 +22,7 @@ enum onUpdateContextKey {
22
22
  LeaderBoards = 'leaderBoards',
23
23
  LevelExtraCounters = 'levelExtraCounters',
24
24
  Segments = 'segments',
25
+ StoreHistory = 'storeHistory'
25
26
  }
26
27
 
27
28
 
@@ -43,7 +44,14 @@ export class WSAPI {
43
44
  on(ClassId.IDENTIFY_RESPONSE, () => OCache.clear(ECacheContext.WSAPI));
44
45
  }
45
46
 
46
- /** Returns information about current user */
47
+ /** Returns information about current user
48
+ * Example usage:
49
+ * ```
50
+ * _smartico.api.getUserProfile().then((result) => {
51
+ * console.log(result);
52
+ * });
53
+ * ```
54
+ * */
47
55
  public getUserProfile(): TUserProfile {
48
56
  if (this.api.tracker) {
49
57
  const o: TUserProfile = Object.assign({}, this.api.tracker.userPublicProps);
@@ -54,8 +62,14 @@ export class WSAPI {
54
62
  }
55
63
  }
56
64
 
57
- /** Check if user belongs to specific segments */
58
-
65
+ /** Check if user belongs to specific segments
66
+ * Example usage:
67
+ * ```
68
+ * _smartico.api.checkSegmentMatch(1).then((result) => {
69
+ * console.log(result);
70
+ * });
71
+ * ```
72
+ */
59
73
  public async checkSegmentMatch(segment_id: number): Promise<boolean> {
60
74
  const r = await this.api.coreCheckSegments(null, [segment_id]);
61
75
  if (r && r.find(s => s.segment_id === segment_id && s.is_matching)) {
@@ -65,19 +79,40 @@ export class WSAPI {
65
79
  }
66
80
  }
67
81
 
68
- /** Check if user belongs to specific list of segments */
82
+ /** Check if user belongs to specific list of segments
83
+ * Example usage:
84
+ * ```
85
+ * _smartico.api.checkSegmentListMatch([1, 2, 3]).then((result) => {
86
+ * console.log(result);
87
+ * });
88
+ * ```
89
+ */
69
90
  public async checkSegmentListMatch(segment_ids: number[]): Promise<TSegmentCheckResult[]> {
70
- return await this.api.coreCheckSegments(null, segment_ids)
91
+ return await this.api.coreCheckSegments(null, Array.isArray(segment_ids) ? segment_ids : [segment_ids]);
71
92
  }
72
93
 
73
- /** Returns all the levels available the current user */
94
+ /** Returns all the levels available the current user
95
+ * Example usage:
96
+ * ```
97
+ * _smartico.api.getLevels().then((result) => {
98
+ * console.log(result);
99
+ * });
100
+ * ```
101
+ */
74
102
  public async getLevels(): Promise<TLevel[]> {
75
103
  return OCache.use(onUpdateContextKey.Levels, ECacheContext.WSAPI, () => this.api.levelsGetT(null), CACHE_DATA_SEC);
76
104
  }
77
105
 
78
106
  /** Returns all the missions available the current user.
79
- * The returned missions is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
80
- * The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it. */
107
+ * The returned missions are cached for 30 seconds. But you can pass the onUpdate callback as a parameter.
108
+ * Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
109
+ * The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it.
110
+ * Example usage:
111
+ * ```
112
+ * _smartico.api.getMissions().then((result) => {
113
+ * console.log(result);
114
+ * });
115
+ * ```
81
116
  /**
82
117
  * @param params
83
118
  */
@@ -94,17 +129,40 @@ export class WSAPI {
94
129
  return OCache.use(onUpdateContextKey.Badges, ECacheContext.WSAPI, () => this.api.badgetsGetItemsT(null), CACHE_DATA_SEC);
95
130
  }
96
131
 
97
- /** Returns the extra counters for the current user level */
132
+ /**
133
+ * Returns the extra counters for the current user level.
134
+ * These are counters that are configured for each Smartico client separatly by request.
135
+ * For example 1st counter could be total wagering amount, 2nd counter could be total deposit amount, etc.
136
+ * Example usage:
137
+ * ```
138
+ * _smartico.api.getUserLevelExtraCounters().then((result) => {
139
+ * console.log(result);
140
+ * });
141
+ * ```
142
+ */
98
143
  public async getUserLevelExtraCounters(): Promise<UserLevelExtraCountersT> {
99
144
  return OCache.use(onUpdateContextKey.LevelExtraCounters, ECacheContext.WSAPI, () => this.api.getUserGamificationInfoT(null), CACHE_DATA_SEC);
100
145
  }
101
146
 
102
- /** Returns all the store items available the current user */
147
+ /** Returns all the store items available the current user
148
+ * Example usage:
149
+ * ```
150
+ * _smartico.api.getStoreItems().then((result) => {
151
+ * console.log(result);
152
+ * });
153
+ */
154
+
103
155
  public async getStoreItems(): Promise<TStoreItem[]> {
104
156
  return OCache.use(onUpdateContextKey.StoreItems, ECacheContext.WSAPI, () => this.api.storeGetItemsT(null), CACHE_DATA_SEC);
105
157
  }
106
158
 
107
- /** Buy the specific shop item by item_id. Returns the err_code.*/
159
+ /** Buy the specific shop item by item_id. Returns the err_code in case of success or error.
160
+ * Example usage:
161
+ * ```
162
+ * _smartico.api.buyStoreItem(1).then((result) => {
163
+ * console.log(result);
164
+ * });
165
+ */
108
166
  public async buyStoreItem(item_id: number): Promise<TBuyStoreItemResult> {
109
167
  const r = await this.api.buyStoreItem(null, item_id);
110
168
 
@@ -121,7 +179,23 @@ export class WSAPI {
121
179
  return OCache.use(onUpdateContextKey.StoreCategories, ECacheContext.WSAPI, () => this.api.storeGetCategoriesT(null), CACHE_DATA_SEC);
122
180
  }
123
181
 
124
- /** Returns ach categories */
182
+ /** Returns store purchased items based on the provided parameters. "From" and "to" indicate the range of items to be fetched.
183
+ * The maximum number of messages per request is limited to 20.
184
+ * You can leave this params empty and by default it will return list of purchased items ranging from 0 to 20.
185
+ * This functions return list of purchased items.
186
+ * The "onUpdate" callback will be triggered when the user receives a new purchased item. It will provide an updated list of items, ranging from 0 to 20, to the onUpdate callback function. */
187
+ /**
188
+ * @param params
189
+ */
190
+ public async storeGetPurchasedItems({ from, to, onUpdate }: { from?: number, to?: number, onUpdate?: (data: TStoreItem[]) => void } = {}): Promise<TStoreItem[]> {
191
+ if (onUpdate) {
192
+ this.onUpdateCallback.set(onUpdateContextKey.StoreHistory, onUpdate);
193
+ }
194
+
195
+ return await this.api.storeGetPurchasedItemsT(null, from, to);
196
+ }
197
+
198
+ /** Returns missions & badges categories */
125
199
  public async getAchCategories(): Promise<TAchCategory[]> {
126
200
  return OCache.use(onUpdateContextKey.AchCategories, ECacheContext.WSAPI, () => this.api.achGetCategoriesT(null), CACHE_DATA_SEC);
127
201
  }
@@ -377,6 +377,10 @@ export interface TStoreItem {
377
377
  pool?: number;
378
378
  /** The T&C text for the store item */
379
379
  hint_text?: string;
380
+ /** Purchase time to show in purchase history screen */
381
+ purchase_ts?: number;
382
+ /** The amount of points you can purchase an item */
383
+ purchase_points_amount?: number;
380
384
  }
381
385
 
382
386
  /**
package/src/index.ts CHANGED
@@ -11,4 +11,5 @@ export * from './Missions';
11
11
  export * from './Store';
12
12
  export * from './Tournaments';
13
13
  export * from './Level';
14
- export * from './Quiz';
14
+ export * from './Quiz';
15
+ export * from './Jackpots';
@@ -1,8 +0,0 @@
1
- import { StoreItem } from "./StoreItem";
2
-
3
- interface StorItemPruchased extends StoreItem {
4
- purchase_ts: number;
5
- purchase_points_amount: number;
6
- }
7
-
8
- export { StorItemPruchased }