@smartico/public-api 0.0.216 → 0.0.217

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.
Files changed (45) hide show
  1. package/dist/Base/ClassId.d.ts +4 -0
  2. package/dist/Raffle/GetDrawResponse.d.ts +5 -0
  3. package/dist/Raffle/GetDrawRunRequest.d.ts +5 -0
  4. package/dist/Raffle/GetDrawRunResponse.d.ts +5 -0
  5. package/dist/Raffle/GetRafflesRequest.d.ts +4 -0
  6. package/dist/Raffle/GetRafflesResponse.d.ts +5 -0
  7. package/dist/Raffle/Raffle.d.ts +34 -0
  8. package/dist/Raffle/RaffleDraw.d.ts +70 -0
  9. package/dist/Raffle/RafflePrize.d.ts +97 -0
  10. package/dist/Raffle/RafflePrizeWinner.d.ts +9 -0
  11. package/dist/Raffle/RaffleTicket.d.ts +5 -0
  12. package/dist/Raffle/index.d.ts +9 -0
  13. package/dist/SmarticoAPI.d.ts +2 -0
  14. package/dist/WSAPI/WSAPI.d.ts +2 -0
  15. package/dist/index.js +28 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.modern.mjs +18 -1
  18. package/dist/index.modern.mjs.map +1 -1
  19. package/docs/README.md +9 -0
  20. package/docs/classes/WSAPI.md +11 -1
  21. package/docs/interfaces/GetDrawRunRequest.md +49 -0
  22. package/docs/interfaces/GetDrawRunResponse.md +63 -0
  23. package/docs/interfaces/GetRafflesRequest.md +37 -0
  24. package/docs/interfaces/GetRafflesResponse.md +63 -0
  25. package/docs/interfaces/Raffle.md +59 -0
  26. package/docs/interfaces/RaffleDraw.md +124 -0
  27. package/docs/interfaces/RafflePrize.md +137 -0
  28. package/docs/interfaces/RafflePrizeWinner.md +31 -0
  29. package/docs/interfaces/RaffleTicket.md +13 -0
  30. package/package.json +1 -1
  31. package/src/Base/ClassId.ts +13 -0
  32. package/src/MiniGames/SAWGetTemplatesResponse.ts +1 -1
  33. package/src/Raffle/GetDrawRunRequest.ts +6 -0
  34. package/src/Raffle/GetDrawRunResponse.ts +6 -0
  35. package/src/Raffle/GetRafflesRequest.ts +5 -0
  36. package/src/Raffle/GetRafflesResponse.ts +6 -0
  37. package/src/Raffle/Raffle.ts +41 -0
  38. package/src/Raffle/RaffleDraw.ts +92 -0
  39. package/src/Raffle/RafflePrize.ts +117 -0
  40. package/src/Raffle/RafflePrizeWinner.ts +11 -0
  41. package/src/Raffle/RaffleTicket.ts +9 -0
  42. package/src/Raffle/index.ts +9 -0
  43. package/src/SmarticoAPI.ts +11 -0
  44. package/src/WSAPI/WSAPI.ts +6 -0
  45. package/tsconfig.json +1 -0
@@ -0,0 +1,41 @@
1
+ import { RaffleDraw } from "./RaffleDraw";
2
+
3
+
4
+ interface RafflePublicMeta {
5
+ /** Name of the raffle */
6
+ name: string;
7
+ /** Description of the raffle */
8
+ description: string;
9
+ /** ID of the custom section that is linked to the raffle in the Gamification widget */
10
+ custom_section_id: number;
11
+ /** URL of the image that represents the raffle */
12
+ image_url: string;
13
+ }
14
+
15
+
16
+ interface Raffle {
17
+ /** ID of the Raffle template */
18
+ raffle_id: number;
19
+ /** Meta information about raffle for the presentation on UI */
20
+ public_meta: RafflePublicMeta;
21
+ /** Date of start */
22
+ start_date_ts: number;
23
+ /** Date of end */
24
+ end_date_ts: number;
25
+ /** Maximum numer of tickets that can be given to all users for the whole period of raffle */
26
+ max_tickets_count: number;
27
+ /**
28
+ * Number of tickets that are already given to all users for this raffle
29
+ */
30
+ current_tickets_count: number;
31
+
32
+ /**
33
+ * List of draws that are available for this raffle.
34
+ * For example, if the raffle is containg one hourly draw, one daily draw and one draw on fixed date like 01/01/2022,
35
+ * Then the list will always return 3 draws, no matter if the draws are already executed or they are in the future.
36
+ */
37
+ draws: RaffleDraw[]
38
+
39
+ }
40
+
41
+ export { Raffle };
@@ -0,0 +1,92 @@
1
+ import { RafflePrize } from "./RafflePrize";
2
+ import { RaffleTicket } from "./RaffleTicket";
3
+
4
+ interface RaffleDrawPublicMeta {
5
+ /** Name of the draw, e.g. 'Daily draw' */
6
+ name: string;
7
+ /** Description of the draw */
8
+ description: string;
9
+ /** URL of the image that represents the draw */
10
+ image_url: string;
11
+ }
12
+
13
+ enum RaffleDrawInstanceState {
14
+ /** Draw is open for the tickets collection */
15
+ Open = 1,
16
+ /** Winner selection is in progress */
17
+ WinnerSelection = 2,
18
+ /** Draw is executed and the winners are selected */
19
+ Executed = 3,
20
+ }
21
+
22
+
23
+ interface RaffleDraw {
24
+ /**
25
+ * Id of the Draw definition, for the repetative draws (e.g. daily), this number will be the same for all draws that are repeating daily
26
+ * (internal name: schedule_id)
27
+ */
28
+ draw_id: number;
29
+
30
+ /** Meta information of the Draw for the presentaiton in UI */
31
+ public_meta: RaffleDrawPublicMeta;
32
+
33
+ /** Information about prizes in the draw */
34
+ prizes: RafflePrize[];
35
+
36
+ /**
37
+ * State of current instance of Draw
38
+ */
39
+ current_state: RaffleDrawInstanceState;
40
+
41
+ /**
42
+ * Field indicates the ID of the latest instance/run of draw
43
+ */
44
+ run_id: number;
45
+
46
+ /** Date/time of the draw execution */
47
+ execution_ts: number;
48
+
49
+ /** Date of the previously executed draw (if there is such) */
50
+ previous_run_ts?: number;
51
+
52
+ /** Unique ID of the previusly executed draw (if there is such) */
53
+ previous_run_id?: number;
54
+
55
+ /**
56
+ * Date/time starting from which the tickets will participate in the upcoming draw
57
+ * This value need to be taken into account with next_execute_ts field value, for example
58
+ * Next draw is at 10:00, tickets_time_back_ts is 9:00, so all tickets that are collected after 9:00 will participate in the draw at 10:00
59
+ * (internally this value is calculated as next_execute_ts - time_back_period_ms)
60
+ */
61
+ tickets_time_back_ts: number;
62
+
63
+ /** Field is indicating if same ticket can win multiple prizes in the same draw
64
+ * For example there are 3 types of prizes in the draw - iPhone, iPad, MacBook
65
+ * If this field is true, then one ticket can win all 3 prizes (depending on the chances of course),
66
+ * if false, then one ticket can win only one prize.
67
+ * The distribution of the prizes is start from top (assuming on top are the most valuable prizes) to bottom (less valuable prizes)
68
+ * If specific prize has multiple values, e.g. we have 3 iPhones,
69
+ * then the same ticket can win only one prize of a kind, but can win multiple prizes of different kind (if allow_multi_prize_per_ticket is true)
70
+ */
71
+ allow_multi_prize_per_ticket: boolean;
72
+
73
+
74
+ /**
75
+ * The number of tickets that are already given to all users for this instance of draw.
76
+ * In other words tickets that are collected between tickets_time_back_ts and current time (or till current_execution_ts is the instance is executed).
77
+ */
78
+ total_tickets_count: number;
79
+
80
+ /**
81
+ * The number of tickets collected by current user for this instance of draw.
82
+ */
83
+ my_tickets_count: number;
84
+
85
+ /*
86
+ * List of last 5 tickets are collected by current user for this instance of draw.
87
+ */
88
+ my_last_tickets: RaffleTicket[];
89
+ }
90
+
91
+
92
+ export { RaffleDraw }
@@ -0,0 +1,117 @@
1
+ import { RafflePrizeWinner } from "./RafflePrizeWinner";
2
+
3
+
4
+ interface RafflePrizePublicMeta {
5
+ /** Name of the prize */
6
+ name: string;
7
+ /** Description of the prize */
8
+ description: string;
9
+ /** URL of the image that represents the prize */
10
+ image_url: string;
11
+ }
12
+
13
+ /**
14
+ * Represents a prize in a draw.
15
+ */
16
+ interface RafflePrize {
17
+
18
+ /**
19
+ * The unique identifier for the prize definition
20
+ */
21
+ prize_id: string;
22
+
23
+ /**
24
+ * Meta information about the prize for presentation in the UI.
25
+ */
26
+ public_meta: RafflePrizePublicMeta;
27
+
28
+ /**
29
+ * The number of prizes available per run of the draw.
30
+ * E.g. if the draw is run daily, this is the number of prizes available each day, for example 3 iPhones.
31
+ */
32
+ prizes_per_run: number;
33
+
34
+ /**
35
+ * The actual number of prizes for the current instance.
36
+ * This value is taking into account follwing values:
37
+ * - min_required_total_tickets,
38
+ * - add_one_prize_per_each_x_tickets
39
+ * - stock_items_per_draw
40
+ * - total_tickets_count (from Draw instance)
41
+ * - cap_prizes_per_run
42
+ * For example:
43
+ * - prizes_per_run = 1
44
+ * - min_required_total_tickets = 1000
45
+ * - add_one_prize_per_each_x_tickets = 1000
46
+ * - stock_items_per_draw = 5
47
+ * - total_tickets_count = 7000
48
+ * - cap_prizes_per_run = 6
49
+ * prizes_per_run_actual will be 5, because
50
+ * 7000 tickets are collected, so 7 iPhones are available, but the cap is 6 and the stock is 5.
51
+ */
52
+ prizes_per_run_actual: number;
53
+
54
+
55
+ /**
56
+ *
57
+ * The chances to win the prize by current player.
58
+ * Calculated as the ratio of the number of tickets collected by the current player to the
59
+ * total number of tickets collected by all players and multiplied by number of actual prizes of this kind.
60
+ */
61
+ chances_to_win_perc: number;
62
+
63
+ /**
64
+ * The minimum number of total tickets collected during draw period required to unlock the prize.
65
+ * If the number of tickets collected is less than this value, the prize is not available.
66
+ * Under total tickets we understand the number of tickets collected by all users.
67
+ * The 'draw period' is the time between the tickets_time_back_ts value of the draw and the current time.
68
+ */
69
+ min_required_total_tickets?: number;
70
+
71
+ /**
72
+ * One additional prize will be awarded for each X tickets.
73
+ * E.g. if the prize is 1 iPhone and the value is set to 1000, then for every 1000 tickets collected, an additional iPhone is awarded.
74
+ * If min_required_total_tickets is set to 1000, then next iPhone is awarded when 2000 tickets are collected, and so on.
75
+ * If min_required_total_tickets is not set, then the next iPhone will be awarded when 1000 tickets are collected.
76
+ */
77
+ add_one_prize_per_each_x_tickets?: number;
78
+
79
+ /**
80
+ * Indicates whether the prize requires a claim action from the user.
81
+ */
82
+ requires_claim: boolean;
83
+
84
+ /**
85
+ * The minimum number of tickets a user must have to be eligible for the prize.
86
+ * For example iPhone prize may require 10 tickets to be collected, only users with 10 or more tickets will be eligible for the prize.
87
+ * More tickets are better, as they increase the chances of winning.
88
+ */
89
+ min_required_tickets_for_user: number;
90
+
91
+
92
+ /**
93
+ * The maximum number of prizes that can be given withing one instance/run of draw.
94
+ * For example the prize is iPhone and add_one_prize_per_each_x_tickets is set to 1000,
95
+ * cap_prizes_per_run is set to 3, and the total number of tickets collected is 7000.
96
+ * In this case, the prizes_per_run_actual will be limitted by 3
97
+ */
98
+ cap_prizes_per_run?: number;
99
+
100
+
101
+ /**
102
+ * The priority of the prize. The low number means higher priority (e.g. 1 is higher priority than 2).
103
+ * If there are multiple prizes available, the prize with the highest priority (lowest number) will be awarded first.
104
+ */
105
+ priority: number;
106
+
107
+ /**
108
+ * Optional field that indicates total remaining number of the prize for all draws of the type.
109
+ * For example, the Daily draw has 1 iPhone daily, and the total number of iPhones is 10.
110
+ * the stock_items_per_draw will be decreasing by 1 each day (assuming there is enough tickets and it is won every day), and when it reaches 0, the prize is not available anymore.
111
+ */
112
+ stock_items_per_draw?: number;
113
+
114
+ winners: RafflePrizeWinner[]
115
+ }
116
+
117
+ export { RafflePrize }
@@ -0,0 +1,11 @@
1
+ import { RaffleTicket } from "./RaffleTicket";
2
+
3
+ interface RafflePrizeWinner {
4
+ user_id: number;
5
+ public_username?: string;
6
+ avatar_id: string;
7
+ avatar_url?: string;
8
+ ticket: RaffleTicket;
9
+ }
10
+
11
+ export { RafflePrizeWinner }
@@ -0,0 +1,9 @@
1
+
2
+ interface RaffleTicket {
3
+ /* int presentation of the ticket */
4
+ id: number;
5
+ /* String presentation of ticket */
6
+ s: string;
7
+ }
8
+
9
+ export { RaffleTicket };
@@ -0,0 +1,9 @@
1
+ export * from './GetDrawRunRequest';
2
+ export * from './GetDrawRunResponse';
3
+ export * from './GetRafflesRequest';
4
+ export * from './GetRafflesResponse';
5
+ export * from './Raffle';
6
+ export * from './RaffleDraw';
7
+ export * from './RafflePrize';
8
+ export * from './RafflePrizeWinner';
9
+ export * from './RaffleTicket';
@@ -121,6 +121,8 @@ import { SAWDoAcknowledgeBatchRequest } from './MiniGames/SAWDoAcknowledgeBatchR
121
121
  import { SAWDoAcknowledgeBatchResponse } from './MiniGames/SAWDoAcknowledgeBatchResponse';
122
122
  import { GetRelatedAchTourRequest } from './Missions/GetRelatedAchTourRequest';
123
123
  import { GetRelatedAchTourResponse } from './Missions/GetRelatedAchTourResponse';
124
+ import { GetRafflesResponse } from './Raffle/GetRafflesResponse';
125
+ import { GetRafflesRequest } from './Raffle/GetRafflesRequest';
124
126
 
125
127
  const PUBLIC_API_URL = 'https://papi{ENV_ID}.smartico.ai/services/public';
126
128
  const C_SOCKET_PROD = 'wss://api{ENV_ID}.smartico.ai/websocket/services';
@@ -1106,6 +1108,15 @@ class SmarticoAPI {
1106
1108
  return await this.send<GetRelatedAchTourResponse>(message, ClassId.GET_RELATED_ACH_N_TOURNAMENTS_RESPONSE);
1107
1109
 
1108
1110
  }
1111
+
1112
+ public async getRaffles(user_ext_id: string): Promise<GetRafflesResponse> {
1113
+ const message = this.buildMessage< GetRafflesRequest, GetRafflesResponse>(
1114
+ user_ext_id,
1115
+ ClassId.RAF_GET_RAFFLES_REQUEST
1116
+ );
1117
+
1118
+ return await this.send<GetRafflesResponse>(message, ClassId.RAF_GET_DRAW_RESPONSE);
1119
+ }
1109
1120
  }
1110
1121
 
1111
1122
  export { SmarticoAPI, MessageSender };
@@ -51,6 +51,7 @@ import {
51
51
  import { GetTournamentsResponse } from '../Tournaments';
52
52
  import { GetAchievementMapResponse } from '../Missions';
53
53
  import { GetRelatedAchTourResponse } from 'src/Missions/GetRelatedAchTourResponse';
54
+ import { GetRafflesResponse } from '../Raffle/GetRafflesResponse';
54
55
 
55
56
  /** @hidden */
56
57
  const CACHE_DATA_SEC = 30;
@@ -1044,4 +1045,9 @@ export class WSAPI {
1044
1045
  const result = await this.api.getRelatedItemsForGame(null, related_game_id);
1045
1046
  return result;
1046
1047
  }
1048
+
1049
+
1050
+ public async getRaffles(): Promise<GetRafflesResponse> {
1051
+ return await this.api.getRaffles(null);
1052
+ }
1047
1053
  }
package/tsconfig.json CHANGED
@@ -27,6 +27,7 @@
27
27
  "src/Leaderboard/LeaderBoardPeriodType.ts",
28
28
  "src/Base/AchRelatedGame.ts",
29
29
  "src/Jackpots/index.ts",
30
+ "src/Raffle/index.ts",
30
31
  "src/Missions/AchievementAvailabilityStatus.ts"
31
32
  ],
32
33
  "out": "docs",