@smartico/public-api 0.0.154 → 0.0.155

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 (269) hide show
  1. package/.prettierrc +12 -0
  2. package/dist/Base/ProtocolRequest.d.ts +1 -1
  3. package/dist/Base/ProtocolResponse.d.ts +1 -1
  4. package/dist/Core/CheckSegmentMatchRequest.d.ts +1 -1
  5. package/dist/Core/CheckSegmentMatchResponse.d.ts +1 -1
  6. package/dist/Core/GetAchievementsUserInfoRequest.d.ts +1 -1
  7. package/dist/Core/GetAchievementsUserInfoResponse.d.ts +1 -1
  8. package/dist/Core/GetLabelInfoRequest.d.ts +1 -1
  9. package/dist/Core/GetLabelInfoResponse.d.ts +1 -1
  10. package/dist/Core/GetTranslationsRequest.d.ts +2 -2
  11. package/dist/Core/GetTranslationsResponse.d.ts +1 -1
  12. package/dist/Core/ResponseIdentify.d.ts +2 -2
  13. package/dist/CustomSections/GetCustomSectionsRequest.d.ts +1 -1
  14. package/dist/CustomSections/GetCustomSectionsResponse.d.ts +2 -2
  15. package/dist/CustomSections/UICustomSection.d.ts +2 -2
  16. package/dist/GResponse.d.ts +1 -1
  17. package/dist/Inbox/GetInboxMessagesRequest.d.ts +1 -1
  18. package/dist/Inbox/GetInboxMessagesResponse.d.ts +3 -3
  19. package/dist/Inbox/InboxMessage.d.ts +2 -2
  20. package/dist/Inbox/MarkInboxMessageDeletedRequest.d.ts +1 -1
  21. package/dist/Inbox/MarkInboxMessageDeletedResponse.d.ts +1 -1
  22. package/dist/Inbox/MarkInboxMessageReadRequest.d.ts +1 -1
  23. package/dist/Inbox/MarkInboxMessageReadResponse.d.ts +1 -1
  24. package/dist/Inbox/MarkInboxMessageStarredRequest.d.ts +1 -1
  25. package/dist/Inbox/MarkInboxMessageStarredResponse.d.ts +1 -1
  26. package/dist/Inbox/index.d.ts +8 -8
  27. package/dist/Jackpots/GetJackpotsPotsRequest.d.ts +1 -1
  28. package/dist/Jackpots/GetJackpotsPotsResponse.d.ts +2 -2
  29. package/dist/Jackpots/GetJackpotsRequest.d.ts +1 -1
  30. package/dist/Jackpots/GetJackpotsResponse.d.ts +2 -2
  31. package/dist/Jackpots/JackpotDetails.d.ts +6 -6
  32. package/dist/Jackpots/JackpotWinPush.d.ts +3 -3
  33. package/dist/Jackpots/JackpotsOptinRequest.d.ts +1 -1
  34. package/dist/Jackpots/JackpotsOptinResponse.d.ts +1 -1
  35. package/dist/Jackpots/JackpotsOptoutRequest.d.ts +1 -1
  36. package/dist/Jackpots/JackpotsOptoutResponse.d.ts +1 -1
  37. package/dist/Leaderboard/GetLeaderBoardsRequest.d.ts +2 -2
  38. package/dist/Leaderboard/GetLeaderBoardsResponse.d.ts +2 -2
  39. package/dist/Leaderboard/LeaderBoardDetails.d.ts +3 -3
  40. package/dist/Leaderboard/LeaderBoards.d.ts +2 -2
  41. package/dist/Leaderboard/index.d.ts +6 -6
  42. package/dist/Level/GetLevelMapResponse.d.ts +3 -3
  43. package/dist/Level/Level.d.ts +1 -1
  44. package/dist/MiniGames/SAWAcknowledgeSpinPushRequest.d.ts +1 -1
  45. package/dist/MiniGames/SAWDoAknowledgeRequest.d.ts +1 -1
  46. package/dist/MiniGames/SAWDoAknowledgeResponse.d.ts +1 -1
  47. package/dist/MiniGames/SAWDoSpinRequest.d.ts +1 -1
  48. package/dist/MiniGames/SAWDoSpinResponse.d.ts +2 -2
  49. package/dist/MiniGames/SAWEventSawPush.d.ts +1 -1
  50. package/dist/MiniGames/SAWGetTemplatesRequest.d.ts +1 -1
  51. package/dist/MiniGames/SAWGetTemplatesResponse.d.ts +3 -3
  52. package/dist/MiniGames/SAWPrize.d.ts +2 -2
  53. package/dist/MiniGames/SAWPrizeDropAknowledgeRequest.d.ts +3 -1
  54. package/dist/MiniGames/SAWPrizeDropAknowledgeResponse.d.ts +1 -1
  55. package/dist/MiniGames/SAWPrizeDropWinPush.d.ts +4 -3
  56. package/dist/MiniGames/SAWPrizeUI.d.ts +2 -2
  57. package/dist/MiniGames/SAWSpinsCountPush.d.ts +1 -1
  58. package/dist/MiniGames/SAWTemplate.d.ts +4 -4
  59. package/dist/MiniGames/SAWTemplateUI.d.ts +1 -1
  60. package/dist/MiniGames/SAWUtils.d.ts +1 -1
  61. package/dist/MiniGames/index.d.ts +24 -22
  62. package/dist/Missions/AchClaimPrizeRequest.d.ts +1 -1
  63. package/dist/Missions/AchClaimPrizeResponse.d.ts +1 -1
  64. package/dist/Missions/AchievementCategory.d.ts +2 -2
  65. package/dist/Missions/AchievementOptinRequest.d.ts +1 -1
  66. package/dist/Missions/AchievementOptinResponse.d.ts +1 -1
  67. package/dist/Missions/GetAchCategoriesRequest.d.ts +1 -1
  68. package/dist/Missions/GetAchCategoriesResponse.d.ts +2 -2
  69. package/dist/Missions/GetAchievementMapRequest.d.ts +1 -1
  70. package/dist/Missions/GetAchievementMapResponse.d.ts +2 -2
  71. package/dist/Missions/GetRelatedAchTourRequest.d.ts +1 -1
  72. package/dist/Missions/GetRelatedAchTourResponse.d.ts +3 -3
  73. package/dist/Missions/ReloadAchievementsEvent.d.ts +2 -2
  74. package/dist/Missions/UserAchievement.d.ts +7 -7
  75. package/dist/Missions/UserAchievementTask.d.ts +2 -2
  76. package/dist/Missions/index.d.ts +13 -13
  77. package/dist/Quiz/MarketsInfo.d.ts +2 -2
  78. package/dist/Quiz/MarketsPerSport.d.ts +1 -1
  79. package/dist/SmarticoAPI.d.ts +8 -8
  80. package/dist/SmarticoLib/index.d.ts +39 -39
  81. package/dist/Store/BuyStoreItemRequest.d.ts +1 -1
  82. package/dist/Store/BuyStoreItemResponse.d.ts +1 -1
  83. package/dist/Store/GetCategoriesStoreResponse.d.ts +2 -2
  84. package/dist/Store/GetStoreHistoryRequest.d.ts +1 -1
  85. package/dist/Store/GetStoreHistoryResponse.d.ts +2 -2
  86. package/dist/Store/GetStoreItemsResponse.d.ts +2 -2
  87. package/dist/Store/StoreCategory.d.ts +2 -2
  88. package/dist/Store/StoreItem.d.ts +3 -3
  89. package/dist/Store/StoreItemPurchased.d.ts +2 -2
  90. package/dist/Store/index.d.ts +10 -10
  91. package/dist/Tournaments/GetTournamentInfoRequest.d.ts +1 -1
  92. package/dist/Tournaments/GetTournamentInfoResponse.d.ts +5 -5
  93. package/dist/Tournaments/GetTournamentsRequest.d.ts +1 -1
  94. package/dist/Tournaments/GetTournamentsResponse.d.ts +2 -2
  95. package/dist/Tournaments/Tournament.d.ts +8 -8
  96. package/dist/Tournaments/TournamentPrize.d.ts +1 -1
  97. package/dist/Tournaments/TournamentRegisterRequest.d.ts +1 -1
  98. package/dist/Tournaments/TournamentRegisterResponse.d.ts +2 -2
  99. package/dist/Tournaments/TournamentUtils.d.ts +3 -3
  100. package/dist/Tournaments/index.d.ts +16 -16
  101. package/dist/WSAPI/WSAPI.d.ts +65 -65
  102. package/dist/WSAPI/WSAPITypes.d.ts +18 -18
  103. package/dist/index.js +76 -78
  104. package/dist/index.js.map +1 -1
  105. package/dist/index.modern.mjs +103 -103
  106. package/dist/index.modern.mjs.map +1 -1
  107. package/package.json +1 -1
  108. package/src/Base/AchRelatedGame.ts +13 -13
  109. package/src/Base/ClassId.ts +118 -121
  110. package/src/Base/ProtocolMessage.ts +6 -7
  111. package/src/Base/ProtocolRequest.ts +4 -5
  112. package/src/Base/ProtocolResponse.ts +3 -5
  113. package/src/CookieStore.ts +10 -11
  114. package/src/Core/ActivityTypeLimited.ts +17 -18
  115. package/src/Core/CheckSegmentMatchRequest.ts +2 -3
  116. package/src/Core/CheckSegmentMatchResponse.ts +6 -6
  117. package/src/Core/CoreUtils.ts +37 -39
  118. package/src/Core/GetAchievementsUserInfoRequest.ts +2 -4
  119. package/src/Core/GetAchievementsUserInfoResponse.ts +4 -4
  120. package/src/Core/GetLabelInfoRequest.ts +2 -4
  121. package/src/Core/GetLabelInfoResponse.ts +4 -4
  122. package/src/Core/GetTranslationsRequest.ts +5 -7
  123. package/src/Core/GetTranslationsResponse.ts +3 -5
  124. package/src/Core/PublicLabelSettings.ts +29 -30
  125. package/src/Core/PublicProperties.ts +7 -7
  126. package/src/Core/ResponseIdentify.ts +12 -12
  127. package/src/Core/TranslationArea.ts +8 -9
  128. package/src/Core/index.ts +1 -1
  129. package/src/CustomSections/AchCustomSection.ts +20 -20
  130. package/src/CustomSections/GetCustomSectionsRequest.ts +2 -4
  131. package/src/CustomSections/GetCustomSectionsResponse.ts +4 -5
  132. package/src/CustomSections/UICustomSection.ts +30 -29
  133. package/src/CustomSections/index.ts +4 -4
  134. package/src/ErrorCodes.ts +11 -12
  135. package/src/GResponse.ts +5 -5
  136. package/src/ILogger.ts +6 -10
  137. package/src/Inbox/GetInboxMessagesRequest.ts +4 -5
  138. package/src/Inbox/GetInboxMessagesResponse.ts +15 -17
  139. package/src/Inbox/InboxMessage.ts +31 -33
  140. package/src/Inbox/InboxMessageType.ts +9 -9
  141. package/src/Inbox/MarkInboxMessageDeletedRequest.ts +3 -3
  142. package/src/Inbox/MarkInboxMessageDeletedResponse.ts +3 -3
  143. package/src/Inbox/MarkInboxMessageReadRequest.ts +4 -5
  144. package/src/Inbox/MarkInboxMessageReadResponse.ts +4 -5
  145. package/src/Inbox/MarkInboxMessageStarredRequest.ts +4 -5
  146. package/src/Inbox/MarkInboxMessageStarredResponse.ts +4 -5
  147. package/src/Inbox/index.ts +10 -10
  148. package/src/IntUtils.ts +72 -85
  149. package/src/Jackpots/GetJackpotsPotsRequest.ts +3 -3
  150. package/src/Jackpots/GetJackpotsPotsResponse.ts +3 -5
  151. package/src/Jackpots/GetJackpotsRequest.ts +4 -6
  152. package/src/Jackpots/GetJackpotsResponse.ts +5 -7
  153. package/src/Jackpots/JackPotWinner.ts +11 -12
  154. package/src/Jackpots/JackpotContributionType.ts +3 -4
  155. package/src/Jackpots/JackpotDetails.ts +31 -31
  156. package/src/Jackpots/JackpotHtmlTemplate.ts +3 -3
  157. package/src/Jackpots/JackpotPot.ts +11 -12
  158. package/src/Jackpots/JackpotPublicMeta.ts +16 -16
  159. package/src/Jackpots/JackpotType.ts +2 -5
  160. package/src/Jackpots/JackpotWinPush.ts +6 -6
  161. package/src/Jackpots/JackpotsOptinRequest.ts +3 -5
  162. package/src/Jackpots/JackpotsOptinResponse.ts +2 -4
  163. package/src/Jackpots/JackpotsOptoutRequest.ts +3 -5
  164. package/src/Jackpots/JackpotsOptoutResponse.ts +2 -4
  165. package/src/Jackpots/index.ts +16 -16
  166. package/src/Leaderboard/GetLeaderBoardsRequest.ts +8 -9
  167. package/src/Leaderboard/GetLeaderBoardsResponse.ts +4 -6
  168. package/src/Leaderboard/LeaderBoardDetails.ts +11 -12
  169. package/src/Leaderboard/LeaderBoardPeriodType.ts +3 -3
  170. package/src/Leaderboard/LeaderBoardPosition.ts +9 -10
  171. package/src/Leaderboard/LeaderBoardPublicMeta.ts +3 -4
  172. package/src/Leaderboard/LeaderBoards.ts +42 -42
  173. package/src/Leaderboard/index.ts +6 -6
  174. package/src/Level/GetLevelMapResponse.ts +18 -21
  175. package/src/Level/Level.ts +10 -11
  176. package/src/Level/LevelPublicMeta.ts +17 -17
  177. package/src/Level/index.ts +3 -3
  178. package/src/MiniGames/SAWAcknowledgeSpinPushRequest.ts +3 -4
  179. package/src/MiniGames/SAWAcknowledgeType.ts +3 -4
  180. package/src/MiniGames/SAWAskForUsername.ts +3 -4
  181. package/src/MiniGames/SAWBuyInType.ts +15 -13
  182. package/src/MiniGames/SAWDoAknowledgeRequest.ts +3 -3
  183. package/src/MiniGames/SAWDoAknowledgeResponse.ts +3 -3
  184. package/src/MiniGames/SAWDoSpinRequest.ts +3 -5
  185. package/src/MiniGames/SAWDoSpinResponse.ts +10 -11
  186. package/src/MiniGames/SAWEventSawPush.ts +3 -4
  187. package/src/MiniGames/SAWGameType.ts +23 -21
  188. package/src/MiniGames/SAWGetTemplatesRequest.ts +3 -3
  189. package/src/MiniGames/SAWGetTemplatesResponse.ts +53 -65
  190. package/src/MiniGames/SAWPrize.ts +11 -12
  191. package/src/MiniGames/SAWPrizeDropAknowledgeRequest.ts +5 -3
  192. package/src/MiniGames/SAWPrizeDropAknowledgeResponse.ts +3 -3
  193. package/src/MiniGames/SAWPrizeDropWinPush.ts +9 -8
  194. package/src/MiniGames/SAWPrizeType.ts +23 -22
  195. package/src/MiniGames/SAWPrizeUI.ts +17 -17
  196. package/src/MiniGames/SAWSpinErrorCode.ts +15 -16
  197. package/src/MiniGames/SAWSpinsCountPush.ts +4 -4
  198. package/src/MiniGames/SAWTemplate.ts +29 -29
  199. package/src/MiniGames/SAWTemplateUI.ts +45 -47
  200. package/src/MiniGames/SAWUtils.ts +23 -26
  201. package/src/MiniGames/SAWWinSoundType.ts +10 -11
  202. package/src/MiniGames/index.ts +24 -22
  203. package/src/Missions/AchCategoryPublicMeta.ts +2 -3
  204. package/src/Missions/AchClaimPrizeRequest.ts +4 -5
  205. package/src/Missions/AchClaimPrizeResponse.ts +3 -4
  206. package/src/Missions/AchievementCategory.ts +14 -15
  207. package/src/Missions/AchievementOptinRequest.ts +3 -5
  208. package/src/Missions/AchievementOptinResponse.ts +2 -4
  209. package/src/Missions/AchievementPublicMeta.ts +19 -20
  210. package/src/Missions/AchievementStatus.ts +7 -8
  211. package/src/Missions/AchievementTaskPublicMeta.ts +2 -3
  212. package/src/Missions/AchievementTaskType.ts +2 -2
  213. package/src/Missions/AchievementType.ts +2 -3
  214. package/src/Missions/GetAchCategoriesRequest.ts +2 -4
  215. package/src/Missions/GetAchCategoriesResponse.ts +4 -5
  216. package/src/Missions/GetAchievementMapRequest.ts +2 -4
  217. package/src/Missions/GetAchievementMapResponse.ts +3 -5
  218. package/src/Missions/GetRelatedAchTourRequest.ts +3 -4
  219. package/src/Missions/GetRelatedAchTourResponse.ts +5 -7
  220. package/src/Missions/ReloadAchievementsEvent.ts +5 -5
  221. package/src/Missions/ScheduledMissionType.ts +4 -5
  222. package/src/Missions/UserAchievement.ts +104 -108
  223. package/src/Missions/UserAchievementTask.ts +13 -15
  224. package/src/Missions/index.ts +19 -19
  225. package/src/NodeCache.ts +44 -49
  226. package/src/OCache.ts +51 -57
  227. package/src/Quiz/MarketsAnswers.ts +34 -34
  228. package/src/Quiz/MarketsInfo.ts +184 -177
  229. package/src/Quiz/MarketsPerSport.ts +30 -37
  230. package/src/Quiz/MarketsType.ts +28 -28
  231. package/src/Quiz/ScoreResultTypes.ts +18 -18
  232. package/src/Quiz/SportTypes.ts +4 -4
  233. package/src/Quiz/index.ts +6 -6
  234. package/src/SmarticoAPI.ts +769 -730
  235. package/src/SmarticoLib/index.ts +1053 -1069
  236. package/src/Store/BuyStoreItemErrorCode.ts +10 -10
  237. package/src/Store/BuyStoreItemRequest.ts +2 -2
  238. package/src/Store/BuyStoreItemResponse.ts +2 -3
  239. package/src/Store/GetCategoriesStoreResponse.ts +3 -8
  240. package/src/Store/GetStoreHistoryRequest.ts +3 -3
  241. package/src/Store/GetStoreHistoryResponse.ts +4 -4
  242. package/src/Store/GetStoreItemsResponse.ts +3 -4
  243. package/src/Store/StoreCategory.ts +14 -15
  244. package/src/Store/StoreCategoryPublicMeta.ts +2 -3
  245. package/src/Store/StoreItem.ts +32 -33
  246. package/src/Store/StoreItemPublicMeta.ts +10 -10
  247. package/src/Store/StoreItemPurchased.ts +40 -40
  248. package/src/Store/StoreItemType.ts +20 -19
  249. package/src/Store/index.ts +13 -13
  250. package/src/Tournaments/GetTournamentInfoRequest.ts +2 -3
  251. package/src/Tournaments/GetTournamentInfoResponse.ts +45 -48
  252. package/src/Tournaments/GetTournamentsRequest.ts +2 -4
  253. package/src/Tournaments/GetTournamentsResponse.ts +7 -14
  254. package/src/Tournaments/Tournament.ts +109 -115
  255. package/src/Tournaments/TournamentInstanceStatus.ts +17 -18
  256. package/src/Tournaments/TournamentPlayer.ts +7 -8
  257. package/src/Tournaments/TournamentPrize.ts +9 -10
  258. package/src/Tournaments/TournamentPublicMeta.ts +26 -26
  259. package/src/Tournaments/TournamentRegisterRequest.ts +2 -3
  260. package/src/Tournaments/TournamentRegisterResponse.ts +3 -7
  261. package/src/Tournaments/TournamentRegistrationError.ts +9 -9
  262. package/src/Tournaments/TournamentRegistrationStatus.ts +25 -27
  263. package/src/Tournaments/TournamentRegistrationType.ts +15 -16
  264. package/src/Tournaments/TournamentType.ts +3 -4
  265. package/src/Tournaments/TournamentUtils.ts +90 -89
  266. package/src/Tournaments/index.ts +16 -16
  267. package/src/WSAPI/WSAPI.ts +781 -763
  268. package/src/WSAPI/WSAPITypes.ts +574 -586
  269. package/src/index.ts +15 -15
@@ -1,772 +1,790 @@
1
- import { ClassId } from "../Base/ClassId";
2
- import { CoreUtils } from "../Core";
3
- import { MiniGamePrizeTypeName, SAWDoSpinResponse, SAWSpinErrorCode, SAWSpinsCountPush } from "../MiniGames";
4
- import { ECacheContext, OCache } from "../OCache";
5
- import { SmarticoAPI } from "../SmarticoAPI";
6
- import { InboxMarkMessageAction, LeaderBoardDetailsT, TAchCategory, TBuyStoreItemResult, TGetTranslations, TInboxMessage, TInboxMessageBody, TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionClaimRewardResult, TMissionOptInResult, TMissionOrBadge, TSegmentCheckResult, TStoreCategory, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUICustomSection, TUserProfile, UserLevelExtraCountersT } from "./WSAPITypes";
7
- import { LeaderBoardPeriodType } from "../Leaderboard";
8
- import { JackpotDetails, JackpotPot, JackpotWinPush, JackpotsOptinResponse, JackpotsOptoutRequest, JackpotsOptoutResponse } from "../Jackpots";
9
-
1
+ import { ClassId } from '../Base/ClassId'
2
+ import { CoreUtils } from '../Core'
3
+ import { MiniGamePrizeTypeName, SAWDoSpinResponse, SAWSpinErrorCode, SAWSpinsCountPush } from '../MiniGames'
4
+ import { ECacheContext, OCache } from '../OCache'
5
+ import { SmarticoAPI } from '../SmarticoAPI'
6
+ import {
7
+ InboxMarkMessageAction,
8
+ LeaderBoardDetailsT,
9
+ TAchCategory,
10
+ TBuyStoreItemResult,
11
+ TGetTranslations,
12
+ TInboxMessage,
13
+ TInboxMessageBody,
14
+ TLevel,
15
+ TMiniGamePlayResult,
16
+ TMiniGameTemplate,
17
+ TMissionClaimRewardResult,
18
+ TMissionOptInResult,
19
+ TMissionOrBadge,
20
+ TSegmentCheckResult,
21
+ TStoreCategory,
22
+ TStoreItem,
23
+ TTournament,
24
+ TTournamentDetailed,
25
+ TTournamentRegistrationResult,
26
+ TUICustomSection,
27
+ TUserProfile,
28
+ UserLevelExtraCountersT,
29
+ } from './WSAPITypes'
30
+ import { LeaderBoardPeriodType } from '../Leaderboard'
31
+ import { JackpotDetails, JackpotPot, JackpotWinPush, JackpotsOptinResponse, JackpotsOptoutRequest, JackpotsOptoutResponse } from '../Jackpots'
32
+
10
33
  /** @hidden */
11
- const CACHE_DATA_SEC = 30;
34
+ const CACHE_DATA_SEC = 30
12
35
 
13
- const JACKPOT_TEMPLATE_CACHE_SEC = 30;
14
- const JACKPOT_POT_CACHE_SEC = 1;
36
+ const JACKPOT_TEMPLATE_CACHE_SEC = 30
37
+ const JACKPOT_POT_CACHE_SEC = 1
15
38
 
16
- /** @hidden */
39
+ /** @hidden */
17
40
  enum onUpdateContextKey {
18
- Saw = 'saw',
19
- Missions = 'missions',
20
- TournamentList = 'tournamentList',
21
- InboxMessages = 'inboxMessages',
22
- Badges = 'badges',
23
- Levels = 'levels',
24
- StoreItems = 'storeItems',
25
- StoreCategories = 'storeCategories',
26
- AchCategories = 'achCategories',
27
- LeaderBoards = 'leaderBoards',
28
- LevelExtraCounters = 'levelExtraCounters',
29
- Segments = 'segments',
30
- StoreHistory = 'storeHistory',
31
- Jackpots = 'jackpots',
32
- Pots = 'Pots',
33
- CustomSections = 'customSections'
41
+ Saw = 'saw',
42
+ Missions = 'missions',
43
+ TournamentList = 'tournamentList',
44
+ InboxMessages = 'inboxMessages',
45
+ Badges = 'badges',
46
+ Levels = 'levels',
47
+ StoreItems = 'storeItems',
48
+ StoreCategories = 'storeCategories',
49
+ AchCategories = 'achCategories',
50
+ LeaderBoards = 'leaderBoards',
51
+ LevelExtraCounters = 'levelExtraCounters',
52
+ Segments = 'segments',
53
+ StoreHistory = 'storeHistory',
54
+ Jackpots = 'jackpots',
55
+ Pots = 'Pots',
56
+ CustomSections = 'customSections',
34
57
  }
35
58
 
36
-
37
59
  /** @group General API */
38
60
  export class WSAPI {
39
-
40
- private onUpdateCallback: Map<onUpdateContextKey, (data: any) => void> = new Map();
41
- private jackpotGetSignature: string = '';
42
-
43
- /** @private */
44
- constructor(private api: SmarticoAPI) {
45
-
46
- OCache.clearAll();
47
- if (this.api.tracker) {
48
- const on = this.api.tracker.on;
49
- on(ClassId.SAW_SPINS_COUNT_PUSH, (data: SAWSpinsCountPush) => this.updateOnSpin(data));
50
- on(ClassId.SAW_SHOW_SPIN_PUSH, () => this.updateOnAddSpin());
51
- on(ClassId.SAW_DO_SPIN_RESPONSE, (data: SAWDoSpinResponse) => on(ClassId.SAW_AKNOWLEDGE_RESPONSE, () => this.updateOnPrizeWin(data)));
52
- on(ClassId.MISSION_OPTIN_RESPONSE, () => this.updateMissionsOnOptIn());
53
- on(ClassId.TOURNAMENT_REGISTER_RESPONSE, () => this.updateTournamentsOnRegistration());
54
- on(ClassId.CLIENT_ENGAGEMENT_EVENT_NEW, () => this.updateInboxMessages());
55
- on(ClassId.LOGOUT_RESPONSE, () => OCache.clearContext(ECacheContext.WSAPI));
56
- on(ClassId.IDENTIFY_RESPONSE, () => OCache.clearContext(ECacheContext.WSAPI));
57
- on(ClassId.JP_WIN_PUSH, (data: JackpotWinPush) => this.jackpotClearCache());
58
- on(ClassId.JP_OPTOUT_RESPONSE, (data: JackpotsOptoutRequest) => this.jackpotClearCache());
59
- on(ClassId.JP_OPTIN_RESPONSE, (data: JackpotsOptinResponse) => this.jackpotClearCache());
60
- }
61
- }
62
-
63
- /** Returns information about current user
64
- *
65
- * **Example**:
66
- * ```
67
- * _smartico.api.getUserProfile().then((result) => {
68
- * console.log(result);
69
- * });
70
- * ```
71
- * **Visitor mode: not supported**
72
- * */
73
- public getUserProfile(): TUserProfile {
74
- if (this.api.tracker) {
75
- const o: TUserProfile = Object.assign({}, this.api.tracker.userPublicProps);
76
- o.avatar_url = CoreUtils.avatarUrl(this.api.tracker.userPublicProps.avatar_id, this.api.avatarDomain);
77
- return o;
78
- } else {
79
- throw new Error('Tracker is not initialized, cannot getUserProfile');
80
- }
81
- }
82
-
83
- /** Check if user belongs to specific segments
84
- * **Example**:
85
- * ```
86
- * _smartico.api.checkSegmentMatch(1).then((result) => {
87
- * console.log(result);
88
- * });
89
- * ```
90
- *
91
- * **Visitor mode: not supported**
92
- */
93
- public async checkSegmentMatch(segment_id: number): Promise<boolean> {
94
- const r = await this.api.coreCheckSegments(null, [segment_id]);
95
- if (r && r.find(s => s.segment_id === segment_id && s.is_matching)) {
96
- return true;
97
- } else {
98
- return false;
99
- }
100
- }
101
-
102
- /** Check if user belongs to specific list of segments
103
- * **Example**:
104
- * ```
105
- * _smartico.api.checkSegmentListMatch([1, 2, 3]).then((result) => {
106
- * console.log(result);
107
- * });
108
- * ```
109
- * **Visitor mode: not supported**
110
- */
111
- public async checkSegmentListMatch(segment_ids: number[]): Promise<TSegmentCheckResult[]> {
112
- return await this.api.coreCheckSegments(null, Array.isArray(segment_ids) ? segment_ids : [segment_ids]);
113
- }
114
-
115
- /** Returns all the levels available the current user
116
- * **Example**:
117
- * ```
118
- * _smartico.api.getLevels().then((result) => {
119
- * console.log(result);
120
- * });
121
- * ```
122
- *
123
- * **Example in the Visitor mode**:
124
- * ```
125
- * _smartico.vapi('EN').getLevels().then((result) => {
126
- * console.log(result);
127
- * });
128
- * ```
129
- */
130
- public async getLevels(): Promise<TLevel[]> {
131
- return OCache.use(onUpdateContextKey.Levels, ECacheContext.WSAPI, () => this.api.levelsGetT(null), CACHE_DATA_SEC);
132
- }
133
-
134
- /** Returns all the missions available the current user.
135
- * The returned missions are cached for 30 seconds. But you can pass the onUpdate callback as a parameter.
136
- * Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
137
- * The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it.
138
- *
139
- * **Example**:
140
- * ```
141
- * _smartico.api.getMissions().then((result) => {
142
- * console.log(result);
143
- * });
144
- * ```
145
- *
146
- * **Example in the Visitor mode**:
147
- * ```
148
- * _smartico.vapi('EN').getMissions().then((result) => {
149
- * console.log(result);
150
- * });
151
- * ```
152
- */
153
- public async getMissions({ onUpdate }: { onUpdate?: (data: TMissionOrBadge[]) => void } = {}): Promise<TMissionOrBadge[]> {
154
- if (onUpdate) {
155
- this.onUpdateCallback.set(onUpdateContextKey.Missions, onUpdate);
156
- }
157
-
158
- return OCache.use(onUpdateContextKey.Missions, ECacheContext.WSAPI, () => this.api.missionsGetItemsT(null), CACHE_DATA_SEC);
159
- }
160
-
161
- /**
162
- * Returns all the badges available the current user
163
- *
164
- * **Visitor mode: not supported**
165
- */
166
- public async getBadges(): Promise<TMissionOrBadge[]> {
167
- return OCache.use(onUpdateContextKey.Badges, ECacheContext.WSAPI, () => this.api.badgetsGetItemsT(null), CACHE_DATA_SEC);
168
- }
169
-
170
- /**
171
- * Returns the extra counters for the current user level.
172
- * These are counters that are configured for each Smartico client separatly by request.
173
- * For example 1st counter could be total wagering amount, 2nd counter could be total deposit amount, etc.
174
- *
175
- * **Example**:
176
- * ```
177
- * _smartico.api.getUserLevelExtraCounters().then((result) => {
178
- * console.log(result);
179
- * });
180
- * ```
181
- *
182
- * **Visitor mode: not supported**
183
- */
184
- public async getUserLevelExtraCounters(): Promise<UserLevelExtraCountersT> {
185
- return OCache.use(onUpdateContextKey.LevelExtraCounters, ECacheContext.WSAPI, () => this.api.getUserGamificationInfoT(null), CACHE_DATA_SEC);
186
- }
187
-
188
- /**
189
- *
190
- * Returns all the store items available the current user
191
- *
192
- * **Example**:
193
- * ```
194
- * _smartico.api.getStoreItems().then((result) => {
195
- * console.log(result);
196
- * });
197
- * ```
198
- *
199
- * **Example in the Visitor mode**:
200
- * ```
201
- * _smartico.vapi('EN').getStoreItems().then((result) => {
202
- * console.log(result);
203
- * });
204
- * ```
205
- */
206
-
207
- public async getStoreItems(): Promise<TStoreItem[]> {
208
- return OCache.use(onUpdateContextKey.StoreItems, ECacheContext.WSAPI, () => this.api.storeGetItemsT(null), CACHE_DATA_SEC);
209
- }
210
-
211
- /** Buy the specific shop item by item_id. Returns the err_code in case of success or error.
212
- * **Example**:
213
- * ```
214
- * _smartico.api.buyStoreItem(1).then((result) => {
215
- * console.log(result);
216
- * });
217
- * ```
218
- *
219
- * **Visitor mode: not supported**
220
- */
221
- public async buyStoreItem(item_id: number): Promise<TBuyStoreItemResult> {
222
- const r = await this.api.buyStoreItem(null, item_id);
223
-
224
- const o: TBuyStoreItemResult = {
225
- err_code: r.errCode,
226
- err_message: r.errMsg,
227
- }
228
-
229
- return o;
230
- }
231
-
232
- /**
233
- *
234
- * Returns store categories
235
- *
236
- * **Example**:
237
- * ```
238
- * _smartico.api.getStoreCategories().then((result) => {
239
- * console.log(result);
240
- * });
241
- * ```
242
- *
243
- * **Example in the Visitor mode**:
244
- * ```
245
- * _smartico.vapi('EN').getStoreCategories().then((result) => {
246
- * console.log(result);
247
- * });
248
- * ```
249
- */
250
- public async getStoreCategories(): Promise<TStoreCategory[]> {
251
- return OCache.use(onUpdateContextKey.StoreCategories, ECacheContext.WSAPI, () => this.api.storeGetCategoriesT(null), CACHE_DATA_SEC);
252
- }
253
-
254
- /**
255
- * Returns purchased items based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
256
- * The maximum number of items per request is limited to 20.
257
- * You can leave this params empty and by default it will return list of purchased items ranging from 0 to 20.
258
- *
259
- * **Example**:
260
- * ```
261
- * _smartico.api.getStorePurchasedItems().then((result) => {
262
- * console.log(result);
263
- * });
264
- * ```
265
- *
266
- * **Visitor mode: not supported**
267
- */
268
-
269
- public async getStorePurchasedItems({ limit, offset, onUpdate } : { limit?: number, offset?: number, onUpdate?: (data: TStoreItem[]) => void} = {}): Promise<TStoreItem[]> {
270
- if (onUpdate) {
271
- this.onUpdateCallback.set(onUpdateContextKey.StoreHistory, onUpdate);
272
- }
273
- return OCache.use(onUpdateContextKey.StoreHistory, ECacheContext.WSAPI, () => this.api.storeGetPurchasedItemsT(null, limit, offset), CACHE_DATA_SEC);
274
- }
275
-
276
- /**
277
- * Returns missions & badges categories
278
- *
279
- * **Example**:
280
- * ```
281
- * _smartico.api.getAchCategories().then((result) => {
282
- * console.log(result);
283
- * });
284
- * ```
285
- *
286
- * **Example in the Visitor mode**:
287
- * ```
288
- * _smartico.vapi('EN').getAchCategories().then((result) => {
289
- * console.log(result);
290
- * });
291
- * ```
292
- *
293
- * */
294
- public async getAchCategories(): Promise<TAchCategory[]> {
295
- return OCache.use(onUpdateContextKey.AchCategories, ECacheContext.WSAPI, () => this.api.achGetCategoriesT(null), CACHE_DATA_SEC);
296
- }
297
-
298
- /**
299
- * Returns list of custom sections
300
- *
301
- * **Example**:
302
- * ```
303
- * _smartico.api.getCustomSections().then((result) => {
304
- * console.log(result);
305
- * });
306
- * ```
307
- *
308
- * **Example in the Visitor mode**:
309
- * ```
310
- * _smartico.vapi('EN').getCustomSections().then((result) => {
311
- * console.log(result);
312
- * });
313
- * ```
314
- *
315
- * */
316
- public async getCustomSections(): Promise<TUICustomSection[]> {
317
- return OCache.use(onUpdateContextKey.CustomSections, ECacheContext.WSAPI, () => this.api.getCustomSectionsT(null), CACHE_DATA_SEC);
318
- }
319
-
320
- /**
321
- * Returns the list of mini-games available for user
322
- * The returned list of mini-games is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMiniGames with a new onUpdate callback, the old one will be overwritten by the new one.
323
- * The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
324
- *
325
- * **Example**:
326
- * ```
327
- * _smartico.api.getMiniGames().then((result) => {
328
- * console.log(result);
329
- * });
330
- * ```
331
- *
332
- * **Example in the Visitor mode**:
333
- * ```
334
- * _smartico.vapi('EN').getMiniGames().then((result) => {
335
- * console.log(result);
336
- * });
337
- * ```
338
- *
339
- */
340
- public async getMiniGames({ onUpdate }: { onUpdate?: (data: TMiniGameTemplate[]) => void } = {}): Promise<TMiniGameTemplate[]> {
341
- if (onUpdate) {
342
- this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate);
343
- }
344
-
345
- return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC);
346
- }
347
-
348
- /**
349
- * Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
350
- *
351
- * **Visitor mode: not supported**
352
- */
353
- public async playMiniGame(template_id: number): Promise<TMiniGamePlayResult> {
354
- const r = await this.api.sawSpinRequest(null, template_id);
355
- this.api.doAcknowledgeRequest(null, r.request_id)
356
-
357
- const o: TMiniGamePlayResult = {
358
- err_code: r.errCode,
359
- err_message: r.errMsg,
360
- prize_id: r.saw_prize_id,
361
- }
362
-
363
- return o;
364
- }
365
-
366
- /**
367
- * Requests an opt-in for the specified mission_id. Returns the err_code.
368
- *
369
- * **Visitor mode: not supported**
370
- */
371
- public async requestMissionOptIn(mission_id: number): Promise<TMissionOptInResult>{
372
- const r = await this.api.missionOptIn(null, mission_id);
373
-
374
- const o: TMissionOptInResult = {
375
- err_code: r.errCode,
376
- err_message: r.errMsg,
377
- }
378
-
379
- return o;
380
- }
381
-
382
- /**
383
- * Request for claim reward for the specified mission id. Returns the err_code.
384
- *
385
- * **Visitor mode: not supported**
386
- */
387
- public async requestMissionClaimReward(mission_id: number, ach_completed_id: number): Promise<TMissionClaimRewardResult> {
388
- const r = await this.api.missionClaimPrize(null, mission_id, ach_completed_id);
389
-
390
- const o: TMissionClaimRewardResult = {
391
- err_code: r.errCode,
392
- err_message: r.errMsg,
393
- }
394
-
395
- return o;
396
- }
397
-
398
- /** Returns all the active instances of tournaments
399
- * The returned list is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getTournamentsList with a new onUpdate callback, the old one will be overwritten by the new one.
400
- * The onUpdate callback will be called when the user has registered in a tournament. Updated list will be passed to onUpdate callback.
401
- *
402
- * **Example**:
403
- * ```
404
- * _smartico.api.getTournamentsList().then((result) => {
405
- * console.log(result);
406
- * });
407
- * ```
408
- *
409
- * **Example in the Visitor mode**:
410
- * ```
411
- * _smartico.vapi('EN').getTournamentsList().then((result) => {
412
- * console.log(result);
413
- * });
414
- * ```
415
- * */
416
- public async getTournamentsList({ onUpdate }: { onUpdate?: (data: TTournament[]) => void } = {}): Promise<TTournament[]> {
417
- if (onUpdate) {
418
- this.onUpdateCallback.set(onUpdateContextKey.TournamentList, onUpdate);
419
- }
420
-
421
- return OCache.use(onUpdateContextKey.TournamentList, ECacheContext.WSAPI, () => this.api.tournamentsGetLobbyT(null), CACHE_DATA_SEC);
422
- }
423
-
424
- /**
425
- * Returns details information of specific tournament instance, the response will include tournament info and the leaderboard of players
426
- *
427
- * **Example**:
428
- * ```
429
- * _smartico.api.getTournamentsList().then((result) => {
430
- * if (result.length > 0) {
431
- * _smartico.api.getTournamentInstanceInfo(result[0].instance_id).then((result) => {
432
- * console.log(result);
433
- * });
434
- * }
435
- * });
436
- * ```
437
- *
438
- * **Example in the Visitor mode**:
439
- * ```
440
- * _smartico.vapi('EN').getTournamentsList().then((result) => {
441
- * if (result.length > 0) {
442
- * _smartico.vapi('EN').getTournamentInstanceInfo(result[0].instance_id).then((result) => {
443
- * console.log(result);
444
- * });
445
- * }
446
- * });
447
- * ```
448
- */
449
- public async getTournamentInstanceInfo(tournamentInstanceId: number): Promise<TTournamentDetailed> {
450
- return this.api.tournamentsGetInfoT(null, tournamentInstanceId);
451
- }
452
-
453
- /**
454
- * Requests registration for the specified tournament instance. Returns the err_code.
455
- *
456
- * **Visitor mode: not supported**
457
- */
458
- public async registerInTournament(tournamentInstanceId: number): Promise<TTournamentRegistrationResult>{
459
- const r = await this.api.registerInTournament(null, tournamentInstanceId);
460
-
461
- const o: TTournamentRegistrationResult = {
462
- err_code: r.errCode,
463
- err_message: r.errMsg,
464
- }
465
-
466
- return o;
467
- }
468
-
469
- /**
470
- * Returns the leaderboard for the current type (default is Daily). If getPreviousPeriod is passed as true, a leaderboard for the previous period for the current type will be returned.
471
- * For example, if the type is Weekly and getPreviousPeriod is true, a leaderboard for the previous week will be returned.
472
- *
473
- * **Example**:
474
- * ```
475
- * _smartico.api.getLeaderBoard(1).then((result) => {
476
- * console.log(result);
477
- * });
478
- * ```
479
- *
480
- * **Example in the Visitor mode**:
481
- * ```
482
- * _smartico.vapi('EN').getLeaderBoard(1).then((result) => {
483
- * console.log(result);
484
- * });
485
- * ```
486
- */
487
- public async getLeaderBoard(periodType: LeaderBoardPeriodType, getPreviousPeriod?: boolean): Promise<LeaderBoardDetailsT> {
488
- return OCache.use(onUpdateContextKey.LeaderBoards, ECacheContext.WSAPI, () => this.api.leaderboardsGetT(null, periodType, getPreviousPeriod), CACHE_DATA_SEC);
489
- }
490
-
491
- /** Returns inbox messages based on the provided parameters. "From" and "to" indicate the range of messages to be fetched.
492
- * The maximum number of messages per request is limited to 20. An indicator "onlyFavorite" can be passed to get only messages marked as favorites.
493
- * You can leave this params empty and by default it will return list of messages ranging from 0 to 20.
494
- * This functions return list of messages without the body of the message.
495
- * To get the body of the message you need to call getInboxMessageBody function and pass the message guid contained in each message of this request.
496
- * All other action like mark as read, favorite, delete, etc. can be done using this message GUID.
497
- * The "onUpdate" callback will be triggered when the user receives a new message. It will provide an updated list of messages, ranging from 0 to 20, to the onUpdate callback function.
498
- *
499
- * **Visitor mode: not supported**
500
- *
501
- * @param params
502
- */
503
- public async getInboxMessages({ from, to, onlyFavorite, onUpdate }: { from?: number, to?: number, onlyFavorite?: boolean, onUpdate?: (data: TInboxMessage[]) => void } = {}): Promise<TInboxMessage[]> {
504
- if (onUpdate) {
505
- this.onUpdateCallback.set(onUpdateContextKey.InboxMessages, onUpdate);
506
- }
507
-
508
- return await this.api.getInboxMessagesT(null, from, to, onlyFavorite);
509
- }
510
-
511
- /**
512
- * Returns the message body of the specified message guid.
513
- *
514
- * **Visitor mode: not supported**
515
- */
516
- public async getInboxMessageBody(messageGuid: string): Promise<TInboxMessageBody> {
517
- return await this.api.getInboxMessageBodyT(messageGuid);
518
- }
519
-
520
- /**
521
- * Requests to mark inbox message with specified guid as read
522
- *
523
- * **Visitor mode: not supported**
524
- */
525
- public async markInboxMessageAsRead(messageGuid: string): Promise<InboxMarkMessageAction> {
526
- const r = await this.api.markInboxMessageRead(null, messageGuid);
527
-
528
- return {
529
- err_code: r.errCode,
530
- err_message: r.errMsg,
531
- }
532
- }
533
-
534
- /**
535
- * Requests to mark all inbox messages as rea
536
- *
537
- * **Visitor mode: not supported**
538
- */
539
- public async markAllInboxMessagesAsRead(): Promise<InboxMarkMessageAction> {
540
- const r = await this.api.markAllInboxMessageRead(null);
541
-
542
- return {
543
- err_code: r.errCode,
544
- err_message: r.errMsg,
545
- }
546
- }
547
-
548
- /**
549
- * Requests to mark inbox message with specified guid as favorite. Pass mark true to add message to favorite and false to remove.
550
- *
551
- * **Visitor mode: not supported**
552
- */
553
- public async markUnmarkInboxMessageAsFavorite(messageGuid: string, mark: boolean): Promise<InboxMarkMessageAction> {
554
- const r = await this.api.markUnmarkInboxMessageAsFavorite(null, messageGuid, mark);
555
-
556
- return {
557
- err_code: r.errCode,
558
- err_message: r.errMsg,
559
- }
560
- }
561
-
562
- /**
563
- * Requests to delete inbox message
564
- *
565
- * **Visitor mode: not supported**
566
- */
567
-
568
- public async deleteInboxMessage(messageGuid: string): Promise<InboxMarkMessageAction> {
569
- const r = await this.api.deleteInboxMessage(null, messageGuid);
570
-
571
- return {
572
- err_code: r.errCode,
573
- err_message: r.errMsg,
574
- }
575
- }
576
-
577
- /**
578
- * Requests to delete all inbox messages
579
- *
580
- * **Visitor mode: not supported**
581
- */
582
-
583
- public async deleteAllInboxMessages(): Promise<InboxMarkMessageAction> {
584
- const r = await this.api.deleteAllInboxMessages(null);
585
-
586
- return {
587
- err_code: r.errCode,
588
- err_message: r.errMsg,
589
- }
590
- }
591
-
592
- /**
593
- * Requests translations for the given language. Returns the object including translation key/translation value pairs. All possible translation keys defined in the back office.
594
- */
595
- public async getTranslations(lang_code: string): Promise<TGetTranslations> {
596
- const r = await this.api.getTranslationsT(null, lang_code, []);
597
-
598
- return {
599
- translations: r.translations
600
- }
601
- }
602
-
603
- private async updateOnSpin(data: SAWSpinsCountPush) {
604
- const templates: TMiniGameTemplate[] = await OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC);
605
- const index = templates.findIndex(t => t.id === data.saw_template_id);
606
- templates[index].spin_count = data.spin_count;
607
- this.updateEntity(onUpdateContextKey.Saw, templates)
608
- }
609
-
610
- private async updateOnAddSpin() {
611
- const payload = await this.api.sawGetTemplatesT(null);
612
- this.updateEntity(onUpdateContextKey.Saw, payload)
613
- }
614
-
615
- private async updateOnPrizeWin(data: SAWDoSpinResponse) {
616
- if (data.errCode === SAWSpinErrorCode.SAW_OK) {
617
- const templates: TMiniGameTemplate[] = await OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC);
618
- const template: TMiniGameTemplate = templates.find(t => t.prizes.find(p => p.id === data.saw_prize_id));
619
- const prizeType = template.prizes.find(p => p.id === data.saw_prize_id)?.prize_type;
620
-
621
- if (
622
- template.jackpot_add_on_attempt ||
623
- template.spin_count === 1 ||
624
- prizeType === MiniGamePrizeTypeName.JACKPOT ||
625
- prizeType === MiniGamePrizeTypeName.SPIN
626
- ) {
627
- const updatedTemplates = await this.api.sawGetTemplatesT(null);
628
- this.updateEntity(onUpdateContextKey.Saw, updatedTemplates)
629
- }
630
- }
631
- }
632
-
633
- private async updateMissionsOnOptIn() {
634
- const payload = await this.api.missionsGetItemsT(null);
635
- this.updateEntity(onUpdateContextKey.Missions, payload)
636
- }
637
-
638
- private async updateTournamentsOnRegistration() {
639
- const payload = await this.api.tournamentsGetLobbyT(null);
640
- this.updateEntity(onUpdateContextKey.TournamentList, payload)
641
- }
642
-
643
- private async updateInboxMessages() {
644
- const payload = await this.api.getInboxMessagesT(null);
645
- this.updateEntity(onUpdateContextKey.InboxMessages, payload)
646
- }
647
-
648
- private async updateEntity(contextKey: onUpdateContextKey, payload: any) {
649
- OCache.set(contextKey, payload, ECacheContext.WSAPI);
650
-
651
- const onUpdate = this.onUpdateCallback.get(contextKey);
652
- if (onUpdate) {
653
- onUpdate(payload);
654
- }
655
- }
656
-
657
- private async jackpotClearCache() {
658
- OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Jackpots);
659
- OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Pots);
660
- }
661
-
662
- /** Returns list of Jackpots that are active in the systen and matching to the filter definition.
663
- * If filter is not provided, all active jackpots will be returned.
664
- * Filter can be used to get jackpots related to specific game or specific jackpot template.
665
- * You can call this method every second in order to get up to date information about current value of the jackpot(s) and present them to the end-users
666
- *
667
- * **Example**:
668
- * ```
669
- * _smartico.api.jackpotGet({ related_game_id: 'wooko-slot' }).then((result) => {
670
- * console.log(result);
671
- * });
672
- * ```
673
- *
674
- * **Example in the Visitor mode**:
675
- * ```
676
- * _smartico.vapi('EN').jackpotGet({ related_game_id: 'wooko-slot' }).then((result) => {
677
- * console.log(result);
678
- * });
679
- * ```
680
- */
681
- public async jackpotGet(filter?: { related_game_id?: string, jp_template_id?: number }): Promise<JackpotDetails[]> {
682
-
683
- const signature: string = `${filter?.jp_template_id}:${filter?.related_game_id}`;
684
-
685
- if (signature !== this.jackpotGetSignature) {
686
- this.jackpotGetSignature = signature;
687
- this.jackpotClearCache();
688
- }
689
-
690
- let jackpots: JackpotDetails[] = [];
691
- let pots: JackpotPot[] = [];
692
-
693
- jackpots = await OCache.use<JackpotDetails[]>(onUpdateContextKey.Jackpots, ECacheContext.WSAPI, async () => {
694
-
695
- const _jackpots = await this.api.jackpotGet(null, filter);
696
- const _pots = _jackpots.items.map( jp => jp.pot);
697
-
698
- OCache.set(onUpdateContextKey.Pots, _pots, ECacheContext.WSAPI, JACKPOT_POT_CACHE_SEC);
699
- return _jackpots.items;
700
-
701
- }, JACKPOT_TEMPLATE_CACHE_SEC);
702
-
703
-
704
- if (jackpots.length > 0) {
705
- pots = await OCache.use<JackpotPot[]>(onUpdateContextKey.Pots, ECacheContext.WSAPI, async () => {
706
-
707
- const jp_template_ids = jackpots.map(jp => jp.jp_template_id);
708
- return (await this.api.potGet(null, { jp_template_ids })).items;
709
-
710
- }, JACKPOT_POT_CACHE_SEC);
711
- }
712
-
713
- return jackpots.map( jp => {
714
- let _jp: JackpotDetails = {
715
- ...jp,
716
- pot: pots.find( p => p.jp_template_id === jp.jp_template_id),
717
- };
718
- return _jp;
719
- });
720
-
721
- }
722
-
723
- /**
724
- * Opt-in currently logged in user to the jackpot with the specified jp_template_id.
725
- * You may call jackpotGet method after doing optin to see that user is opted in to the jackpot.
726
- *
727
- * **Example**:
728
- * ```
729
- * _smartico.api.jackpotOptIn({ jp_template_id: 123 }).then((result) => {
730
- * console.log('Opted in to the jackpot');
731
- * });
732
- * ```
733
- *
734
- * **Visitor mode: not supported**
735
- *
736
- */
737
- public async jackpotOptIn(filter: { jp_template_id: number }): Promise<JackpotsOptinResponse> {
738
-
739
- if (!filter.jp_template_id) {
740
- throw new Error('jp_template_id is required in jackpotOptIn');
741
- };
742
-
743
- const result = await this.api.jackpotOptIn(null, filter);
744
-
745
- return result;
746
- }
747
-
748
- /**
749
- * Opt-out currently logged in user from the jackpot with the specified jp_template_id.
750
- * You may call jackpotGet method after doing optout to see that user is not opted in to the jackpot.
751
- *
752
- * **Example**:
753
- * ```
754
- * _smartico.api.jackpotOptOut({ jp_template_id: 123 }).then((result) => {
755
- * console.log('Opted out from the jackpot');
756
- * });
757
- * ```
758
- *
759
- * **Visitor mode: not supported**
760
- *
761
- */
762
- public async jackpotOptOut(filter: { jp_template_id: number }): Promise<JackpotsOptoutResponse> {
763
-
764
- if (!filter.jp_template_id) {
765
- throw new Error('jp_template_id is required in jackpotOptOut');
766
- };
767
-
768
- const result = await this.api.jackpotOptOut(null, filter);
769
-
770
- return result;
771
- }
61
+ private onUpdateCallback: Map<onUpdateContextKey, (data: any) => void> = new Map()
62
+ private jackpotGetSignature: string = ''
63
+
64
+ /** @private */
65
+ constructor(private api: SmarticoAPI) {
66
+ OCache.clearAll()
67
+ if (this.api.tracker) {
68
+ const on = this.api.tracker.on
69
+ on(ClassId.SAW_SPINS_COUNT_PUSH, (data: SAWSpinsCountPush) => this.updateOnSpin(data))
70
+ on(ClassId.SAW_SHOW_SPIN_PUSH, () => this.updateOnAddSpin())
71
+ on(ClassId.SAW_DO_SPIN_RESPONSE, (data: SAWDoSpinResponse) => on(ClassId.SAW_AKNOWLEDGE_RESPONSE, () => this.updateOnPrizeWin(data)))
72
+ on(ClassId.MISSION_OPTIN_RESPONSE, () => this.updateMissionsOnOptIn())
73
+ on(ClassId.TOURNAMENT_REGISTER_RESPONSE, () => this.updateTournamentsOnRegistration())
74
+ on(ClassId.CLIENT_ENGAGEMENT_EVENT_NEW, () => this.updateInboxMessages())
75
+ on(ClassId.LOGOUT_RESPONSE, () => OCache.clearContext(ECacheContext.WSAPI))
76
+ on(ClassId.IDENTIFY_RESPONSE, () => OCache.clearContext(ECacheContext.WSAPI))
77
+ on(ClassId.JP_WIN_PUSH, (data: JackpotWinPush) => this.jackpotClearCache())
78
+ on(ClassId.JP_OPTOUT_RESPONSE, (data: JackpotsOptoutRequest) => this.jackpotClearCache())
79
+ on(ClassId.JP_OPTIN_RESPONSE, (data: JackpotsOptinResponse) => this.jackpotClearCache())
80
+ }
81
+ }
82
+
83
+ /** Returns information about current user
84
+ *
85
+ * **Example**:
86
+ * ```
87
+ * _smartico.api.getUserProfile().then((result) => {
88
+ * console.log(result);
89
+ * });
90
+ * ```
91
+ * **Visitor mode: not supported**
92
+ * */
93
+ public getUserProfile(): TUserProfile {
94
+ if (this.api.tracker) {
95
+ const o: TUserProfile = Object.assign({}, this.api.tracker.userPublicProps)
96
+ o.avatar_url = CoreUtils.avatarUrl(this.api.tracker.userPublicProps.avatar_id, this.api.avatarDomain)
97
+ return o
98
+ } else {
99
+ throw new Error('Tracker is not initialized, cannot getUserProfile')
100
+ }
101
+ }
102
+
103
+ /** Check if user belongs to specific segments
104
+ * **Example**:
105
+ * ```
106
+ * _smartico.api.checkSegmentMatch(1).then((result) => {
107
+ * console.log(result);
108
+ * });
109
+ * ```
110
+ *
111
+ * **Visitor mode: not supported**
112
+ */
113
+ public async checkSegmentMatch(segment_id: number): Promise<boolean> {
114
+ const r = await this.api.coreCheckSegments(null, [segment_id])
115
+ if (r && r.find((s) => s.segment_id === segment_id && s.is_matching)) {
116
+ return true
117
+ } else {
118
+ return false
119
+ }
120
+ }
121
+
122
+ /** Check if user belongs to specific list of segments
123
+ * **Example**:
124
+ * ```
125
+ * _smartico.api.checkSegmentListMatch([1, 2, 3]).then((result) => {
126
+ * console.log(result);
127
+ * });
128
+ * ```
129
+ * **Visitor mode: not supported**
130
+ */
131
+ public async checkSegmentListMatch(segment_ids: number[]): Promise<TSegmentCheckResult[]> {
132
+ return await this.api.coreCheckSegments(null, Array.isArray(segment_ids) ? segment_ids : [segment_ids])
133
+ }
134
+
135
+ /** Returns all the levels available the current user
136
+ * **Example**:
137
+ * ```
138
+ * _smartico.api.getLevels().then((result) => {
139
+ * console.log(result);
140
+ * });
141
+ * ```
142
+ *
143
+ * **Example in the Visitor mode**:
144
+ * ```
145
+ * _smartico.vapi('EN').getLevels().then((result) => {
146
+ * console.log(result);
147
+ * });
148
+ * ```
149
+ */
150
+ public async getLevels(): Promise<TLevel[]> {
151
+ return OCache.use(onUpdateContextKey.Levels, ECacheContext.WSAPI, () => this.api.levelsGetT(null), CACHE_DATA_SEC)
152
+ }
153
+
154
+ /** Returns all the missions available the current user.
155
+ * The returned missions are cached for 30 seconds. But you can pass the onUpdate callback as a parameter.
156
+ * Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
157
+ * The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it.
158
+ *
159
+ * **Example**:
160
+ * ```
161
+ * _smartico.api.getMissions().then((result) => {
162
+ * console.log(result);
163
+ * });
164
+ * ```
165
+ *
166
+ * **Example in the Visitor mode**:
167
+ * ```
168
+ * _smartico.vapi('EN').getMissions().then((result) => {
169
+ * console.log(result);
170
+ * });
171
+ * ```
172
+ */
173
+ public async getMissions({ onUpdate }: { onUpdate?: (data: TMissionOrBadge[]) => void } = {}): Promise<TMissionOrBadge[]> {
174
+ if (onUpdate) {
175
+ this.onUpdateCallback.set(onUpdateContextKey.Missions, onUpdate)
176
+ }
177
+
178
+ return OCache.use(onUpdateContextKey.Missions, ECacheContext.WSAPI, () => this.api.missionsGetItemsT(null), CACHE_DATA_SEC)
179
+ }
180
+
181
+ /**
182
+ * Returns all the badges available the current user
183
+ *
184
+ * **Visitor mode: not supported**
185
+ */
186
+ public async getBadges(): Promise<TMissionOrBadge[]> {
187
+ return OCache.use(onUpdateContextKey.Badges, ECacheContext.WSAPI, () => this.api.badgetsGetItemsT(null), CACHE_DATA_SEC)
188
+ }
189
+
190
+ /**
191
+ * Returns the extra counters for the current user level.
192
+ * These are counters that are configured for each Smartico client separatly by request.
193
+ * For example 1st counter could be total wagering amount, 2nd counter could be total deposit amount, etc.
194
+ *
195
+ * **Example**:
196
+ * ```
197
+ * _smartico.api.getUserLevelExtraCounters().then((result) => {
198
+ * console.log(result);
199
+ * });
200
+ * ```
201
+ *
202
+ * **Visitor mode: not supported**
203
+ */
204
+ public async getUserLevelExtraCounters(): Promise<UserLevelExtraCountersT> {
205
+ return OCache.use(onUpdateContextKey.LevelExtraCounters, ECacheContext.WSAPI, () => this.api.getUserGamificationInfoT(null), CACHE_DATA_SEC)
206
+ }
207
+
208
+ /**
209
+ *
210
+ * Returns all the store items available the current user
211
+ *
212
+ * **Example**:
213
+ * ```
214
+ * _smartico.api.getStoreItems().then((result) => {
215
+ * console.log(result);
216
+ * });
217
+ * ```
218
+ *
219
+ * **Example in the Visitor mode**:
220
+ * ```
221
+ * _smartico.vapi('EN').getStoreItems().then((result) => {
222
+ * console.log(result);
223
+ * });
224
+ * ```
225
+ */
226
+
227
+ public async getStoreItems(): Promise<TStoreItem[]> {
228
+ return OCache.use(onUpdateContextKey.StoreItems, ECacheContext.WSAPI, () => this.api.storeGetItemsT(null), CACHE_DATA_SEC)
229
+ }
230
+
231
+ /** Buy the specific shop item by item_id. Returns the err_code in case of success or error.
232
+ * **Example**:
233
+ * ```
234
+ * _smartico.api.buyStoreItem(1).then((result) => {
235
+ * console.log(result);
236
+ * });
237
+ * ```
238
+ *
239
+ * **Visitor mode: not supported**
240
+ */
241
+ public async buyStoreItem(item_id: number): Promise<TBuyStoreItemResult> {
242
+ const r = await this.api.buyStoreItem(null, item_id)
243
+
244
+ const o: TBuyStoreItemResult = {
245
+ err_code: r.errCode,
246
+ err_message: r.errMsg,
247
+ }
248
+
249
+ return o
250
+ }
251
+
252
+ /**
253
+ *
254
+ * Returns store categories
255
+ *
256
+ * **Example**:
257
+ * ```
258
+ * _smartico.api.getStoreCategories().then((result) => {
259
+ * console.log(result);
260
+ * });
261
+ * ```
262
+ *
263
+ * **Example in the Visitor mode**:
264
+ * ```
265
+ * _smartico.vapi('EN').getStoreCategories().then((result) => {
266
+ * console.log(result);
267
+ * });
268
+ * ```
269
+ */
270
+ public async getStoreCategories(): Promise<TStoreCategory[]> {
271
+ return OCache.use(onUpdateContextKey.StoreCategories, ECacheContext.WSAPI, () => this.api.storeGetCategoriesT(null), CACHE_DATA_SEC)
272
+ }
273
+
274
+ /**
275
+ * Returns purchased items based on the provided parameters. "Limit" and "offset" indicate the range of items to be fetched.
276
+ * The maximum number of items per request is limited to 20.
277
+ * You can leave this params empty and by default it will return list of purchased items ranging from 0 to 20.
278
+ *
279
+ * **Example**:
280
+ * ```
281
+ * _smartico.api.getStorePurchasedItems().then((result) => {
282
+ * console.log(result);
283
+ * });
284
+ * ```
285
+ *
286
+ * **Visitor mode: not supported**
287
+ */
288
+
289
+ public async getStorePurchasedItems({ limit, offset, onUpdate }: { limit?: number; offset?: number; onUpdate?: (data: TStoreItem[]) => void } = {}): Promise<TStoreItem[]> {
290
+ if (onUpdate) {
291
+ this.onUpdateCallback.set(onUpdateContextKey.StoreHistory, onUpdate)
292
+ }
293
+ return OCache.use(onUpdateContextKey.StoreHistory, ECacheContext.WSAPI, () => this.api.storeGetPurchasedItemsT(null, limit, offset), CACHE_DATA_SEC)
294
+ }
295
+
296
+ /**
297
+ * Returns missions & badges categories
298
+ *
299
+ * **Example**:
300
+ * ```
301
+ * _smartico.api.getAchCategories().then((result) => {
302
+ * console.log(result);
303
+ * });
304
+ * ```
305
+ *
306
+ * **Example in the Visitor mode**:
307
+ * ```
308
+ * _smartico.vapi('EN').getAchCategories().then((result) => {
309
+ * console.log(result);
310
+ * });
311
+ * ```
312
+ *
313
+ * */
314
+ public async getAchCategories(): Promise<TAchCategory[]> {
315
+ return OCache.use(onUpdateContextKey.AchCategories, ECacheContext.WSAPI, () => this.api.achGetCategoriesT(null), CACHE_DATA_SEC)
316
+ }
317
+
318
+ /**
319
+ * Returns list of custom sections
320
+ *
321
+ * **Example**:
322
+ * ```
323
+ * _smartico.api.getCustomSections().then((result) => {
324
+ * console.log(result);
325
+ * });
326
+ * ```
327
+ *
328
+ * **Example in the Visitor mode**:
329
+ * ```
330
+ * _smartico.vapi('EN').getCustomSections().then((result) => {
331
+ * console.log(result);
332
+ * });
333
+ * ```
334
+ *
335
+ * */
336
+ public async getCustomSections(): Promise<TUICustomSection[]> {
337
+ return OCache.use(onUpdateContextKey.CustomSections, ECacheContext.WSAPI, () => this.api.getCustomSectionsT(null), CACHE_DATA_SEC)
338
+ }
339
+
340
+ /**
341
+ * Returns the list of mini-games available for user
342
+ * The returned list of mini-games is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getMiniGames with a new onUpdate callback, the old one will be overwritten by the new one.
343
+ * The onUpdate callback will be called on available spin count change, if mini-game has increasing jackpot per spin or wined prize is spin/jackpot and if max count of the available user spin equal one, also if the spins were issued to the user manually in the BO. Updated templates will be passed to onUpdate callback.
344
+ *
345
+ * **Example**:
346
+ * ```
347
+ * _smartico.api.getMiniGames().then((result) => {
348
+ * console.log(result);
349
+ * });
350
+ * ```
351
+ *
352
+ * **Example in the Visitor mode**:
353
+ * ```
354
+ * _smartico.vapi('EN').getMiniGames().then((result) => {
355
+ * console.log(result);
356
+ * });
357
+ * ```
358
+ *
359
+ */
360
+ public async getMiniGames({ onUpdate }: { onUpdate?: (data: TMiniGameTemplate[]) => void } = {}): Promise<TMiniGameTemplate[]> {
361
+ if (onUpdate) {
362
+ this.onUpdateCallback.set(onUpdateContextKey.Saw, onUpdate)
363
+ }
364
+
365
+ return OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC)
366
+ }
367
+
368
+ /**
369
+ * Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
370
+ *
371
+ * **Visitor mode: not supported**
372
+ */
373
+ public async playMiniGame(template_id: number): Promise<TMiniGamePlayResult> {
374
+ const r = await this.api.sawSpinRequest(null, template_id)
375
+ this.api.doAcknowledgeRequest(null, r.request_id)
376
+
377
+ const o: TMiniGamePlayResult = {
378
+ err_code: r.errCode,
379
+ err_message: r.errMsg,
380
+ prize_id: r.saw_prize_id,
381
+ }
382
+
383
+ return o
384
+ }
385
+
386
+ /**
387
+ * Requests an opt-in for the specified mission_id. Returns the err_code.
388
+ *
389
+ * **Visitor mode: not supported**
390
+ */
391
+ public async requestMissionOptIn(mission_id: number): Promise<TMissionOptInResult> {
392
+ const r = await this.api.missionOptIn(null, mission_id)
393
+
394
+ const o: TMissionOptInResult = {
395
+ err_code: r.errCode,
396
+ err_message: r.errMsg,
397
+ }
398
+
399
+ return o
400
+ }
401
+
402
+ /**
403
+ * Request for claim reward for the specified mission id. Returns the err_code.
404
+ *
405
+ * **Visitor mode: not supported**
406
+ */
407
+ public async requestMissionClaimReward(mission_id: number, ach_completed_id: number): Promise<TMissionClaimRewardResult> {
408
+ const r = await this.api.missionClaimPrize(null, mission_id, ach_completed_id)
409
+
410
+ const o: TMissionClaimRewardResult = {
411
+ err_code: r.errCode,
412
+ err_message: r.errMsg,
413
+ }
414
+
415
+ return o
416
+ }
417
+
418
+ /** Returns all the active instances of tournaments
419
+ * The returned list is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getTournamentsList with a new onUpdate callback, the old one will be overwritten by the new one.
420
+ * The onUpdate callback will be called when the user has registered in a tournament. Updated list will be passed to onUpdate callback.
421
+ *
422
+ * **Example**:
423
+ * ```
424
+ * _smartico.api.getTournamentsList().then((result) => {
425
+ * console.log(result);
426
+ * });
427
+ * ```
428
+ *
429
+ * **Example in the Visitor mode**:
430
+ * ```
431
+ * _smartico.vapi('EN').getTournamentsList().then((result) => {
432
+ * console.log(result);
433
+ * });
434
+ * ```
435
+ * */
436
+ public async getTournamentsList({ onUpdate }: { onUpdate?: (data: TTournament[]) => void } = {}): Promise<TTournament[]> {
437
+ if (onUpdate) {
438
+ this.onUpdateCallback.set(onUpdateContextKey.TournamentList, onUpdate)
439
+ }
440
+
441
+ return OCache.use(onUpdateContextKey.TournamentList, ECacheContext.WSAPI, () => this.api.tournamentsGetLobbyT(null), CACHE_DATA_SEC)
442
+ }
443
+
444
+ /**
445
+ * Returns details information of specific tournament instance, the response will include tournament info and the leaderboard of players
446
+ *
447
+ * **Example**:
448
+ * ```
449
+ * _smartico.api.getTournamentsList().then((result) => {
450
+ * if (result.length > 0) {
451
+ * _smartico.api.getTournamentInstanceInfo(result[0].instance_id).then((result) => {
452
+ * console.log(result);
453
+ * });
454
+ * }
455
+ * });
456
+ * ```
457
+ *
458
+ * **Example in the Visitor mode**:
459
+ * ```
460
+ * _smartico.vapi('EN').getTournamentsList().then((result) => {
461
+ * if (result.length > 0) {
462
+ * _smartico.vapi('EN').getTournamentInstanceInfo(result[0].instance_id).then((result) => {
463
+ * console.log(result);
464
+ * });
465
+ * }
466
+ * });
467
+ * ```
468
+ */
469
+ public async getTournamentInstanceInfo(tournamentInstanceId: number): Promise<TTournamentDetailed> {
470
+ return this.api.tournamentsGetInfoT(null, tournamentInstanceId)
471
+ }
472
+
473
+ /**
474
+ * Requests registration for the specified tournament instance. Returns the err_code.
475
+ *
476
+ * **Visitor mode: not supported**
477
+ */
478
+ public async registerInTournament(tournamentInstanceId: number): Promise<TTournamentRegistrationResult> {
479
+ const r = await this.api.registerInTournament(null, tournamentInstanceId)
480
+
481
+ const o: TTournamentRegistrationResult = {
482
+ err_code: r.errCode,
483
+ err_message: r.errMsg,
484
+ }
485
+
486
+ return o
487
+ }
488
+
489
+ /**
490
+ * Returns the leaderboard for the current type (default is Daily). If getPreviousPeriod is passed as true, a leaderboard for the previous period for the current type will be returned.
491
+ * For example, if the type is Weekly and getPreviousPeriod is true, a leaderboard for the previous week will be returned.
492
+ *
493
+ * **Example**:
494
+ * ```
495
+ * _smartico.api.getLeaderBoard(1).then((result) => {
496
+ * console.log(result);
497
+ * });
498
+ * ```
499
+ *
500
+ * **Example in the Visitor mode**:
501
+ * ```
502
+ * _smartico.vapi('EN').getLeaderBoard(1).then((result) => {
503
+ * console.log(result);
504
+ * });
505
+ * ```
506
+ */
507
+ public async getLeaderBoard(periodType: LeaderBoardPeriodType, getPreviousPeriod?: boolean): Promise<LeaderBoardDetailsT> {
508
+ return OCache.use(onUpdateContextKey.LeaderBoards, ECacheContext.WSAPI, () => this.api.leaderboardsGetT(null, periodType, getPreviousPeriod), CACHE_DATA_SEC)
509
+ }
510
+
511
+ /** Returns inbox messages based on the provided parameters. "From" and "to" indicate the range of messages to be fetched.
512
+ * The maximum number of messages per request is limited to 20. An indicator "onlyFavorite" can be passed to get only messages marked as favorites.
513
+ * You can leave this params empty and by default it will return list of messages ranging from 0 to 20.
514
+ * This functions return list of messages without the body of the message.
515
+ * To get the body of the message you need to call getInboxMessageBody function and pass the message guid contained in each message of this request.
516
+ * All other action like mark as read, favorite, delete, etc. can be done using this message GUID.
517
+ * The "onUpdate" callback will be triggered when the user receives a new message. It will provide an updated list of messages, ranging from 0 to 20, to the onUpdate callback function.
518
+ *
519
+ * **Visitor mode: not supported**
520
+ *
521
+ * @param params
522
+ */
523
+ public async getInboxMessages({ from, to, onlyFavorite, onUpdate }: { from?: number; to?: number; onlyFavorite?: boolean; onUpdate?: (data: TInboxMessage[]) => void } = {}): Promise<
524
+ TInboxMessage[]
525
+ > {
526
+ if (onUpdate) {
527
+ this.onUpdateCallback.set(onUpdateContextKey.InboxMessages, onUpdate)
528
+ }
529
+
530
+ return await this.api.getInboxMessagesT(null, from, to, onlyFavorite)
531
+ }
532
+
533
+ /**
534
+ * Returns the message body of the specified message guid.
535
+ *
536
+ * **Visitor mode: not supported**
537
+ */
538
+ public async getInboxMessageBody(messageGuid: string): Promise<TInboxMessageBody> {
539
+ return await this.api.getInboxMessageBodyT(messageGuid)
540
+ }
541
+
542
+ /**
543
+ * Requests to mark inbox message with specified guid as read
544
+ *
545
+ * **Visitor mode: not supported**
546
+ */
547
+ public async markInboxMessageAsRead(messageGuid: string): Promise<InboxMarkMessageAction> {
548
+ const r = await this.api.markInboxMessageRead(null, messageGuid)
549
+
550
+ return {
551
+ err_code: r.errCode,
552
+ err_message: r.errMsg,
553
+ }
554
+ }
555
+
556
+ /**
557
+ * Requests to mark all inbox messages as rea
558
+ *
559
+ * **Visitor mode: not supported**
560
+ */
561
+ public async markAllInboxMessagesAsRead(): Promise<InboxMarkMessageAction> {
562
+ const r = await this.api.markAllInboxMessageRead(null)
563
+
564
+ return {
565
+ err_code: r.errCode,
566
+ err_message: r.errMsg,
567
+ }
568
+ }
569
+
570
+ /**
571
+ * Requests to mark inbox message with specified guid as favorite. Pass mark true to add message to favorite and false to remove.
572
+ *
573
+ * **Visitor mode: not supported**
574
+ */
575
+ public async markUnmarkInboxMessageAsFavorite(messageGuid: string, mark: boolean): Promise<InboxMarkMessageAction> {
576
+ const r = await this.api.markUnmarkInboxMessageAsFavorite(null, messageGuid, mark)
577
+
578
+ return {
579
+ err_code: r.errCode,
580
+ err_message: r.errMsg,
581
+ }
582
+ }
583
+
584
+ /**
585
+ * Requests to delete inbox message
586
+ *
587
+ * **Visitor mode: not supported**
588
+ */
589
+
590
+ public async deleteInboxMessage(messageGuid: string): Promise<InboxMarkMessageAction> {
591
+ const r = await this.api.deleteInboxMessage(null, messageGuid)
592
+
593
+ return {
594
+ err_code: r.errCode,
595
+ err_message: r.errMsg,
596
+ }
597
+ }
598
+
599
+ /**
600
+ * Requests to delete all inbox messages
601
+ *
602
+ * **Visitor mode: not supported**
603
+ */
604
+
605
+ public async deleteAllInboxMessages(): Promise<InboxMarkMessageAction> {
606
+ const r = await this.api.deleteAllInboxMessages(null)
607
+
608
+ return {
609
+ err_code: r.errCode,
610
+ err_message: r.errMsg,
611
+ }
612
+ }
613
+
614
+ /**
615
+ * Requests translations for the given language. Returns the object including translation key/translation value pairs. All possible translation keys defined in the back office.
616
+ */
617
+ public async getTranslations(lang_code: string): Promise<TGetTranslations> {
618
+ const r = await this.api.getTranslationsT(null, lang_code, [])
619
+
620
+ return {
621
+ translations: r.translations,
622
+ }
623
+ }
624
+
625
+ private async updateOnSpin(data: SAWSpinsCountPush) {
626
+ const templates: TMiniGameTemplate[] = await OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC)
627
+ const index = templates.findIndex((t) => t.id === data.saw_template_id)
628
+ templates[index].spin_count = data.spin_count
629
+ this.updateEntity(onUpdateContextKey.Saw, templates)
630
+ }
631
+
632
+ private async updateOnAddSpin() {
633
+ const payload = await this.api.sawGetTemplatesT(null)
634
+ this.updateEntity(onUpdateContextKey.Saw, payload)
635
+ }
636
+
637
+ private async updateOnPrizeWin(data: SAWDoSpinResponse) {
638
+ if (data.errCode === SAWSpinErrorCode.SAW_OK) {
639
+ const templates: TMiniGameTemplate[] = await OCache.use(onUpdateContextKey.Saw, ECacheContext.WSAPI, () => this.api.sawGetTemplatesT(null), CACHE_DATA_SEC)
640
+ const template: TMiniGameTemplate = templates.find((t) => t.prizes.find((p) => p.id === data.saw_prize_id))
641
+ const prizeType = template.prizes.find((p) => p.id === data.saw_prize_id)?.prize_type
642
+
643
+ if (template.jackpot_add_on_attempt || template.spin_count === 1 || prizeType === MiniGamePrizeTypeName.JACKPOT || prizeType === MiniGamePrizeTypeName.SPIN) {
644
+ const updatedTemplates = await this.api.sawGetTemplatesT(null)
645
+ this.updateEntity(onUpdateContextKey.Saw, updatedTemplates)
646
+ }
647
+ }
648
+ }
649
+
650
+ private async updateMissionsOnOptIn() {
651
+ const payload = await this.api.missionsGetItemsT(null)
652
+ this.updateEntity(onUpdateContextKey.Missions, payload)
653
+ }
654
+
655
+ private async updateTournamentsOnRegistration() {
656
+ const payload = await this.api.tournamentsGetLobbyT(null)
657
+ this.updateEntity(onUpdateContextKey.TournamentList, payload)
658
+ }
659
+
660
+ private async updateInboxMessages() {
661
+ const payload = await this.api.getInboxMessagesT(null)
662
+ this.updateEntity(onUpdateContextKey.InboxMessages, payload)
663
+ }
664
+
665
+ private async updateEntity(contextKey: onUpdateContextKey, payload: any) {
666
+ OCache.set(contextKey, payload, ECacheContext.WSAPI)
667
+
668
+ const onUpdate = this.onUpdateCallback.get(contextKey)
669
+ if (onUpdate) {
670
+ onUpdate(payload)
671
+ }
672
+ }
673
+
674
+ private async jackpotClearCache() {
675
+ OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Jackpots)
676
+ OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Pots)
677
+ }
678
+
679
+ /** Returns list of Jackpots that are active in the systen and matching to the filter definition.
680
+ * If filter is not provided, all active jackpots will be returned.
681
+ * Filter can be used to get jackpots related to specific game or specific jackpot template.
682
+ * You can call this method every second in order to get up to date information about current value of the jackpot(s) and present them to the end-users
683
+ *
684
+ * **Example**:
685
+ * ```
686
+ * _smartico.api.jackpotGet({ related_game_id: 'wooko-slot' }).then((result) => {
687
+ * console.log(result);
688
+ * });
689
+ * ```
690
+ *
691
+ * **Example in the Visitor mode**:
692
+ * ```
693
+ * _smartico.vapi('EN').jackpotGet({ related_game_id: 'wooko-slot' }).then((result) => {
694
+ * console.log(result);
695
+ * });
696
+ * ```
697
+ */
698
+ public async jackpotGet(filter?: { related_game_id?: string; jp_template_id?: number }): Promise<JackpotDetails[]> {
699
+ const signature: string = `${filter?.jp_template_id}:${filter?.related_game_id}`
700
+
701
+ if (signature !== this.jackpotGetSignature) {
702
+ this.jackpotGetSignature = signature
703
+ this.jackpotClearCache()
704
+ }
705
+
706
+ let jackpots: JackpotDetails[] = []
707
+ let pots: JackpotPot[] = []
708
+
709
+ jackpots = await OCache.use<JackpotDetails[]>(
710
+ onUpdateContextKey.Jackpots,
711
+ ECacheContext.WSAPI,
712
+ async () => {
713
+ const _jackpots = await this.api.jackpotGet(null, filter)
714
+ const _pots = _jackpots.items.map((jp) => jp.pot)
715
+
716
+ OCache.set(onUpdateContextKey.Pots, _pots, ECacheContext.WSAPI, JACKPOT_POT_CACHE_SEC)
717
+ return _jackpots.items
718
+ },
719
+ JACKPOT_TEMPLATE_CACHE_SEC,
720
+ )
721
+
722
+ if (jackpots.length > 0) {
723
+ pots = await OCache.use<JackpotPot[]>(
724
+ onUpdateContextKey.Pots,
725
+ ECacheContext.WSAPI,
726
+ async () => {
727
+ const jp_template_ids = jackpots.map((jp) => jp.jp_template_id)
728
+ return (await this.api.potGet(null, { jp_template_ids })).items
729
+ },
730
+ JACKPOT_POT_CACHE_SEC,
731
+ )
732
+ }
733
+
734
+ return jackpots.map((jp) => {
735
+ let _jp: JackpotDetails = {
736
+ ...jp,
737
+ pot: pots.find((p) => p.jp_template_id === jp.jp_template_id),
738
+ }
739
+ return _jp
740
+ })
741
+ }
742
+
743
+ /**
744
+ * Opt-in currently logged in user to the jackpot with the specified jp_template_id.
745
+ * You may call jackpotGet method after doing optin to see that user is opted in to the jackpot.
746
+ *
747
+ * **Example**:
748
+ * ```
749
+ * _smartico.api.jackpotOptIn({ jp_template_id: 123 }).then((result) => {
750
+ * console.log('Opted in to the jackpot');
751
+ * });
752
+ * ```
753
+ *
754
+ * **Visitor mode: not supported**
755
+ *
756
+ */
757
+ public async jackpotOptIn(filter: { jp_template_id: number }): Promise<JackpotsOptinResponse> {
758
+ if (!filter.jp_template_id) {
759
+ throw new Error('jp_template_id is required in jackpotOptIn')
760
+ }
761
+
762
+ const result = await this.api.jackpotOptIn(null, filter)
763
+
764
+ return result
765
+ }
766
+
767
+ /**
768
+ * Opt-out currently logged in user from the jackpot with the specified jp_template_id.
769
+ * You may call jackpotGet method after doing optout to see that user is not opted in to the jackpot.
770
+ *
771
+ * **Example**:
772
+ * ```
773
+ * _smartico.api.jackpotOptOut({ jp_template_id: 123 }).then((result) => {
774
+ * console.log('Opted out from the jackpot');
775
+ * });
776
+ * ```
777
+ *
778
+ * **Visitor mode: not supported**
779
+ *
780
+ */
781
+ public async jackpotOptOut(filter: { jp_template_id: number }): Promise<JackpotsOptoutResponse> {
782
+ if (!filter.jp_template_id) {
783
+ throw new Error('jp_template_id is required in jackpotOptOut')
784
+ }
785
+
786
+ const result = await this.api.jackpotOptOut(null, filter)
787
+
788
+ return result
789
+ }
772
790
  }