@smartico/public-api 0.0.318 → 0.0.320

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.
@@ -743,7 +743,7 @@ ___
743
743
  ▸ **getInboxMessages**(`params?`): `Promise`\<[`TInboxMessage`](../interfaces/TInboxMessage.md)[]\>
744
744
 
745
745
  Returns inbox messages based on the provided parameters. "From" and "to" indicate the range of messages to be fetched.
746
- The maximum number of messages per request is limited to 20.
746
+ The maximum number of messages per request is limited to 20.
747
747
  An indicator "onlyFavorite" can be passed to get only messages marked as favorites.
748
748
  An indicator "read_status" can be passed to get only messages marked as read or unread.
749
749
  You can leave this params empty and by default it will return list of messages ranging from 0 to 20.
@@ -28,6 +28,14 @@ Name of the mission or badge, translated to the user language
28
28
 
29
29
  ___
30
30
 
31
+ ### sub\_header
32
+
33
+ • **sub\_header**: `string`
34
+
35
+ Sub-header of the mission, translated to the user language
36
+
37
+ ___
38
+
31
39
  ### description
32
40
 
33
41
  • **description**: `string`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.318",
3
+ "version": "0.0.320",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +1,5 @@
1
1
  export interface AchievementPublicMeta {
2
+ sub_header?: string;
2
3
  description?: string;
3
4
  unlock_mission_description?: string;
4
5
  custom_data?: string;
@@ -166,65 +166,82 @@ export class MissionUtils {
166
166
  return new Date(ts).getTime();
167
167
  }
168
168
 
169
- public static replaceTagsFavMissionTask = (task: UserAchievementTask, valueToReplace: string): string => {
169
+ public static replaceTagsFavMissionTask = ({ task, valueToReplace, currencySymbol }: { task: UserAchievementTask, valueToReplace: string, currencySymbol?: string }): string => {
170
170
  let result = valueToReplace || '';
171
171
 
172
172
  if (!task) {
173
173
  return result;
174
174
  }
175
-
175
+
176
176
  const userStateParams = (task.user_state_params || {});
177
177
  const userStateOperator = task.task_public_meta?.user_state_operations;
178
178
  const userStateParamsKeys = Object.keys(userStateParams);
179
-
179
+
180
180
  if (userStateParamsKeys.length === 0 || !userStateOperator) {
181
181
  return result;
182
182
  }
183
-
183
+
184
184
  const operatorsMulti = ['has', '!has'];
185
185
  const operatorsPos = ['pos1', 'pos2', 'pos3'];
186
-
187
- let replacementValue: string = '';
188
-
189
- userStateParamsKeys.forEach((k: 'core_fav_game_top3' | 'core_fav_game_type_top3') => {
186
+
187
+ let suggestedGames: string = '';
188
+ let suggestedValue: string = '';
189
+
190
+ userStateParamsKeys.forEach((k: 'core_fav_game_top3' | 'core_fav_game_type_top3' | 'core_fav_game_provider_top3' | 'core_recommended_deposit_amount' | 'core_recommended_casino_bet_amount') => {
190
191
  const operator = userStateOperator[k]?.op;
191
-
192
- if (operatorsMulti.includes(operator)) {
193
- const value = userStateParams[k]?.filter(v => Boolean(v));
194
- if (value && value.length > 0) {
195
- replacementValue = value.map((v: string) => {
196
- const cleaned = v.replace(/_/g, ' ').toLowerCase();
197
- return cleaned.charAt(0).toUpperCase() + cleaned.slice(1);
198
- }).join(' ,');
192
+
193
+ if (k === 'core_fav_game_top3' || k === 'core_fav_game_type_top3' || k === 'core_fav_game_provider_top3') {
194
+ if (operatorsMulti.includes(operator)) {
195
+ const value = userStateParams[k]?.filter(v => Boolean(v));
196
+ if (value && value.length > 0) {
197
+ suggestedGames = value.map((v: string) => {
198
+ const cleaned = v.replace(/_/g, ' ').toLowerCase();
199
+ return cleaned.charAt(0).toUpperCase() + cleaned.slice(1);
200
+ }).join(' ,');
201
+ }
199
202
  }
200
- }
201
-
202
- if (operatorsPos.includes(operator)) {
203
- const value = userStateParams[k];
204
- const pos = Number(operator.replace('pos', '')) - 1;
205
-
206
- if (IntUtils.isNotNull(pos) && value && value[pos]) {
207
- replacementValue = value[pos];
208
-
209
- if (replacementValue) {
210
- replacementValue = replacementValue.replace('_', ' ').toLowerCase();
211
- replacementValue = replacementValue.charAt(0).toUpperCase() + replacementValue.slice(1);
203
+
204
+ if (operatorsPos.includes(operator)) {
205
+ const value = userStateParams[k];
206
+ const pos = Number(operator.replace('pos', '')) - 1;
207
+
208
+ if (IntUtils.isNotNull(pos) && value && value[pos]) {
209
+ suggestedGames = value[pos];
210
+
211
+ if (suggestedGames) {
212
+ suggestedGames = suggestedGames.replace('_', ' ').toLowerCase();
213
+ suggestedGames = suggestedGames.charAt(0).toUpperCase() + suggestedGames.slice(1);
214
+ }
215
+
212
216
  }
217
+ }
218
+ }
219
+
220
+ if (k === 'core_recommended_deposit_amount' || k === 'core_recommended_casino_bet_amount') {
221
+ suggestedValue = userStateParams[k];
213
222
 
223
+ if (suggestedValue) {
224
+ const currencyFromTheTask = userStateParams?.core_wallet_currency;
225
+
226
+ suggestedValue = `${suggestedValue} ${currencySymbol || currencyFromTheTask || ''}`;
214
227
  }
215
228
  }
216
229
  });
217
-
218
- if (replacementValue && result) {
219
- result = result.replace('{{suggested_games}}', replacementValue);
230
+
231
+ if (suggestedGames && result) {
232
+ result = result.replace('{{suggested_games}}', suggestedGames);
220
233
  }
221
-
234
+
235
+ if (suggestedValue && result) {
236
+ result = result.replace('{{suggested_value}}', suggestedValue);
237
+ }
238
+
222
239
  return result;
223
240
  }
224
241
 
225
- public static replaceFavGameNameTag = (task: UserAchievementTask): UserAchievementTask => {
242
+ public static replaceFavGameNameTag = ({ task, currencySymbol }: { task: UserAchievementTask, currencySymbol?: string }): UserAchievementTask => {
226
243
  if (task && task.task_public_meta && task.task_public_meta.name) {
227
- task.task_public_meta.name = MissionUtils.replaceTagsFavMissionTask(task, task.task_public_meta.name);
244
+ task.task_public_meta.name = MissionUtils.replaceTagsFavMissionTask({ task, valueToReplace: task.task_public_meta.name, currencySymbol });
228
245
  }
229
246
 
230
247
  return task;
@@ -55,10 +55,29 @@ export const UserAchievementTransform = (items: UserAchievement[]): TMissionOrBa
55
55
  const completedThisWeek = r.complete_date_ts ? IntUtils.isWithinPeriod(r.complete_date_ts, 'thisWeek') : false;
56
56
  const completedThisMonth = r.complete_date_ts ? IntUtils.isWithinPeriod(r.complete_date_ts, 'thisMonth') : false;
57
57
 
58
+ let missionName = r.ach_public_meta.name;
59
+ let missionSubHeader = r.ach_public_meta.sub_header;
60
+ let missionDescription = r.ach_public_meta.description;
61
+
62
+ if (missionName?.includes('{{suggested_') || missionSubHeader?.includes('{{suggested_') || missionDescription?.includes('{{suggested_')) {
63
+ r.achievementTasks.forEach(t => {
64
+ if (r.ach_public_meta.name?.includes('{{suggested_')) {
65
+ missionName = MissionUtils.replaceTagsFavMissionTask({ task: t, valueToReplace: r.ach_public_meta.name });
66
+ }
67
+ if (r.ach_public_meta.sub_header?.includes('{{suggested_')) {
68
+ missionSubHeader = MissionUtils.replaceTagsFavMissionTask({ task: t, valueToReplace: r.ach_public_meta.sub_header });
69
+ }
70
+ if (r.ach_public_meta.description?.includes('{{suggested_')) {
71
+ missionDescription = MissionUtils.replaceTagsFavMissionTask({ task: t, valueToReplace: r.ach_public_meta.description });
72
+ }
73
+ });
74
+ }
75
+
58
76
  const x: TMissionOrBadge = {
59
77
  id: r.ach_id,
60
- name: r.ach_public_meta.name,
61
- description: r.ach_public_meta.description,
78
+ name: missionName,
79
+ sub_header: missionSubHeader,
80
+ description: missionDescription,
62
81
  hint_text: r.ach_public_meta.hint_text,
63
82
  unlock_mission_description: r.ach_public_meta.unlock_mission_description,
64
83
  image: r.ach_public_meta.image_url,
@@ -84,7 +103,11 @@ export const UserAchievementTransform = (items: UserAchievement[]): TMissionOrBa
84
103
  tasks: (r.achievementTasks || [])
85
104
  .filter((t) => t.task_type_id === AchievementTaskType.CompleteAchievement)
86
105
  .map((t) => {
87
- MissionUtils.replaceFavGameNameTag(t);
106
+ MissionUtils.replaceFavGameNameTag({ task: t });
107
+
108
+ x.name = MissionUtils.replaceTagsFavMissionTask({ task: t, valueToReplace: x.name });
109
+ x.sub_header = MissionUtils.replaceTagsFavMissionTask({ task: t, valueToReplace: x.sub_header });
110
+ x.description = MissionUtils.replaceTagsFavMissionTask({ task: t, valueToReplace: x.description });
88
111
 
89
112
  return ({
90
113
  id: t.task_id,
@@ -561,6 +561,8 @@ export interface TMissionOrBadge {
561
561
  type: 'mission' | 'badge';
562
562
  /** Name of the mission or badge, translated to the user language */
563
563
  name: string;
564
+ /** Sub-header of the mission, translated to the user language */
565
+ sub_header: string;
564
566
  /** Description of the mission or badge, translated to the user language */
565
567
  description: string;
566
568
  /** Description of the mission reward if defined */