@smartico/public-api 0.0.326 → 0.0.328

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
@@ -103,6 +103,8 @@
103
103
  - [RaffleDraw](interfaces/RaffleDraw.md)
104
104
  - [RaffleDrawPublicMeta](interfaces/RaffleDrawPublicMeta.md)
105
105
  - [RaffleDrawRun](interfaces/RaffleDrawRun.md)
106
+ - [RaffleOptinRequest](interfaces/RaffleOptinRequest.md)
107
+ - [RaffleOptinResponse](interfaces/RaffleOptinResponse.md)
106
108
  - [RafflePrizePublicMeta](interfaces/RafflePrizePublicMeta.md)
107
109
  - [RafflePrize](interfaces/RafflePrize.md)
108
110
  - [RafflePrizeWinner](interfaces/RafflePrizeWinner.md)
@@ -149,6 +151,7 @@
149
151
  - [TRaffleDrawRun](interfaces/TRaffleDrawRun.md)
150
152
  - [TransformedRaffleClaimPrizeResponse](interfaces/TransformedRaffleClaimPrizeResponse.md)
151
153
  - [TPointsHistoryLog](interfaces/TPointsHistoryLog.md)
154
+ - [TRaffleOptinResponse](interfaces/TRaffleOptinResponse.md)
152
155
 
153
156
  ## General API
154
157
 
@@ -1357,3 +1357,26 @@ _smartico.vapi('EN').claimRafflePrize({ won_id: 251 }).then((result) => {
1357
1357
  #### Returns
1358
1358
 
1359
1359
  `Promise`\<[`TransformedRaffleClaimPrizeResponse`](../interfaces/TransformedRaffleClaimPrizeResponse.md)\>
1360
+
1361
+ ___
1362
+
1363
+ ### requestRaffleOptin
1364
+
1365
+ ▸ **requestRaffleOptin**(`props`): `Promise`\<[`TRaffleOptinResponse`](../interfaces/TRaffleOptinResponse.md)\>
1366
+
1367
+ Requests an opt-in for the specified raffle. Returns the err_code.
1368
+
1369
+ **Visitor mode: not supported**
1370
+
1371
+ #### Parameters
1372
+
1373
+ | Name | Type |
1374
+ | :------ | :------ |
1375
+ | `props` | `Object` |
1376
+ | `props.raffle_id` | `number` |
1377
+ | `props.draw_id` | `number` |
1378
+ | `props.raffle_run_id` | `number` |
1379
+
1380
+ #### Returns
1381
+
1382
+ `Promise`\<[`TRaffleOptinResponse`](../interfaces/TRaffleOptinResponse.md)\>
@@ -71,3 +71,9 @@ ___
71
71
  ### RAFFLE
72
72
 
73
73
  • **RAFFLE** = ``13``
74
+
75
+ ___
76
+
77
+ ### BADGES
78
+
79
+ • **BADGES** = ``14``
@@ -0,0 +1,55 @@
1
+ # Interface: RaffleOptinRequest
2
+
3
+ ## Hierarchy
4
+
5
+ - `ProtocolMessage`
6
+
7
+ ↳ **`RaffleOptinRequest`**
8
+
9
+ ## Properties
10
+
11
+ ### cid
12
+
13
+ • **cid**: `number`
14
+
15
+ #### Inherited from
16
+
17
+ ProtocolMessage.cid
18
+
19
+ ___
20
+
21
+ ### ts
22
+
23
+ • `Optional` **ts**: `number`
24
+
25
+ #### Inherited from
26
+
27
+ ProtocolMessage.ts
28
+
29
+ ___
30
+
31
+ ### uuid
32
+
33
+ • `Optional` **uuid**: `string`
34
+
35
+ #### Inherited from
36
+
37
+ ProtocolMessage.uuid
38
+
39
+ ___
40
+
41
+ ### raffle\_id
42
+
43
+ • **raffle\_id**: `number`
44
+
45
+ ___
46
+
47
+ ### draw\_id
48
+
49
+ • **draw\_id**: `number`
50
+
51
+ ___
52
+
53
+ ### raffle\_run\_id
54
+
55
+ • **raffle\_run\_id**: `number`
@@ -0,0 +1,57 @@
1
+ # Interface: RaffleOptinResponse
2
+
3
+ ## Hierarchy
4
+
5
+ - `ProtocolResponse`
6
+
7
+ ↳ **`RaffleOptinResponse`**
8
+
9
+ ## Properties
10
+
11
+ ### cid
12
+
13
+ • **cid**: `number`
14
+
15
+ #### Inherited from
16
+
17
+ ProtocolResponse.cid
18
+
19
+ ___
20
+
21
+ ### ts
22
+
23
+ • `Optional` **ts**: `number`
24
+
25
+ #### Inherited from
26
+
27
+ ProtocolResponse.ts
28
+
29
+ ___
30
+
31
+ ### uuid
32
+
33
+ • `Optional` **uuid**: `string`
34
+
35
+ #### Inherited from
36
+
37
+ ProtocolResponse.uuid
38
+
39
+ ___
40
+
41
+ ### errCode
42
+
43
+ • `Optional` **errCode**: `number`
44
+
45
+ #### Inherited from
46
+
47
+ ProtocolResponse.errCode
48
+
49
+ ___
50
+
51
+ ### errMsg
52
+
53
+ • `Optional` **errMsg**: `string`
54
+
55
+ #### Inherited from
56
+
57
+ ProtocolResponse.errMsg
@@ -0,0 +1,17 @@
1
+ # Interface: TRaffleOptinResponse
2
+
3
+ ## Properties
4
+
5
+ ### err\_code
6
+
7
+ • **err\_code**: `number`
8
+
9
+ Error code that represents outcome of the opt-in attempt. Opt-in succeed in case err_code is 0
10
+
11
+ ___
12
+
13
+ ### err\_message
14
+
15
+ • `Optional` **err\_message**: `string`
16
+
17
+ Optional error message
@@ -65,8 +65,8 @@ ___
65
65
  • **limit\_message**: `string`
66
66
 
67
67
  The message that should be shown to the user if he is not eligible to buy it. this message can be used to explain the reason why user cannot buy the item, e.g. 'You should be VIP to buy this item' and can be used in case can_buy property is false.
68
- The message is translated to the user language.
69
- **Note**: when user is trying to buy the item, the response from server can return custom error messages that can be shown to the user as well
68
+ The message is translated to the user language.
69
+ *Note**: when user is trying to buy the item, the response from server can return custom error messages that can be shown to the user as well
70
70
 
71
71
  ___
72
72
 
@@ -119,3 +119,11 @@ ___
119
119
  • `Optional` **liquid\_template**: `number`
120
120
 
121
121
  Liquid template id to be used for Liquid templates
122
+
123
+ ___
124
+
125
+ ### ach\_category\_ids
126
+
127
+ • `Optional` **ach\_category\_ids**: `number`[]
128
+
129
+ List of IDs of the categories where the badge item is assigned, information about categories can be retrieved with getAchCategories method
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.326",
3
+ "version": "0.0.328",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -164,6 +164,8 @@ export enum ClassId {
164
164
  RAF_GET_DRAW_HISTORY_RESPONSE = 907,
165
165
  RAF_CLAIM_PRIZE_REQUEST = 908,
166
166
  RAF_CLAIM_PRIZE_RESPONSE = 909,
167
+ RAF_OPTIN_REQUEST = 910,
168
+ RAF_OPTIN_RESPONSE = 911,
167
169
  /*
168
170
  RAF_GET_TICKETS_REQUEST = 902,
169
171
  RAF_GET_TICKETS_RESPONSE = 903,
@@ -11,6 +11,7 @@ export enum AchCustomSectionType {
11
11
  LOOTBOX_CALENDAR_DAYS = 11,
12
12
  TREASURE_HUNT = 12,
13
13
  RAFFLE = 13,
14
+ BADGES = 14,
14
15
  }
15
16
 
16
17
  export enum AchCustomLayoutTheme {
@@ -23,6 +23,7 @@ export interface UICustomSection {
23
23
  ach_tournament_id?: number;
24
24
  show_raw_data?: boolean;
25
25
  liquid_template?: number;
26
+ ach_category_ids?: number[];
26
27
  }
27
28
 
28
29
  export const UICustomSectionTransform = (response: GetCustomSectionsResponse): TUICustomSection[] => {
@@ -54,6 +55,12 @@ export const UICustomSectionTransform = (response: GetCustomSectionsResponse): T
54
55
  }
55
56
  : {}
56
57
  ),
58
+ ...(r.section_type_id === AchCustomSectionType.BADGES
59
+ ? {
60
+ ach_category_ids: r.ach_category_ids,
61
+ }
62
+ : {}
63
+ ),
57
64
  };
58
65
 
59
66
  items.push(x);
@@ -0,0 +1,7 @@
1
+ import { ProtocolMessage } from "../Base/ProtocolMessage";
2
+
3
+ export interface RaffleOptinRequest extends ProtocolMessage {
4
+ raffle_id: number;
5
+ draw_id: number;
6
+ raffle_run_id: number;
7
+ }
@@ -0,0 +1,5 @@
1
+ import { ProtocolResponse } from "../Base/ProtocolResponse";
2
+
3
+ export interface RaffleOptinResponse extends ProtocolResponse {
4
+
5
+ }
@@ -13,3 +13,5 @@ export * from './GetRaffleDrawRunsHistoryResponse';
13
13
  export * from './RaffleClaimPrizeRequest';
14
14
  export * from './RaffleClaimPrizeResponse';
15
15
  export * from './RaffleDrawPublicMeta';
16
+ export * from './RaffleOptinRequest';
17
+ export * from './RaffleOptinResponse';
@@ -127,7 +127,7 @@ import { GetRafflesResponse, raffleTransform } from './Raffle/GetRafflesResponse
127
127
  import { GetRafflesRequest } from './Raffle/GetRafflesRequest';
128
128
  import { GetPointsHistoryRequest, GetPointsHistoryResponse, PointsHistoryTransform } from './PointsHistory';
129
129
  import { InboxCategories } from './Inbox/InboxCategories';
130
- import { GetDrawRunRequest, GetDrawRunResponse, GetRaffleDrawRunsHistoryRequest, GetRaffleDrawRunsHistoryResponse, RaffleClaimPrizeRequest, RaffleClaimPrizeResponse } from './Raffle';
130
+ import { GetDrawRunRequest, GetDrawRunResponse, GetRaffleDrawRunsHistoryRequest, GetRaffleDrawRunsHistoryResponse, RaffleClaimPrizeRequest, RaffleClaimPrizeResponse, RaffleOptinRequest, RaffleOptinResponse } from './Raffle';
131
131
  import { GetJackpotWinnersResponse, GetJackpotWinnersResponseTransform, JackpotWinnerHistory } from './Jackpots/GetJackpotWinnersResponse';
132
132
  import { GetJackpotWinnersRequest } from './Jackpots/GetJackpotWinnersRequest';
133
133
  import { GetJackpotEligibleGamesRequest } from './Jackpots/GetJackpotEligibleGamesRequest';
@@ -1326,6 +1326,17 @@ class SmarticoAPI {
1326
1326
 
1327
1327
  }
1328
1328
 
1329
+ public async raffleOptin(user_ext_id: string, props: { raffle_id: number; draw_id: number; raffle_run_id: number }): Promise<RaffleOptinResponse> {
1330
+ const message = this.buildMessage<RaffleOptinRequest, RaffleOptinResponse>(
1331
+ user_ext_id,
1332
+ ClassId.RAF_OPTIN_REQUEST,
1333
+ props,
1334
+ );
1335
+
1336
+ return await this.send<RaffleOptinResponse>(message, ClassId.RAF_OPTIN_RESPONSE);
1337
+
1338
+ }
1339
+
1329
1340
  public async getPointsHistory(
1330
1341
  user_ext_id: string,
1331
1342
  startTimeSeconds: number,
@@ -38,6 +38,7 @@ import {
38
38
  TransformedRaffleClaimPrizeResponse,
39
39
  TLevelCurrent,
40
40
  TPointsHistoryLog,
41
+ TRaffleOptinResponse,
41
42
  } from './WSAPITypes';
42
43
  import { LeaderBoardPeriodType } from '../Leaderboard';
43
44
  import {
@@ -55,6 +56,8 @@ import {
55
56
  drawRunHistoryTransform,
56
57
  drawRunTransform,
57
58
  raffleClaimPrizeResponseTransform,
59
+ RaffleOptinRequest,
60
+ RaffleOptinResponse,
58
61
  } from '../Raffle';
59
62
  import { IntUtils } from '../IntUtils';
60
63
  import { TGetJackpotEligibleGamesResponse } from '../Jackpots/GetJackpotEligibleGamesResponse';
@@ -136,10 +139,7 @@ export class WSAPI {
136
139
  this.reloadMiniGameTemplate();
137
140
  OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.SAWHistory);
138
141
  });
139
- on(ClassId.RAF_CLAIM_PRIZE_RESPONSE, () => {
140
- this.updateRaffles();
141
- OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Raffles);
142
- });
142
+ on(ClassId.RAF_CLAIM_PRIZE_RESPONSE, () => this.updateRaffles());
143
143
  on(ClassId.GET_INBOX_MESSAGES_RESPONSE, (res) => {
144
144
  if (res.unread_count !== undefined && res.unread_count !== null) {
145
145
  this.updateInboxUnreadCount(res.unread_count);
@@ -153,6 +153,7 @@ export class WSAPI {
153
153
  this.notifyPointsHistoryUpdate();
154
154
  }
155
155
  });
156
+ on(ClassId.RAF_OPTIN_RESPONSE, () => this.updateRaffles());
156
157
  }
157
158
  }
158
159
 
@@ -1463,4 +1464,28 @@ export class WSAPI {
1463
1464
  const res = await this.api.claimRafflePrize(null, { won_id: props.won_id });
1464
1465
  return raffleClaimPrizeResponseTransform(res);
1465
1466
  }
1467
+
1468
+ /**
1469
+ * Requests an opt-in for the specified raffle. Returns the err_code.
1470
+ *
1471
+ * **Visitor mode: not supported**
1472
+ */
1473
+ public async requestRaffleOptin(props: { raffle_id: number; draw_id: number; raffle_run_id: number }): Promise<TRaffleOptinResponse> {
1474
+ if (!props.raffle_id) {
1475
+ throw new Error('raffle_id is required');
1476
+ }
1477
+ if (!props.draw_id) {
1478
+ throw new Error('draw_id is required');
1479
+ }
1480
+ if (!props.raffle_run_id) {
1481
+ throw new Error('raffle_run_id is required');
1482
+ }
1483
+
1484
+ const r = await this.api.raffleOptin(null, props);
1485
+
1486
+ return {
1487
+ err_code: r.errCode,
1488
+ err_message: r.errMsg,
1489
+ };;
1490
+ }
1466
1491
  }
@@ -171,7 +171,7 @@ export interface TMiniGameTemplate {
171
171
 
172
172
  /** When enabled, the number of items in the pool and number of won items will be exposed in the Retention API and in the UI Widgets */
173
173
  expose_game_stat_on_api?: boolean;
174
-
174
+
175
175
  /** Time zone to ensure each day aligns with your local midnight. */
176
176
  relative_period_timezone?: number;
177
177
  /** Holds time from which template will become available, for the template that are targeted to be available from specific time (UNIX timestamp) */
@@ -186,7 +186,7 @@ export interface TMiniGameTemplate {
186
186
  /** The UI definition of the mini-game */
187
187
  saw_template_ui_definition: SAWTemplateUI;
188
188
  /** When enabled the prize history icon is visible on a certain template */
189
- show_prize_history?:boolean;
189
+ show_prize_history?: boolean;
190
190
  /** The maximum number of attempts that user can do during period of time */
191
191
  max_number_of_attempts?: number;
192
192
  /** The period of time in milliseconds during which the user can do the maximum number of attempts */
@@ -495,10 +495,10 @@ export interface TStoreItem {
495
495
  /** The ribbon of the store item. Can be 'sale', 'hot', 'new', 'vip' or URL to the image in case of custom ribbon */
496
496
  ribbon: TRibbon;
497
497
  /**
498
- * The message that should be shown to the user if he is not eligible to buy it. this message can be used to explain the reason why user cannot buy the item, e.g. 'You should be VIP to buy this item' and can be used in case can_buy property is false.
499
- The message is translated to the user language.
500
- **Note**: when user is trying to buy the item, the response from server can return custom error messages that can be shown to the user as well
501
- */
498
+ * The message that should be shown to the user if he is not eligible to buy it. this message can be used to explain the reason why user cannot buy the item, e.g. 'You should be VIP to buy this item' and can be used in case can_buy property is false.
499
+ The message is translated to the user language.
500
+ **Note**: when user is trying to buy the item, the response from server can return custom error messages that can be shown to the user as well
501
+ */
502
502
  limit_message: string;
503
503
  /** The message that should be shown to the user if they are not eligible to buy it because of purchase limitation. This message can be used to explain the reason why user cannot buy the item, e.g. 'Item is no more available today. Come back Friday'.
504
504
  The message is translated to the user language.
@@ -590,7 +590,7 @@ export interface TMissionOrBadge {
590
590
 
591
591
  /** Holds time from which mission will become available, for the missions that are targeted to be available from specific date/time */
592
592
  active_from_ts: number;
593
-
593
+
594
594
  /** Holds time till mission will become unavailable, for the missions that are targeted to be available from specific date/time */
595
595
  active_till_ts: number;
596
596
 
@@ -907,6 +907,8 @@ export interface TUICustomSection {
907
907
  show_raw_data?: boolean;
908
908
  /** Liquid template id to be used for Liquid templates */
909
909
  liquid_template?: number;
910
+ /** List of IDs of the categories where the badge item is assigned, information about categories can be retrieved with getAchCategories method */
911
+ ach_category_ids?: number[];
910
912
  }
911
913
 
912
914
  export interface TBonus {
@@ -929,18 +931,18 @@ export interface TBonus {
929
931
  }
930
932
 
931
933
  export enum BonusStatus {
932
- /** The bonus is newly created (shouldn't be shown to the client) */
933
- New = 1,
934
- /** The bonus is issued and available for redemption but has not been redeemed yet */
935
- COUPON_ISSUED = 2,
936
- /** The bonus has been successfully redeemed */
937
- REDEEMED = 3,
938
- /** The bonus is still valid, but a previous redemption attempt failed */
939
- REDEEM_FAILED = 4,
940
- /** Failed to issue the bonus (shouldn't be shown to the client) */
941
- COUPON_ISSUE_FAILED = 5,
942
- /** The bonus was issued but has expired and can no longer be redeemed (shouldn't be shown to the client) */
943
- EXPIRED = 6,
934
+ /** The bonus is newly created (shouldn't be shown to the client) */
935
+ New = 1,
936
+ /** The bonus is issued and available for redemption but has not been redeemed yet */
937
+ COUPON_ISSUED = 2,
938
+ /** The bonus has been successfully redeemed */
939
+ REDEEMED = 3,
940
+ /** The bonus is still valid, but a previous redemption attempt failed */
941
+ REDEEM_FAILED = 4,
942
+ /** Failed to issue the bonus (shouldn't be shown to the client) */
943
+ COUPON_ISSUE_FAILED = 5,
944
+ /** The bonus was issued but has expired and can no longer be redeemed (shouldn't be shown to the client) */
945
+ EXPIRED = 6,
944
946
  }
945
947
  export interface BonusTemplateMetaMap {
946
948
  /** Description of the bonus template*/
@@ -1243,14 +1245,14 @@ export interface TRaffleDraw {
1243
1245
 
1244
1246
  export interface TRaffleDrawRun {
1245
1247
  /**
1246
- * Id of the Draw definition, for the repetative draws (e.g. daily), this number will be the same for all draws that are repeating daily
1247
- * (internal name: schedule_id)
1248
- */
1248
+ * Id of the Draw definition, for the repetative draws (e.g. daily), this number will be the same for all draws that are repeating daily
1249
+ * (internal name: schedule_id)
1250
+ */
1249
1251
  id: number;
1250
- /**
1251
- * Field indicates the ID of the latest instance/run of draw
1252
- */
1253
- run_id:number;
1252
+ /**
1253
+ * Field indicates the ID of the latest instance/run of draw
1254
+ */
1255
+ run_id: number;
1254
1256
  /** Name of the draw, e.g. 'Daily draw' */
1255
1257
  name: string;
1256
1258
  /** Description of the draw */
@@ -1270,32 +1272,31 @@ export interface TRaffleDrawRun {
1270
1272
  /** Date/time of the draw execution */
1271
1273
  execution_ts: number;
1272
1274
  /** Actual Date/time of the draw execution */
1273
- actual_execution_ts: number;
1274
- /**
1275
- * Date/time starting from which the tickets will participate in the upcoming draw
1276
- * This value need to be taken into account with next_execute_ts field value, for example
1277
- * Next draw is at 10:00, ticket_start_date is 9:00, so all tickets that are collected after 9:00 will participate in the draw at 10:00
1278
- * (internally this value is calculated as next_execute_ts - ticket_start_date)
1279
- */
1275
+ actual_execution_ts: number;
1276
+ /**
1277
+ * Date/time starting from which the tickets will participate in the upcoming draw
1278
+ * This value need to be taken into account with next_execute_ts field value, for example
1279
+ * Next draw is at 10:00, ticket_start_date is 9:00, so all tickets that are collected after 9:00 will participate in the draw at 10:00
1280
+ * (internally this value is calculated as next_execute_ts - ticket_start_date)
1281
+ */
1280
1282
  ticket_start_ts: number;
1281
- /**
1282
- * Shows if user has won a prize in a current run
1283
- */
1284
- is_winner: boolean;
1285
1283
  /**
1286
- * Shows if user has unclaimed prize
1287
- */
1288
- has_unclaimed_prize: boolean;
1284
+ * Shows if user has won a prize in a current run
1285
+ */
1286
+ is_winner: boolean;
1287
+ /**
1288
+ * Shows if user has unclaimed prize
1289
+ */
1290
+ has_unclaimed_prize: boolean;
1289
1291
 
1290
1292
  }
1291
1293
 
1292
1294
  export interface TransformedRaffleClaimPrizeResponse {
1293
1295
  /** Error code, 0 means no error */
1294
- errorCode: number
1296
+ errorCode: number
1295
1297
  /** Error message, will be exposed only if ErrorCode is not 0 */
1296
- errorMessage?: string
1298
+ errorMessage?: string
1297
1299
  }
1298
-
1299
1300
  /**
1300
1301
  * TPointsHistoryLog describes a unified history log entry for points, gems, or diamonds changes.
1301
1302
  * The structure is the same regardless of balance type, making it easy to iterate and display.
@@ -1319,4 +1320,11 @@ export interface TPointsHistoryLog {
1319
1320
  source_type_id: PointChangeSourceType;
1320
1321
  }
1321
1322
 
1323
+ export interface TRaffleOptinResponse {
1324
+ /** Error code that represents outcome of the opt-in attempt. Opt-in succeed in case err_code is 0 */
1325
+ err_code: number;
1326
+ /** Optional error message */
1327
+ err_message?: string;
1328
+ }
1329
+
1322
1330
  export { SAWAcknowledgeTypeName, PrizeModifiers, SAWTemplateUI, InboxCategories, AchCustomSectionType, SAWAskForUsername, SAWGameLayout, PointChangeSourceType, UserBalanceType }