@smartico/public-api 0.0.167 → 0.0.169

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
@@ -32,6 +32,7 @@
32
32
  - [JackpotsOptoutResponse](interfaces/JackpotsOptoutResponse.md)
33
33
  - [TMiniGamePrize](interfaces/TMiniGamePrize.md)
34
34
  - [TMiniGamePlayResult](interfaces/TMiniGamePlayResult.md)
35
+ - [TMiniGamePlayBatchResult](interfaces/TMiniGamePlayBatchResult.md)
35
36
  - [TMiniGameTemplate](interfaces/TMiniGameTemplate.md)
36
37
  - [TUserProfile](interfaces/TUserProfile.md)
37
38
  - [TLevel](interfaces/TLevel.md)
@@ -421,6 +421,13 @@ ___
421
421
 
422
422
  Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
423
423
 
424
+ **Example**:
425
+ ```
426
+ _smartico.api.playMiniGame(55).then((result) => {
427
+ console.log(result);
428
+ });
429
+ ```
430
+
424
431
  **Visitor mode: not supported**
425
432
 
426
433
  #### Parameters
@@ -435,6 +442,33 @@ Plays the specified by template_id mini-game on behalf of user and returns prize
435
442
 
436
443
  ___
437
444
 
445
+ ### playMiniGameBatch
446
+
447
+ ▸ **playMiniGameBatch**(`template_id`, `spin_count`): `Promise`\<[`TMiniGamePlayBatchResult`](../interfaces/TMiniGamePlayBatchResult.md)[]\>
448
+
449
+ Plays the specified by template_id mini-game on behalf of user spin_count times and returns array of the prizes
450
+
451
+ **Example**:
452
+ ```
453
+ _smartico.api.playMiniGameBatch(55, 10).then((result) => {
454
+ console.log(result);
455
+ });
456
+ ```
457
+ **Visitor mode: not supported**
458
+
459
+ #### Parameters
460
+
461
+ | Name | Type |
462
+ | :------ | :------ |
463
+ | `template_id` | `number` |
464
+ | `spin_count` | `number` |
465
+
466
+ #### Returns
467
+
468
+ `Promise`\<[`TMiniGamePlayBatchResult`](../interfaces/TMiniGamePlayBatchResult.md)[]\>
469
+
470
+ ___
471
+
438
472
  ### requestMissionOptIn
439
473
 
440
474
  ▸ **requestMissionOptIn**(`mission_id`): `Promise`\<[`TMissionOptInResult`](../interfaces/TMissionOptInResult.md)\>
@@ -0,0 +1,43 @@
1
+ # Interface: TMiniGamePlayBatchResult
2
+
3
+ TMiniGamePlayBatchResult describes the response of call to _smartico.api.playMiniGameBatch(template_id, spin_count) method
4
+
5
+ ## Properties
6
+
7
+ ### saw\_prize\_id
8
+
9
+ • **saw\_prize\_id**: `number`
10
+
11
+ The saw_prize_id that user won, details of the prize can be found in the mini-game definition
12
+
13
+ ___
14
+
15
+ ### errCode
16
+
17
+ • **errCode**: [`SAWSpinErrorCode`](../enums/SAWSpinErrorCode.md)
18
+
19
+ Error code that represents outcome of the game play attempt. Game succeed to be played in case err_code is 0
20
+
21
+ ___
22
+
23
+ ### errMessage
24
+
25
+ • `Optional` **errMessage**: `string`
26
+
27
+ Optional error message
28
+
29
+ ___
30
+
31
+ ### jackpot\_amount
32
+
33
+ • `Optional` **jackpot\_amount**: `number`
34
+
35
+ Jackpot amount what user won
36
+
37
+ ___
38
+
39
+ ### first\_spin\_in\_period
40
+
41
+ • `Optional` **first\_spin\_in\_period**: `number`
42
+
43
+ Period in miliseconds from last spin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.167",
3
+ "version": "0.0.169",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -121,6 +121,10 @@ export enum ClassId {
121
121
  SAW_PRIZE_DROP_WIN_AKNOWLEDGE_REQUEST = 709,
122
122
  SAW_PRIZE_DROP_WIN_AKNOWLEDGE_RESPONSE = 710,
123
123
  SAW_AKNOWLEDGE_SPIN_PUSH = 711,
124
+ SAW_DO_SPIN_BATCH_REQUEST = 712,
125
+ SAW_DO_SPIN_BATCH_RESPONSE = 713,
126
+ SAW_AKNOWLEDGE_BATCH_REQUEST = 714,
127
+ SAW_AKNOWLEDGE_BATCH_RESPONSE = 715,
124
128
 
125
129
  /*
126
130
  !Important, if adding new messages that are 'acting' on behalf of the client,
@@ -0,0 +1,5 @@
1
+ import { ProtocolRequest } from '../Base/ProtocolRequest';
2
+
3
+ export interface SAWDoAcknowledgeBatchRequest extends ProtocolRequest {
4
+ request_ids: string[];
5
+ }
@@ -0,0 +1,5 @@
1
+ import { ProtocolRequest } from '../Base/ProtocolRequest';
2
+
3
+ export interface SAWDoAcknowledgeBatchResponse extends ProtocolRequest {
4
+ results: Array<{ request_id: string, errCode: number, errMessage?: string }>;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { ProtocolMessage } from 'src/SmarticoLib';
2
+
3
+ export interface SAWDoSpinBatchRequest extends ProtocolMessage {
4
+ spins: Array<{ request_id: string, saw_template_id: number }>;
5
+ }
@@ -0,0 +1,8 @@
1
+ import { ProtocolResponse } from '../Base/ProtocolResponse';
2
+ import { SAWDoSpinResponse } from './SAWDoSpinResponse';
3
+ import { SAWSpinErrorCode } from './SAWSpinErrorCode';
4
+
5
+ export interface SAWDoSpinBatchResponse extends ProtocolResponse {
6
+ results: SAWDoSpinResponse[];
7
+ errCode: SAWSpinErrorCode,
8
+ }
@@ -109,6 +109,10 @@ import {
109
109
  import { GetCustomSectionsRequest, GetCustomSectionsResponse, UICustomSectionTransform } from './CustomSections';
110
110
  import { BonusItemsTransform, ClaimBonusRequest, ClaimBonusResponse, GetBonusesResponse } from './Bonuses';
111
111
  import { GetBonusesRequest } from './Bonuses/GetBonusesRequest';
112
+ import { SAWDoSpinBatchResponse } from './MiniGames/SAWDoSpinBatchResponse';
113
+ import { SAWDoSpinBatchRequest } from './MiniGames/SAWDoSpinBatchRequest';
114
+ import { SAWDoAcknowledgeBatchRequest } from './MiniGames/SAWDoAcknowledgeBatchRequest';
115
+ import { SAWDoAcknowledgeBatchResponse } from './MiniGames/SAWDoAcknowledgeBatchResponse';
112
116
  import { GetRelatedAchTourRequest } from './Missions/GetRelatedAchTourRequest';
113
117
  import { GetRelatedAchTourResponse } from './Missions/GetRelatedAchTourResponse';
114
118
 
@@ -539,6 +543,47 @@ class SmarticoAPI {
539
543
  return { ...spinAttemptResponse, request_id };
540
544
  }
541
545
 
546
+
547
+ public async doAcknowledgeBatchRequest(user_ext_id: string, request_ids: string[]): Promise<SAWDoAcknowledgeBatchResponse> {
548
+ const message = this.buildMessage<SAWDoAcknowledgeBatchRequest, SAWDoAcknowledgeBatchResponse>(
549
+ user_ext_id,
550
+ ClassId.SAW_AKNOWLEDGE_REQUEST,
551
+ {
552
+ request_ids,
553
+ },
554
+ );
555
+
556
+ return await this.send<SAWDoAcknowledgeBatchResponse>(message, ClassId.SAW_AKNOWLEDGE_BATCH_RESPONSE);
557
+ }
558
+
559
+ public async sawSpinBatchRequest(user_ext_id: string, saw_template_id: number, spins_count: number): Promise<SAWDoSpinBatchResponse> {
560
+
561
+ const spins = [];
562
+ for (let i = 0; i < spins_count; i++) {
563
+ const request_id = IntUtils.uuid();
564
+ spins.push({ request_id, saw_template_id })
565
+ }
566
+
567
+ const message = this.buildMessage<SAWDoSpinBatchRequest, SAWDoSpinBatchResponse>(user_ext_id, ClassId.SAW_DO_SPIN_BATCH_REQUEST, { spins });
568
+ const spinAttemptResponse = await this.send<SAWDoSpinBatchResponse>(message, ClassId.SAW_DO_SPIN_BATCH_RESPONSE);
569
+
570
+ // If one response is 'OK' we consider that whole result is 'OK'
571
+ const result = spinAttemptResponse.results.find((res) => res.errCode === 0);
572
+
573
+ let status = 'OK';
574
+ if (!result) {
575
+ status = 'BATCH FAIL';
576
+ }
577
+
578
+ await this.coreReportCustomEvent(user_ext_id, 'minigame_attempt', {
579
+ saw_template_id,
580
+ status,
581
+ spins_count,
582
+ });
583
+
584
+ return { ...spinAttemptResponse };
585
+ }
586
+
542
587
  public async missionOptIn(user_ext_id: string, mission_id: number) {
543
588
  if (!mission_id) {
544
589
  throw new Error('Missing mission id');
@@ -0,0 +1,5 @@
1
+ import { TUserProfile } from "src/WSAPI/WSAPITypes";
2
+
3
+ export interface UserProfile extends TUserProfile {
4
+
5
+ }
@@ -0,0 +1 @@
1
+ export * from './UserProfile';
@@ -26,7 +26,8 @@ import {
26
26
  TUICustomSection,
27
27
  TUserProfile,
28
28
  UserLevelExtraCountersT,TBonus,
29
- TClaimBonusResult
29
+ TClaimBonusResult,
30
+ TMiniGamePlayBatchResult
30
31
  } from './WSAPITypes';
31
32
  import { LeaderBoardPeriodType } from '../Leaderboard';
32
33
  import {
@@ -455,6 +456,13 @@ export class WSAPI {
455
456
 
456
457
  /**
457
458
  * Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
459
+ *
460
+ * **Example**:
461
+ * ```
462
+ * _smartico.api.playMiniGame(55).then((result) => {
463
+ * console.log(result);
464
+ * });
465
+ * ```
458
466
  *
459
467
  * **Visitor mode: not supported**
460
468
  */
@@ -471,6 +479,34 @@ export class WSAPI {
471
479
  return o;
472
480
  }
473
481
 
482
+ /**
483
+ * Plays the specified by template_id mini-game on behalf of user spin_count times and returns array of the prizes
484
+ *
485
+ * **Example**:
486
+ * ```
487
+ * _smartico.api.playMiniGameBatch(55, 10).then((result) => {
488
+ * console.log(result);
489
+ * });
490
+ * ```
491
+ * **Visitor mode: not supported**
492
+ */
493
+ public async playMiniGameBatch(template_id: number, spin_count: number): Promise<TMiniGamePlayBatchResult[]> {
494
+ const response = await this.api.sawSpinBatchRequest(null, template_id, spin_count);
495
+
496
+ const request_ids = response.results.map((result) => result.request_id);
497
+ this.api.doAcknowledgeBatchRequest(null, request_ids);
498
+
499
+ const o: TMiniGamePlayBatchResult[] = response.results.map((result) => ({
500
+ errCode: result.errCode,
501
+ errMessage: result.errMsg,
502
+ saw_prize_id: result.saw_prize_id,
503
+ jackpot_amount: result.jackpot_amount,
504
+ first_spin_in_period: result.first_spin_in_period,
505
+ }));
506
+
507
+ return o;
508
+ }
509
+
474
510
  /**
475
511
  * Requests an opt-in for the specified mission_id. Returns the err_code.
476
512
  *
@@ -55,6 +55,22 @@ export interface TMiniGamePlayResult {
55
55
  prize_id: number;
56
56
  }
57
57
 
58
+ /**
59
+ * TMiniGamePlayBatchResult describes the response of call to _smartico.api.playMiniGameBatch(template_id, spin_count) method
60
+ */
61
+ export interface TMiniGamePlayBatchResult {
62
+ /** The saw_prize_id that user won, details of the prize can be found in the mini-game definition */
63
+ saw_prize_id: number;
64
+ /** Error code that represents outcome of the game play attempt. Game succeed to be played in case err_code is 0 */
65
+ errCode: SAWSpinErrorCode;
66
+ /** Optional error message */
67
+ errMessage?: string;
68
+ /** Jackpot amount what user won */
69
+ jackpot_amount?: number;
70
+ /** Period in miliseconds from last spin */
71
+ first_spin_in_period?: number,
72
+ }
73
+
58
74
  /**
59
75
  * TMiniGameTemplate describes the information of mini-games available for the user
60
76
  */
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ export * from './SmarticoAPI';
4
4
  export * from './CookieStore';
5
5
 
6
6
  export * from './Core';
7
+ export * from './UserProfile';
7
8
  export * from './Inbox';
8
9
  export * from './Leaderboard';
9
10
  export * from './MiniGames';