@smartico/public-api 0.0.106 → 0.0.108
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/dist/Inbox/GetInboxMessagesResponse.d.ts +2 -0
- package/dist/Inbox/InboxMessage.d.ts +15 -12
- package/dist/Inbox/MarkInboxMessageDeletedResponse.d.ts +1 -0
- package/dist/Inbox/MarkInboxMessageReadResponse.d.ts +1 -0
- package/dist/Inbox/MarkInboxMessageStarredResponse.d.ts +1 -0
- package/dist/SmarticoAPI.d.ts +14 -3
- package/dist/Store/BuyStoreItemErrorCode.d.ts +2 -1
- package/dist/Store/StoreItem.d.ts +1 -0
- package/dist/WSAPI/WSAPI.d.ts +31 -2
- package/dist/WSAPI/WSAPITypes.d.ts +41 -1
- package/dist/index.js +325 -40
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +193 -17
- package/dist/index.modern.mjs.map +1 -1
- package/docs/README.md +3 -0
- package/docs/classes/WSAPI.md +118 -1
- package/docs/enums/BuyStoreItemErrorCode.md +6 -0
- package/docs/interfaces/InboxMarkMessageAction.md +17 -0
- package/docs/interfaces/TInboxMessage.md +33 -0
- package/docs/interfaces/TInboxMessageBody.md +52 -0
- package/docs/interfaces/TMissionOrBadge.md +1 -1
- package/docs/interfaces/TStoreItem.md +8 -0
- package/package.json +1 -1
- package/src/Inbox/GetInboxMessagesResponse.ts +14 -0
- package/src/Inbox/InboxMessage.ts +35 -9
- package/src/Inbox/MarkInboxMessageDeletedResponse.ts +1 -0
- package/src/Inbox/MarkInboxMessageReadResponse.ts +1 -0
- package/src/Inbox/MarkInboxMessageStarredResponse.ts +1 -0
- package/src/SmarticoAPI.ts +94 -3
- package/src/Store/BuyStoreItemErrorCode.ts +2 -1
- package/src/Store/StoreItem.ts +3 -1
- package/src/WSAPI/WSAPI.ts +82 -2
- package/src/WSAPI/WSAPITypes.ts +44 -1
package/docs/README.md
CHANGED
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
- [TTournamentRegistrationResult](interfaces/TTournamentRegistrationResult.md)
|
|
29
29
|
- [TBuyStoreItemResult](interfaces/TBuyStoreItemResult.md)
|
|
30
30
|
- [TGetTranslations](interfaces/TGetTranslations.md)
|
|
31
|
+
- [TInboxMessage](interfaces/TInboxMessage.md)
|
|
32
|
+
- [TInboxMessageBody](interfaces/TInboxMessageBody.md)
|
|
33
|
+
- [InboxMarkMessageAction](interfaces/InboxMarkMessageAction.md)
|
|
31
34
|
|
|
32
35
|
## General API
|
|
33
36
|
|
package/docs/classes/WSAPI.md
CHANGED
|
@@ -174,7 +174,7 @@ ___
|
|
|
174
174
|
|
|
175
175
|
▸ **getTournamentInstanceInfo**(`tournamentInstanceId`): `Promise`<[`TTournamentDetailed`](../interfaces/TTournamentDetailed.md)\>
|
|
176
176
|
|
|
177
|
-
Returns details information of specific tournament instance, the response will
|
|
177
|
+
Returns details information of specific tournament instance, the response will include tournament info and the leaderboard of players
|
|
178
178
|
|
|
179
179
|
#### Parameters
|
|
180
180
|
|
|
@@ -206,6 +206,123 @@ Requests registration for the specified tournament instance. Returns the err_cod
|
|
|
206
206
|
|
|
207
207
|
___
|
|
208
208
|
|
|
209
|
+
### getInboxMessages
|
|
210
|
+
|
|
211
|
+
▸ **getInboxMessages**(`params?`): `Promise`<[`TInboxMessage`](../interfaces/TInboxMessage.md)[]\>
|
|
212
|
+
|
|
213
|
+
#### Parameters
|
|
214
|
+
|
|
215
|
+
| Name | Type |
|
|
216
|
+
| :------ | :------ |
|
|
217
|
+
| `params` | `Object` |
|
|
218
|
+
| `params.from?` | `number` |
|
|
219
|
+
| `params.to?` | `number` |
|
|
220
|
+
| `params.onlyFavorite?` | `boolean` |
|
|
221
|
+
| `params.onUpdate?` | (`data`: [`TInboxMessage`](../interfaces/TInboxMessage.md)[]) => `void` |
|
|
222
|
+
|
|
223
|
+
#### Returns
|
|
224
|
+
|
|
225
|
+
`Promise`<[`TInboxMessage`](../interfaces/TInboxMessage.md)[]\>
|
|
226
|
+
|
|
227
|
+
___
|
|
228
|
+
|
|
229
|
+
### getInboxMessageBody
|
|
230
|
+
|
|
231
|
+
▸ **getInboxMessageBody**(`messageGuid`): `Promise`<[`TInboxMessageBody`](../interfaces/TInboxMessageBody.md)\>
|
|
232
|
+
|
|
233
|
+
Returns the message body of the specified message guid.
|
|
234
|
+
|
|
235
|
+
#### Parameters
|
|
236
|
+
|
|
237
|
+
| Name | Type |
|
|
238
|
+
| :------ | :------ |
|
|
239
|
+
| `messageGuid` | `string` |
|
|
240
|
+
|
|
241
|
+
#### Returns
|
|
242
|
+
|
|
243
|
+
`Promise`<[`TInboxMessageBody`](../interfaces/TInboxMessageBody.md)\>
|
|
244
|
+
|
|
245
|
+
___
|
|
246
|
+
|
|
247
|
+
### markInboxMessageAsRead
|
|
248
|
+
|
|
249
|
+
▸ **markInboxMessageAsRead**(`messageGuid`): `Promise`<[`InboxMarkMessageAction`](../interfaces/InboxMarkMessageAction.md)\>
|
|
250
|
+
|
|
251
|
+
Requests to mark inbox message with specified guid as read
|
|
252
|
+
|
|
253
|
+
#### Parameters
|
|
254
|
+
|
|
255
|
+
| Name | Type |
|
|
256
|
+
| :------ | :------ |
|
|
257
|
+
| `messageGuid` | `string` |
|
|
258
|
+
|
|
259
|
+
#### Returns
|
|
260
|
+
|
|
261
|
+
`Promise`<[`InboxMarkMessageAction`](../interfaces/InboxMarkMessageAction.md)\>
|
|
262
|
+
|
|
263
|
+
___
|
|
264
|
+
|
|
265
|
+
### markAllInboxMessagesAsRead
|
|
266
|
+
|
|
267
|
+
▸ **markAllInboxMessagesAsRead**(): `Promise`<[`InboxMarkMessageAction`](../interfaces/InboxMarkMessageAction.md)\>
|
|
268
|
+
|
|
269
|
+
Requests to mark all inbox messages as read
|
|
270
|
+
|
|
271
|
+
#### Returns
|
|
272
|
+
|
|
273
|
+
`Promise`<[`InboxMarkMessageAction`](../interfaces/InboxMarkMessageAction.md)\>
|
|
274
|
+
|
|
275
|
+
___
|
|
276
|
+
|
|
277
|
+
### markUnmarkInboxMessageAsFavorite
|
|
278
|
+
|
|
279
|
+
▸ **markUnmarkInboxMessageAsFavorite**(`messageGuid`, `mark`): `Promise`<[`InboxMarkMessageAction`](../interfaces/InboxMarkMessageAction.md)\>
|
|
280
|
+
|
|
281
|
+
Requests to mark inbox message with specified guid as favorite. Pass mark true to add message to favorite and false to remove.
|
|
282
|
+
|
|
283
|
+
#### Parameters
|
|
284
|
+
|
|
285
|
+
| Name | Type |
|
|
286
|
+
| :------ | :------ |
|
|
287
|
+
| `messageGuid` | `string` |
|
|
288
|
+
| `mark` | `boolean` |
|
|
289
|
+
|
|
290
|
+
#### Returns
|
|
291
|
+
|
|
292
|
+
`Promise`<[`InboxMarkMessageAction`](../interfaces/InboxMarkMessageAction.md)\>
|
|
293
|
+
|
|
294
|
+
___
|
|
295
|
+
|
|
296
|
+
### deleteInboxMessage
|
|
297
|
+
|
|
298
|
+
▸ **deleteInboxMessage**(`messageGuid`): `Promise`<[`InboxMarkMessageAction`](../interfaces/InboxMarkMessageAction.md)\>
|
|
299
|
+
|
|
300
|
+
Requests to delete inbox message
|
|
301
|
+
|
|
302
|
+
#### Parameters
|
|
303
|
+
|
|
304
|
+
| Name | Type |
|
|
305
|
+
| :------ | :------ |
|
|
306
|
+
| `messageGuid` | `string` |
|
|
307
|
+
|
|
308
|
+
#### Returns
|
|
309
|
+
|
|
310
|
+
`Promise`<[`InboxMarkMessageAction`](../interfaces/InboxMarkMessageAction.md)\>
|
|
311
|
+
|
|
312
|
+
___
|
|
313
|
+
|
|
314
|
+
### deleteAllInboxMessages
|
|
315
|
+
|
|
316
|
+
▸ **deleteAllInboxMessages**(): `Promise`<[`InboxMarkMessageAction`](../interfaces/InboxMarkMessageAction.md)\>
|
|
317
|
+
|
|
318
|
+
Requests to delete all inbox messages
|
|
319
|
+
|
|
320
|
+
#### Returns
|
|
321
|
+
|
|
322
|
+
`Promise`<[`InboxMarkMessageAction`](../interfaces/InboxMarkMessageAction.md)\>
|
|
323
|
+
|
|
324
|
+
___
|
|
325
|
+
|
|
209
326
|
### getTranslations
|
|
210
327
|
|
|
211
328
|
▸ **getTranslations**(`lang_code`): `Promise`<[`TGetTranslations`](../interfaces/TGetTranslations.md)\>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Interface: InboxMarkMessageAction
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
### err\_code
|
|
6
|
+
|
|
7
|
+
• **err\_code**: `number`
|
|
8
|
+
|
|
9
|
+
An error code representing the result of marking a message as deleted, favorite or read. Successful marking action if err_code is 0
|
|
10
|
+
|
|
11
|
+
___
|
|
12
|
+
|
|
13
|
+
### err\_message
|
|
14
|
+
|
|
15
|
+
• **err\_message**: `string`
|
|
16
|
+
|
|
17
|
+
Optional error message
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Interface: TInboxMessage
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
### message\_guid
|
|
6
|
+
|
|
7
|
+
• **message\_guid**: `string`
|
|
8
|
+
|
|
9
|
+
Uniq identifier of the message. It is needed to request the message body, mark the message as read/deleted/favorite.
|
|
10
|
+
|
|
11
|
+
___
|
|
12
|
+
|
|
13
|
+
### sent\_date
|
|
14
|
+
|
|
15
|
+
• **sent\_date**: `string`
|
|
16
|
+
|
|
17
|
+
Date when the message was sent
|
|
18
|
+
|
|
19
|
+
___
|
|
20
|
+
|
|
21
|
+
### read
|
|
22
|
+
|
|
23
|
+
• **read**: `boolean`
|
|
24
|
+
|
|
25
|
+
Indicator if a message is read
|
|
26
|
+
|
|
27
|
+
___
|
|
28
|
+
|
|
29
|
+
### favorite
|
|
30
|
+
|
|
31
|
+
• **favorite**: `boolean`
|
|
32
|
+
|
|
33
|
+
Indicator if a message is added to favorites
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Interface: TInboxMessageBody
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
### title
|
|
6
|
+
|
|
7
|
+
• **title**: `string`
|
|
8
|
+
|
|
9
|
+
Message title
|
|
10
|
+
|
|
11
|
+
___
|
|
12
|
+
|
|
13
|
+
### preview\_body
|
|
14
|
+
|
|
15
|
+
• **preview\_body**: `string`
|
|
16
|
+
|
|
17
|
+
Short preview body of the message
|
|
18
|
+
|
|
19
|
+
___
|
|
20
|
+
|
|
21
|
+
### icon
|
|
22
|
+
|
|
23
|
+
• **icon**: `string`
|
|
24
|
+
|
|
25
|
+
Message icon
|
|
26
|
+
|
|
27
|
+
___
|
|
28
|
+
|
|
29
|
+
### action
|
|
30
|
+
|
|
31
|
+
• **action**: `string`
|
|
32
|
+
|
|
33
|
+
The action that should be performed when user clicks on the message.
|
|
34
|
+
Can be URL or deep link, e.g. 'dp:deposit'. The most safe to execute CTA is to pass it to _smartico.dp(cta_action);
|
|
35
|
+
The 'dp' function will handle the CTA and will execute it in the most safe way.
|
|
36
|
+
If the message has a rich html body - the action will always be 'dp:inbox' which will open the inbox widget when triggered.
|
|
37
|
+
|
|
38
|
+
___
|
|
39
|
+
|
|
40
|
+
### html\_body
|
|
41
|
+
|
|
42
|
+
• `Optional` **html\_body**: `string`
|
|
43
|
+
|
|
44
|
+
Rich HTML body of the message.
|
|
45
|
+
|
|
46
|
+
___
|
|
47
|
+
|
|
48
|
+
### buttons
|
|
49
|
+
|
|
50
|
+
• `Optional` **buttons**: { `action`: `string` ; `text`: `string` }[]
|
|
51
|
+
|
|
52
|
+
Optional additional buttons to show in the message, available only if message has rich HTML body. Max count - 2.
|
|
@@ -122,7 +122,7 @@ ___
|
|
|
122
122
|
• **cta\_action**: `string`
|
|
123
123
|
|
|
124
124
|
The action that should be performed when user clicks on the mission or badge
|
|
125
|
-
Can be URL or deep link, e.g. 'dp:deposit'. The most safe to execute CTA is to pass it to _smartico.
|
|
125
|
+
Can be URL or deep link, e.g. 'dp:deposit'. The most safe to execute CTA is to pass it to _smartico.dp(cta_action);
|
|
126
126
|
The 'dp' function will handle the CTA and will execute it in the most safe way
|
|
127
127
|
|
|
128
128
|
___
|
|
@@ -100,3 +100,11 @@ ___
|
|
|
100
100
|
• **category\_ids**: `number`[]
|
|
101
101
|
|
|
102
102
|
The list of IDs of the categories where the store item is assigned, information about categories can be retrievend with getStoreCategories method
|
|
103
|
+
|
|
104
|
+
___
|
|
105
|
+
|
|
106
|
+
### pool
|
|
107
|
+
|
|
108
|
+
• `Optional` **pool**: `number`
|
|
109
|
+
|
|
110
|
+
Number of items in the pool avaliable for the purchase.
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TInboxMessage } from "src/WSAPI/WSAPITypes";
|
|
1
2
|
import { ProtocolResponse } from "../Base/ProtocolResponse";
|
|
2
3
|
import { InboxMessage } from "./InboxMessage";
|
|
3
4
|
|
|
@@ -5,3 +6,16 @@ export interface GetInboxMessagesResponse extends ProtocolResponse {
|
|
|
5
6
|
|
|
6
7
|
log: InboxMessage[];
|
|
7
8
|
}
|
|
9
|
+
|
|
10
|
+
export const InboxMessagesTransform = ((items: InboxMessage[]): TInboxMessage[] => {
|
|
11
|
+
|
|
12
|
+
return items.map(item => {
|
|
13
|
+
const x: TInboxMessage = {
|
|
14
|
+
sent_date: item.createDate,
|
|
15
|
+
message_guid: item.engagement_uid,
|
|
16
|
+
read: item.is_read,
|
|
17
|
+
favorite: item.is_starred,
|
|
18
|
+
}
|
|
19
|
+
return x;
|
|
20
|
+
});
|
|
21
|
+
})
|
|
@@ -1,19 +1,45 @@
|
|
|
1
|
+
import { TInboxMessageBody } from "src/WSAPI/WSAPITypes";
|
|
1
2
|
import { InboxMessageType } from "./InboxMessageType";
|
|
2
3
|
|
|
4
|
+
export interface InboxMessageBody {
|
|
5
|
+
action: string;
|
|
6
|
+
body: string;
|
|
7
|
+
type: InboxMessageType;
|
|
8
|
+
image: string;
|
|
9
|
+
title: string;
|
|
10
|
+
html_body: string;
|
|
11
|
+
additional_buttons?: { inbox_cta_text: string, action: string }[];
|
|
12
|
+
}
|
|
13
|
+
|
|
3
14
|
export interface InboxMessage {
|
|
4
15
|
|
|
5
16
|
createDate: string;
|
|
6
|
-
body:
|
|
7
|
-
action: string;
|
|
8
|
-
body: string;
|
|
9
|
-
type: InboxMessageType;
|
|
10
|
-
image: string;
|
|
11
|
-
title: string;
|
|
12
|
-
html_body: string;
|
|
13
|
-
additional_buttons?: { inbox_cta_text: string, action: string }[];
|
|
14
|
-
};
|
|
17
|
+
body: InboxMessageBody;
|
|
15
18
|
engagement_uid: string;
|
|
16
19
|
is_read: boolean;
|
|
17
20
|
is_starred: boolean;
|
|
18
21
|
is_deleted: boolean;
|
|
19
22
|
}
|
|
23
|
+
|
|
24
|
+
export const InboxMessageBodyTransform = (item: InboxMessageBody): TInboxMessageBody => {
|
|
25
|
+
|
|
26
|
+
const x: TInboxMessageBody = {
|
|
27
|
+
action: item.action,
|
|
28
|
+
icon: item.image,
|
|
29
|
+
title: item.title,
|
|
30
|
+
preview_body: item.body,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (item.action === 'dp:inbox') {
|
|
34
|
+
if (item.additional_buttons && item.additional_buttons.length) {
|
|
35
|
+
x.buttons = item.additional_buttons.map(b => ({
|
|
36
|
+
action: b.action,
|
|
37
|
+
text: b.inbox_cta_text
|
|
38
|
+
}))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
x.html_body = item?.html_body || null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return x;
|
|
45
|
+
}
|
package/src/SmarticoAPI.ts
CHANGED
|
@@ -7,17 +7,17 @@ import { IntUtils } from './IntUtils';
|
|
|
7
7
|
import { ILogger } from './ILogger';
|
|
8
8
|
import { SAWDoAknowledgeRequest, SAWDoAknowledgeResponse, SAWDoSpinRequest, SAWDoSpinResponse, SAWSpinErrorCode, SAWTemplatesTransform } from './MiniGames';
|
|
9
9
|
import { ECacheContext, OCache } from './OCache';
|
|
10
|
-
import { CoreUtils, GetTranslationsRequest, GetTranslationsResponse, ResponseIdentify, TranslationArea } from './Core';
|
|
10
|
+
import { CoreUtils, GetTranslationsRequest, GetTranslationsResponse, PublicLabelSettings, ResponseIdentify, TranslationArea } from './Core';
|
|
11
11
|
import { GetLabelInfoResponse } from './Core/GetLabelInfoResponse';
|
|
12
12
|
import { GetLabelInfoRequest } from './Core/GetLabelInfoRequest';
|
|
13
|
-
import { GetInboxMessagesRequest, GetInboxMessagesResponse } from './Inbox';
|
|
13
|
+
import { GetInboxMessagesRequest, GetInboxMessagesResponse, InboxMessageBody, InboxMessageBodyTransform, InboxMessagesTransform, MarkInboxMessageDeletedRequest, MarkInboxMessageDeletedResponse, MarkInboxMessageReadRequest, MarkInboxMessageReadResponse, MarkInboxMessageStarredRequest, MarkInboxMessageStarredResponse } from './Inbox';
|
|
14
14
|
import { BuyStoreItemRequest, BuyStoreItemResponse, GetCategoriesStoreResponse, GetStoreItemsResponse, StoreCategoryTransform, StoreItemTransform } from './Store';
|
|
15
15
|
import { AchievementOptinRequest, AchievementOptinResponse, AchievementType, GetAchievementMapRequest, GetAchievementMapResponse, UserAchievementTransform } from './Missions';
|
|
16
16
|
import { GetTournamentInfoRequest, GetTournamentInfoResponse, GetTournamentsRequest, GetTournamentsResponse, TournamentItemsTransform, TournamentRegisterRequest, TournamentRegisterResponse, tournamentInfoItemTransform } from './Tournaments';
|
|
17
17
|
import { GetLeaderBoardsRequest, GetLeaderBoardsResponse, LeaderBoardDetails, LeaderBoardPeriodType } from "./Leaderboard";
|
|
18
18
|
import { GetLevelMapResponse, GetLevelMapResponseTransform } from "./Level";
|
|
19
19
|
import { WSAPI } from "./WSAPI/WSAPI";
|
|
20
|
-
import { TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreCategory, TStoreItem, TTournament, TTournamentDetailed } from "./WSAPI/WSAPITypes";
|
|
20
|
+
import { TInboxMessage, TInboxMessageBody, TLevel, TMiniGameTemplate, TMissionOrBadge, TStoreCategory, TStoreItem, TTournament, TTournamentDetailed } from "./WSAPI/WSAPITypes";
|
|
21
21
|
|
|
22
22
|
const PUBLIC_API_URL = 'https://papi{ENV_ID}.smartico.ai/services/public';
|
|
23
23
|
const C_SOCKET_PROD = 'wss://api{ENV_ID}.smartico.ai/websocket/services';
|
|
@@ -28,6 +28,7 @@ interface Tracker {
|
|
|
28
28
|
label_api_key: string;
|
|
29
29
|
userPublicProps: any;
|
|
30
30
|
on: (callBackKey: ClassId, func: (data: any) => void) => void;
|
|
31
|
+
getLabelSetting: (key: PublicLabelSettings) => any;
|
|
31
32
|
}
|
|
32
33
|
interface IOptions {
|
|
33
34
|
logger?: ILogger;
|
|
@@ -43,6 +44,7 @@ class SmarticoAPI {
|
|
|
43
44
|
|
|
44
45
|
private publicUrl: string;
|
|
45
46
|
private wsUrl: string;
|
|
47
|
+
private inboxCdnUrl: string;
|
|
46
48
|
private partnerUrl: string;
|
|
47
49
|
public avatarDomain: string;
|
|
48
50
|
|
|
@@ -525,6 +527,95 @@ class SmarticoAPI {
|
|
|
525
527
|
return await this.coreGetTranslations(user_ext_id, lang_code, areas, 30);
|
|
526
528
|
}
|
|
527
529
|
|
|
530
|
+
public async getInboxMessages(user_ext_id: string, limit: number = 20, offset: number = 0, starred_only: boolean): Promise<GetInboxMessagesResponse> {
|
|
531
|
+
const message = this.buildMessage<GetInboxMessagesRequest, GetInboxMessagesResponse>(user_ext_id, ClassId.GET_INBOX_MESSAGES_REQUEST, {
|
|
532
|
+
limit,
|
|
533
|
+
offset,
|
|
534
|
+
starred_only
|
|
535
|
+
});
|
|
536
|
+
return await this.send<GetInboxMessagesResponse>(message, ClassId.GET_INBOX_MESSAGES_RESPONSE);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
public async getInboxMessagesT(user_ext_id: string, from: number = 0, to: number = 20, favoriteOnly: boolean = false): Promise<TInboxMessage[]> {
|
|
540
|
+
const limit = (to - from) > 20 ? 20 : to - from;
|
|
541
|
+
const offset = from;
|
|
542
|
+
|
|
543
|
+
return InboxMessagesTransform((await this.getInboxMessages(user_ext_id, limit, offset, favoriteOnly)).log);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
public async getInboxMessageBody(messageGuid: string): Promise<InboxMessageBody> {
|
|
547
|
+
|
|
548
|
+
const getMessageBody = async (messageGuid: string): Promise<InboxMessageBody>=> {
|
|
549
|
+
const inboxCdnUrl = this.tracker.getLabelSetting(PublicLabelSettings.INBOX_PUBLIC_CDN);
|
|
550
|
+
|
|
551
|
+
try {
|
|
552
|
+
const url = `${inboxCdnUrl}${messageGuid}.json`;
|
|
553
|
+
|
|
554
|
+
const response = await fetch(url, {
|
|
555
|
+
method: 'GET',
|
|
556
|
+
headers: {
|
|
557
|
+
'Accept': 'application/json',
|
|
558
|
+
'Content-Type': 'application/json',
|
|
559
|
+
'Access-Control-Allow-Origin': '*'
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
const data = await response.json();
|
|
563
|
+
return data || {};
|
|
564
|
+
} catch (error) {
|
|
565
|
+
this.logger.error('Error fetching inbox message body:', error);
|
|
566
|
+
return null;
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
return await getMessageBody(messageGuid)
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
public async getInboxMessageBodyT(messageGuid: string): Promise<TInboxMessageBody> {
|
|
574
|
+
const message = await this.getInboxMessageBody(messageGuid);
|
|
575
|
+
return InboxMessageBodyTransform(message);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
public async markInboxMessageRead(user_ext_id: string, messageGuid: string): Promise<MarkInboxMessageReadResponse> {
|
|
579
|
+
const message = this.buildMessage<MarkInboxMessageReadRequest, MarkInboxMessageReadResponse>(user_ext_id, ClassId.MARK_INBOX_READ_REQUEST, {
|
|
580
|
+
engagement_uid: messageGuid
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
return await this.send<MarkInboxMessageReadResponse>(message, ClassId.MARK_INBOX_READ_RESPONSE);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
public async markAllInboxMessageRead(user_ext_id: string): Promise<MarkInboxMessageReadResponse> {
|
|
587
|
+
const message = this.buildMessage<MarkInboxMessageReadRequest, MarkInboxMessageReadResponse>(user_ext_id, ClassId.MARK_INBOX_READ_REQUEST, {
|
|
588
|
+
all_read: true
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
return await this.send<MarkInboxMessageReadResponse>(message, ClassId.MARK_INBOX_READ_RESPONSE);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
public async markUnmarkInboxMessageAsFavorite(user_ext_id: string, messageGuid: string, mark: boolean): Promise<MarkInboxMessageStarredResponse> {
|
|
595
|
+
const message = this.buildMessage<MarkInboxMessageStarredRequest, MarkInboxMessageStarredResponse>(user_ext_id, ClassId.MARK_INBOX_STARRED_REQUEST, {
|
|
596
|
+
engagement_uid: messageGuid,
|
|
597
|
+
is_starred: mark
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
return await this.send<MarkInboxMessageStarredResponse>(message, ClassId.MARK_INBOX_STARRED_RESPONSE);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
public async deleteInboxMessage(user_ext_id: string, messageGuid: string): Promise<MarkInboxMessageDeletedResponse> {
|
|
604
|
+
const message = this.buildMessage<MarkInboxMessageDeletedRequest, MarkInboxMessageDeletedResponse>(user_ext_id, ClassId.MARK_INBOX_DELETED_REQUEST, {
|
|
605
|
+
engagement_uid: messageGuid,
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
return await this.send<MarkInboxMessageDeletedResponse>(message, ClassId.MARK_INBOX_DELETED_RESPONSE);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
public async deleteAllInboxMessages(user_ext_id: string): Promise<MarkInboxMessageDeletedResponse> {
|
|
612
|
+
const message = this.buildMessage<MarkInboxMessageDeletedRequest, MarkInboxMessageDeletedResponse>(user_ext_id, ClassId.MARK_INBOX_DELETED_REQUEST, {
|
|
613
|
+
all_deleted: true
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
return await this.send<MarkInboxMessageDeletedResponse>(message, ClassId.MARK_INBOX_DELETED_RESPONSE);
|
|
617
|
+
}
|
|
618
|
+
|
|
528
619
|
|
|
529
620
|
public getWSCalls(): WSAPI {
|
|
530
621
|
return new WSAPI(this);
|
|
@@ -6,5 +6,6 @@ export enum BuyStoreItemErrorCode {
|
|
|
6
6
|
SHOP_FAILED_TO_BUY_SHOP_ITEM_CONDITION = 11003, // when not visible but trying to buy. Shoudnt happen
|
|
7
7
|
SHOP_FAILED_TO_BUY_SHOP_ITEM_CONDITION_PURSHASE = 11004, // when visible but not matching to purchase segment
|
|
8
8
|
SHOP_FAILED_TO_BUY_MATCHING_BONUS = 11005,
|
|
9
|
-
SHOP_FAILED_MAX_BOUGHT_ITEMS_REACHED = 11006
|
|
9
|
+
SHOP_FAILED_MAX_BOUGHT_ITEMS_REACHED = 11006,
|
|
10
|
+
SHOP_FAILED_POOL_EMPTY = 11009,
|
|
10
11
|
}
|
package/src/Store/StoreItem.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface StoreItem {
|
|
|
8
8
|
itemPublicMeta: StoreItemPublicMeta;
|
|
9
9
|
categoryIds?: number[];
|
|
10
10
|
canBuy?: boolean;
|
|
11
|
+
shopPool: number;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
|
|
@@ -31,7 +32,8 @@ export const StoreItemTransform = (items: StoreItem[]): TStoreItem[] => {
|
|
|
31
32
|
}[r.itemTypeId] as 'bonus' | 'manual',
|
|
32
33
|
|
|
33
34
|
can_buy: r.canBuy,
|
|
34
|
-
category_ids: r.categoryIds ?? []
|
|
35
|
+
category_ids: r.categoryIds ?? [],
|
|
36
|
+
pool: r.shopPool,
|
|
35
37
|
}
|
|
36
38
|
return x;
|
|
37
39
|
});
|
package/src/WSAPI/WSAPI.ts
CHANGED
|
@@ -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 { TBuyStoreItemResult, TGetTranslations, TLevel, TMiniGamePlayResult,
|
|
6
|
+
import { InboxMarkMessageAction, TBuyStoreItemResult, TGetTranslations, TInboxMessage, TInboxMessageBody, TLevel, TMiniGamePlayResult, TMiniGameTemplate, TMissionOptInResult, TMissionOrBadge, TStoreItem, TTournament, TTournamentDetailed, TTournamentRegistrationResult, TUserProfile } from "./WSAPITypes";
|
|
7
7
|
|
|
8
8
|
/** @hidden */
|
|
9
9
|
const CACHE_DATA_SEC = 30;
|
|
@@ -12,6 +12,7 @@ enum onUpdateContextKey {
|
|
|
12
12
|
Saw = 'saw',
|
|
13
13
|
Missions = 'missions',
|
|
14
14
|
TournamentList = 'tournamentList',
|
|
15
|
+
InboxMessages = 'inboxMessages',
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
|
|
@@ -28,6 +29,7 @@ export class WSAPI {
|
|
|
28
29
|
on(ClassId.SAW_DO_SPIN_RESPONSE, (data: SAWDoSpinResponse) => on(ClassId.SAW_AKNOWLEDGE_RESPONSE, () => this.updateOnPrizeWin(data)));
|
|
29
30
|
on(ClassId.MISSION_OPTIN_RESPONSE, () => this.updateMissionsOnOptIn());
|
|
30
31
|
on(ClassId.TOURNAMENT_REGISTER_RESPONSE, () => this.updateTournamentsOnRegistration());
|
|
32
|
+
on(ClassId.CLIENT_ENGAGEMENT_EVENT_NEW, () => this.updateInboxMessages());
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/** Returns information about current user */
|
|
@@ -142,7 +144,7 @@ export class WSAPI {
|
|
|
142
144
|
return OCache.use(onUpdateContextKey.TournamentList, ECacheContext.WSAPI, () => this.api.tournamentsGetLobbyT(null), CACHE_DATA_SEC);
|
|
143
145
|
}
|
|
144
146
|
|
|
145
|
-
/** Returns details information of specific tournament instance, the response will
|
|
147
|
+
/** Returns details information of specific tournament instance, the response will include tournament info and the leaderboard of players */
|
|
146
148
|
public async getTournamentInstanceInfo(tournamentInstanceId: number): Promise<TTournamentDetailed> {
|
|
147
149
|
return this.api.tournamentsGetInfoT(null, tournamentInstanceId);
|
|
148
150
|
}
|
|
@@ -159,6 +161,79 @@ export class WSAPI {
|
|
|
159
161
|
return o;
|
|
160
162
|
}
|
|
161
163
|
|
|
164
|
+
/** Returns inbox messages based on the provided parameters. "From" and "to" indicate the range of messages to be fetched.
|
|
165
|
+
* The maximum number of messages per request is limited to 20. An indicator "onlyFavorite" can be passed to get only messages marked as favorites.
|
|
166
|
+
* You can leave this params empty and by default it will return list of messages ranging from 0 to 20.
|
|
167
|
+
* This functions return list of messages without the body of the message.
|
|
168
|
+
* To get the body of the message you need to call getInboxMessageBody function and pass the message guid contained in each message of this request.
|
|
169
|
+
* All other action like mark as read, favorite, delete, etc. can be done using this message GUID.
|
|
170
|
+
* The "onUpdate" callback will be triggered when the user receives a new message. It will provide an updated list of messages, ranging from 0 to 20, to the onUpdate callback function. */
|
|
171
|
+
/**
|
|
172
|
+
* @param params
|
|
173
|
+
*/
|
|
174
|
+
public async getInboxMessages({ from, to, onlyFavorite, onUpdate }: { from?: number, to?: number, onlyFavorite?: boolean, onUpdate?: (data: TInboxMessage[]) => void } = {}): Promise<TInboxMessage[]> {
|
|
175
|
+
if (onUpdate) {
|
|
176
|
+
this.onUpdateCallback.set(onUpdateContextKey.InboxMessages, onUpdate);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return await this.api.getInboxMessagesT(null, from, to, onlyFavorite);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Returns the message body of the specified message guid. */
|
|
183
|
+
public async getInboxMessageBody(messageGuid: string): Promise<TInboxMessageBody> {
|
|
184
|
+
return await this.api.getInboxMessageBodyT(messageGuid);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Requests to mark inbox message with specified guid as read */
|
|
188
|
+
public async markInboxMessageAsRead(messageGuid: string): Promise<InboxMarkMessageAction> {
|
|
189
|
+
const r = await this.api.markInboxMessageRead(null, messageGuid);
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
err_code: r.errCode,
|
|
193
|
+
err_message: r.errMsg,
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** Requests to mark all inbox messages as read */
|
|
198
|
+
public async markAllInboxMessagesAsRead(): Promise<InboxMarkMessageAction> {
|
|
199
|
+
const r = await this.api.markAllInboxMessageRead(null);
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
err_code: r.errCode,
|
|
203
|
+
err_message: r.errMsg,
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Requests to mark inbox message with specified guid as favorite. Pass mark true to add message to favorite and false to remove. */
|
|
208
|
+
public async markUnmarkInboxMessageAsFavorite(messageGuid: string, mark: boolean): Promise<InboxMarkMessageAction> {
|
|
209
|
+
const r = await this.api.markUnmarkInboxMessageAsFavorite(null, messageGuid, mark);
|
|
210
|
+
|
|
211
|
+
return {
|
|
212
|
+
err_code: r.errCode,
|
|
213
|
+
err_message: r.errMsg,
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Requests to delete inbox message */
|
|
218
|
+
public async deleteInboxMessage(messageGuid: string): Promise<InboxMarkMessageAction> {
|
|
219
|
+
const r = await this.api.deleteInboxMessage(null, messageGuid);
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
err_code: r.errCode,
|
|
223
|
+
err_message: r.errMsg,
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Requests to delete all inbox messages */
|
|
228
|
+
public async deleteAllInboxMessages(): Promise<InboxMarkMessageAction> {
|
|
229
|
+
const r = await this.api.deleteAllInboxMessages(null);
|
|
230
|
+
|
|
231
|
+
return {
|
|
232
|
+
err_code: r.errCode,
|
|
233
|
+
err_message: r.errMsg,
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
162
237
|
/** Requests translations for the given language. Returns the object including translation key/translation value pairs. All possible translation keys defined in the back office. */
|
|
163
238
|
public async getTranslations(lang_code: string): Promise<TGetTranslations> {
|
|
164
239
|
const r = await this.api.getTranslationsT(null, lang_code, []);
|
|
@@ -208,6 +283,11 @@ export class WSAPI {
|
|
|
208
283
|
this.updateEntity(onUpdateContextKey.TournamentList, payload)
|
|
209
284
|
}
|
|
210
285
|
|
|
286
|
+
private async updateInboxMessages() {
|
|
287
|
+
const payload = await this.api.getInboxMessagesT(null);
|
|
288
|
+
this.updateEntity(onUpdateContextKey.InboxMessages, payload)
|
|
289
|
+
}
|
|
290
|
+
|
|
211
291
|
private async updateEntity(contextKey: onUpdateContextKey, payload: any) {
|
|
212
292
|
OCache.set(contextKey, payload, ECacheContext.WSAPI);
|
|
213
293
|
|