@smartico/public-api 0.0.314 → 0.0.316

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.314",
3
+ "version": "0.0.316",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -58,6 +58,7 @@ export const InboxMessageBodyTransform = (item: InboxMessageBody): TInboxMessage
58
58
  icon: item.image,
59
59
  title: item.title,
60
60
  preview_body: item.body,
61
+ custom_data: IntUtils.JsonOrText(item?.custom_data),
61
62
  };
62
63
 
63
64
  if (item.action === 'dp:inbox') {
@@ -69,7 +70,6 @@ export const InboxMessageBodyTransform = (item: InboxMessageBody): TInboxMessage
69
70
  }
70
71
 
71
72
  x.html_body = item?.html_body || null;
72
- x.custom_data = IntUtils.JsonOrText(item?.custom_data);
73
73
  }
74
74
 
75
75
  return x;
@@ -166,9 +166,11 @@ export class MissionUtils {
166
166
  return new Date(ts).getTime();
167
167
  }
168
168
 
169
- public static replaceFavGameNameTag = (task: UserAchievementTask) => {
169
+ public static replaceTagsFavMissionTask = (task: UserAchievementTask, valueToReplace: string): string => {
170
+ let result = valueToReplace || '';
171
+
170
172
  if (!task) {
171
- return task;
173
+ return result;
172
174
  }
173
175
 
174
176
  const userStateParams = (task.user_state_params || {});
@@ -176,7 +178,7 @@ export class MissionUtils {
176
178
  const userStateParamsKeys = Object.keys(userStateParams);
177
179
 
178
180
  if (userStateParamsKeys.length === 0 || !userStateOperator) {
179
- return task;
181
+ return result;
180
182
  }
181
183
 
182
184
  const operatorsMulti = ['has', '!has'];
@@ -213,10 +215,18 @@ export class MissionUtils {
213
215
  }
214
216
  });
215
217
 
216
- if (replacementValue) {
217
- task.task_public_meta.name = task.task_public_meta.name.replace('{{suggested_games}}', replacementValue);
218
- }
218
+ if (replacementValue && result) {
219
+ result = result.replace('{{suggested_games}}', replacementValue);
220
+ }
219
221
 
222
+ return result;
223
+ }
224
+
225
+ public static replaceFavGameNameTag = (task: UserAchievementTask): UserAchievementTask => {
226
+ 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);
228
+ }
229
+
220
230
  return task;
221
231
  }
222
232
  }