@smartico/public-api 0.0.124 → 0.0.126
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/Jackpots/index.d.ts +15 -0
- package/dist/SmarticoAPI.d.ts +3 -1
- package/dist/Store/GetStoreHistoryRequest.d.ts +2 -2
- package/dist/Store/GetStoreHistoryResponse.d.ts +4 -4
- package/dist/Store/StoreItemPurchased.d.ts +8 -0
- package/dist/Store/index.d.ts +3 -0
- package/dist/WSAPI/WSAPI.d.ts +83 -13
- package/dist/WSAPI/WSAPITypes.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +332 -165
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +143 -16
- package/dist/index.modern.mjs.map +1 -1
- package/docs/classes/WSAPI.md +76 -3
- package/docs/interfaces/TStoreItem.md +16 -0
- package/package.json +1 -1
- package/src/Jackpots/index.ts +15 -0
- package/src/SmarticoAPI.ts +17 -2
- package/src/Store/GetStoreHistoryRequest.ts +2 -2
- package/src/Store/GetStoreHistoryResponse.ts +4 -4
- package/src/Store/StoreItemPurchased.ts +41 -0
- package/src/Store/index.ts +4 -1
- package/src/WSAPI/WSAPI.ts +86 -12
- package/src/WSAPI/WSAPITypes.ts +4 -0
- package/src/index.ts +2 -1
- package/src/Store/StorItemPruchased.ts +0 -8
package/dist/index.modern.mjs
CHANGED
|
@@ -611,6 +611,34 @@ const StoreItemTransform = items => {
|
|
|
611
611
|
});
|
|
612
612
|
};
|
|
613
613
|
|
|
614
|
+
const StoreItemPurchasedTransform = items => {
|
|
615
|
+
return items.filter(r => r.id >= 1).map(r => {
|
|
616
|
+
var _r$categoryIds;
|
|
617
|
+
const x = {
|
|
618
|
+
id: r.id,
|
|
619
|
+
name: r.itemPublicMeta.name,
|
|
620
|
+
price: r.itemPublicMeta.price,
|
|
621
|
+
image: r.itemPublicMeta.image_url,
|
|
622
|
+
description: r.itemPublicMeta.description,
|
|
623
|
+
ribbon: r.itemPublicMeta.label_tag === 'custom' ? r.itemPublicMeta.custom_label_tag : r.itemPublicMeta.label_tag,
|
|
624
|
+
limit_message: r.itemPublicMeta.limit_message,
|
|
625
|
+
priority: r.itemPublicMeta.priority,
|
|
626
|
+
related_item_ids: r.itemPublicMeta.related_items,
|
|
627
|
+
hint_text: r.itemPublicMeta.hint_text,
|
|
628
|
+
type: {
|
|
629
|
+
[StoreItemType.Bonus]: 'bonus',
|
|
630
|
+
[StoreItemType.Manual]: 'manual'
|
|
631
|
+
}[r.itemTypeId],
|
|
632
|
+
can_buy: r.canBuy,
|
|
633
|
+
category_ids: (_r$categoryIds = r.categoryIds) != null ? _r$categoryIds : [],
|
|
634
|
+
pool: r.shopPool,
|
|
635
|
+
purchase_ts: r.purchase_ts,
|
|
636
|
+
purchase_points_amount: r.purchase_points_amount
|
|
637
|
+
};
|
|
638
|
+
return x;
|
|
639
|
+
});
|
|
640
|
+
};
|
|
641
|
+
|
|
614
642
|
var AchievementStatus;
|
|
615
643
|
(function (AchievementStatus) {
|
|
616
644
|
AchievementStatus[AchievementStatus["Draft"] = 1] = "Draft";
|
|
@@ -990,6 +1018,7 @@ var onUpdateContextKey;
|
|
|
990
1018
|
onUpdateContextKey["LeaderBoards"] = "leaderBoards";
|
|
991
1019
|
onUpdateContextKey["LevelExtraCounters"] = "levelExtraCounters";
|
|
992
1020
|
onUpdateContextKey["Segments"] = "segments";
|
|
1021
|
+
onUpdateContextKey["StoreHistory"] = "storeHistory";
|
|
993
1022
|
})(onUpdateContextKey || (onUpdateContextKey = {}));
|
|
994
1023
|
/** @group General API */
|
|
995
1024
|
class WSAPI {
|
|
@@ -1008,7 +1037,14 @@ class WSAPI {
|
|
|
1008
1037
|
on(ClassId.LOGOUT_RESPONSE, () => OCache.clear(ECacheContext.WSAPI));
|
|
1009
1038
|
on(ClassId.IDENTIFY_RESPONSE, () => OCache.clear(ECacheContext.WSAPI));
|
|
1010
1039
|
}
|
|
1011
|
-
/** Returns information about current user
|
|
1040
|
+
/** Returns information about current user
|
|
1041
|
+
* Example usage:
|
|
1042
|
+
* ```
|
|
1043
|
+
* _smartico.api.getUserProfile().then((result) => {
|
|
1044
|
+
* console.log(result);
|
|
1045
|
+
* });
|
|
1046
|
+
* ```
|
|
1047
|
+
* */
|
|
1012
1048
|
getUserProfile() {
|
|
1013
1049
|
if (this.api.tracker) {
|
|
1014
1050
|
const o = Object.assign({}, this.api.tracker.userPublicProps);
|
|
@@ -1018,7 +1054,14 @@ class WSAPI {
|
|
|
1018
1054
|
throw new Error('Tracker is not initialized, cannot getUserProfile');
|
|
1019
1055
|
}
|
|
1020
1056
|
}
|
|
1021
|
-
/** Check if user belongs to specific segments
|
|
1057
|
+
/** Check if user belongs to specific segments
|
|
1058
|
+
* Example usage:
|
|
1059
|
+
* ```
|
|
1060
|
+
* _smartico.api.checkSegmentMatch(1).then((result) => {
|
|
1061
|
+
* console.log(result);
|
|
1062
|
+
* });
|
|
1063
|
+
* ```
|
|
1064
|
+
*/
|
|
1022
1065
|
async checkSegmentMatch(segment_id) {
|
|
1023
1066
|
const r = await this.api.coreCheckSegments(null, [segment_id]);
|
|
1024
1067
|
if (r && r.find(s => s.segment_id === segment_id && s.is_matching)) {
|
|
@@ -1027,20 +1070,41 @@ class WSAPI {
|
|
|
1027
1070
|
return false;
|
|
1028
1071
|
}
|
|
1029
1072
|
}
|
|
1030
|
-
/** Check if user belongs to specific list of segments
|
|
1073
|
+
/** Check if user belongs to specific list of segments
|
|
1074
|
+
* Example usage:
|
|
1075
|
+
* ```
|
|
1076
|
+
* _smartico.api.checkSegmentListMatch([1, 2, 3]).then((result) => {
|
|
1077
|
+
* console.log(result);
|
|
1078
|
+
* });
|
|
1079
|
+
* ```
|
|
1080
|
+
*/
|
|
1031
1081
|
async checkSegmentListMatch(segment_ids) {
|
|
1032
|
-
return await this.api.coreCheckSegments(null, segment_ids);
|
|
1033
|
-
}
|
|
1034
|
-
/** Returns all the levels available the current user
|
|
1082
|
+
return await this.api.coreCheckSegments(null, Array.isArray(segment_ids) ? segment_ids : [segment_ids]);
|
|
1083
|
+
}
|
|
1084
|
+
/** Returns all the levels available the current user
|
|
1085
|
+
* Example usage:
|
|
1086
|
+
* ```
|
|
1087
|
+
* _smartico.api.getLevels().then((result) => {
|
|
1088
|
+
* console.log(result);
|
|
1089
|
+
* });
|
|
1090
|
+
* ```
|
|
1091
|
+
*/
|
|
1035
1092
|
async getLevels() {
|
|
1036
1093
|
return OCache.use(onUpdateContextKey.Levels, ECacheContext.WSAPI, () => this.api.levelsGetT(null), CACHE_DATA_SEC);
|
|
1037
1094
|
}
|
|
1038
1095
|
/** Returns all the missions available the current user.
|
|
1039
|
-
* The returned missions
|
|
1040
|
-
*
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1096
|
+
* The returned missions are cached for 30 seconds. But you can pass the onUpdate callback as a parameter.
|
|
1097
|
+
* Note that each time you call getMissions with a new onUpdate callback, the old one will be overwritten by the new one.
|
|
1098
|
+
* The onUpdate callback will be called on mission OptIn and the updated missions will be passed to it.
|
|
1099
|
+
* Example usage:
|
|
1100
|
+
* ```
|
|
1101
|
+
* _smartico.api.getMissions().then((result) => {
|
|
1102
|
+
* console.log(result);
|
|
1103
|
+
* });
|
|
1104
|
+
* ```
|
|
1105
|
+
/**
|
|
1106
|
+
* @param params
|
|
1107
|
+
*/
|
|
1044
1108
|
async getMissions({
|
|
1045
1109
|
onUpdate
|
|
1046
1110
|
} = {}) {
|
|
@@ -1053,15 +1117,37 @@ class WSAPI {
|
|
|
1053
1117
|
async getBadges() {
|
|
1054
1118
|
return OCache.use(onUpdateContextKey.Badges, ECacheContext.WSAPI, () => this.api.badgetsGetItemsT(null), CACHE_DATA_SEC);
|
|
1055
1119
|
}
|
|
1056
|
-
/**
|
|
1120
|
+
/**
|
|
1121
|
+
* Returns the extra counters for the current user level.
|
|
1122
|
+
* These are counters that are configured for each Smartico client separatly by request.
|
|
1123
|
+
* For example 1st counter could be total wagering amount, 2nd counter could be total deposit amount, etc.
|
|
1124
|
+
* Example usage:
|
|
1125
|
+
* ```
|
|
1126
|
+
* _smartico.api.getUserLevelExtraCounters().then((result) => {
|
|
1127
|
+
* console.log(result);
|
|
1128
|
+
* });
|
|
1129
|
+
* ```
|
|
1130
|
+
*/
|
|
1057
1131
|
async getUserLevelExtraCounters() {
|
|
1058
1132
|
return OCache.use(onUpdateContextKey.LevelExtraCounters, ECacheContext.WSAPI, () => this.api.getUserGamificationInfoT(null), CACHE_DATA_SEC);
|
|
1059
1133
|
}
|
|
1060
|
-
/** Returns all the store items available the current user
|
|
1134
|
+
/** Returns all the store items available the current user
|
|
1135
|
+
* Example usage:
|
|
1136
|
+
* ```
|
|
1137
|
+
* _smartico.api.getStoreItems().then((result) => {
|
|
1138
|
+
* console.log(result);
|
|
1139
|
+
* });
|
|
1140
|
+
*/
|
|
1061
1141
|
async getStoreItems() {
|
|
1062
1142
|
return OCache.use(onUpdateContextKey.StoreItems, ECacheContext.WSAPI, () => this.api.storeGetItemsT(null), CACHE_DATA_SEC);
|
|
1063
1143
|
}
|
|
1064
|
-
/** Buy the specific shop item by item_id. Returns the err_code
|
|
1144
|
+
/** Buy the specific shop item by item_id. Returns the err_code in case of success or error.
|
|
1145
|
+
* Example usage:
|
|
1146
|
+
* ```
|
|
1147
|
+
* _smartico.api.buyStoreItem(1).then((result) => {
|
|
1148
|
+
* console.log(result);
|
|
1149
|
+
* });
|
|
1150
|
+
*/
|
|
1065
1151
|
async buyStoreItem(item_id) {
|
|
1066
1152
|
const r = await this.api.buyStoreItem(null, item_id);
|
|
1067
1153
|
const o = {
|
|
@@ -1074,7 +1160,25 @@ class WSAPI {
|
|
|
1074
1160
|
async getStoreCategories() {
|
|
1075
1161
|
return OCache.use(onUpdateContextKey.StoreCategories, ECacheContext.WSAPI, () => this.api.storeGetCategoriesT(null), CACHE_DATA_SEC);
|
|
1076
1162
|
}
|
|
1077
|
-
/** Returns
|
|
1163
|
+
/** Returns store purchased items based on the provided parameters. "From" and "to" indicate the range of items to be fetched.
|
|
1164
|
+
* The maximum number of messages per request is limited to 20.
|
|
1165
|
+
* You can leave this params empty and by default it will return list of purchased items ranging from 0 to 20.
|
|
1166
|
+
* This functions return list of purchased items.
|
|
1167
|
+
* The "onUpdate" callback will be triggered when the user receives a new purchased item. It will provide an updated list of items, ranging from 0 to 20, to the onUpdate callback function. */
|
|
1168
|
+
/**
|
|
1169
|
+
* @param params
|
|
1170
|
+
*/
|
|
1171
|
+
async storeGetPurchasedItems({
|
|
1172
|
+
from,
|
|
1173
|
+
to,
|
|
1174
|
+
onUpdate
|
|
1175
|
+
} = {}) {
|
|
1176
|
+
if (onUpdate) {
|
|
1177
|
+
this.onUpdateCallback.set(onUpdateContextKey.StoreHistory, onUpdate);
|
|
1178
|
+
}
|
|
1179
|
+
return await this.api.storeGetPurchasedItemsT(null, from, to);
|
|
1180
|
+
}
|
|
1181
|
+
/** Returns missions & badges categories */
|
|
1078
1182
|
async getAchCategories() {
|
|
1079
1183
|
return OCache.use(onUpdateContextKey.AchCategories, ECacheContext.WSAPI, () => this.api.achGetCategoriesT(null), CACHE_DATA_SEC);
|
|
1080
1184
|
}
|
|
@@ -1633,6 +1737,18 @@ class SmarticoAPI {
|
|
|
1633
1737
|
async storeGetCategoriesT(user_ext_id) {
|
|
1634
1738
|
return StoreCategoryTransform((await this.storeGetCategories(user_ext_id)).categories);
|
|
1635
1739
|
}
|
|
1740
|
+
async storeGetPurchasedItems(user_ext_id, limit = 20, offset = 0) {
|
|
1741
|
+
const message = this.buildMessage(user_ext_id, ClassId.ACH_SHOP_ITEM_HISTORY_REQUEST, {
|
|
1742
|
+
limit,
|
|
1743
|
+
offset
|
|
1744
|
+
});
|
|
1745
|
+
return await this.send(message, ClassId.ACH_SHOP_ITEM_HISTORY_RESPONSE);
|
|
1746
|
+
}
|
|
1747
|
+
async storeGetPurchasedItemsT(user_ext_id, from = 0, to = 20) {
|
|
1748
|
+
const limit = to - from > 20 ? 20 : to - from;
|
|
1749
|
+
const offset = from;
|
|
1750
|
+
return StoreItemPurchasedTransform((await this.storeGetPurchasedItems(user_ext_id, limit, offset)).items);
|
|
1751
|
+
}
|
|
1636
1752
|
async missionsGetItems(user_ext_id) {
|
|
1637
1753
|
const message = this.buildMessage(user_ext_id, ClassId.GET_ACHIEVEMENT_MAP_REQUEST);
|
|
1638
1754
|
const response = await this.send(message, ClassId.GET_ACHIEVEMENT_MAP_RESPONSE);
|
|
@@ -2169,5 +2285,16 @@ const QuizMarketPerSport = {
|
|
|
2169
2285
|
[QuizSportType.Tennis]: [QuizMarketType.One_Two, QuizMarketType.FirstSet, QuizMarketType.SecondSet, QuizMarketType.ThirdSet, QuizMarketType.FourthSet, QuizMarketType.FifthSet, QuizMarketType.PlayerOneWinsOneSet, QuizMarketType.PlayerTwoWinsOneSet, QuizMarketType.OddEven]
|
|
2170
2286
|
};
|
|
2171
2287
|
|
|
2172
|
-
|
|
2288
|
+
var JackpotContributionType;
|
|
2289
|
+
(function (JackpotContributionType) {
|
|
2290
|
+
JackpotContributionType[JackpotContributionType["Fixed"] = 1] = "Fixed";
|
|
2291
|
+
JackpotContributionType[JackpotContributionType["Percentage"] = 2] = "Percentage";
|
|
2292
|
+
})(JackpotContributionType || (JackpotContributionType = {}));
|
|
2293
|
+
|
|
2294
|
+
var JackpotType;
|
|
2295
|
+
(function (JackpotType) {
|
|
2296
|
+
JackpotType[JackpotType["Main"] = 1] = "Main";
|
|
2297
|
+
})(JackpotType || (JackpotType = {}));
|
|
2298
|
+
|
|
2299
|
+
export { AchCategoryTransform, AchievementStatus, AchievementTaskType, AchievementType, ActivityTypeLimited, BuyStoreItemErrorCode, ClassId, CookieStore, CoreUtils, GetLevelMapResponseTransform, InboxMessageBodyTransform, InboxMessageType, InboxMessagesTransform, JackpotContributionType, JackpotType, LeaderBoardPeriodType, MarketsValueType, MiniGamePrizeTypeName, MiniGamePrizeTypeNamed, PublicLabelSettings, QuizMarketPerSport, QuizMarketType, QuizSportType, SAWAcknowledgeType, SAWAskForUsername, SAWBuyInType, SAWBuyInTypeName, SAWBuyInTypeNamed, SAWGameType, SAWGameTypeName, SAWGameTypeNamed, SAWPrizeType, SAWSpinErrorCode, SAWTemplatesTransform, SAWUtils, SAWWinSoundFiles, SAWWinSoundType, ScheduledMissionType, SmarticoAPI, StoreCategoryTransform, StoreItemPurchasedTransform, StoreItemTransform, StoreItemType, TournamentInstanceStatus, TournamentInstanceStatusName, TournamentItemsTransform, TournamentRegistrationError, TournamentRegistrationStatus, TournamentRegistrationStatusName, TournamentRegistrationStatusNamed, TournamentRegistrationType, TournamentRegistrationTypeGetName, TournamentType, TournamentUtils, TranslationArea, UserAchievementTransform, marketsInfo, quizSupportedSports, tournamentInfoItemTransform };
|
|
2173
2300
|
//# sourceMappingURL=index.modern.mjs.map
|