@smartico/public-api 0.0.73 → 0.0.74

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/docs/README.md CHANGED
@@ -21,6 +21,7 @@
21
21
  - [TStoreItem](interfaces/TStoreItem.md)
22
22
  - [TMissionOrBadge](interfaces/TMissionOrBadge.md)
23
23
  - [TMissionOrBadgeTask](interfaces/TMissionOrBadgeTask.md)
24
+ - [TMissionOptInResult](interfaces/TMissionOptInResult.md)
24
25
 
25
26
  ## General API
26
27
 
@@ -117,6 +117,24 @@ Plays the specified by template_id mini-game on behalf of user and returns prize
117
117
 
118
118
  ___
119
119
 
120
+ ### requestMissionOptIn
121
+
122
+ ▸ **requestMissionOptIn**(`mission_id`): `Promise`<[`TMissionOptInResult`](../interfaces/TMissionOptInResult.md)\>
123
+
124
+ Requests an opt-in for the specified mission_id. Returns the err_code.
125
+
126
+ #### Parameters
127
+
128
+ | Name | Type |
129
+ | :------ | :------ |
130
+ | `mission_id` | `number` |
131
+
132
+ #### Returns
133
+
134
+ `Promise`<[`TMissionOptInResult`](../interfaces/TMissionOptInResult.md)\>
135
+
136
+ ___
137
+
120
138
  ### getTournamentsList
121
139
 
122
140
  ▸ **getTournamentsList**(`params?`): `Promise`<[`TTournament`](../interfaces/TTournament.md)[]\>
@@ -0,0 +1,19 @@
1
+ # Interface: TMissionOptInResult
2
+
3
+ TMissionOptInResult describes the response of call to _smartico.api.requestMissionOptIn(mission_id) method
4
+
5
+ ## Properties
6
+
7
+ ### err\_code
8
+
9
+ • **err\_code**: `number`
10
+
11
+ Error code that represents outcome of the opt-in request. Successful opt-in in case err_code is 0
12
+
13
+ ___
14
+
15
+ ### err\_message
16
+
17
+ • **err\_message**: `string`
18
+
19
+ Optional error message
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.73",
3
+ "version": "0.0.74",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,7 @@ import { GetLabelInfoResponse } from './Core/GetLabelInfoResponse';
12
12
  import { GetLabelInfoRequest } from './Core/GetLabelInfoRequest';
13
13
  import { GetInboxMessagesRequest, GetInboxMessagesResponse } from './Inbox';
14
14
  import { GetCategoriesStoreResponse, GetStoreItemsResponse, StoreCategoryTransform, StoreItemTransform } from './Store';
15
- import { AchievementType, GetAchievementMapRequest, GetAchievementMapResponse, UserAchievementTransform } from './Missions';
15
+ import { AchievementOptinRequest, AchievementOptinResponse, AchievementType, GetAchievementMapRequest, GetAchievementMapResponse, UserAchievementTransform } from './Missions';
16
16
  import { GetTournamentInfoRequest, GetTournamentInfoResponse, GetTournamentsRequest, GetTournamentsResponse, TournamentItemsTransform, tournamentInfoItemTransform } from './Tournaments';
17
17
  import { GetLeaderBoardsRequest, GetLeaderBoardsResponse, LeaderBoardDetails, LeaderBoardPeriodType } from "./Leaderboard";
18
18
  import { GetLevelMapResponse, GetLevelMapResponseTransform } from "./Level";
@@ -334,6 +334,16 @@ class SmarticoAPI {
334
334
  return {...spinAttemptResponse, request_id };
335
335
  }
336
336
 
337
+ public async missionOptIn(user_ext_id: string, mission_id: number) {
338
+ const message = this.buildMessage<AchievementOptinRequest, AchievementOptinResponse>(user_ext_id, ClassId.MISSION_OPTIN_REQUEST, {
339
+ achievementId: mission_id
340
+ });
341
+
342
+ const res = await this.send<AchievementOptinResponse>(message, ClassId.MISSION_OPTIN_RESPONSE);
343
+
344
+ return res;
345
+ }
346
+
337
347
  public async inboxGetMessages(user_ext_id: string, limit: number = 10, offset: number = 0): Promise<GetInboxMessagesResponse> {
338
348
 
339
349
  const message = this.buildMessage<GetInboxMessagesRequest, GetInboxMessagesResponse>(user_ext_id, ClassId.GET_INBOX_MESSAGES_REQUEST, {
@@ -3,7 +3,7 @@ import { CoreUtils } from "../Core";
3
3
  import { MiniGamePrizeTypeName, SAWDoSpinResponse, SAWSpinErrorCode, SAWSpinsCountPush } from "../MiniGames";
4
4
  import { ECacheContext, OCache } from "../OCache";
5
5
  import { SmarticoAPI } from "../SmarticoAPI";
6
- import { TLevel, TMiniGamePlayResult, TMiniGamePrize, TMiniGameTemplate, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TUserProfile } from "./WSAPITypes";
6
+ import { TLevel, TMiniGamePlayResult, TMiniGamePrize, TMiniGameTemplate, TMissionOptInResult, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TUserProfile } from "./WSAPITypes";
7
7
 
8
8
  /** @hidden */
9
9
  const CACHE_DATA_SEC = 30;
@@ -24,7 +24,6 @@ export class WSAPI {
24
24
  constructor(private api: SmarticoAPI) {
25
25
  const on = this.api.tracker.on;
26
26
  on(ClassId.SAW_SPINS_COUNT_PUSH, (data: SAWSpinsCountPush) => this.updateOnSpin(data));
27
- on(ClassId.SAW_SPINS_COUNT_PUSH, (data: SAWSpinsCountPush) => this.updateOnSpin(data));
28
27
  on(ClassId.SAW_SHOW_SPIN_PUSH, () => this.updateOnAddSpin());
29
28
  on(ClassId.SAW_DO_SPIN_RESPONSE, (data: SAWDoSpinResponse) => on(ClassId.SAW_AKNOWLEDGE_RESPONSE, () => this.updateOnPrizeWin(data)));
30
29
  on(ClassId.MISSION_OPTIN_RESPONSE, () => this.updateMissionsOnOptIn());
@@ -103,7 +102,19 @@ export class WSAPI {
103
102
  }
104
103
 
105
104
  return o;
106
- }
105
+ }
106
+
107
+ /** Requests an opt-in for the specified mission_id. Returns the err_code. */
108
+ public async requestMissionOptIn(mission_id: number): Promise<TMissionOptInResult>{
109
+ const r = await this.api.missionOptIn(null, mission_id);
110
+
111
+ const o: TMissionOptInResult = {
112
+ err_code: r.errCode,
113
+ err_message: r.errMsg,
114
+ }
115
+
116
+ return o;
117
+ }
107
118
 
108
119
  /** Returns all the active instances of tournaments
109
120
  * The returned list is cached for 30 seconds. But you can pass the onUpdate callback as a parameter. Note that each time you call getTournamentsList with a new onUpdate callback, the old one will be overwritten by the new one.
@@ -372,4 +372,14 @@ export interface TMissionOrBadgeTask {
372
372
  is_completed: boolean,
373
373
  /** The progress of the task in percents */
374
374
  progress: number
375
+ }
376
+
377
+ /**
378
+ * TMissionOptInResult describes the response of call to _smartico.api.requestMissionOptIn(mission_id) method
379
+ */
380
+ export interface TMissionOptInResult {
381
+ /** Error code that represents outcome of the opt-in request. Successful opt-in in case err_code is 0 */
382
+ err_code: number;
383
+ /** Optional error message */
384
+ err_message: string;
375
385
  }