@smartico/public-api 0.0.325 → 0.0.326

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.
Files changed (42) hide show
  1. package/dist/Base/ClassId.d.ts +2 -0
  2. package/dist/MiniGames/AttemptPeriodType.d.ts +6 -0
  3. package/dist/MiniGames/SAWPrize.d.ts +2 -0
  4. package/dist/MiniGames/index.d.ts +1 -0
  5. package/dist/PointsHistory/GetPointsHistoryRequest.d.ts +6 -0
  6. package/dist/PointsHistory/GetPointsHistoryResponse.d.ts +7 -0
  7. package/dist/PointsHistory/PointChangeSourceType.d.ts +19 -0
  8. package/dist/PointsHistory/PointsHistoryLog.d.ts +21 -0
  9. package/dist/PointsHistory/UserBalanceType.d.ts +5 -0
  10. package/dist/PointsHistory/index.d.ts +5 -0
  11. package/dist/SmarticoAPI.d.ts +4 -1
  12. package/dist/WSAPI/WSAPI.d.ts +34 -1
  13. package/dist/WSAPI/WSAPITypes.d.ts +28 -2
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +221 -74
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.modern.mjs +125 -3
  18. package/dist/index.modern.mjs.map +1 -1
  19. package/docs/README.md +4 -0
  20. package/docs/classes/WSAPI.md +41 -0
  21. package/docs/enums/AttemptPeriodType.md +25 -0
  22. package/docs/enums/PointChangeSourceType.md +103 -0
  23. package/docs/enums/UserBalanceType.md +19 -0
  24. package/docs/interfaces/SAWPrize.md +6 -0
  25. package/docs/interfaces/TMiniGamePrize.md +8 -0
  26. package/docs/interfaces/TPointsHistoryLog.md +68 -0
  27. package/package.json +1 -1
  28. package/src/Base/ClassId.ts +3 -0
  29. package/src/MiniGames/AttemptPeriodType.ts +6 -0
  30. package/src/MiniGames/SAWGetTemplatesResponse.ts +1 -0
  31. package/src/MiniGames/SAWPrize.ts +2 -0
  32. package/src/MiniGames/index.ts +2 -1
  33. package/src/PointsHistory/GetPointsHistoryRequest.ts +8 -0
  34. package/src/PointsHistory/GetPointsHistoryResponse.ts +39 -0
  35. package/src/PointsHistory/PointChangeSourceType.ts +20 -0
  36. package/src/PointsHistory/PointsHistoryLog.ts +24 -0
  37. package/src/PointsHistory/UserBalanceType.ts +6 -0
  38. package/src/PointsHistory/index.ts +6 -0
  39. package/src/SmarticoAPI.ts +29 -0
  40. package/src/WSAPI/WSAPI.ts +64 -2
  41. package/src/WSAPI/WSAPITypes.ts +28 -2
  42. package/src/index.ts +2 -1
@@ -68,6 +68,8 @@ export declare enum ClassId {
68
68
  ACH_SHOP_ITEM_HISTORY_RESPONSE = 542,
69
69
  GET_RELATED_ACH_N_TOURNAMENTS_REQUEST = 543,
70
70
  GET_RELATED_ACH_N_TOURNAMENTS_RESPONSE = 544,
71
+ GET_POINT_HISTORY_REQUEST = 545,
72
+ GET_POINT_HISTORY_RESPONSE = 546,
71
73
  GET_BONUSES_REQUEST = 600,
72
74
  GET_BONUSES_RESPONSE = 601,
73
75
  CLAIM_BONUS_REQUEST = 602,
@@ -0,0 +1,6 @@
1
+ export declare enum AttemptPeriodType {
2
+ FromLastAttempt = 1,
3
+ CalendarDaysUTC = 2,
4
+ CalendarDaysUserTimeZone = 3,
5
+ Lifetime = 4
6
+ }
@@ -1,3 +1,4 @@
1
+ import { AttemptPeriodType } from './AttemptPeriodType';
1
2
  import { SAWPrizeType } from './SAWPrizeType';
2
3
  import { SAWPrizeUI } from './SAWPrizeUI';
3
4
  export interface SAWPrize {
@@ -20,4 +21,5 @@ export interface SAWPrize {
20
21
  prize_details_json?: {
21
22
  [key: string]: any;
22
23
  };
24
+ max_give_period_type_id?: AttemptPeriodType;
23
25
  }
@@ -29,3 +29,4 @@ export * from './PrizeModifiers';
29
29
  export * from './SAWWheelLayout';
30
30
  export * from './SAWGameDifficulty';
31
31
  export * from './SAWExposeUserSpinId';
32
+ export * from './AttemptPeriodType';
@@ -0,0 +1,6 @@
1
+ import { ProtocolMessage } from '../Base/ProtocolMessage';
2
+ export interface GetPointsHistoryRequest extends ProtocolMessage {
3
+ userId: number;
4
+ startTimeSeconds: number;
5
+ endTimeSeconds: number;
6
+ }
@@ -0,0 +1,7 @@
1
+ import { ProtocolResponse } from '../Base/ProtocolResponse';
2
+ import { PointsHistoryLog } from './PointsHistoryLog';
3
+ import { TPointsHistoryLog } from '../WSAPI/WSAPITypes';
4
+ export interface GetPointsHistoryResponse extends ProtocolResponse {
5
+ logHistory: PointsHistoryLog[];
6
+ }
7
+ export declare const PointsHistoryTransform: (items: PointsHistoryLog[]) => TPointsHistoryLog[];
@@ -0,0 +1,19 @@
1
+ export declare enum PointChangeSourceType {
2
+ Journey = 1,
3
+ AchievementTaskCompletion = 2,
4
+ AchievementCompletion = 3,
5
+ LevelsStructureChange = 4,
6
+ StorePurchase = 5,
7
+ ManualAdjustment = 6,
8
+ Leaderboard = 7,
9
+ Tournament = 11,
10
+ AutomationRule = 12,
11
+ TournamentRegistration = 13,
12
+ TournamentRegistrationCancellation = 14,
13
+ RefundPoints = 15,
14
+ PlayMiniGame = 16,
15
+ WinMiniGame = 17,
16
+ API = 18,
17
+ DynamicFormula = 19,
18
+ Raffle = 21
19
+ }
@@ -0,0 +1,21 @@
1
+ import { PointChangeSourceType } from './PointChangeSourceType';
2
+ import { UserBalanceType } from './UserBalanceType';
3
+ export interface PointsLog {
4
+ create_date: number;
5
+ user_ext_id: string;
6
+ crm_brand_id: number;
7
+ points_collected: number;
8
+ user_points_ever: number;
9
+ user_points_balance: number;
10
+ source_type_id: PointChangeSourceType;
11
+ }
12
+ export interface GemsDiamondsLog {
13
+ create_date: number;
14
+ user_ext_id: string;
15
+ crm_brand_id: number;
16
+ type: UserBalanceType;
17
+ amount: number;
18
+ balance: number;
19
+ source_type_id: PointChangeSourceType;
20
+ }
21
+ export type PointsHistoryLog = PointsLog | GemsDiamondsLog;
@@ -0,0 +1,5 @@
1
+ export declare enum UserBalanceType {
2
+ Points = 0,
3
+ Gems = 1,
4
+ Diamonds = 2
5
+ }
@@ -0,0 +1,5 @@
1
+ export * from './GetPointsHistoryRequest';
2
+ export * from './GetPointsHistoryResponse';
3
+ export * from './PointsHistoryLog';
4
+ export * from './PointChangeSourceType';
5
+ export * from './UserBalanceType';
@@ -11,7 +11,7 @@ import { GetTournamentInfoResponse, GetTournamentsResponse, TournamentRegisterRe
11
11
  import { LeaderBoardDetails, LeaderBoardPeriodType } from './Leaderboard';
12
12
  import { GetLevelMapResponse } from './Level';
13
13
  import { WSAPI } from './WSAPI/WSAPI';
14
- import { TInboxMessage, TInboxMessageBody, TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreCategory, TAchCategory, TStoreItem, TTournament, TTournamentDetailed, LeaderBoardDetailsT, UserLevelExtraCountersT, TSegmentCheckResult, TUICustomSection, TBonus, TRaffle, TLevelCurrent } from './WSAPI/WSAPITypes';
14
+ import { TInboxMessage, TInboxMessageBody, TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreCategory, TAchCategory, TStoreItem, TTournament, TTournamentDetailed, LeaderBoardDetailsT, UserLevelExtraCountersT, TSegmentCheckResult, TUICustomSection, TBonus, TRaffle, TLevelCurrent, TPointsHistoryLog } from './WSAPI/WSAPITypes';
15
15
  import { GetAchievementsUserInfoResponse } from './Core/GetAchievementsUserInfoResponse';
16
16
  import { GetJackpotsPotsResponse, GetJackpotsResponse, JackpotsOptinResponse, JackpotsOptoutResponse } from './Jackpots';
17
17
  import { GetCustomSectionsResponse } from './CustomSections';
@@ -20,6 +20,7 @@ import { SAWDoSpinBatchResponse } from './MiniGames/SAWDoSpinBatchResponse';
20
20
  import { SAWDoAcknowledgeBatchResponse } from './MiniGames/SAWDoAcknowledgeBatchResponse';
21
21
  import { GetRelatedAchTourResponse } from './Missions/GetRelatedAchTourResponse';
22
22
  import { GetRafflesResponse } from './Raffle/GetRafflesResponse';
23
+ import { GetPointsHistoryResponse } from './PointsHistory';
23
24
  import { InboxCategories } from './Inbox/InboxCategories';
24
25
  import { GetDrawRunResponse, GetRaffleDrawRunsHistoryResponse, RaffleClaimPrizeResponse } from './Raffle';
25
26
  import { GetJackpotWinnersResponse, JackpotWinnerHistory } from './Jackpots/GetJackpotWinnersResponse';
@@ -167,5 +168,7 @@ declare class SmarticoAPI {
167
168
  claimRafflePrize(user_ext_id: string, props: {
168
169
  won_id: number;
169
170
  }): Promise<RaffleClaimPrizeResponse>;
171
+ getPointsHistory(user_ext_id: string, startTimeSeconds: number, endTimeSeconds: number): Promise<GetPointsHistoryResponse>;
172
+ getPointsHistoryT(user_ext_id: string, startTimeSeconds: number, endTimeSeconds: number): Promise<TPointsHistoryLog[]>;
170
173
  }
171
174
  export { SmarticoAPI, MessageSender };
@@ -1,6 +1,6 @@
1
1
  import { ActivityTypeLimited } from '../Core';
2
2
  import { SmarticoAPI } from '../SmarticoAPI';
3
- import { InboxMarkMessageAction, LeaderBoardDetailsT, TAchCategory, TBuyStoreItemResult, TGetTranslations, TInboxMessage, TInboxMessageBody, TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionClaimRewardResult, TMissionOptInResult, TMissionOrBadge, TSegmentCheckResult, TStoreCategory, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUICustomSection, TUserProfile, UserLevelExtraCountersT, TBonus, TClaimBonusResult, TMiniGamePlayBatchResult, TSawHistory, TRaffle, TRaffleDraw, TRaffleDrawRun, TransformedRaffleClaimPrizeResponse, TLevelCurrent } from './WSAPITypes';
3
+ import { InboxMarkMessageAction, LeaderBoardDetailsT, TAchCategory, TBuyStoreItemResult, TGetTranslations, TInboxMessage, TInboxMessageBody, TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionClaimRewardResult, TMissionOptInResult, TMissionOrBadge, TSegmentCheckResult, TStoreCategory, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUICustomSection, TUserProfile, UserLevelExtraCountersT, TBonus, TClaimBonusResult, TMiniGamePlayBatchResult, TSawHistory, TRaffle, TRaffleDraw, TRaffleDrawRun, TransformedRaffleClaimPrizeResponse, TLevelCurrent, TPointsHistoryLog } from './WSAPITypes';
4
4
  import { LeaderBoardPeriodType } from '../Leaderboard';
5
5
  import { JackpotDetails, JackpotWinnerHistory, JackpotsOptinResponse, JackpotsOptoutResponse } from '../Jackpots';
6
6
  import { GetRelatedAchTourResponse } from '../Missions/GetRelatedAchTourResponse';
@@ -545,6 +545,38 @@ export declare class WSAPI {
545
545
  activityType: ActivityTypeLimited | number;
546
546
  action?: string;
547
547
  }): void;
548
+ /**
549
+ * Returns the points history for a user within a specified time range.
550
+ * The response includes both points changes and gems/diamonds changes.
551
+ * Each log entry contains information about the change amount, balance, and source.
552
+ * The returned list is cached for 30 seconds.
553
+ * You can pass the onUpdate callback as a parameter, it will be called every time the points history is updated and will provide the updated list of points history logs for the last 10 minutes.
554
+ *
555
+ * **Example**:
556
+ * ```
557
+ * const startTime = Math.floor(Date.now() / 1000) - 86400 * 30; // 30 days ago
558
+ * const endTime = Math.floor(Date.now() / 1000); // now
559
+ *
560
+ * _smartico.api.getPointsHistory({
561
+ * startTimeSeconds: startTime,
562
+ * endTimeSeconds: endTime,
563
+ * onUpdate: (data) => console.log('Updated:', data)
564
+ * }).then((result) => {
565
+ * console.log(result);
566
+ * });
567
+ * ```
568
+ *
569
+ * **Visitor mode: not supported**
570
+ *
571
+ * @param params.startTimeSeconds - Start time in seconds (epoch timestamp)
572
+ * @param params.endTimeSeconds - End time in seconds (epoch timestamp)
573
+ * @param params.onUpdate - Optional callback function that will be called when the points history is updated
574
+ */
575
+ getPointsHistory({ startTimeSeconds, endTimeSeconds, onUpdate, }: {
576
+ startTimeSeconds: number;
577
+ endTimeSeconds: number;
578
+ onUpdate?: (data: TPointsHistoryLog[]) => void;
579
+ }): Promise<TPointsHistoryLog[]>;
548
580
  private updateOnSpin;
549
581
  private reloadMiniGameTemplate;
550
582
  private updateMissions;
@@ -555,6 +587,7 @@ export declare class WSAPI {
555
587
  private updateInboxUnreadCount;
556
588
  private updateInboxMessages;
557
589
  private updateRaffles;
590
+ private notifyPointsHistoryUpdate;
558
591
  private updateEntity;
559
592
  private jackpotClearCache;
560
593
  /** Returns list of Jackpots that are active in the systen and matching to the filter definition.
@@ -1,5 +1,5 @@
1
1
  import { BuyStoreItemErrorCode } from '../Store';
2
- import { MiniGamePrizeTypeName, SAWAcknowledgeTypeName, SAWAskForUsername, SAWBuyInTypeName, SAWGameLayout, SAWGameTypeName, SAWSpinErrorCode, SAWTemplate, SAWTemplateUI } from '../MiniGames';
2
+ import { AttemptPeriodType, MiniGamePrizeTypeName, SAWAcknowledgeTypeName, SAWAskForUsername, SAWBuyInTypeName, SAWGameLayout, SAWGameTypeName, SAWSpinErrorCode, SAWTemplate, SAWTemplateUI } from '../MiniGames';
3
3
  import { TournamentRegistrationError, TournamentRegistrationStatusName, TournamentRegistrationTypeName } from '../Tournaments';
4
4
  import { AchievementAvailabilityStatus, BadgesTimeLimitStates } from '../Missions';
5
5
  import { LeaderBoardPeriodType } from '../Leaderboard';
@@ -7,6 +7,8 @@ import { AchCustomLayoutTheme, AchCustomSectionType, AchMissionsTabsOptions, Ach
7
7
  import { PrizeModifiers } from '../MiniGames/PrizeModifiers';
8
8
  import { InboxCategories } from '../Inbox/InboxCategories';
9
9
  import { RaffleDrawInstanceState, RaffleDrawTypeExecution } from '../Raffle';
10
+ import { PointChangeSourceType } from '../PointsHistory/PointChangeSourceType';
11
+ import { UserBalanceType } from '../PointsHistory/UserBalanceType';
10
12
  type TRibbon = 'sale' | 'hot' | 'new' | 'vip' | string;
11
13
  /**
12
14
  * TMiniGamePrize describes the information of prize in the array of prizes in the TMiniGameTemplate
@@ -74,6 +76,8 @@ export interface TMiniGamePrize {
74
76
  hide_prize_from_history?: boolean;
75
77
  /** Requirements to claim the prize (lootbox specific)*/
76
78
  requirements_to_get_prize?: string;
79
+ /** The period type for the prize to be given: Time from last attempt, Calendar days UTC, Calendar days user time zone, Lifetime */
80
+ max_give_period_type_id?: AttemptPeriodType;
77
81
  }
78
82
  /**
79
83
  * TMiniGamePlayResult describes the response of call to _smartico.api.playMiniGame(template_id) method
@@ -1177,4 +1181,26 @@ export interface TransformedRaffleClaimPrizeResponse {
1177
1181
  /** Error message, will be exposed only if ErrorCode is not 0 */
1178
1182
  errorMessage?: string;
1179
1183
  }
1180
- export { SAWAcknowledgeTypeName, PrizeModifiers, SAWTemplateUI, InboxCategories, AchCustomSectionType, SAWAskForUsername, SAWGameLayout };
1184
+ /**
1185
+ * TPointsHistoryLog describes a unified history log entry for points, gems, or diamonds changes.
1186
+ * The structure is the same regardless of balance type, making it easy to iterate and display.
1187
+ */
1188
+ export interface TPointsHistoryLog {
1189
+ /** Date when the change was created (epoch timestamp in seconds) */
1190
+ create_date: number;
1191
+ /** External user ID */
1192
+ user_ext_id: string;
1193
+ /** CRM brand ID */
1194
+ crm_brand_id: number;
1195
+ /** Type of balance: Points = 0, Gems = 1, Diamonds = 2 */
1196
+ type: UserBalanceType;
1197
+ /** Amount changed (positive or negative) */
1198
+ amount: number;
1199
+ /** Current balance after this change */
1200
+ balance: number;
1201
+ /** Total ever collected (only relevant for type points) */
1202
+ total_ever?: number;
1203
+ /** Source type ID indicating what triggered this change */
1204
+ source_type_id: PointChangeSourceType;
1205
+ }
1206
+ export { SAWAcknowledgeTypeName, PrizeModifiers, SAWTemplateUI, InboxCategories, AchCustomSectionType, SAWAskForUsername, SAWGameLayout, PointChangeSourceType, UserBalanceType };
package/dist/index.d.ts CHANGED
@@ -17,3 +17,4 @@ export * from './Jackpots';
17
17
  export * from './OCache';
18
18
  export * from './Bonuses';
19
19
  export * from './CustomSections';
20
+ export * from './PointsHistory';