@smartico/public-api 0.0.378 → 0.0.380

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 (99) hide show
  1. package/.nvmrc +1 -1
  2. package/README.md +31 -2
  3. package/dist/Store/BuyStoreItemErrorCode.d.ts +9 -1
  4. package/dist/Tournaments/TournamentRegistrationError.d.ts +3 -1
  5. package/dist/WSAPI/WSAPI.d.ts +13 -1235
  6. package/dist/WSAPI/WSAPIAvatars.d.ts +78 -0
  7. package/dist/WSAPI/WSAPIBase.d.ts +71 -0
  8. package/dist/WSAPI/WSAPIBonuses.d.ts +26 -0
  9. package/dist/WSAPI/WSAPIClans.d.ts +388 -0
  10. package/dist/WSAPI/WSAPIGamePick.d.ts +308 -0
  11. package/dist/WSAPI/WSAPIGeneral.d.ts +30 -0
  12. package/dist/WSAPI/WSAPIInbox.d.ts +126 -0
  13. package/dist/WSAPI/WSAPIJackpots.d.ts +109 -0
  14. package/dist/WSAPI/WSAPILeaderBoard.d.ts +25 -0
  15. package/dist/WSAPI/WSAPIMiniGames.d.ts +94 -0
  16. package/dist/WSAPI/WSAPIMissions.d.ts +517 -0
  17. package/dist/WSAPI/WSAPIRaffles.d.ts +119 -0
  18. package/dist/WSAPI/WSAPIStore.d.ts +656 -0
  19. package/dist/WSAPI/WSAPITournaments.d.ts +501 -0
  20. package/dist/WSAPI/WSAPITypes.d.ts +145 -85
  21. package/dist/WSAPI/WSAPIUser.d.ts +383 -0
  22. package/dist/index.js +3818 -1528
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.modern.mjs +3180 -981
  25. package/dist/index.modern.mjs.map +1 -1
  26. package/docs/api/README.md +56 -2
  27. package/docs/api/classes/WSAPIAvatars.md +116 -0
  28. package/docs/api/classes/WSAPIBonuses.md +50 -0
  29. package/docs/api/classes/WSAPIClans.md +66 -0
  30. package/docs/api/classes/WSAPIGamePick.md +181 -0
  31. package/docs/api/classes/WSAPIGeneral.md +63 -0
  32. package/docs/api/classes/WSAPIInbox.md +277 -0
  33. package/docs/api/classes/WSAPIJackpots.md +185 -0
  34. package/docs/api/classes/WSAPILeaderBoard.md +39 -0
  35. package/docs/api/classes/WSAPIMiniGames.md +175 -0
  36. package/docs/api/classes/WSAPIMissions.md +611 -0
  37. package/docs/api/classes/WSAPIRaffles.md +195 -0
  38. package/docs/api/classes/WSAPIStore.md +744 -0
  39. package/docs/api/classes/WSAPITournaments.md +104 -0
  40. package/docs/api/classes/WSAPIUser.md +200 -0
  41. package/docs/api/enumerations/AchievementClaimPeriodTypeId.md +13 -0
  42. package/docs/api/enumerations/BuyStoreItemErrorCode.md +32 -0
  43. package/docs/api/interfaces/ClanPrizePublicMeta.md +41 -0
  44. package/docs/api/interfaces/ClanPrizeStructureEntry.md +7 -1
  45. package/docs/api/interfaces/ClanPublicMeta.md +4 -0
  46. package/docs/api/interfaces/SAWTemplateUI.md +10 -0
  47. package/docs/api/interfaces/TAchCategory.md +19 -4
  48. package/docs/api/interfaces/TBuyStoreItemResult.md +26 -8
  49. package/docs/api/interfaces/TMissionClaimRewardResult.md +14 -3
  50. package/docs/api/interfaces/TMissionOptInResult.md +10 -3
  51. package/docs/api/interfaces/TMissionOrBadge.md +6 -2
  52. package/docs/api/interfaces/TStoreItem.md +21 -1
  53. package/docs/api/interfaces/TTournamentDetailed.md +8 -0
  54. package/docs/api/interfaces/UserAchievement.md +1 -1
  55. package/docs/ui/clans/UIGuide_getClanInfo.md +153 -0
  56. package/docs/ui/clans/UIGuide_getClans.md +172 -0
  57. package/docs/ui/clans/UIGuide_joinClan.md +196 -0
  58. package/docs/ui/missions/UIGuide_getAchCategories.md +17 -0
  59. package/docs/ui/missions/UIGuide_getBadges.md +237 -0
  60. package/docs/ui/missions/UIGuide_getMissions.md +268 -0
  61. package/docs/ui/missions/UIGuide_requestMissionClaimReward.md +21 -0
  62. package/docs/ui/missions/UIGuide_requestMissionOptIn.md +16 -0
  63. package/docs/ui/store/UIGuide_buyStoreItem.md +133 -0
  64. package/docs/ui/store/UIGuide_getStoreCategories.md +19 -0
  65. package/docs/ui/store/UIGuide_getStoreItems.md +264 -0
  66. package/docs/ui/store/UIGuide_getStorePurchasedItems.md +122 -0
  67. package/docs/ui/tournaments/UIGuide_getClanTournamentPlayers.md +140 -0
  68. package/docs/ui/tournaments/UIGuide_getTournamentInstanceInfo.md +265 -0
  69. package/docs/ui/tournaments/UIGuide_getTournamentsList.md +236 -0
  70. package/docs/ui/tournaments/UIGuide_registerInTournament.md +156 -0
  71. package/docs/ui/user/UIGuide_getLevels.md +162 -0
  72. package/docs/ui/user/UIGuide_getUserProfile.md +213 -0
  73. package/package.json +3 -3
  74. package/scripts/postdoc-cleanup.js +195 -0
  75. package/src/Missions/MissionsUtils.ts +5 -2
  76. package/src/Store/BuyStoreItemErrorCode.ts +8 -0
  77. package/src/Store/StoreItem.ts +1 -0
  78. package/src/Store/StoreItemPurchased.ts +1 -0
  79. package/src/Store/StoreItemType.ts +1 -1
  80. package/src/Tournaments/TournamentRegistrationError.ts +4 -0
  81. package/src/WSAPI/WSAPI.ts +27 -2007
  82. package/src/WSAPI/WSAPIAvatars.ts +127 -0
  83. package/src/WSAPI/WSAPIBase.ts +93 -0
  84. package/src/WSAPI/WSAPIBonuses.ts +54 -0
  85. package/src/WSAPI/WSAPIClans.ts +417 -0
  86. package/src/WSAPI/WSAPIGamePick.ts +382 -0
  87. package/src/WSAPI/WSAPIGeneral.ts +57 -0
  88. package/src/WSAPI/WSAPIInbox.ts +222 -0
  89. package/src/WSAPI/WSAPIJackpots.ts +212 -0
  90. package/src/WSAPI/WSAPILeaderBoard.ts +40 -0
  91. package/src/WSAPI/WSAPIMiniGames.ts +181 -0
  92. package/src/WSAPI/WSAPIMissions.ts +572 -0
  93. package/src/WSAPI/WSAPIRaffles.ts +175 -0
  94. package/src/WSAPI/WSAPIStore.ts +732 -0
  95. package/src/WSAPI/WSAPITournaments.ts +541 -0
  96. package/src/WSAPI/WSAPITypes.ts +145 -87
  97. package/src/WSAPI/WSAPIUser.ts +456 -0
  98. package/tsconfig.json +17 -1
  99. package/docs/api/classes/WSAPI.md +0 -1927
@@ -0,0 +1,175 @@
1
+ import { ECacheContext, OCache } from '../OCache';
2
+ import {
3
+ TRaffle,
4
+ TRaffleDraw,
5
+ TRaffleDrawRun,
6
+ TransformedRaffleClaimPrizeResponse,
7
+ TRaffleOptinResponse,
8
+ } from './WSAPITypes';
9
+ import {
10
+ drawRunHistoryTransform,
11
+ raffleClaimPrizeResponseTransform,
12
+ } from '../Raffle';
13
+ import {
14
+ CACHE_DATA_SEC,
15
+ onUpdateContextKey,
16
+ } from './WSAPIBase';
17
+ import { WSAPIJackpots } from './WSAPIJackpots';
18
+
19
+ /** @group Raffles */
20
+ export class WSAPIRaffles extends WSAPIJackpots {
21
+ protected async updateRaffles() {
22
+ const payload = await this.api.getRafflesT(this.userExtId);
23
+ this.updateEntity(onUpdateContextKey.Raffles, payload);
24
+ }
25
+
26
+ /**
27
+ * Returns the list of Raffles available for user
28
+ * The returned list of Raffles is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getRaffles with a new onUpdate callback, the old one will be overwritten by the new one.
29
+ * The onUpdate callback will be called on claiming prize. Updated Raffles will be passed to onUpdate callback.
30
+ *
31
+ * **Example**:
32
+ *
33
+ * ```
34
+ * _smartico.api.getRaffles().then((result) => {
35
+ * console.log(result);
36
+ * });
37
+ * ```
38
+ *
39
+ * **Example in the Visitor mode**:
40
+ *
41
+ * ```
42
+ * _smartico.vapi('EN').getRaffles().then((result) => {
43
+ * console.log(result);
44
+ * });
45
+ * ```
46
+ *
47
+ */
48
+
49
+ public async getRaffles({ onUpdate }: { onUpdate?: (data: TRaffle[]) => void } = {}): Promise<TRaffle[]> {
50
+ if (onUpdate) {
51
+ this.onUpdateCallback.set(onUpdateContextKey.Raffles, onUpdate);
52
+ }
53
+
54
+ return OCache.use(onUpdateContextKey.Raffles, ECacheContext.WSAPI, () => this.api.getRafflesT(this.userExtId), CACHE_DATA_SEC);
55
+ }
56
+
57
+ /**
58
+ * Returns draw run for provided raffle_id and run_id.
59
+ * You can pass winners_from and winners_to parameters to get a specific range of winners. Default is 0-20.
60
+ *
61
+ *
62
+ * **Example**:
63
+ *
64
+ * ```javascript
65
+ * _smartico.api.getRaffleDrawRun({raffle_id: 156, run_id: 145}).then((result) => {
66
+ * console.log(result);
67
+ * });
68
+ * ```
69
+ *
70
+ * **Example in the Visitor mode**:
71
+ *
72
+ *
73
+ * ```javascript
74
+ * _smartico.vapi('EN').getRaffleDrawRun({ raffle_id: 156, run_id: 145 }).then((result) => {
75
+ * console.log(result);
76
+ * });
77
+ * ```
78
+ *
79
+ */
80
+
81
+ public async getRaffleDrawRun(props: { raffle_id: number; run_id: number; winners_from?: number; winners_to?: number }): Promise<TRaffleDraw> {
82
+ if (!props.raffle_id || !props.run_id) {
83
+ throw new Error('both raffle_id and run_id are required');
84
+ }
85
+
86
+ return await this.api.getRaffleDrawRunT(this.userExtId, props.raffle_id, props.run_id, props.winners_from, props.winners_to);
87
+ }
88
+
89
+ /**
90
+ * Returns history of draw runs for the provided raffle_id and draw_id, if the draw_id is not provided will return history of all the draws for the provided raffle_id
91
+ *
92
+ *
93
+ * **Example**:
94
+ *
95
+ * ```javascript
96
+ * _smartico.api.getRaffleDrawRunsHistory({ raffle_id: 156, draw_id: 432 }).then((result) => {
97
+ * console.log(result);
98
+ * });
99
+ * ```
100
+ *
101
+ * **Example in the Visitor mode**:
102
+ *
103
+ * ```javascript
104
+ * _smartico.vapi('EN').getRaffleDrawRunsHistory({ raffle_id: 156, draw_id: 432 }).then((result) => {
105
+ * console.log(result);
106
+ * });
107
+ * ```
108
+ *
109
+ */
110
+
111
+ public async getRaffleDrawRunsHistory(props: { raffle_id: number; draw_id?: number }): Promise<TRaffleDrawRun[]> {
112
+
113
+ const res = await this.api.getRaffleDrawRunsHistory(this.userExtId, props);
114
+
115
+ if (!props.raffle_id) {
116
+ throw new Error('raffle_id is required');
117
+ }
118
+
119
+ return drawRunHistoryTransform(res);
120
+ }
121
+
122
+ /**
123
+ * Returns `err_code` and `err_message` after the call; `err_code` 0 means the request succeeded.
124
+ *
125
+ *
126
+ * **Example**:
127
+ *
128
+ * ```javascript
129
+ * _smartico.api.claimRafflePrize({won_id:251}).then((result) => {
130
+ * console.log(result);
131
+ * });
132
+ * ```
133
+ *
134
+ * **Example in the Visitor mode**:
135
+ *
136
+ * ```javascript
137
+ * _smartico.vapi('EN').claimRafflePrize({ won_id: 251 }).then((result) => {
138
+ * console.log(result);
139
+ * });
140
+ * ```
141
+ *
142
+ */
143
+ public async claimRafflePrize(props: { won_id: number }): Promise<TransformedRaffleClaimPrizeResponse> {
144
+ if (!props.won_id) {
145
+ throw new Error('won_id is required');
146
+ }
147
+
148
+ const res = await this.api.claimRafflePrize(this.userExtId, { won_id: props.won_id });
149
+ return raffleClaimPrizeResponseTransform(res);
150
+ }
151
+
152
+ /**
153
+ * Requests an opt-in for the specified raffle. Returns the err_code.
154
+ *
155
+ * **Visitor mode: not supported**
156
+ */
157
+ public async requestRaffleOptin(props: { raffle_id: number; draw_id: number; raffle_run_id: number }): Promise<TRaffleOptinResponse> {
158
+ if (!props.raffle_id) {
159
+ throw new Error('raffle_id is required');
160
+ }
161
+ if (!props.draw_id) {
162
+ throw new Error('draw_id is required');
163
+ }
164
+ if (!props.raffle_run_id) {
165
+ throw new Error('raffle_run_id is required');
166
+ }
167
+
168
+ const r = await this.api.raffleOptin(this.userExtId, props);
169
+
170
+ return {
171
+ err_code: r.errCode,
172
+ err_message: r.errMsg,
173
+ };
174
+ }
175
+ }