@smartico/public-api 0.0.288 → 0.0.290

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.
@@ -145,6 +145,9 @@ Info about current player in tournament
145
145
  | `avatar_url` | `string` | The URL to the avatar of the participant |
146
146
  | `position` | `number` | The position of the participant in the tournament |
147
147
  | `scores` | `number` | The scores of the participant in the tournament |
148
+ | `user_ext_id` | `string` | The external user id of the participant |
149
+ | `crm_brand_id` | `number` | The crm brand id of the participant |
150
+ | `user_id` | `number` | The user id of the participant |
148
151
 
149
152
  ___
150
153
 
@@ -441,7 +441,7 @@ ___
441
441
 
442
442
  ### players
443
443
 
444
- • `Optional` **players**: \{ `public_username`: `string` ; `avatar_url`: `string` ; `position`: `number` ; `scores`: `number` ; `is_me`: `boolean` }[]
444
+ • `Optional` **players**: \{ `public_username`: `string` ; `avatar_url`: `string` ; `position`: `number` ; `scores`: `number` ; `is_me`: `boolean` ; `user_ext_id`: `string` ; `crm_brand_id`: `number` ; `user_id`: `number` }[]
445
445
 
446
446
  The list of the tournament participants
447
447
 
@@ -461,6 +461,9 @@ The information about current user in the tournament if he is registered in the
461
461
  | `avatar_url` | `string` | The URL to the avatar of the current user |
462
462
  | `position` | `number` | The position of the current user in the tournament |
463
463
  | `scores` | `number` | The scores of the current user in the tournament |
464
+ | `user_ext_id` | `string` | The external user id of the current user |
465
+ | `crm_brand_id` | `number` | The crm brand id of the current user |
466
+ | `user_id` | `number` | The user id of the current user |
464
467
 
465
468
  #### Overrides
466
469
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.288",
3
+ "version": "0.0.290",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,5 +1,5 @@
1
1
  type TeamType = 'Home' | 'Away';
2
- type CardType = 'Yellow' | 'Red';
2
+ type CardType = 'Yellow' | 'Red' | 'YellowRed';
3
3
  type TimeType = 'FT' | '1st Half' | '2nd Half';
4
4
 
5
5
  export type OverHalfFullTimeScoreType = {
@@ -1034,27 +1034,32 @@ class SmarticoAPI {
1034
1034
  const userInfo = await this.getUserGamificationInfo(user_ext_id);
1035
1035
  if (!levels || levels.length === 0) return null;
1036
1036
 
1037
- const userPoints = userInfo.points_balance;
1037
+ const sortedLevels = [...levels].sort((a, b) => a.required_points - b.required_points);
1038
1038
 
1039
- const sortedLevels = levels.sort((a, b) => a.required_points - b.required_points);
1040
-
1041
- let currentLevelIndex = sortedLevels.findIndex((level, index) => {
1042
- const nextLevel = sortedLevels[index + 1];
1043
- return userPoints >= level.required_points && (!nextLevel || userPoints < nextLevel.required_points);
1044
- });
1039
+ let currentLevelIndex = sortedLevels.findIndex((level) => level.id === userInfo.current_level);
1045
1040
 
1046
1041
  if (currentLevelIndex === -1) {
1047
- currentLevelIndex = sortedLevels.length - 1;
1042
+ const userPointsEver = userInfo.points_ever ?? 0;
1043
+ currentLevelIndex = sortedLevels.findIndex((level, index) => {
1044
+ const nextLevel = sortedLevels[index + 1];
1045
+ return userPointsEver >= level.required_points && (!nextLevel || userPointsEver < nextLevel.required_points);
1046
+ });
1047
+ if (currentLevelIndex === -1) {
1048
+ currentLevelIndex = sortedLevels.length - 1;
1049
+ }
1048
1050
  }
1049
1051
 
1050
1052
  const currentLevel = sortedLevels[currentLevelIndex];
1051
1053
  const nextLevel = sortedLevels[currentLevelIndex + 1];
1052
- const progress = nextLevel ? ((userPoints - currentLevel.required_points) / (nextLevel.required_points - currentLevel.required_points)) * 100 : 100;
1054
+ const userPointsEver = userInfo.points_ever ?? 0;
1055
+ const progress = nextLevel
1056
+ ? ((userPointsEver - currentLevel.required_points) / (nextLevel.required_points - currentLevel.required_points)) * 100
1057
+ : 100;
1053
1058
 
1054
1059
  return {
1055
1060
  ...currentLevel,
1056
1061
  ordinal_position: currentLevelIndex + 1,
1057
- progress: Math.min(Math.max(progress, 0), 100)
1062
+ progress: Math.min(Math.max(progress, 0), 100),
1058
1063
  };
1059
1064
  }
1060
1065
 
@@ -1,5 +1,7 @@
1
1
  export interface TournamentPlayer {
2
2
  userAltName: string;
3
+ cleanExtUserId: string;
4
+ crmBrandId: number;
3
5
  position: number;
4
6
  scores: number;
5
7
  isMe: boolean;
@@ -96,6 +96,9 @@ export class TournamentUtils {
96
96
  position: player.position,
97
97
  scores: player.scores,
98
98
  is_me: player.isMe,
99
+ user_ext_id: player.cleanExtUserId,
100
+ crm_brand_id: player.crmBrandId,
101
+ user_id: player.userId,
99
102
  };
100
103
 
101
104
  if (isMe) {
@@ -331,6 +331,12 @@ export interface TTournament {
331
331
  position: number;
332
332
  /** The scores of the participant in the tournament */
333
333
  scores: number;
334
+ /** The external user id of the participant */
335
+ user_ext_id: string;
336
+ /** The crm brand id of the participant */
337
+ crm_brand_id: number;
338
+ /** The user id of the participant */
339
+ user_id: number;
334
340
  };
335
341
  /** Prize structure */
336
342
  prizes?: {
@@ -412,6 +418,12 @@ export interface TTournamentDetailed extends TTournament {
412
418
  scores: number;
413
419
  /** The indicator if the participant is current user */
414
420
  is_me: boolean;
421
+ /** The external user id of the participant */
422
+ user_ext_id: string;
423
+ /** The crm brand id of the participant */
424
+ crm_brand_id: number;
425
+ /** The user id of the participant */
426
+ user_id: number;
415
427
  }[];
416
428
  /** The information about current user in the tournament if he is registered in the tournamnet */
417
429
  me?: {
@@ -423,6 +435,12 @@ export interface TTournamentDetailed extends TTournament {
423
435
  position: number;
424
436
  /** The scores of the current user in the tournament */
425
437
  scores: number;
438
+ /** The external user id of the current user */
439
+ user_ext_id: string;
440
+ /** The crm brand id of the current user */
441
+ crm_brand_id: number;
442
+ /** The user id of the current user */
443
+ user_id: number;
426
444
  };
427
445
 
428
446
  prizes?: {