@smartico/public-api 0.0.107 → 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/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
 
@@ -16,19 +16,19 @@ ___
16
16
 
17
17
  ### getLevels
18
18
 
19
- ▸ **getLevels**(): `Promise`\<[`TLevel`](../interfaces/TLevel.md)[]\>
19
+ ▸ **getLevels**(): `Promise`<[`TLevel`](../interfaces/TLevel.md)[]\>
20
20
 
21
21
  Returns all the levels available the current user
22
22
 
23
23
  #### Returns
24
24
 
25
- `Promise`\<[`TLevel`](../interfaces/TLevel.md)[]\>
25
+ `Promise`<[`TLevel`](../interfaces/TLevel.md)[]\>
26
26
 
27
27
  ___
28
28
 
29
29
  ### getMissions
30
30
 
31
- ▸ **getMissions**(`params?`): `Promise`\<[`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]\>
31
+ ▸ **getMissions**(`params?`): `Promise`<[`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]\>
32
32
 
33
33
  #### Parameters
34
34
 
@@ -39,37 +39,37 @@ ___
39
39
 
40
40
  #### Returns
41
41
 
42
- `Promise`\<[`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]\>
42
+ `Promise`<[`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]\>
43
43
 
44
44
  ___
45
45
 
46
46
  ### getBadges
47
47
 
48
- ▸ **getBadges**(): `Promise`\<[`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]\>
48
+ ▸ **getBadges**(): `Promise`<[`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]\>
49
49
 
50
50
  Returns all the badges available the current user
51
51
 
52
52
  #### Returns
53
53
 
54
- `Promise`\<[`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]\>
54
+ `Promise`<[`TMissionOrBadge`](../interfaces/TMissionOrBadge.md)[]\>
55
55
 
56
56
  ___
57
57
 
58
58
  ### getStoreItems
59
59
 
60
- ▸ **getStoreItems**(): `Promise`\<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
60
+ ▸ **getStoreItems**(): `Promise`<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
61
61
 
62
62
  Returns all the store items available the current user
63
63
 
64
64
  #### Returns
65
65
 
66
- `Promise`\<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
66
+ `Promise`<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
67
67
 
68
68
  ___
69
69
 
70
70
  ### buyStoreItem
71
71
 
72
- ▸ **buyStoreItem**(`item_id`): `Promise`\<[`TBuyStoreItemResult`](../interfaces/TBuyStoreItemResult.md)\>
72
+ ▸ **buyStoreItem**(`item_id`): `Promise`<[`TBuyStoreItemResult`](../interfaces/TBuyStoreItemResult.md)\>
73
73
 
74
74
  Buy the specific shop item by item_id. Returns the err_code.
75
75
 
@@ -81,25 +81,25 @@ Buy the specific shop item by item_id. Returns the err_code.
81
81
 
82
82
  #### Returns
83
83
 
84
- `Promise`\<[`TBuyStoreItemResult`](../interfaces/TBuyStoreItemResult.md)\>
84
+ `Promise`<[`TBuyStoreItemResult`](../interfaces/TBuyStoreItemResult.md)\>
85
85
 
86
86
  ___
87
87
 
88
88
  ### getStoreCategories
89
89
 
90
- ▸ **getStoreCategories**(): `Promise`\<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
90
+ ▸ **getStoreCategories**(): `Promise`<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
91
91
 
92
92
  Returns store categories
93
93
 
94
94
  #### Returns
95
95
 
96
- `Promise`\<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
96
+ `Promise`<[`TStoreItem`](../interfaces/TStoreItem.md)[]\>
97
97
 
98
98
  ___
99
99
 
100
100
  ### getMiniGames
101
101
 
102
- ▸ **getMiniGames**(`params?`): `Promise`\<[`TMiniGameTemplate`](../interfaces/TMiniGameTemplate.md)[]\>
102
+ ▸ **getMiniGames**(`params?`): `Promise`<[`TMiniGameTemplate`](../interfaces/TMiniGameTemplate.md)[]\>
103
103
 
104
104
  /**
105
105
  *
@@ -113,13 +113,13 @@ ___
113
113
 
114
114
  #### Returns
115
115
 
116
- `Promise`\<[`TMiniGameTemplate`](../interfaces/TMiniGameTemplate.md)[]\>
116
+ `Promise`<[`TMiniGameTemplate`](../interfaces/TMiniGameTemplate.md)[]\>
117
117
 
118
118
  ___
119
119
 
120
120
  ### playMiniGame
121
121
 
122
- ▸ **playMiniGame**(`template_id`): `Promise`\<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
122
+ ▸ **playMiniGame**(`template_id`): `Promise`<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
123
123
 
124
124
  Plays the specified by template_id mini-game on behalf of user and returns prize_id or err_code
125
125
 
@@ -131,13 +131,13 @@ Plays the specified by template_id mini-game on behalf of user and returns prize
131
131
 
132
132
  #### Returns
133
133
 
134
- `Promise`\<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
134
+ `Promise`<[`TMiniGamePlayResult`](../interfaces/TMiniGamePlayResult.md)\>
135
135
 
136
136
  ___
137
137
 
138
138
  ### requestMissionOptIn
139
139
 
140
- ▸ **requestMissionOptIn**(`mission_id`): `Promise`\<[`TMissionOptInResult`](../interfaces/TMissionOptInResult.md)\>
140
+ ▸ **requestMissionOptIn**(`mission_id`): `Promise`<[`TMissionOptInResult`](../interfaces/TMissionOptInResult.md)\>
141
141
 
142
142
  Requests an opt-in for the specified mission_id. Returns the err_code.
143
143
 
@@ -149,13 +149,13 @@ Requests an opt-in for the specified mission_id. Returns the err_code.
149
149
 
150
150
  #### Returns
151
151
 
152
- `Promise`\<[`TMissionOptInResult`](../interfaces/TMissionOptInResult.md)\>
152
+ `Promise`<[`TMissionOptInResult`](../interfaces/TMissionOptInResult.md)\>
153
153
 
154
154
  ___
155
155
 
156
156
  ### getTournamentsList
157
157
 
158
- ▸ **getTournamentsList**(`params?`): `Promise`\<[`TTournament`](../interfaces/TTournament.md)[]\>
158
+ ▸ **getTournamentsList**(`params?`): `Promise`<[`TTournament`](../interfaces/TTournament.md)[]\>
159
159
 
160
160
  #### Parameters
161
161
 
@@ -166,15 +166,15 @@ ___
166
166
 
167
167
  #### Returns
168
168
 
169
- `Promise`\<[`TTournament`](../interfaces/TTournament.md)[]\>
169
+ `Promise`<[`TTournament`](../interfaces/TTournament.md)[]\>
170
170
 
171
171
  ___
172
172
 
173
173
  ### getTournamentInstanceInfo
174
174
 
175
- ▸ **getTournamentInstanceInfo**(`tournamentInstanceId`): `Promise`\<[`TTournamentDetailed`](../interfaces/TTournamentDetailed.md)\>
175
+ ▸ **getTournamentInstanceInfo**(`tournamentInstanceId`): `Promise`<[`TTournamentDetailed`](../interfaces/TTournamentDetailed.md)\>
176
176
 
177
- Returns details information of specific tournament instance, the response will includ tournamnet info and the leaderboard of players
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
 
@@ -184,13 +184,13 @@ Returns details information of specific tournament instance, the response will i
184
184
 
185
185
  #### Returns
186
186
 
187
- `Promise`\<[`TTournamentDetailed`](../interfaces/TTournamentDetailed.md)\>
187
+ `Promise`<[`TTournamentDetailed`](../interfaces/TTournamentDetailed.md)\>
188
188
 
189
189
  ___
190
190
 
191
191
  ### registerInTournament
192
192
 
193
- ▸ **registerInTournament**(`tournamentInstanceId`): `Promise`\<[`TTournamentRegistrationResult`](../interfaces/TTournamentRegistrationResult.md)\>
193
+ ▸ **registerInTournament**(`tournamentInstanceId`): `Promise`<[`TTournamentRegistrationResult`](../interfaces/TTournamentRegistrationResult.md)\>
194
194
 
195
195
  Requests registration for the specified tournament instance. Returns the err_code.
196
196
 
@@ -202,13 +202,130 @@ Requests registration for the specified tournament instance. Returns the err_cod
202
202
 
203
203
  #### Returns
204
204
 
205
- `Promise`\<[`TTournamentRegistrationResult`](../interfaces/TTournamentRegistrationResult.md)\>
205
+ `Promise`<[`TTournamentRegistrationResult`](../interfaces/TTournamentRegistrationResult.md)\>
206
+
207
+ ___
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)\>
206
323
 
207
324
  ___
208
325
 
209
326
  ### getTranslations
210
327
 
211
- ▸ **getTranslations**(`lang_code`): `Promise`\<[`TGetTranslations`](../interfaces/TGetTranslations.md)\>
328
+ ▸ **getTranslations**(`lang_code`): `Promise`<[`TGetTranslations`](../interfaces/TGetTranslations.md)\>
212
329
 
213
330
  Requests translations for the given language. Returns the object including translation key/translation value pairs. All possible translation keys defined in the back office.
214
331
 
@@ -220,4 +337,4 @@ Requests translations for the given language. Returns the object including trans
220
337
 
221
338
  #### Returns
222
339
 
223
- `Promise`\<[`TGetTranslations`](../interfaces/TGetTranslations.md)\>
340
+ `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.do(cta_action);
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
  ___
@@ -134,7 +134,7 @@ ___
134
134
 
135
135
  ### prizes
136
136
 
137
- • `Optional` **prizes**: \{ `name`: `string` ; `description`: `string` ; `image_url`: `string` ; `place_from`: `number` ; `place_to`: `number` ; `type`: `string` ; `points?`: `number` }[]
137
+ • `Optional` **prizes**: { `name`: `string` ; `description`: `string` ; `image_url`: `string` ; `place_from`: `number` ; `place_to`: `number` ; `type`: `string` ; `points?`: `number` }[]
138
138
 
139
139
  Prize structure
140
140
 
@@ -373,7 +373,7 @@ ___
373
373
 
374
374
  ### players
375
375
 
376
- • `Optional` **players**: \{ `public_username`: `string` ; `avatar_url`: `string` ; `position`: `number` ; `scores`: `number` ; `is_me`: `boolean` }[]
376
+ • `Optional` **players**: { `public_username`: `string` ; `avatar_url`: `string` ; `position`: `number` ; `scores`: `number` ; `is_me`: `boolean` }[]
377
377
 
378
378
  The list of the tournament participants
379
379
 
@@ -402,7 +402,7 @@ ___
402
402
 
403
403
  ### prizes
404
404
 
405
- • `Optional` **prizes**: \{ `name`: `string` ; `description`: `string` ; `image_url`: `string` ; `place_from`: `number` ; `place_to`: `number` ; `type`: `string` ; `points?`: `number` }[]
405
+ • `Optional` **prizes**: { `name`: `string` ; `description`: `string` ; `image_url`: `string` ; `place_from`: `number` ; `place_to`: `number` ; `type`: `string` ; `points?`: `number` }[]
406
406
 
407
407
  Prize structure
408
408
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.107",
3
+ "version": "0.0.108",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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
+ }
@@ -2,4 +2,5 @@ import { ProtocolMessage } from "../Base/ProtocolMessage";
2
2
 
3
3
  export interface MarkInboxMessageDeletedResponse extends ProtocolMessage {
4
4
  errCode: number;
5
+ errMsg?: string;
5
6
  }
@@ -3,4 +3,5 @@ import { ProtocolMessage } from "../Base/ProtocolMessage";
3
3
 
4
4
  export interface MarkInboxMessageReadResponse extends ProtocolMessage {
5
5
  errCode: number;
6
+ errMsg?: string;
6
7
  }
@@ -3,4 +3,5 @@ import { ProtocolMessage } from "../Base/ProtocolMessage";
3
3
 
4
4
  export interface MarkInboxMessageStarredResponse extends ProtocolMessage {
5
5
  errCode: number;
6
+ errMsg?: string;
6
7
  }