@smartico/public-api 0.0.226 → 0.0.228

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 (78) hide show
  1. package/dist/Base/ClassId.d.ts +4 -2
  2. package/dist/Raffle/GetRaffleDrawRunsHistoryRequest.d.ts +5 -0
  3. package/dist/Raffle/GetRaffleDrawRunsHistoryResponse.d.ts +5 -0
  4. package/dist/Raffle/RaffleDraw.d.ts +31 -1
  5. package/dist/Raffle/RafflePrize.d.ts +4 -0
  6. package/dist/Raffle/RafflePrizeWinner.d.ts +2 -1
  7. package/dist/Raffle/index.d.ts +2 -0
  8. package/dist/SmarticoAPI.d.ts +4 -1
  9. package/dist/WSAPI/WSAPI.d.ts +3 -0
  10. package/dist/index.js +71 -21
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.modern.mjs +45 -19
  13. package/dist/index.modern.mjs.map +1 -1
  14. package/docs/README.md +3 -0
  15. package/docs/classes/WSAPI.md +32 -0
  16. package/docs/interfaces/GetRaffleDrawRunsHistoryRequest.md +49 -0
  17. package/docs/interfaces/GetRaffleDrawRunsHistoryResponse.md +63 -0
  18. package/docs/interfaces/RaffleDrawRun.md +61 -0
  19. package/docs/interfaces/RafflePrize.md +8 -0
  20. package/docs/interfaces/RafflePrizeWinner.md +6 -0
  21. package/package.json +1 -1
  22. package/src/Base/ClassId.ts +4 -3
  23. package/src/Raffle/GetRaffleDrawRunsHistoryRequest.ts +6 -0
  24. package/src/Raffle/GetRaffleDrawRunsHistoryResponse.ts +6 -0
  25. package/src/Raffle/RaffleDraw.ts +39 -1
  26. package/src/Raffle/RafflePrize.ts +6 -1
  27. package/src/Raffle/RafflePrizeWinner.ts +7 -6
  28. package/src/Raffle/index.ts +3 -1
  29. package/src/SmarticoAPI.ts +52 -18
  30. package/src/WSAPI/WSAPI.ts +10 -1
  31. package/dist/Quiz/MarketsAnswersType.d.ts +0 -22
  32. package/dist/Raffle/GetDrawResponse.d.ts +0 -5
  33. package/dist/SmarticoPublicAPI.d.ts +0 -23
  34. package/dist/Store/BuyShopItemErrorCode.d.ts +0 -10
  35. package/dist/Store/BuyShopItemRequest.d.ts +0 -4
  36. package/dist/Store/BuyShopItemResponse.d.ts +0 -4
  37. package/dist/Store/GetCategoriesShopResponse.d.ts +0 -5
  38. package/dist/Store/GetShopItemsResponse.d.ts +0 -5
  39. package/dist/Store/ShopCategory.d.ts +0 -5
  40. package/dist/Store/ShopCategoryPublicMeta.d.ts +0 -4
  41. package/dist/Store/ShopItem.d.ts +0 -9
  42. package/dist/Store/ShopItemPublicMeta.d.ts +0 -10
  43. package/dist/Store/ShopItemType.d.ts +0 -4
  44. package/dist/Store/StorItemPruchased.d.ts +0 -6
  45. package/dist/service/index.d.ts +0 -5
  46. package/dist/service/types/ErrorCodes.d.ts +0 -13
  47. package/dist/service/types/GRequest.d.ts +0 -16
  48. package/dist/service/types/GResponse.d.ts +0 -10
  49. package/dist/service/types/Game/GameAttemptType.d.ts +0 -6
  50. package/dist/service/types/Game/GameCanPlayType.d.ts +0 -10
  51. package/dist/service/types/Game/GameExternalStatus.d.ts +0 -6
  52. package/dist/service/types/Game/GameInfo.d.ts +0 -9
  53. package/dist/service/types/Game/GamePick.d.ts +0 -90
  54. package/dist/service/types/Game/GameUtil.d.ts +0 -7
  55. package/dist/service/types/SmarticoProto/GetTranslationsRequest.d.ts +0 -7
  56. package/dist/service/types/SmarticoProto/GetTranslationsResponse.d.ts +0 -7
  57. package/dist/service/types/SmarticoProto/ProtocolMessage.d.ts +0 -5
  58. package/dist/service/types/SmarticoProto/ProtocolRequest.d.ts +0 -6
  59. package/dist/service/types/SmarticoProto/ProtocolResponse.d.ts +0 -5
  60. package/dist/service/types/SmarticoProto/PublicLabelInfo.d.ts +0 -34
  61. package/dist/service/types/SmarticoProto/PublicProperties.d.ts +0 -11
  62. package/dist/service/types/SmarticoProto/ResponseIdentify.d.ts +0 -12
  63. package/dist/service/types/SmarticoProto/SAW/SAWAcknowledgeType.d.ts +0 -5
  64. package/dist/service/types/SmarticoProto/SAW/SAWBuyInType.d.ts +0 -5
  65. package/dist/service/types/SmarticoProto/SAW/SAWDoSpinRequest.d.ts +0 -5
  66. package/dist/service/types/SmarticoProto/SAW/SAWDoSpinResponse.d.ts +0 -15
  67. package/dist/service/types/SmarticoProto/SAW/SAWGameType.d.ts +0 -10
  68. package/dist/service/types/SmarticoProto/SAW/SAWGetTemplatesRequest.d.ts +0 -3
  69. package/dist/service/types/SmarticoProto/SAW/SAWGetTemplatesResponse.d.ts +0 -5
  70. package/dist/service/types/SmarticoProto/SAW/SAWPrize.d.ts +0 -11
  71. package/dist/service/types/SmarticoProto/SAW/SAWPrizeType.d.ts +0 -8
  72. package/dist/service/types/SmarticoProto/SAW/SAWPrizeUI.d.ts +0 -13
  73. package/dist/service/types/SmarticoProto/SAW/SAWTemplate.d.ts +0 -21
  74. package/dist/service/types/SmarticoProto/SAW/SAWTemplateUI.d.ts +0 -31
  75. package/dist/service/types/SmarticoProto/SAW/SAWWinSoundType.d.ts +0 -12
  76. package/dist/service/types/SmarticoProto/TranslationArea.d.ts +0 -9
  77. package/dist/service/types/User/UserInfo.d.ts +0 -10
  78. package/dist/util/Util.d.ts +0 -51
@@ -101,8 +101,10 @@ export declare enum ClassId {
101
101
  JP_WIN_PUSH = 808,
102
102
  RAF_GET_RAFFLES_REQUEST = 902,
103
103
  RAF_GET_RAFFLES_RESPONSE = 903,
104
- RAF_GET_DRAW_REQUEST = 904,
105
- RAF_GET_DRAW_RESPONSE = 905,
104
+ RAF_GET_DRAW_RUN_REQUEST = 904,
105
+ RAF_GET_DRAW_RUN_RESPONSE = 905,
106
+ RAF_GET_DRAW_HISTORY_REQUEST = 906,
107
+ RAF_GET_DRAW_HISTORY_RESPONSE = 907,
106
108
  REGISTER_PUSH_NOTIFICATIONS_TOKEN_REQ = 1003,
107
109
  REGISTER_PUSH_NOTIFICATIONS_TOKEN_RESP = 2003,
108
110
  CLIENT_DEBUG_REQUEST = 77777,
@@ -0,0 +1,5 @@
1
+ import { ProtocolMessage } from "src/Base/ProtocolMessage";
2
+ export interface GetRaffleDrawRunsHistoryRequest extends ProtocolMessage {
3
+ raffle_id: number;
4
+ draw_id: number;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { ProtocolResponse } from 'src/Base/ProtocolResponse';
2
+ import { RaffleDrawRun } from './RaffleDraw';
3
+ export interface GetRaffleDrawRunsHistoryResponse extends ProtocolResponse {
4
+ draw_runs: RaffleDrawRun[];
5
+ }
@@ -92,4 +92,34 @@ interface RaffleDraw {
92
92
  my_tickets_count: number;
93
93
  my_last_tickets: RaffleTicket[];
94
94
  }
95
- export { RaffleDraw };
95
+ interface RaffleDrawRun {
96
+ /**
97
+ * 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
98
+ * (internal name: schedule_id)
99
+ */
100
+ draw_id: number;
101
+ /**
102
+ * Field indicates the ID of the latest instance/run of draw
103
+ */
104
+ run_id: number;
105
+ /** Meta information of the Draw for the presentaiton in UI */
106
+ public_meta: RaffleDrawPublicMeta;
107
+ /** Date/time of the draw execution */
108
+ execution_ts: number;
109
+ /**
110
+ * Date/time starting from which the tickets will participate in the upcoming draw
111
+ * This value need to be taken into account with next_execute_ts field value, for example
112
+ * Next draw is at 10:00, ticket_start_date is 9:00, so all tickets that are collected after 9:00 will participate in the draw at 10:00
113
+ * (internally this value is calculated as next_execute_ts - ticket_start_date)
114
+ */
115
+ ticket_start_date: number;
116
+ /**
117
+ * Shows if user has won a prize in a current run
118
+ */
119
+ is_winner: boolean;
120
+ /**
121
+ * Shows if user has unclaimed prize
122
+ */
123
+ has_unclaimed_prize: boolean;
124
+ }
125
+ export { RaffleDraw, RaffleDrawRun };
@@ -92,6 +92,10 @@ interface RafflePrize {
92
92
  * 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.
93
93
  */
94
94
  stock_items_per_draw?: number;
95
+ /**
96
+ * Shows if the prize has been claimed
97
+ */
98
+ is_claimed: boolean;
95
99
  winners: RafflePrizeWinner[];
96
100
  }
97
101
  export { RafflePrize };
@@ -1,9 +1,10 @@
1
- import { RaffleTicket } from "./RaffleTicket";
1
+ import { RaffleTicket } from './RaffleTicket';
2
2
  interface RafflePrizeWinner {
3
3
  user_id: number;
4
4
  public_username?: string;
5
5
  avatar_id: string;
6
6
  avatar_url?: string;
7
7
  ticket: RaffleTicket;
8
+ won_ids: number[];
8
9
  }
9
10
  export { RafflePrizeWinner };
@@ -7,3 +7,5 @@ export * from './RaffleDraw';
7
7
  export * from './RafflePrize';
8
8
  export * from './RafflePrizeWinner';
9
9
  export * from './RaffleTicket';
10
+ export * from './GetRaffleDrawRunsHistoryRequest';
11
+ export * from './GetRaffleDrawRunsHistoryResponse';
@@ -21,6 +21,7 @@ import { SAWDoAcknowledgeBatchResponse } from './MiniGames/SAWDoAcknowledgeBatch
21
21
  import { GetRelatedAchTourResponse } from './Missions/GetRelatedAchTourResponse';
22
22
  import { GetRafflesResponse } from './Raffle/GetRafflesResponse';
23
23
  import { InboxCategories } from './Inbox/InboxCategories';
24
+ import { GetDrawRunRequest, GetDrawRunResponse, GetRaffleDrawRunsHistoryRequest, GetRaffleDrawRunsHistoryResponse } from './Raffle';
24
25
  interface Tracker {
25
26
  label_api_key: string;
26
27
  userPublicProps: any;
@@ -49,7 +50,7 @@ declare class SmarticoAPI {
49
50
  tracker?: Tracker;
50
51
  constructor(label_api_key: string, brand_api_key: string, messageSender: MessageSender, options?: IOptions);
51
52
  static getEnvDnsSuffix(label_api_key: string): string;
52
- private replaceDomains;
53
+ private static replaceSmrDomainsWithCloudfront;
53
54
  static getEnvId(label_api_key: string): number;
54
55
  static getCleanLabelApiKey(label_api_key: string): string;
55
56
  static getPublicUrl(label_api_key: string): string;
@@ -131,5 +132,7 @@ declare class SmarticoAPI {
131
132
  getWSCalls(): WSAPI;
132
133
  getRelatedItemsForGame(user_ext_id: string, related_game_id: string): Promise<GetRelatedAchTourResponse>;
133
134
  getRaffles(user_ext_id: string): Promise<GetRafflesResponse>;
135
+ getDrawRun(user_ext_id: string, payload: GetDrawRunRequest): Promise<GetDrawRunResponse>;
136
+ getRaffleDrawRunsHistory(user_ext_id: string, payload: GetRaffleDrawRunsHistoryRequest): Promise<GetRaffleDrawRunsHistoryResponse>;
134
137
  }
135
138
  export { SmarticoAPI, MessageSender };
@@ -5,6 +5,7 @@ import { JackpotDetails, JackpotsOptinResponse, JackpotsOptoutResponse } from '.
5
5
  import { GetRelatedAchTourResponse } from '../Missions/GetRelatedAchTourResponse';
6
6
  import { GetRafflesResponse } from '../Raffle/GetRafflesResponse';
7
7
  import { InboxCategories } from '../Inbox/InboxCategories';
8
+ import { GetDrawRunRequest, GetDrawRunResponse, GetRaffleDrawRunsHistoryRequest, GetRaffleDrawRunsHistoryResponse } from 'src/Raffle';
8
9
  /** @group General API */
9
10
  export declare class WSAPI {
10
11
  private api;
@@ -545,4 +546,6 @@ export declare class WSAPI {
545
546
  */
546
547
  getRelatedItemsForGame(related_game_id: string): Promise<GetRelatedAchTourResponse>;
547
548
  getRaffles(): Promise<GetRafflesResponse>;
549
+ getDrawRun(payload: GetDrawRunRequest): Promise<GetDrawRunResponse>;
550
+ getRaffleDrawRunsHistory(payload: GetRaffleDrawRunsHistoryRequest): Promise<GetRaffleDrawRunsHistoryResponse>;
548
551
  }
package/dist/index.js CHANGED
@@ -125,8 +125,10 @@ exports.ClassId = void 0;
125
125
  ClassId[ClassId["JP_WIN_PUSH"] = 808] = "JP_WIN_PUSH";
126
126
  ClassId[ClassId["RAF_GET_RAFFLES_REQUEST"] = 902] = "RAF_GET_RAFFLES_REQUEST";
127
127
  ClassId[ClassId["RAF_GET_RAFFLES_RESPONSE"] = 903] = "RAF_GET_RAFFLES_RESPONSE";
128
- ClassId[ClassId["RAF_GET_DRAW_REQUEST"] = 904] = "RAF_GET_DRAW_REQUEST";
129
- ClassId[ClassId["RAF_GET_DRAW_RESPONSE"] = 905] = "RAF_GET_DRAW_RESPONSE";
128
+ ClassId[ClassId["RAF_GET_DRAW_RUN_REQUEST"] = 904] = "RAF_GET_DRAW_RUN_REQUEST";
129
+ ClassId[ClassId["RAF_GET_DRAW_RUN_RESPONSE"] = 905] = "RAF_GET_DRAW_RUN_RESPONSE";
130
+ ClassId[ClassId["RAF_GET_DRAW_HISTORY_REQUEST"] = 906] = "RAF_GET_DRAW_HISTORY_REQUEST";
131
+ ClassId[ClassId["RAF_GET_DRAW_HISTORY_RESPONSE"] = 907] = "RAF_GET_DRAW_HISTORY_RESPONSE";
130
132
  /*
131
133
  RAF_GET_TICKETS_REQUEST = 902,
132
134
  RAF_GET_TICKETS_RESPONSE = 903,
@@ -2742,6 +2744,22 @@ var WSAPI = /*#__PURE__*/function () {
2742
2744
  return Promise.reject(e);
2743
2745
  }
2744
2746
  };
2747
+ _proto.getDrawRun = function getDrawRun(payload) {
2748
+ try {
2749
+ var _this47 = this;
2750
+ return Promise.resolve(_this47.api.getDrawRun(null, payload));
2751
+ } catch (e) {
2752
+ return Promise.reject(e);
2753
+ }
2754
+ };
2755
+ _proto.getRaffleDrawRunsHistory = function getRaffleDrawRunsHistory(payload) {
2756
+ try {
2757
+ var _this48 = this;
2758
+ return Promise.resolve(_this48.api.getRaffleDrawRunsHistory(null, payload));
2759
+ } catch (e) {
2760
+ return Promise.reject(e);
2761
+ }
2762
+ };
2745
2763
  return WSAPI;
2746
2764
  }();
2747
2765
 
@@ -2931,25 +2949,37 @@ var SmarticoAPI = /*#__PURE__*/function () {
2931
2949
  }
2932
2950
  return ENV_ID;
2933
2951
  };
2934
- var _proto = SmarticoAPI.prototype;
2935
- _proto.replaceDomains = function replaceDomains(obj) {
2952
+ SmarticoAPI.replaceSmrDomainsWithCloudfront = function replaceSmrDomainsWithCloudfront(value) {
2953
+ if (!value) {
2954
+ return value;
2955
+ }
2936
2956
  var domains = {
2957
+ 'img.smr.vc': 'd1am61onjxtys8.cloudfront.net',
2958
+ 'img3.smr.vc': 'd3dubbodzd2q05.cloudfront.net',
2959
+ 'img4.smr.vc': 'dvm0p9vsezqr2.cloudfront.net',
2960
+ 'img5.smr.vc': 'd3gen1ksvxhac8.cloudfront.net',
2961
+ 'img6.smr.vc': 'db1kmyg7iufeo.cloudfront.net',
2962
+ 'static.smr.vc': 'dtt380pweilws.cloudfront.net',
2963
+ 'static3.smr.vc': 'd1qt8ake8g4imn.cloudfront.net',
2937
2964
  'static4.smr.vc': 'd146b4m7rkvjkw.cloudfront.net',
2938
- 'img4.smr.vc': 'dvm0p9vsezqr2.cloudfront.net'
2965
+ 'static5.smr.vc': 'd121pfj16xdfcq.cloudfront.net',
2966
+ 'static6.smr.vc': 'd21deilz814qgl.cloudfront.net'
2939
2967
  };
2940
- var newObject = obj;
2941
- var oldDomains = Object.keys(domains);
2942
- for (var _i = 0, _oldDomains = oldDomains; _i < _oldDomains.length; _i++) {
2943
- var oldDomain = _oldDomains[_i];
2944
- var stringified = JSON.stringify(newObject);
2945
- try {
2946
- var replacedString = stringified.replace(new RegExp(oldDomain, 'g'), domains[oldDomain]);
2947
- newObject = JSON.parse(replacedString);
2948
- } catch (error) {
2949
- console.error(error);
2950
- }
2968
+ var escapeRegExp = function escapeRegExp(str) {
2969
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2970
+ };
2971
+ var replacedValue = typeof value === 'string' ? value : JSON.stringify(value);
2972
+ for (var _i = 0, _Object$entries = Object.entries(domains); _i < _Object$entries.length; _i++) {
2973
+ var _Object$entries$_i = _Object$entries[_i],
2974
+ oldDomain = _Object$entries$_i[0],
2975
+ newDomain = _Object$entries$_i[1];
2976
+ replacedValue = replacedValue.replace(new RegExp(escapeRegExp(oldDomain), 'g'), newDomain);
2977
+ }
2978
+ try {
2979
+ return typeof value === 'string' ? replacedValue : JSON.parse(replacedValue);
2980
+ } catch (err) {
2981
+ return value;
2951
2982
  }
2952
- return newObject;
2953
2983
  };
2954
2984
  SmarticoAPI.getEnvId = function getEnvId(label_api_key) {
2955
2985
  return label_api_key.length === 38 ? parseInt(label_api_key.substring(37, 38), 10) : 2;
@@ -2965,12 +2995,14 @@ var SmarticoAPI = /*#__PURE__*/function () {
2965
2995
  };
2966
2996
  SmarticoAPI.getAvatarUrl = function getAvatarUrl(label_api_key) {
2967
2997
  var envId = SmarticoAPI.getEnvDnsSuffix(label_api_key);
2998
+ var avatarUrl = AVATAR_DOMAIN.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
2968
2999
  if (envId === '4') {
2969
- return 'https://dvm0p9vsezqr2.cloudfront.net';
3000
+ return SmarticoAPI.replaceSmrDomainsWithCloudfront(avatarUrl);
2970
3001
  } else {
2971
- return AVATAR_DOMAIN.replace('{ENV_ID}', SmarticoAPI.getEnvDnsSuffix(label_api_key));
3002
+ return avatarUrl;
2972
3003
  }
2973
3004
  };
3005
+ var _proto = SmarticoAPI.prototype;
2974
3006
  _proto.send = function send(message, expectCID, force_language) {
2975
3007
  try {
2976
3008
  var _temp2 = function _temp2(_result) {
@@ -3029,8 +3061,8 @@ var SmarticoAPI = /*#__PURE__*/function () {
3029
3061
  return Promise.resolve(_this.messageSender(message, _this.publicUrl, expectCID)).then(function (_this$messageSender) {
3030
3062
  result = _this$messageSender;
3031
3063
  var timeEnd = new Date().getTime();
3032
- if (_this.label_api_key === 'a6e7ac26-c368-4892-9380-96e7ff82cf3e-4' && result) {
3033
- result = _this.replaceDomains(result);
3064
+ if (SmarticoAPI.getEnvDnsSuffix(_this.label_api_key) === 'a6e7ac26-c368-4892-9380-96e7ff82cf3e-4' && result) {
3065
+ result = SmarticoAPI.replaceSmrDomainsWithCloudfront(result);
3034
3066
  }
3035
3067
  if (_this.logHTTPTiming) {
3036
3068
  _this.logger.always('HTTP time, ms:' + (timeEnd - timeStart));
@@ -3951,6 +3983,24 @@ var SmarticoAPI = /*#__PURE__*/function () {
3951
3983
  return Promise.reject(e);
3952
3984
  }
3953
3985
  };
3986
+ _proto.getDrawRun = function getDrawRun(user_ext_id, payload) {
3987
+ try {
3988
+ var _this64 = this;
3989
+ var message = _this64.buildMessage(user_ext_id, exports.ClassId.RAF_GET_DRAW_RUN_REQUEST, payload);
3990
+ return Promise.resolve(_this64.send(message, exports.ClassId.RAF_GET_DRAW_RUN_RESPONSE));
3991
+ } catch (e) {
3992
+ return Promise.reject(e);
3993
+ }
3994
+ };
3995
+ _proto.getRaffleDrawRunsHistory = function getRaffleDrawRunsHistory(user_ext_id, payload) {
3996
+ try {
3997
+ var _this65 = this;
3998
+ var message = _this65.buildMessage(user_ext_id, exports.ClassId.RAF_GET_DRAW_HISTORY_REQUEST, payload);
3999
+ return Promise.resolve(_this65.send(message, exports.ClassId.RAF_GET_DRAW_HISTORY_RESPONSE));
4000
+ } catch (e) {
4001
+ return Promise.reject(e);
4002
+ }
4003
+ };
3954
4004
  return SmarticoAPI;
3955
4005
  }();
3956
4006