@docbrasil/api-systemmanager 1.1.31 → 1.1.32
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/api/user/notification.js +47 -6
- package/dist/bundle.cjs +47 -6
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +35 -4
- package/docs/Dispatch.html +2 -2
- package/docs/Notification.html +324 -10
- package/docs/dispatch.js.html +1 -6
- package/docs/user_notification.js.html +47 -6
- package/package.json +1 -1
package/doc/api.md
CHANGED
|
@@ -2493,6 +2493,7 @@ Class for user registration in a user
|
|
|
2493
2493
|
* [Notification](#Notification)
|
|
2494
2494
|
* [.tokenTypes](#Notification+tokenTypes) ⇒ <code>Object</code>
|
|
2495
2495
|
* [.addToken(params, session)](#Notification+addToken) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
2496
|
+
* [.removeToken(params, session)](#Notification+removeToken) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
2496
2497
|
* [.getNew(session)](#Notification+getNew)
|
|
2497
2498
|
* [.getOld(session)](#Notification+getOld)
|
|
2498
2499
|
* [.setRead(params, session)](#Notification+setRead) ⇒ <code>Promise</code>
|
|
@@ -2518,8 +2519,10 @@ Method to add a notification token
|
|
|
2518
2519
|
| Param | Type | Description |
|
|
2519
2520
|
| --- | --- | --- |
|
|
2520
2521
|
| params | <code>object</code> | Params to add notification token |
|
|
2521
|
-
| params.token | <code>
|
|
2522
|
-
| params.
|
|
2522
|
+
| params.token | <code>obhect</code> | The token |
|
|
2523
|
+
| params.token.value | <code>object</code> | The token value |
|
|
2524
|
+
| params.token.type | <code>object</code> | The token type |
|
|
2525
|
+
| params.token.data | <code>object</code> | The extra data of a token, if there is. |
|
|
2523
2526
|
| session | <code>string</code> | Is token JWT of user NOT allow SU |
|
|
2524
2527
|
|
|
2525
2528
|
**Example**
|
|
@@ -2528,11 +2531,39 @@ const API = require('@docbrasil/api-systemmanager');
|
|
|
2528
2531
|
const api = new API();
|
|
2529
2532
|
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2530
2533
|
const params = {
|
|
2531
|
-
token:
|
|
2532
|
-
|
|
2534
|
+
token: {
|
|
2535
|
+
value: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
|
|
2536
|
+
type: 'FCM_CAPACITOR'
|
|
2537
|
+
}
|
|
2533
2538
|
};
|
|
2534
2539
|
const retData = await api.user.notification.addToken(params, session);
|
|
2535
2540
|
```
|
|
2541
|
+
<a name="Notification+removeToken"></a>
|
|
2542
|
+
|
|
2543
|
+
### notification.removeToken(params, session) ⇒ <code>promise.<object></code> \| <code>boolean</code>
|
|
2544
|
+
Method to remove a notification token
|
|
2545
|
+
|
|
2546
|
+
**Kind**: instance method of [<code>Notification</code>](#Notification)
|
|
2547
|
+
**Returns**: <code>promise.<object></code> - data<code>boolean</code> - data._id the id of the added token
|
|
2548
|
+
**Access**: public
|
|
2549
|
+
**Author**: Myndware <augusto.pissarra@myndware.com>
|
|
2550
|
+
|
|
2551
|
+
| Param | Type | Description |
|
|
2552
|
+
| --- | --- | --- |
|
|
2553
|
+
| params | <code>object</code> | Params to add notification token |
|
|
2554
|
+
| params.token | <code>obhect</code> | The token value |
|
|
2555
|
+
| session | <code>string</code> | Is token JWT of user NOT allow SU |
|
|
2556
|
+
|
|
2557
|
+
**Example**
|
|
2558
|
+
```js
|
|
2559
|
+
const API = require('@docbrasil/api-systemmanager');
|
|
2560
|
+
const api = new API();
|
|
2561
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
2562
|
+
const params = {
|
|
2563
|
+
token:'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2'
|
|
2564
|
+
};
|
|
2565
|
+
const retData = await api.user.notification.removeToken(params, session);
|
|
2566
|
+
```
|
|
2536
2567
|
<a name="Notification+getNew"></a>
|
|
2537
2568
|
|
|
2538
2569
|
### notification.getNew(session)
|
package/docs/Dispatch.html
CHANGED
|
@@ -300,7 +300,7 @@
|
|
|
300
300
|
<p class="tag-source">
|
|
301
301
|
<a href="dispatch.js.html" class="button">View Source</a>
|
|
302
302
|
<span>
|
|
303
|
-
<a href="dispatch.js.html">dispatch.js</a>, <a href="dispatch.js.html#
|
|
303
|
+
<a href="dispatch.js.html">dispatch.js</a>, <a href="dispatch.js.html#line91">line 91</a>
|
|
304
304
|
</span>
|
|
305
305
|
</p>
|
|
306
306
|
|
|
@@ -523,7 +523,7 @@ await api.dispatch.getClient();</code></pre>
|
|
|
523
523
|
<p class="tag-source">
|
|
524
524
|
<a href="dispatch.js.html" class="button">View Source</a>
|
|
525
525
|
<span>
|
|
526
|
-
<a href="dispatch.js.html">dispatch.js</a>, <a href="dispatch.js.html#
|
|
526
|
+
<a href="dispatch.js.html">dispatch.js</a>, <a href="dispatch.js.html#line64">line 64</a>
|
|
527
527
|
</span>
|
|
528
528
|
</p>
|
|
529
529
|
|
package/docs/Notification.html
CHANGED
|
@@ -386,7 +386,7 @@
|
|
|
386
386
|
<td class="type">
|
|
387
387
|
|
|
388
388
|
|
|
389
|
-
<code class="param-type">
|
|
389
|
+
<code class="param-type">obhect</code>
|
|
390
390
|
|
|
391
391
|
|
|
392
392
|
|
|
@@ -403,7 +403,30 @@
|
|
|
403
403
|
|
|
404
404
|
<tr class="deep-level-1">
|
|
405
405
|
|
|
406
|
-
<td class="name"><code>
|
|
406
|
+
<td class="name"><code>token.value</code></td>
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
<td class="type">
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
<code class="param-type">object</code>
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
</td>
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
<td class="description last">The token value</td>
|
|
423
|
+
</tr>
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
<tr class="deep-level-1">
|
|
428
|
+
|
|
429
|
+
<td class="name"><code>token.type</code></td>
|
|
407
430
|
|
|
408
431
|
|
|
409
432
|
<td class="type">
|
|
@@ -423,6 +446,29 @@
|
|
|
423
446
|
</tr>
|
|
424
447
|
|
|
425
448
|
|
|
449
|
+
|
|
450
|
+
<tr class="deep-level-1">
|
|
451
|
+
|
|
452
|
+
<td class="name"><code>token.data</code></td>
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
<td class="type">
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
<code class="param-type">object</code>
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
</td>
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
<td class="description last">The extra data of a token, if there is.</td>
|
|
469
|
+
</tr>
|
|
470
|
+
|
|
471
|
+
|
|
426
472
|
|
|
427
473
|
|
|
428
474
|
|
|
@@ -501,7 +547,7 @@
|
|
|
501
547
|
<p class="tag-source">
|
|
502
548
|
<a href="user_notification.js.html" class="button">View Source</a>
|
|
503
549
|
<span>
|
|
504
|
-
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#
|
|
550
|
+
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#line86">line 86</a>
|
|
505
551
|
</span>
|
|
506
552
|
</p>
|
|
507
553
|
|
|
@@ -577,8 +623,10 @@
|
|
|
577
623
|
const api = new API();
|
|
578
624
|
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
579
625
|
const params = {
|
|
580
|
-
token:
|
|
581
|
-
|
|
626
|
+
token: {
|
|
627
|
+
value: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
|
|
628
|
+
type: 'FCM_CAPACITOR'
|
|
629
|
+
}
|
|
582
630
|
};
|
|
583
631
|
const retData = await api.user.notification.addToken(params, session);</code></pre>
|
|
584
632
|
|
|
@@ -717,7 +765,7 @@ const retData = await api.user.notification.addToken(params, session);</code></p
|
|
|
717
765
|
<p class="tag-source">
|
|
718
766
|
<a href="user_notification.js.html" class="button">View Source</a>
|
|
719
767
|
<span>
|
|
720
|
-
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#
|
|
768
|
+
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#line154">line 154</a>
|
|
721
769
|
</span>
|
|
722
770
|
</p>
|
|
723
771
|
|
|
@@ -886,7 +934,7 @@ await api.user.notification.getNew(session);</code></pre>
|
|
|
886
934
|
<p class="tag-source">
|
|
887
935
|
<a href="user_notification.js.html" class="button">View Source</a>
|
|
888
936
|
<span>
|
|
889
|
-
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#
|
|
937
|
+
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#line180">line 180</a>
|
|
890
938
|
</span>
|
|
891
939
|
</p>
|
|
892
940
|
|
|
@@ -922,6 +970,272 @@ await api.user.notification.getOld(session);</code></pre>
|
|
|
922
970
|
|
|
923
971
|
|
|
924
972
|
|
|
973
|
+
</div>
|
|
974
|
+
|
|
975
|
+
<div class="member">
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
<h4 class="name" id="removeToken">
|
|
980
|
+
<a class="href-link" href="#removeToken">#</a>
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
<span class='tag'>async</span>
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
<span class="code-name">
|
|
987
|
+
|
|
988
|
+
removeToken<span class="signature">(params, session)</span><span class="type-signature"> → {promise.<object>|boolean}</span>
|
|
989
|
+
|
|
990
|
+
</span>
|
|
991
|
+
</h4>
|
|
992
|
+
|
|
993
|
+
|
|
994
|
+
|
|
995
|
+
|
|
996
|
+
<div class="description">
|
|
997
|
+
Method to remove a notification token
|
|
998
|
+
</div>
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
|
|
1002
|
+
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
<h5>Parameters:</h5>
|
|
1010
|
+
|
|
1011
|
+
<div class="table-container">
|
|
1012
|
+
<table class="params table">
|
|
1013
|
+
<thead>
|
|
1014
|
+
<tr>
|
|
1015
|
+
|
|
1016
|
+
<th>Name</th>
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
<th>Type</th>
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
<th class="last">Description</th>
|
|
1026
|
+
</tr>
|
|
1027
|
+
</thead>
|
|
1028
|
+
|
|
1029
|
+
<tbody>
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
<tr class="deep-level-0">
|
|
1034
|
+
|
|
1035
|
+
<td class="name"><code>params</code></td>
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
<td class="type">
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
<code class="param-type">object</code>
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
</td>
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
|
|
1050
|
+
|
|
1051
|
+
<td class="description last">Params to add notification token</td>
|
|
1052
|
+
</tr>
|
|
1053
|
+
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+
|
|
1057
|
+
<tr class="deep-level-1">
|
|
1058
|
+
|
|
1059
|
+
<td class="name"><code>token</code></td>
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
<td class="type">
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
<code class="param-type">obhect</code>
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
</td>
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
<td class="description last">The token value</td>
|
|
1076
|
+
</tr>
|
|
1077
|
+
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
|
|
1084
|
+
<tr class="deep-level-0">
|
|
1085
|
+
|
|
1086
|
+
<td class="name"><code>session</code></td>
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
<td class="type">
|
|
1090
|
+
|
|
1091
|
+
|
|
1092
|
+
<code class="param-type">string</code>
|
|
1093
|
+
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
</td>
|
|
1097
|
+
|
|
1098
|
+
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
|
|
1102
|
+
<td class="description last">Is token JWT of user NOT allow SU</td>
|
|
1103
|
+
</tr>
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
|
|
1107
|
+
</tbody>
|
|
1108
|
+
</table>
|
|
1109
|
+
</div>
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
|
|
1113
|
+
|
|
1114
|
+
|
|
1115
|
+
<dl class="details">
|
|
1116
|
+
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
<dt class="tag-author">Author:</dt>
|
|
1135
|
+
<dd class="tag-author">
|
|
1136
|
+
<ul>
|
|
1137
|
+
<li><a href="mailto:augusto.pissarra@myndware.com">Myndware</a></li>
|
|
1138
|
+
</ul>
|
|
1139
|
+
</dd>
|
|
1140
|
+
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
|
|
1147
|
+
|
|
1148
|
+
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
|
|
1154
|
+
<p class="tag-source">
|
|
1155
|
+
<a href="user_notification.js.html" class="button">View Source</a>
|
|
1156
|
+
<span>
|
|
1157
|
+
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#line124">line 124</a>
|
|
1158
|
+
</span>
|
|
1159
|
+
</p>
|
|
1160
|
+
|
|
1161
|
+
</dl>
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
<div class='columns method-parameter'>
|
|
1181
|
+
<div class="column is-2"><label>Returns:</label></div>
|
|
1182
|
+
<div class="column is-10">
|
|
1183
|
+
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
<div class="columns">
|
|
1187
|
+
|
|
1188
|
+
<div class='param-desc column is-7'>data</div>
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
<div class='column is-5 has-text-left'>
|
|
1192
|
+
<label>Type: </label>
|
|
1193
|
+
|
|
1194
|
+
<code class="param-type">promise.<object></code>
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
</div>
|
|
1198
|
+
|
|
1199
|
+
</div>
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
<div class="columns">
|
|
1205
|
+
|
|
1206
|
+
<div class='param-desc column is-7'>data._id the id of the added token</div>
|
|
1207
|
+
|
|
1208
|
+
|
|
1209
|
+
<div class='column is-5 has-text-left'>
|
|
1210
|
+
<label>Type: </label>
|
|
1211
|
+
|
|
1212
|
+
<code class="param-type">boolean</code>
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
</div>
|
|
1216
|
+
|
|
1217
|
+
</div>
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
</div>
|
|
1221
|
+
</div>
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
|
|
1226
|
+
<h5>Example</h5>
|
|
1227
|
+
|
|
1228
|
+
|
|
1229
|
+
<pre class="prettyprint"><code>const API = require('@docbrasil/api-systemmanager');
|
|
1230
|
+
const api = new API();
|
|
1231
|
+
const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
1232
|
+
const params = {
|
|
1233
|
+
token:'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2'
|
|
1234
|
+
};
|
|
1235
|
+
const retData = await api.user.notification.removeToken(params, session);</code></pre>
|
|
1236
|
+
|
|
1237
|
+
|
|
1238
|
+
|
|
925
1239
|
</div>
|
|
926
1240
|
|
|
927
1241
|
<div class="member">
|
|
@@ -1106,7 +1420,7 @@ await api.user.notification.getOld(session);</code></pre>
|
|
|
1106
1420
|
<p class="tag-source">
|
|
1107
1421
|
<a href="user_notification.js.html" class="button">View Source</a>
|
|
1108
1422
|
<span>
|
|
1109
|
-
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#
|
|
1423
|
+
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#line212">line 212</a>
|
|
1110
1424
|
</span>
|
|
1111
1425
|
</p>
|
|
1112
1426
|
|
|
@@ -1301,7 +1615,7 @@ await api.user.notification.setRead(params, session);</code></pre>
|
|
|
1301
1615
|
<p class="tag-source">
|
|
1302
1616
|
<a href="user_notification.js.html" class="button">View Source</a>
|
|
1303
1617
|
<span>
|
|
1304
|
-
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#
|
|
1618
|
+
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#line243">line 243</a>
|
|
1305
1619
|
</span>
|
|
1306
1620
|
</p>
|
|
1307
1621
|
|
|
@@ -1544,7 +1858,7 @@ await api.user.notification.setReadAll(session);</code></pre>
|
|
|
1544
1858
|
<p class="tag-source">
|
|
1545
1859
|
<a href="user_notification.js.html" class="button">View Source</a>
|
|
1546
1860
|
<span>
|
|
1547
|
-
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#
|
|
1861
|
+
<a href="user_notification.js.html">user/notification.js</a>, <a href="user_notification.js.html#line279">line 279</a>
|
|
1548
1862
|
</span>
|
|
1549
1863
|
</p>
|
|
1550
1864
|
|
package/docs/dispatch.js.html
CHANGED
|
@@ -101,12 +101,7 @@ class Dispatch {
|
|
|
101
101
|
|
|
102
102
|
const self = this;
|
|
103
103
|
self.parent = options.parent;
|
|
104
|
-
self._client = Axios.create({
|
|
105
|
-
baseURL: self.parent.options.uri,
|
|
106
|
-
headers: {
|
|
107
|
-
'Referer': self.parent.options.uri, // Default Referer header
|
|
108
|
-
}
|
|
109
|
-
});
|
|
104
|
+
self._client = Axios.create({baseURL: self.parent.options.uri});
|
|
110
105
|
}
|
|
111
106
|
|
|
112
107
|
/**
|
|
@@ -149,8 +149,10 @@ class Notification {
|
|
|
149
149
|
* @author Myndware <augusto.pissarra@myndware.com>
|
|
150
150
|
* @description Method to add a notification token
|
|
151
151
|
* @param {object} params Params to add notification token
|
|
152
|
-
* @param {
|
|
153
|
-
* @param {object} params.
|
|
152
|
+
* @param {obhect} params.token The token
|
|
153
|
+
* @param {object} params.token.value The token value
|
|
154
|
+
* @param {object} params.token.type The token type
|
|
155
|
+
* @param {object} params.token.data The extra data of a token, if there is.
|
|
154
156
|
* @param {string} session Is token JWT of user NOT allow SU
|
|
155
157
|
* @returns {promise<object>} data
|
|
156
158
|
* @returns {boolean} data._id the id of the added token
|
|
@@ -161,21 +163,60 @@ class Notification {
|
|
|
161
163
|
* const api = new API();
|
|
162
164
|
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
163
165
|
* const params = {
|
|
164
|
-
* token:
|
|
165
|
-
*
|
|
166
|
+
* token: {
|
|
167
|
+
* value: 'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2',
|
|
168
|
+
* type: 'FCM_CAPACITOR'
|
|
169
|
+
* }
|
|
166
170
|
* };
|
|
167
171
|
* const retData = await api.user.notification.addToken(params, session);
|
|
168
172
|
*/
|
|
169
173
|
async addToken(params = {}, session) {
|
|
170
174
|
const self = this;
|
|
171
175
|
|
|
176
|
+
try {
|
|
177
|
+
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
178
|
+
Joi.assert(params.token, Joi.object().required(), 'Token information to add');
|
|
179
|
+
Joi.assert(params.token.value, Joi.string().required(), 'Token token value');
|
|
180
|
+
Joi.assert(params.token.type, Joi.string().required(), 'The type of the token');
|
|
181
|
+
|
|
182
|
+
const apiCall = self._client
|
|
183
|
+
.put(`/notifications/token`, params, self._setHeader(session));
|
|
184
|
+
|
|
185
|
+
const retData = self._returnData(await apiCall);
|
|
186
|
+
return retData;
|
|
187
|
+
} catch (ex) {
|
|
188
|
+
throw ex;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
194
|
+
* @description Method to remove a notification token
|
|
195
|
+
* @param {object} params Params to add notification token
|
|
196
|
+
* @param {obhect} params.token The token value
|
|
197
|
+
* @param {string} session Is token JWT of user NOT allow SU
|
|
198
|
+
* @returns {promise<object>} data
|
|
199
|
+
* @returns {boolean} data._id the id of the added token
|
|
200
|
+
* @public
|
|
201
|
+
* @example
|
|
202
|
+
*
|
|
203
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
204
|
+
* const api = new API();
|
|
205
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
206
|
+
* const params = {
|
|
207
|
+
* token:'V6OSBr4aEVoiE9H1b4xzLe+vqmXB+ShVNc/FvJGxnIz4tZv6jBJkk4aQzz2'
|
|
208
|
+
* };
|
|
209
|
+
* const retData = await api.user.notification.removeToken(params, session);
|
|
210
|
+
*/
|
|
211
|
+
async removeToken(params = {}, session) {
|
|
212
|
+
const self = this;
|
|
213
|
+
|
|
172
214
|
try {
|
|
173
215
|
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
174
216
|
Joi.assert(params.token, Joi.string().required(), 'Token is required');
|
|
175
|
-
Joi.assert(params.type, Joi.string().required(), ' The token type');
|
|
176
217
|
|
|
177
218
|
const apiCall = self._client
|
|
178
|
-
|
|
219
|
+
.delete(`/notifications/token/${params.token}`, self._setHeader(session));
|
|
179
220
|
|
|
180
221
|
const retData = self._returnData(await apiCall);
|
|
181
222
|
return retData;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docbrasil/api-systemmanager",
|
|
3
3
|
"description": "Module API System Manager",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.32",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"htmldoc": "rm -rf docs && jsdoc api/** -d docs -t ./node_modules/better-docs",
|
|
7
7
|
"doc": "rm -rf doc && mkdir doc && jsdoc2md api/**/* api/* > doc/api.md",
|