@smartico/public-api 0.0.339 → 0.0.340
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/dist/ActivityLog/GetActivityLogRequest.d.ts +2 -0
- package/dist/SmarticoAPI.d.ts +2 -2
- package/dist/WSAPI/WSAPI.d.ts +7 -1
- package/dist/index.js +22 -6
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +16 -6
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +3 -3
- package/docs/classes/WSAPI.md +11 -7
- package/docs/interfaces/{TPointsHistoryLog.md → TActivityLog.md} +2 -2
- package/package.json +1 -1
- package/src/ActivityLog/GetActivityLogRequest.ts +2 -0
- package/src/SmarticoAPI.ts +10 -1
- package/src/WSAPI/WSAPI.ts +10 -2
package/docs/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
## Enumerations
|
|
4
4
|
|
|
5
|
+
- [PointChangeSourceType](enums/PointChangeSourceType.md)
|
|
6
|
+
- [UserBalanceType](enums/UserBalanceType.md)
|
|
5
7
|
- [BonusStatus](enums/BonusStatus.md)
|
|
6
8
|
- [AchCustomSectionType](enums/AchCustomSectionType.md)
|
|
7
9
|
- [AchCustomLayoutTheme](enums/AchCustomLayoutTheme.md)
|
|
@@ -32,8 +34,6 @@
|
|
|
32
34
|
- [SAWWheelLayout](enums/SAWWheelLayout.md)
|
|
33
35
|
- [SAWWinSoundType](enums/SAWWinSoundType.md)
|
|
34
36
|
- [AchievementAvailabilityStatus](enums/AchievementAvailabilityStatus.md)
|
|
35
|
-
- [PointChangeSourceType](enums/PointChangeSourceType.md)
|
|
36
|
-
- [UserBalanceType](enums/UserBalanceType.md)
|
|
37
37
|
- [RaffleDrawInstanceState](enums/RaffleDrawInstanceState.md)
|
|
38
38
|
- [RaffleDrawTypeExecution](enums/RaffleDrawTypeExecution.md)
|
|
39
39
|
- [BuyStoreItemErrorCode](enums/BuyStoreItemErrorCode.md)
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
- [TRaffleDraw](interfaces/TRaffleDraw.md)
|
|
151
151
|
- [TRaffleDrawRun](interfaces/TRaffleDrawRun.md)
|
|
152
152
|
- [TransformedRaffleClaimPrizeResponse](interfaces/TransformedRaffleClaimPrizeResponse.md)
|
|
153
|
-
- [
|
|
153
|
+
- [TActivityLog](interfaces/TActivityLog.md)
|
|
154
154
|
- [TRaffleOptinResponse](interfaces/TRaffleOptinResponse.md)
|
|
155
155
|
|
|
156
156
|
## General API
|
package/docs/classes/WSAPI.md
CHANGED
|
@@ -986,24 +986,26 @@ _smartico.api.reportClickEvent({
|
|
|
986
986
|
|
|
987
987
|
___
|
|
988
988
|
|
|
989
|
-
###
|
|
989
|
+
### getActivityLog
|
|
990
990
|
|
|
991
|
-
▸ **
|
|
991
|
+
▸ **getActivityLog**(`«destructured»`): `Promise`\<[`TActivityLog`](../interfaces/TActivityLog.md)[]\>
|
|
992
992
|
|
|
993
|
-
Returns the
|
|
993
|
+
Returns the activity log for a user within a specified time range.
|
|
994
994
|
The response includes both points changes and gems/diamonds changes.
|
|
995
995
|
Each log entry contains information about the change amount, balance, and source.
|
|
996
996
|
The returned list is cached for 30 seconds.
|
|
997
|
-
You can pass the onUpdate callback as a parameter, it will be called every time the
|
|
997
|
+
You can pass the onUpdate callback as a parameter, it will be called every time the activity log is updated and will provide the updated list of activity logs for the last 10 minutes.
|
|
998
998
|
|
|
999
999
|
**Example**:
|
|
1000
1000
|
```
|
|
1001
1001
|
const startTime = Math.floor(Date.now() / 1000) - 86400 * 30; // 30 days ago
|
|
1002
1002
|
const endTime = Math.floor(Date.now() / 1000); // now
|
|
1003
1003
|
|
|
1004
|
-
_smartico.api.
|
|
1004
|
+
_smartico.api.getActivityLog({
|
|
1005
1005
|
startTimeSeconds: startTime,
|
|
1006
1006
|
endTimeSeconds: endTime,
|
|
1007
|
+
from: 0,
|
|
1008
|
+
to: 50,
|
|
1007
1009
|
onUpdate: (data) => console.log('Updated:', data)
|
|
1008
1010
|
}).then((result) => {
|
|
1009
1011
|
console.log(result);
|
|
@@ -1019,11 +1021,13 @@ _smartico.api.getPointsHistory({
|
|
|
1019
1021
|
| `«destructured»` | `Object` |
|
|
1020
1022
|
| › `startTimeSeconds` | `number` |
|
|
1021
1023
|
| › `endTimeSeconds` | `number` |
|
|
1022
|
-
| › `
|
|
1024
|
+
| › `from` | `number` |
|
|
1025
|
+
| › `to` | `number` |
|
|
1026
|
+
| › `onUpdate?` | (`data`: [`TActivityLog`](../interfaces/TActivityLog.md)[]) => `void` |
|
|
1023
1027
|
|
|
1024
1028
|
#### Returns
|
|
1025
1029
|
|
|
1026
|
-
`Promise`\<[`
|
|
1030
|
+
`Promise`\<[`TActivityLog`](../interfaces/TActivityLog.md)[]\>
|
|
1027
1031
|
|
|
1028
1032
|
___
|
|
1029
1033
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Interface:
|
|
1
|
+
# Interface: TActivityLog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TActivityLog describes a unified history log entry for points, gems, or diamonds changes.
|
|
4
4
|
The structure is the same regardless of balance type, making it easy to iterate and display.
|
|
5
5
|
|
|
6
6
|
## Properties
|
package/package.json
CHANGED
package/src/SmarticoAPI.ts
CHANGED
|
@@ -1341,6 +1341,8 @@ class SmarticoAPI {
|
|
|
1341
1341
|
user_ext_id: string,
|
|
1342
1342
|
startTimeSeconds: number,
|
|
1343
1343
|
endTimeSeconds: number,
|
|
1344
|
+
limit: number,
|
|
1345
|
+
offset: number,
|
|
1344
1346
|
): Promise<GetActivityLogResponse> {
|
|
1345
1347
|
const message = this.buildMessage<GetActivityLogRequest, GetActivityLogResponse>(
|
|
1346
1348
|
user_ext_id,
|
|
@@ -1348,6 +1350,8 @@ class SmarticoAPI {
|
|
|
1348
1350
|
{
|
|
1349
1351
|
startTimeSeconds: Math.floor(startTimeSeconds),
|
|
1350
1352
|
endTimeSeconds: Math.floor(endTimeSeconds),
|
|
1353
|
+
limit,
|
|
1354
|
+
offset,
|
|
1351
1355
|
},
|
|
1352
1356
|
);
|
|
1353
1357
|
|
|
@@ -1358,9 +1362,14 @@ class SmarticoAPI {
|
|
|
1358
1362
|
user_ext_id: string,
|
|
1359
1363
|
startTimeSeconds: number,
|
|
1360
1364
|
endTimeSeconds: number,
|
|
1365
|
+
from: number = 0,
|
|
1366
|
+
to: number = 50,
|
|
1361
1367
|
): Promise<TActivityLog[]> {
|
|
1368
|
+
const limit = to - from > 50 ? 50 : to - from;
|
|
1369
|
+
const offset = from;
|
|
1370
|
+
|
|
1362
1371
|
return ActivityLogTransform(
|
|
1363
|
-
(await this.getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds)).logHistory,
|
|
1372
|
+
(await this.getActivityLog(user_ext_id, startTimeSeconds, endTimeSeconds, limit, offset)).logHistory,
|
|
1364
1373
|
);
|
|
1365
1374
|
}
|
|
1366
1375
|
}
|
package/src/WSAPI/WSAPI.ts
CHANGED
|
@@ -1027,6 +1027,8 @@ export class WSAPI {
|
|
|
1027
1027
|
* _smartico.api.getActivityLog({
|
|
1028
1028
|
* startTimeSeconds: startTime,
|
|
1029
1029
|
* endTimeSeconds: endTime,
|
|
1030
|
+
* from: 0,
|
|
1031
|
+
* to: 50,
|
|
1030
1032
|
* onUpdate: (data) => console.log('Updated:', data)
|
|
1031
1033
|
* }).then((result) => {
|
|
1032
1034
|
* console.log(result);
|
|
@@ -1037,15 +1039,21 @@ export class WSAPI {
|
|
|
1037
1039
|
*
|
|
1038
1040
|
* @param params.startTimeSeconds - Start time in seconds (epoch timestamp)
|
|
1039
1041
|
* @param params.endTimeSeconds - End time in seconds (epoch timestamp)
|
|
1042
|
+
* @param params.from - Start index of records to return
|
|
1043
|
+
* @param params.to - End index of records to return
|
|
1040
1044
|
* @param params.onUpdate - Optional callback function that will be called when the activity log is updated
|
|
1041
1045
|
*/
|
|
1042
1046
|
public async getActivityLog({
|
|
1043
1047
|
startTimeSeconds,
|
|
1044
1048
|
endTimeSeconds,
|
|
1049
|
+
from,
|
|
1050
|
+
to,
|
|
1045
1051
|
onUpdate,
|
|
1046
1052
|
}: {
|
|
1047
1053
|
startTimeSeconds: number;
|
|
1048
1054
|
endTimeSeconds: number;
|
|
1055
|
+
from: number;
|
|
1056
|
+
to: number;
|
|
1049
1057
|
onUpdate?: (data: TActivityLog[]) => void;
|
|
1050
1058
|
}): Promise<TActivityLog[]> {
|
|
1051
1059
|
|
|
@@ -1056,7 +1064,7 @@ export class WSAPI {
|
|
|
1056
1064
|
return await OCache.use(
|
|
1057
1065
|
onUpdateContextKey.ActivityLog,
|
|
1058
1066
|
ECacheContext.WSAPI,
|
|
1059
|
-
() => this.api.getActivityLogT(null, startTimeSeconds, endTimeSeconds),
|
|
1067
|
+
() => this.api.getActivityLogT(null, startTimeSeconds, endTimeSeconds, from, to),
|
|
1060
1068
|
CACHE_DATA_SEC,
|
|
1061
1069
|
);
|
|
1062
1070
|
}
|
|
@@ -1120,7 +1128,7 @@ export class WSAPI {
|
|
|
1120
1128
|
private async notifyActivityLogUpdate() {
|
|
1121
1129
|
const startSeconds = Date.now() / 1000 - 600;
|
|
1122
1130
|
const endSeconds = Date.now() / 1000;
|
|
1123
|
-
const payload = await this.api.getActivityLogT(null, startSeconds ,
|
|
1131
|
+
const payload = await this.api.getActivityLogT(null, startSeconds, endSeconds, 0, 50);
|
|
1124
1132
|
|
|
1125
1133
|
this.updateEntity(onUpdateContextKey.ActivityLog, payload);
|
|
1126
1134
|
}
|