@smartico/public-api 0.0.379 → 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.
- package/.nvmrc +1 -1
- package/README.md +31 -2
- package/dist/Store/BuyStoreItemErrorCode.d.ts +9 -1
- package/dist/Tournaments/TournamentRegistrationError.d.ts +3 -1
- package/dist/WSAPI/WSAPI.d.ts +13 -1235
- package/dist/WSAPI/WSAPIAvatars.d.ts +78 -0
- package/dist/WSAPI/WSAPIBase.d.ts +71 -0
- package/dist/WSAPI/WSAPIBonuses.d.ts +26 -0
- package/dist/WSAPI/WSAPIClans.d.ts +388 -0
- package/dist/WSAPI/WSAPIGamePick.d.ts +308 -0
- package/dist/WSAPI/WSAPIGeneral.d.ts +30 -0
- package/dist/WSAPI/WSAPIInbox.d.ts +126 -0
- package/dist/WSAPI/WSAPIJackpots.d.ts +109 -0
- package/dist/WSAPI/WSAPILeaderBoard.d.ts +25 -0
- package/dist/WSAPI/WSAPIMiniGames.d.ts +94 -0
- package/dist/WSAPI/WSAPIMissions.d.ts +517 -0
- package/dist/WSAPI/WSAPIRaffles.d.ts +119 -0
- package/dist/WSAPI/WSAPIStore.d.ts +656 -0
- package/dist/WSAPI/WSAPITournaments.d.ts +501 -0
- package/dist/WSAPI/WSAPITypes.d.ts +145 -85
- package/dist/WSAPI/WSAPIUser.d.ts +383 -0
- package/dist/index.js +3818 -1528
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +3180 -981
- package/dist/index.modern.mjs.map +1 -1
- package/docs/api/README.md +56 -2
- package/docs/api/classes/WSAPIAvatars.md +116 -0
- package/docs/api/classes/WSAPIBonuses.md +50 -0
- package/docs/api/classes/WSAPIClans.md +66 -0
- package/docs/api/classes/WSAPIGamePick.md +181 -0
- package/docs/api/classes/WSAPIGeneral.md +63 -0
- package/docs/api/classes/WSAPIInbox.md +277 -0
- package/docs/api/classes/WSAPIJackpots.md +185 -0
- package/docs/api/classes/WSAPILeaderBoard.md +39 -0
- package/docs/api/classes/WSAPIMiniGames.md +175 -0
- package/docs/api/classes/WSAPIMissions.md +611 -0
- package/docs/api/classes/WSAPIRaffles.md +195 -0
- package/docs/api/classes/WSAPIStore.md +744 -0
- package/docs/api/classes/WSAPITournaments.md +104 -0
- package/docs/api/classes/WSAPIUser.md +200 -0
- package/docs/api/enumerations/AchievementClaimPeriodTypeId.md +13 -0
- package/docs/api/enumerations/BuyStoreItemErrorCode.md +32 -0
- package/docs/api/interfaces/ClanPrizePublicMeta.md +41 -0
- package/docs/api/interfaces/ClanPrizeStructureEntry.md +7 -1
- package/docs/api/interfaces/ClanPublicMeta.md +4 -0
- package/docs/api/interfaces/SAWTemplateUI.md +10 -0
- package/docs/api/interfaces/TAchCategory.md +19 -4
- package/docs/api/interfaces/TBuyStoreItemResult.md +26 -8
- package/docs/api/interfaces/TMissionClaimRewardResult.md +14 -3
- package/docs/api/interfaces/TMissionOptInResult.md +10 -3
- package/docs/api/interfaces/TMissionOrBadge.md +6 -2
- package/docs/api/interfaces/TStoreItem.md +21 -1
- package/docs/api/interfaces/TTournamentDetailed.md +8 -0
- package/docs/api/interfaces/UserAchievement.md +1 -1
- package/docs/ui/clans/UIGuide_getClanInfo.md +153 -0
- package/docs/ui/clans/UIGuide_getClans.md +172 -0
- package/docs/ui/clans/UIGuide_joinClan.md +196 -0
- package/docs/ui/missions/UIGuide_getAchCategories.md +17 -0
- package/docs/ui/missions/UIGuide_getBadges.md +237 -0
- package/docs/ui/missions/UIGuide_getMissions.md +268 -0
- package/docs/ui/missions/UIGuide_requestMissionClaimReward.md +21 -0
- package/docs/ui/missions/UIGuide_requestMissionOptIn.md +16 -0
- package/docs/ui/store/UIGuide_buyStoreItem.md +133 -0
- package/docs/ui/store/UIGuide_getStoreCategories.md +19 -0
- package/docs/ui/store/UIGuide_getStoreItems.md +264 -0
- package/docs/ui/store/UIGuide_getStorePurchasedItems.md +122 -0
- package/docs/ui/tournaments/UIGuide_getClanTournamentPlayers.md +140 -0
- package/docs/ui/tournaments/UIGuide_getTournamentInstanceInfo.md +265 -0
- package/docs/ui/tournaments/UIGuide_getTournamentsList.md +236 -0
- package/docs/ui/tournaments/UIGuide_registerInTournament.md +156 -0
- package/docs/ui/user/UIGuide_getLevels.md +162 -0
- package/docs/ui/user/UIGuide_getUserProfile.md +213 -0
- package/package.json +3 -3
- package/scripts/postdoc-cleanup.js +195 -0
- package/src/Missions/MissionsUtils.ts +5 -2
- package/src/Store/BuyStoreItemErrorCode.ts +8 -0
- package/src/Store/StoreItem.ts +1 -0
- package/src/Store/StoreItemPurchased.ts +1 -0
- package/src/Store/StoreItemType.ts +1 -1
- package/src/Tournaments/TournamentRegistrationError.ts +4 -0
- package/src/WSAPI/WSAPI.ts +27 -2007
- package/src/WSAPI/WSAPIAvatars.ts +127 -0
- package/src/WSAPI/WSAPIBase.ts +93 -0
- package/src/WSAPI/WSAPIBonuses.ts +54 -0
- package/src/WSAPI/WSAPIClans.ts +417 -0
- package/src/WSAPI/WSAPIGamePick.ts +382 -0
- package/src/WSAPI/WSAPIGeneral.ts +57 -0
- package/src/WSAPI/WSAPIInbox.ts +222 -0
- package/src/WSAPI/WSAPIJackpots.ts +212 -0
- package/src/WSAPI/WSAPILeaderBoard.ts +40 -0
- package/src/WSAPI/WSAPIMiniGames.ts +181 -0
- package/src/WSAPI/WSAPIMissions.ts +572 -0
- package/src/WSAPI/WSAPIRaffles.ts +175 -0
- package/src/WSAPI/WSAPIStore.ts +732 -0
- package/src/WSAPI/WSAPITournaments.ts +541 -0
- package/src/WSAPI/WSAPITypes.ts +145 -87
- package/src/WSAPI/WSAPIUser.ts +456 -0
- package/tsconfig.json +17 -1
- 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
|
+
}
|