@smartico/public-api 0.0.78 → 0.0.80

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/docs/README.md CHANGED
@@ -6,6 +6,8 @@
6
6
  - [SAWGameTypeName](enums/SAWGameTypeName.md)
7
7
  - [MiniGamePrizeTypeName](enums/MiniGamePrizeTypeName.md)
8
8
  - [SAWSpinErrorCode](enums/SAWSpinErrorCode.md)
9
+ - [BuyStoreItemErrorCode](enums/BuyStoreItemErrorCode.md)
10
+ - [TournamentRegistrationError](enums/TournamentRegistrationError.md)
9
11
  - [TournamentRegistrationStatusName](enums/TournamentRegistrationStatusName.md)
10
12
 
11
13
  ## Interfaces
@@ -22,6 +24,8 @@
22
24
  - [TMissionOrBadge](interfaces/TMissionOrBadge.md)
23
25
  - [TMissionOrBadgeTask](interfaces/TMissionOrBadgeTask.md)
24
26
  - [TMissionOptInResult](interfaces/TMissionOptInResult.md)
27
+ - [TTournamentRegistrationResult](interfaces/TTournamentRegistrationResult.md)
28
+ - [TBuyStoreItemResult](interfaces/TBuyStoreItemResult.md)
25
29
 
26
30
  ## General API
27
31
 
@@ -67,6 +67,24 @@ Returns all the store items available the current user
67
67
 
68
68
  ___
69
69
 
70
+ ### buyStoreItem
71
+
72
+ ▸ **buyStoreItem**(`item_id`): `Promise`<[`TBuyStoreItemResult`](../interfaces/TBuyStoreItemResult.md)\>
73
+
74
+ Buy the specific shop item by item_id. Returns the err_code.
75
+
76
+ #### Parameters
77
+
78
+ | Name | Type |
79
+ | :------ | :------ |
80
+ | `item_id` | `number` |
81
+
82
+ #### Returns
83
+
84
+ `Promise`<[`TBuyStoreItemResult`](../interfaces/TBuyStoreItemResult.md)\>
85
+
86
+ ___
87
+
70
88
  ### getStoreCategories
71
89
 
72
90
  ▸ **getStoreCategories**(): `Promise`<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
@@ -167,3 +185,21 @@ Returns details information of specific tournament instance, the response will i
167
185
  #### Returns
168
186
 
169
187
  `Promise`<[`TTournamentDetailed`](../interfaces/TTournamentDetailed.md)\>
188
+
189
+ ___
190
+
191
+ ### registerInTournament
192
+
193
+ ▸ **registerInTournament**(`tournamentInstanceId`): `Promise`<[`TTournamentRegistrationResult`](../interfaces/TTournamentRegistrationResult.md)\>
194
+
195
+ Requests registration for the specified tournament instance. Returns the err_code.
196
+
197
+ #### Parameters
198
+
199
+ | Name | Type |
200
+ | :------ | :------ |
201
+ | `tournamentInstanceId` | `number` |
202
+
203
+ #### Returns
204
+
205
+ `Promise`<[`TTournamentRegistrationResult`](../interfaces/TTournamentRegistrationResult.md)\>
@@ -0,0 +1,49 @@
1
+ # Enumeration: BuyStoreItemErrorCode
2
+
3
+ ## Enumeration Members
4
+
5
+ ### FAILED\_TO\_BUY\_SHOP\_ITEM
6
+
7
+ • **FAILED\_TO\_BUY\_SHOP\_ITEM** = ``121``
8
+
9
+ ___
10
+
11
+ ### SHOP\_NO\_BALANCE
12
+
13
+ • **SHOP\_NO\_BALANCE** = ``11000``
14
+
15
+ ___
16
+
17
+ ### SHOP\_WRONG\_LABEL
18
+
19
+ • **SHOP\_WRONG\_LABEL** = ``11001``
20
+
21
+ ___
22
+
23
+ ### SHOP\_FAILED\_TO\_BUY\_BONUS
24
+
25
+ • **SHOP\_FAILED\_TO\_BUY\_BONUS** = ``11002``
26
+
27
+ ___
28
+
29
+ ### SHOP\_FAILED\_TO\_BUY\_SHOP\_ITEM\_CONDITION
30
+
31
+ • **SHOP\_FAILED\_TO\_BUY\_SHOP\_ITEM\_CONDITION** = ``11003``
32
+
33
+ ___
34
+
35
+ ### SHOP\_FAILED\_TO\_BUY\_SHOP\_ITEM\_CONDITION\_PURSHASE
36
+
37
+ • **SHOP\_FAILED\_TO\_BUY\_SHOP\_ITEM\_CONDITION\_PURSHASE** = ``11004``
38
+
39
+ ___
40
+
41
+ ### SHOP\_FAILED\_TO\_BUY\_MATCHING\_BONUS
42
+
43
+ • **SHOP\_FAILED\_TO\_BUY\_MATCHING\_BONUS** = ``11005``
44
+
45
+ ___
46
+
47
+ ### SHOP\_FAILED\_MAX\_BOUGHT\_ITEMS\_REACHED
48
+
49
+ • **SHOP\_FAILED\_MAX\_BOUGHT\_ITEMS\_REACHED** = ``11006``
@@ -0,0 +1,55 @@
1
+ # Enumeration: TournamentRegistrationError
2
+
3
+ ## Enumeration Members
4
+
5
+ ### NO\_ERROR
6
+
7
+ • **NO\_ERROR** = ``0``
8
+
9
+ ___
10
+
11
+ ### TOURNAMENT\_INSTANCE\_NOT\_FOUND
12
+
13
+ • **TOURNAMENT\_INSTANCE\_NOT\_FOUND** = ``30001``
14
+
15
+ ___
16
+
17
+ ### TOURNAMENT\_REGISTRATION\_NOT\_ENOUGH\_POINTS
18
+
19
+ • **TOURNAMENT\_REGISTRATION\_NOT\_ENOUGH\_POINTS** = ``30002``
20
+
21
+ ___
22
+
23
+ ### TOURNAMENT\_INSTANCE\_NOT\_IN\_STATE
24
+
25
+ • **TOURNAMENT\_INSTANCE\_NOT\_IN\_STATE** = ``30003``
26
+
27
+ ___
28
+
29
+ ### TOURNAMENT\_ALREADY\_REGISTERED
30
+
31
+ • **TOURNAMENT\_ALREADY\_REGISTERED** = ``30004``
32
+
33
+ ___
34
+
35
+ ### TOURNAMENT\_USER\_DONT\_MATCH\_CONDITIONS
36
+
37
+ • **TOURNAMENT\_USER\_DONT\_MATCH\_CONDITIONS** = ``30005``
38
+
39
+ ___
40
+
41
+ ### TOURNAMENT\_USER\_NOT\_REGISTERED
42
+
43
+ • **TOURNAMENT\_USER\_NOT\_REGISTERED** = ``30006``
44
+
45
+ ___
46
+
47
+ ### TOURNAMENT\_CANT\_CHANGE\_REGISTRATION\_STATUS
48
+
49
+ • **TOURNAMENT\_CANT\_CHANGE\_REGISTRATION\_STATUS** = ``30007``
50
+
51
+ ___
52
+
53
+ ### TOURNAMENT\_MAX\_REGISTRATIONS\_REACHED
54
+
55
+ • **TOURNAMENT\_MAX\_REGISTRATIONS\_REACHED** = ``30008``
@@ -0,0 +1,17 @@
1
+ # Interface: TBuyStoreItemResult
2
+
3
+ ## Properties
4
+
5
+ ### err\_code
6
+
7
+ • **err\_code**: [`BuyStoreItemErrorCode`](../enums/BuyStoreItemErrorCode.md)
8
+
9
+ Error code representing the result of the purchase of the shop item. Successful purchase if err_code is 0
10
+
11
+ ___
12
+
13
+ ### err\_message
14
+
15
+ • **err\_message**: `string`
16
+
17
+ Optional error message
@@ -0,0 +1,17 @@
1
+ # Interface: TTournamentRegistrationResult
2
+
3
+ ## Properties
4
+
5
+ ### err\_code
6
+
7
+ • **err\_code**: [`TournamentRegistrationError`](../enums/TournamentRegistrationError.md)
8
+
9
+ Error code that represents outcome of the tournament registration request. Successful registration in case err_code is 0
10
+
11
+ ___
12
+
13
+ ### err\_message
14
+
15
+ • **err\_message**: `string`
16
+
17
+ Optional error message
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.78",
3
+ "version": "0.0.80",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,5 +14,5 @@ export interface InboxMessage {
14
14
  engagement_uid: string;
15
15
  is_read: boolean;
16
16
  is_starred: boolean;
17
- additional_buttons?: { inbox_cta_text: string, action: string }
17
+ additional_buttons?: { inbox_cta_text: string, action: string }[];
18
18
  }
@@ -11,9 +11,9 @@ import { CoreUtils, GetTranslationsRequest, GetTranslationsResponse, ResponseIde
11
11
  import { GetLabelInfoResponse } from './Core/GetLabelInfoResponse';
12
12
  import { GetLabelInfoRequest } from './Core/GetLabelInfoRequest';
13
13
  import { GetInboxMessagesRequest, GetInboxMessagesResponse } from './Inbox';
14
- import { GetCategoriesStoreResponse, GetStoreItemsResponse, StoreCategoryTransform, StoreItemTransform } from './Store';
14
+ import { BuyStoreItemRequest, BuyStoreItemResponse, GetCategoriesStoreResponse, GetStoreItemsResponse, StoreCategoryTransform, StoreItemTransform } from './Store';
15
15
  import { AchievementOptinRequest, AchievementOptinResponse, AchievementType, GetAchievementMapRequest, GetAchievementMapResponse, UserAchievementTransform } from './Missions';
16
- import { GetTournamentInfoRequest, GetTournamentInfoResponse, GetTournamentsRequest, GetTournamentsResponse, TournamentItemsTransform, tournamentInfoItemTransform } from './Tournaments';
16
+ import { GetTournamentInfoRequest, GetTournamentInfoResponse, GetTournamentsRequest, GetTournamentsResponse, TournamentItemsTransform, TournamentRegisterRequest, TournamentRegisterResponse, tournamentInfoItemTransform } from './Tournaments';
17
17
  import { GetLeaderBoardsRequest, GetLeaderBoardsResponse, LeaderBoardDetails, LeaderBoardPeriodType } from "./Leaderboard";
18
18
  import { GetLevelMapResponse, GetLevelMapResponseTransform } from "./Level";
19
19
  import { WSAPI } from "./WSAPI/WSAPI";
@@ -264,7 +264,7 @@ class SmarticoAPI {
264
264
  public_username_custom
265
265
  });
266
266
 
267
- return this.send(message, ClassId.CLIENT_SET_CUSTOM_USERNAME_RESPONSE);
267
+ return await this.send(message, ClassId.CLIENT_SET_CUSTOM_USERNAME_RESPONSE);
268
268
  }
269
269
 
270
270
  public async sawGetTemplates(user_ext_id: string, lang?: string, is_visitor_mode: boolean = false): Promise<SAWGetTemplatesResponse> {
@@ -351,6 +351,32 @@ class SmarticoAPI {
351
351
  return res;
352
352
  }
353
353
 
354
+ public async registerInTournament(user_ext_id: string, tournamentInstanceId: number) {
355
+ if (!tournamentInstanceId) {
356
+ throw new Error('Missing tournament instance id');
357
+ }
358
+ const message = this.buildMessage<TournamentRegisterRequest, TournamentRegisterResponse>(user_ext_id, ClassId.TOURNAMENT_REGISTER_REQUEST, {
359
+ tournamentInstanceId
360
+ });
361
+
362
+ const res = await this.send<TournamentRegisterResponse>(message, ClassId.TOURNAMENT_REGISTER_RESPONSE);
363
+
364
+ return res;
365
+ }
366
+
367
+ public async buyStoreItem(user_ext_id: string, itemId: number) {
368
+ if (!itemId) {
369
+ throw new Error('Missing store item id');
370
+ }
371
+ const message = this.buildMessage<BuyStoreItemRequest, BuyStoreItemResponse>(user_ext_id, ClassId.BUY_SHOP_ITEM_REQUEST, {
372
+ itemId
373
+ });
374
+
375
+ const res = await this.send<BuyStoreItemResponse>(message, ClassId.BUY_SHOP_ITEM_RESPONSE);
376
+
377
+ return res;
378
+ }
379
+
354
380
  public async inboxGetMessages(user_ext_id: string, limit: number = 10, offset: number = 0): Promise<GetInboxMessagesResponse> {
355
381
 
356
382
  const message = this.buildMessage<GetInboxMessagesRequest, GetInboxMessagesResponse>(user_ext_id, ClassId.GET_INBOX_MESSAGES_REQUEST, {
@@ -3,7 +3,7 @@ import { CoreUtils } from "../Core";
3
3
  import { MiniGamePrizeTypeName, SAWDoSpinResponse, SAWSpinErrorCode, SAWSpinsCountPush } from "../MiniGames";
4
4
  import { ECacheContext, OCache } from "../OCache";
5
5
  import { SmarticoAPI } from "../SmarticoAPI";
6
- import { TLevel, TMiniGamePlayResult, TMiniGamePrize, TMiniGameTemplate, TMissionOptInResult, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TUserProfile } from "./WSAPITypes";
6
+ import { TBuyStoreItemResult, TLevel, TMiniGamePlayResult, TMiniGamePrize, TMiniGameTemplate, TMissionOptInResult, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUserProfile } from "./WSAPITypes";
7
7
 
8
8
  /** @hidden */
9
9
  const CACHE_DATA_SEC = 30;
@@ -70,6 +70,18 @@ export class WSAPI {
70
70
  return this.api.storeGetItemsT(null);
71
71
  }
72
72
 
73
+ /** Buy the specific shop item by item_id. Returns the err_code.*/
74
+ public async buyStoreItem(item_id: number): Promise<TBuyStoreItemResult> {
75
+ const r = await this.api.buyStoreItem(null, item_id);
76
+
77
+ const o: TBuyStoreItemResult = {
78
+ err_code: r.errCode,
79
+ err_message: r.errMsg,
80
+ }
81
+
82
+ return o;
83
+ }
84
+
73
85
  /** Returns store categories */
74
86
  public async getStoreCategories(): Promise<TStoreItem[]> {
75
87
  return this.api.storeGetItemsT(null);
@@ -135,6 +147,18 @@ export class WSAPI {
135
147
  return this.api.tournamentsGetInfoT(null, tournamentInstanceId);
136
148
  }
137
149
 
150
+ /** Requests registration for the specified tournament instance. Returns the err_code. */
151
+ public async registerInTournament(tournamentInstanceId: number): Promise<TTournamentRegistrationResult>{
152
+ const r = await this.api.registerInTournament(null, tournamentInstanceId);
153
+
154
+ const o: TTournamentRegistrationResult = {
155
+ err_code: r.errCode,
156
+ err_message: r.errMsg,
157
+ }
158
+
159
+ return o;
160
+ }
161
+
138
162
  private async updateOnSpin(data: SAWSpinsCountPush) {
139
163
  const templates: TMiniGameTemplate[] = await OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC);
140
164
  const index = templates.findIndex(t => t.id === data.saw_template_id);
@@ -1,5 +1,6 @@
1
- import { MiniGamePrizeTypeName, SAWBuyInTypeName, SAWGameTypeName, SAWPrizeType, SAWPrizeUI, SAWSpinErrorCode } from "../MiniGames";
2
- import { TournamentRegistrationStatusName, TournamentRegistrationTypeName } from "../Tournaments";
1
+ import { BuyStoreItemErrorCode } from "../Store";
2
+ import { MiniGamePrizeTypeName, SAWBuyInTypeName, SAWGameTypeName, SAWSpinErrorCode } from "../MiniGames";
3
+ import { TournamentRegistrationError, TournamentRegistrationStatusName, TournamentRegistrationTypeName } from "../Tournaments";
3
4
 
4
5
  type TRibbon = 'sale' | 'hot' | 'new' | 'vip' | string
5
6
 
@@ -398,4 +399,18 @@ export interface TMissionOptInResult {
398
399
  err_code: number;
399
400
  /** Optional error message */
400
401
  err_message: string;
402
+ }
403
+
404
+ export interface TTournamentRegistrationResult {
405
+ /** Error code that represents outcome of the tournament registration request. Successful registration in case err_code is 0 */
406
+ err_code: TournamentRegistrationError;
407
+ /** Optional error message */
408
+ err_message: string;
409
+ }
410
+
411
+ export interface TBuyStoreItemResult {
412
+ /** Error code representing the result of the purchase of the shop item. Successful purchase if err_code is 0 */
413
+ err_code: BuyStoreItemErrorCode;
414
+ /** Optional error message */
415
+ err_message: string;
401
416
  }
package/tsconfig.json CHANGED
@@ -23,6 +23,8 @@
23
23
  "src/MiniGames/SAWGameType.ts",
24
24
  "src/MiniGames/SAWPrizeType.ts",
25
25
  "src/MiniGames/SAWSpinErrorCode.ts",
26
+ "src/Tournaments/TournamentRegistrationError.ts",
27
+ "src/Store/BuyStoreItemErrorCode.ts",
26
28
  ],
27
29
  "out": "docs",
28
30
  "plugin": ["typedoc-plugin-markdown", "typedoc-plugin-merge-modules"],