@selfcommunity/api-services 0.1.6 → 0.1.7

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 (188) hide show
  1. package/lib/cjs/index.js +36 -0
  2. package/lib/cjs/services/category/index.js +168 -286
  3. package/lib/cjs/services/comment/index.js +107 -186
  4. package/lib/cjs/services/custom_adv/index.js +31 -51
  5. package/lib/cjs/services/custom_page/index.js +32 -52
  6. package/lib/cjs/services/data_portability/index.js +18 -43
  7. package/lib/cjs/services/embed/index.js +90 -151
  8. package/lib/cjs/services/feature/index.js +8 -16
  9. package/lib/cjs/services/feed/index.js +46 -81
  10. package/lib/cjs/services/feed_object/index.js +339 -505
  11. package/lib/cjs/services/incubator/index.js +64 -116
  12. package/lib/cjs/services/insight/index.js +51 -94
  13. package/lib/cjs/services/legal_page/index.js +60 -101
  14. package/lib/cjs/services/locality/index.js +14 -30
  15. package/lib/cjs/services/loyalty/index.js +92 -154
  16. package/lib/cjs/services/media/index.js +80 -122
  17. package/lib/cjs/services/moderation/index.js +65 -103
  18. package/lib/cjs/services/notification/index.js +67 -136
  19. package/lib/cjs/services/preference/index.js +25 -51
  20. package/lib/cjs/services/private_message/index.js +98 -177
  21. package/lib/cjs/services/score/index.js +22 -46
  22. package/lib/cjs/services/sso/index.js +17 -32
  23. package/lib/cjs/services/suggestion/index.js +23 -57
  24. package/lib/cjs/services/tag/index.js +72 -119
  25. package/lib/cjs/services/user/index.js +420 -767
  26. package/lib/cjs/services/webhook/index.js +4 -7
  27. package/lib/cjs/types/baseParams.js +3 -0
  28. package/lib/cjs/types/category.js +3 -0
  29. package/lib/cjs/types/comment.js +3 -0
  30. package/lib/cjs/types/customAdv.js +3 -0
  31. package/lib/cjs/types/customPage.js +3 -0
  32. package/lib/cjs/types/embed.js +3 -0
  33. package/lib/cjs/types/feed.js +3 -0
  34. package/lib/cjs/types/feedObject.js +3 -0
  35. package/lib/cjs/types/incubator.js +3 -0
  36. package/lib/cjs/types/index.js +91 -1
  37. package/lib/cjs/types/legalPage.js +3 -0
  38. package/lib/cjs/types/media.js +29 -0
  39. package/lib/cjs/types/moderation.js +3 -0
  40. package/lib/cjs/types/notification.js +3 -0
  41. package/lib/cjs/types/privateMessage.js +3 -0
  42. package/lib/cjs/types/prize.js +3 -0
  43. package/lib/cjs/types/sso.js +3 -0
  44. package/lib/cjs/types/tag.js +3 -0
  45. package/lib/cjs/types/user.js +3 -0
  46. package/lib/cjs/utils/apiRequest.js +2 -1
  47. package/lib/esm/index.js +36 -0
  48. package/lib/esm/services/category/index.js +168 -286
  49. package/lib/esm/services/comment/index.js +107 -186
  50. package/lib/esm/services/custom_adv/index.js +31 -51
  51. package/lib/esm/services/custom_page/index.js +32 -52
  52. package/lib/esm/services/data_portability/index.js +18 -43
  53. package/lib/esm/services/embed/index.js +90 -151
  54. package/lib/esm/services/feature/index.js +8 -16
  55. package/lib/esm/services/feed/index.js +46 -81
  56. package/lib/esm/services/feed_object/index.js +339 -505
  57. package/lib/esm/services/incubator/index.js +64 -116
  58. package/lib/esm/services/insight/index.js +51 -94
  59. package/lib/esm/services/legal_page/index.js +60 -101
  60. package/lib/esm/services/locality/index.js +14 -30
  61. package/lib/esm/services/loyalty/index.js +92 -154
  62. package/lib/esm/services/media/index.js +80 -122
  63. package/lib/esm/services/moderation/index.js +65 -103
  64. package/lib/esm/services/notification/index.js +67 -136
  65. package/lib/esm/services/preference/index.js +25 -51
  66. package/lib/esm/services/private_message/index.js +98 -177
  67. package/lib/esm/services/score/index.js +22 -46
  68. package/lib/esm/services/sso/index.js +17 -32
  69. package/lib/esm/services/suggestion/index.js +23 -57
  70. package/lib/esm/services/tag/index.js +72 -119
  71. package/lib/esm/services/user/index.js +420 -767
  72. package/lib/esm/services/webhook/index.js +4 -7
  73. package/lib/esm/types/baseParams.js +3 -0
  74. package/lib/esm/types/category.js +3 -0
  75. package/lib/esm/types/comment.js +3 -0
  76. package/lib/esm/types/customAdv.js +3 -0
  77. package/lib/esm/types/customPage.js +3 -0
  78. package/lib/esm/types/embed.js +3 -0
  79. package/lib/esm/types/feed.js +3 -0
  80. package/lib/esm/types/feedObject.js +3 -0
  81. package/lib/esm/types/incubator.js +3 -0
  82. package/lib/esm/types/index.js +91 -1
  83. package/lib/esm/types/legalPage.js +3 -0
  84. package/lib/esm/types/media.js +29 -0
  85. package/lib/esm/types/moderation.js +3 -0
  86. package/lib/esm/types/notification.js +3 -0
  87. package/lib/esm/types/privateMessage.js +3 -0
  88. package/lib/esm/types/prize.js +3 -0
  89. package/lib/esm/types/sso.js +3 -0
  90. package/lib/esm/types/tag.js +3 -0
  91. package/lib/esm/types/user.js +3 -0
  92. package/lib/esm/utils/apiRequest.js +2 -1
  93. package/lib/types/index.d.ts +2 -2
  94. package/lib/types/index.d.ts.map +1 -1
  95. package/lib/types/services/category/index.d.ts +114 -42
  96. package/lib/types/services/category/index.d.ts.map +1 -1
  97. package/lib/types/services/comment/index.d.ts +74 -23
  98. package/lib/types/services/comment/index.d.ts.map +1 -1
  99. package/lib/types/services/custom_adv/index.d.ts +26 -9
  100. package/lib/types/services/custom_adv/index.d.ts.map +1 -1
  101. package/lib/types/services/custom_page/index.d.ts +26 -9
  102. package/lib/types/services/custom_page/index.d.ts.map +1 -1
  103. package/lib/types/services/data_portability/index.d.ts +19 -6
  104. package/lib/types/services/data_portability/index.d.ts.map +1 -1
  105. package/lib/types/services/embed/index.d.ts +62 -24
  106. package/lib/types/services/embed/index.d.ts.map +1 -1
  107. package/lib/types/services/feature/index.d.ts +11 -3
  108. package/lib/types/services/feature/index.d.ts.map +1 -1
  109. package/lib/types/services/feed/index.d.ts +37 -15
  110. package/lib/types/services/feed/index.d.ts.map +1 -1
  111. package/lib/types/services/feed_object/index.d.ts +229 -81
  112. package/lib/types/services/feed_object/index.d.ts.map +1 -1
  113. package/lib/types/services/incubator/index.d.ts +51 -18
  114. package/lib/types/services/incubator/index.d.ts.map +1 -1
  115. package/lib/types/services/insight/index.d.ts +44 -18
  116. package/lib/types/services/insight/index.d.ts.map +1 -1
  117. package/lib/types/services/legal_page/index.d.ts +46 -18
  118. package/lib/types/services/legal_page/index.d.ts.map +1 -1
  119. package/lib/types/services/locality/index.d.ts +17 -6
  120. package/lib/types/services/locality/index.d.ts.map +1 -1
  121. package/lib/types/services/loyalty/index.d.ts +70 -27
  122. package/lib/types/services/loyalty/index.d.ts.map +1 -1
  123. package/lib/types/services/media/index.d.ts +55 -18
  124. package/lib/types/services/media/index.d.ts.map +1 -1
  125. package/lib/types/services/moderation/index.d.ts +51 -18
  126. package/lib/types/services/moderation/index.d.ts.map +1 -1
  127. package/lib/types/services/notification/index.d.ts +63 -27
  128. package/lib/types/services/notification/index.d.ts.map +1 -1
  129. package/lib/types/services/preference/index.d.ts +28 -9
  130. package/lib/types/services/preference/index.d.ts.map +1 -1
  131. package/lib/types/services/private_message/index.d.ts +68 -24
  132. package/lib/types/services/private_message/index.d.ts.map +1 -1
  133. package/lib/types/services/score/index.d.ts +24 -9
  134. package/lib/types/services/score/index.d.ts.map +1 -1
  135. package/lib/types/services/sso/index.d.ts +18 -6
  136. package/lib/types/services/sso/index.d.ts.map +1 -1
  137. package/lib/types/services/suggestion/index.d.ts +29 -12
  138. package/lib/types/services/suggestion/index.d.ts.map +1 -1
  139. package/lib/types/services/tag/index.d.ts +57 -21
  140. package/lib/types/services/tag/index.d.ts.map +1 -1
  141. package/lib/types/services/user/index.d.ts +313 -114
  142. package/lib/types/services/user/index.d.ts.map +1 -1
  143. package/lib/types/services/webhook/index.d.ts +3 -4
  144. package/lib/types/services/webhook/index.d.ts.map +1 -1
  145. package/lib/types/tsconfig.build.tsbuildinfo +1 -1
  146. package/lib/types/types/baseParams.d.ts +23 -0
  147. package/lib/types/types/baseParams.d.ts.map +1 -0
  148. package/lib/types/types/category.d.ts +15 -0
  149. package/lib/types/types/category.d.ts.map +1 -0
  150. package/lib/types/types/comment.d.ts +51 -0
  151. package/lib/types/types/comment.d.ts.map +1 -0
  152. package/lib/types/types/customAdv.d.ts +19 -0
  153. package/lib/types/types/customAdv.d.ts.map +1 -0
  154. package/lib/types/types/customPage.d.ts +24 -0
  155. package/lib/types/types/customPage.d.ts.map +1 -0
  156. package/lib/types/types/embed.d.ts +26 -0
  157. package/lib/types/types/embed.d.ts.map +1 -0
  158. package/lib/types/types/feed.d.ts +11 -0
  159. package/lib/types/types/feed.d.ts.map +1 -0
  160. package/lib/types/types/feedObject.d.ts +56 -0
  161. package/lib/types/types/feedObject.d.ts.map +1 -0
  162. package/lib/types/types/incubator.d.ts +33 -0
  163. package/lib/types/types/incubator.d.ts.map +1 -0
  164. package/lib/types/types/index.d.ts +19 -1
  165. package/lib/types/types/index.d.ts.map +1 -1
  166. package/lib/types/types/legalPage.d.ts +19 -0
  167. package/lib/types/types/legalPage.d.ts.map +1 -0
  168. package/lib/types/types/media.d.ts +80 -0
  169. package/lib/types/types/media.d.ts.map +1 -0
  170. package/lib/types/types/moderation.d.ts +23 -0
  171. package/lib/types/types/moderation.d.ts.map +1 -0
  172. package/lib/types/types/notification.d.ts +31 -0
  173. package/lib/types/types/notification.d.ts.map +1 -0
  174. package/lib/types/types/privateMessage.d.ts +176 -0
  175. package/lib/types/types/privateMessage.d.ts.map +1 -0
  176. package/lib/types/types/prize.d.ts +47 -0
  177. package/lib/types/types/prize.d.ts.map +1 -0
  178. package/lib/types/types/sso.d.ts +12 -0
  179. package/lib/types/types/sso.d.ts.map +1 -0
  180. package/lib/types/types/tag.d.ts +39 -0
  181. package/lib/types/types/tag.d.ts.map +1 -0
  182. package/lib/types/types/user.d.ts +105 -0
  183. package/lib/types/types/user.d.ts.map +1 -0
  184. package/lib/types/utils/apiRequest.d.ts +1 -1
  185. package/lib/types/utils/apiRequest.d.ts.map +1 -1
  186. package/lib/umd/api-services.js +1 -1
  187. package/lib/umd/api-services.js.map +1 -1
  188. package/package.json +4 -4
@@ -3,122 +3,84 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = exports.ModerationApiClient = void 0;
5
5
 
6
- var _client = _interopRequireDefault(require("../../client"));
6
+ var _apiRequest = require("../../utils/apiRequest");
7
7
 
8
8
  var _Endpoints = _interopRequireDefault(require("../../constants/Endpoints"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
+ /**
13
+ * Contains all the endpoints needed to manage moderation.
14
+ */
12
15
  class ModerationApiClient {
16
+ /**
17
+ * This endpoint retrieves all users for moderation purpose.
18
+ */
13
19
  static getUsersForModeration() {
14
- return _client.default.request({
15
- url: _Endpoints.default.UsersForModeration.url({}),
16
- method: _Endpoints.default.UsersForModeration.method
17
- }).then(res => {
18
- if (res.status >= 300) {
19
- console.log(`Unable to retrieve users (Response code: ${res.status}).`);
20
- return Promise.reject(res);
21
- }
22
-
23
- return Promise.resolve(res);
24
- }).catch(error => {
25
- console.log('Unable to retrieve users.');
26
- return Promise.reject(error);
27
- });
20
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.UsersForModeration.url({}), _Endpoints.default.UsersForModeration.method);
28
21
  }
29
-
30
- static moderateASpecificUser(id) {
31
- return _client.default.request({
32
- url: _Endpoints.default.ModerateUser.url({
33
- id
34
- }),
35
- method: _Endpoints.default.ModerateUser.method
36
- }).then(res => {
37
- if (res.status >= 300) {
38
- console.log(`Unable to perform action (Response code: ${res.status}).`);
39
- return Promise.reject(res);
40
- }
41
-
42
- return Promise.resolve(res);
43
- }).catch(error => {
44
- console.log('Unable to perform action.');
45
- return Promise.reject(error);
22
+ /**
23
+ * This endpoint performs users moderation.
24
+ * @param id
25
+ * @param status
26
+ */
27
+
28
+
29
+ static moderateASpecificUser(id, status) {
30
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.ModerateUser.url({
31
+ id
32
+ }), _Endpoints.default.ModerateUser.method, {
33
+ status: status
46
34
  });
47
35
  }
36
+ /**
37
+ * This endpoint retrieves all flagged contributions.
38
+ */
39
+
48
40
 
49
41
  static getAllFlaggedContributions() {
50
- return _client.default.request({
51
- url: _Endpoints.default.FlaggedContributions.url({}),
52
- method: _Endpoints.default.FlaggedContributions.method
53
- }).then(res => {
54
- if (res.status >= 300) {
55
- console.log(`Unable to retrieve contributions (Response code: ${res.status}).`);
56
- return Promise.reject(res);
57
- }
58
-
59
- return Promise.resolve(res);
60
- }).catch(error => {
61
- console.log('Unable to retrieve contributions.');
62
- return Promise.reject(error);
63
- });
42
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.FlaggedContributions.url({}), _Endpoints.default.FlaggedContributions.method);
64
43
  }
65
-
66
- static getSpecificContributionFlag(id, contribution_type) {
67
- return _client.default.request({
68
- url: _Endpoints.default.FlagsForSpecificContribution.url({
69
- id,
70
- contribution_type
71
- }),
72
- method: _Endpoints.default.FlagsForSpecificContribution.method
73
- }).then(res => {
74
- if (res.status >= 300) {
75
- console.log(`Unable to perform action (Response code: ${res.status}).`);
76
- return Promise.reject(res);
77
- }
78
-
79
- return Promise.resolve(res);
80
- }).catch(error => {
81
- console.log('Unable to perform action.');
82
- return Promise.reject(error);
44
+ /**
45
+ * This endpoint retrieves all flags for a specific contribution.
46
+ * @param id
47
+ * @param contribution_type
48
+ * @param flag_type
49
+ */
50
+
51
+
52
+ static getAllFlagsForSpecificContribution(id, contribution_type, flag_type) {
53
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.FlagsForSpecificContribution.url({
54
+ id
55
+ }), _Endpoints.default.FlagsForSpecificContribution.method, {
56
+ contribution_type: contribution_type,
57
+ flag_type: flag_type != null ? flag_type : null
83
58
  });
84
59
  }
60
+ /**
61
+ * This endpoint provides actions for flagged contributions moderation.
62
+ * @param id
63
+ * @param data
64
+ */
85
65
 
86
- static moderateAContribution(id) {
87
- return _client.default.request({
88
- url: _Endpoints.default.ModerateContribution.url({
89
- id
90
- }),
91
- method: _Endpoints.default.ModerateContribution.method
92
- }).then(res => {
93
- if (res.status >= 300) {
94
- console.log(`Unable to perform action (Response code: ${res.status}).`);
95
- return Promise.reject(res);
96
- }
97
-
98
- return Promise.resolve(res);
99
- }).catch(error => {
100
- console.log('Unable to perform action.');
101
- return Promise.reject(error);
102
- });
66
+
67
+ static moderateAContribution(id, data) {
68
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.ModerateContribution.url({
69
+ id
70
+ }), _Endpoints.default.ModerateContribution.method, data);
103
71
  }
72
+ /**
73
+ * This endpoint retrieves moderation status for a specific contribution.
74
+ * @param id
75
+ * @param contribution_type
76
+ */
77
+
104
78
 
105
79
  static getContributionModerationStatus(id, contribution_type) {
106
- return _client.default.request({
107
- url: _Endpoints.default.ModerateContributionStatus.url({
108
- id,
109
- contribution_type
110
- }),
111
- method: _Endpoints.default.ModerateContributionStatus.method
112
- }).then(res => {
113
- if (res.status >= 300) {
114
- console.log(`Unable to retrieve moderation status for this contribute (Response code: ${res.status}).`);
115
- return Promise.reject(res);
116
- }
117
-
118
- return Promise.resolve(res);
119
- }).catch(error => {
120
- console.log('Unable to retrieve moderation status for this contribute.');
121
- return Promise.reject(error);
80
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.ModerateContributionStatus.url({
81
+ id
82
+ }), _Endpoints.default.ModerateContributionStatus.method, {
83
+ contribution_type: contribution_type
122
84
  });
123
85
  }
124
86
 
@@ -131,20 +93,20 @@ class ModerationService {
131
93
  return ModerationApiClient.getUsersForModeration();
132
94
  }
133
95
 
134
- static async moderateASpecificUser(id) {
135
- return ModerationApiClient.moderateASpecificUser(id);
96
+ static async moderateASpecificUser(id, status) {
97
+ return ModerationApiClient.moderateASpecificUser(id, status);
136
98
  }
137
99
 
138
100
  static async getAllFlaggedContributions() {
139
101
  return ModerationApiClient.getAllFlaggedContributions();
140
102
  }
141
103
 
142
- static async getSpecificContributionFlag(id, contribution_type) {
143
- return ModerationApiClient.getSpecificContributionFlag(id, contribution_type);
104
+ static async getAllFlagsForSpecificContribution(id, contribution_type, flag_type) {
105
+ return ModerationApiClient.getAllFlagsForSpecificContribution(id, contribution_type, flag_type);
144
106
  }
145
107
 
146
- static async moderateAContribution(id) {
147
- return ModerationApiClient.moderateAContribution(id);
108
+ static async moderateAContribution(id, data) {
109
+ return ModerationApiClient.moderateAContribution(id, data);
148
110
  }
149
111
 
150
112
  static async getContributionModerationStatus(id, contribution_type) {
@@ -3,163 +3,94 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = exports.NotificationApiClient = void 0;
5
5
 
6
- var _client = _interopRequireDefault(require("../../client"));
6
+ var _apiRequest = require("../../utils/apiRequest");
7
7
 
8
8
  var _Endpoints = _interopRequireDefault(require("../../constants/Endpoints"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
+ /**
13
+ * Contains all the endpoints needed to manage notifications.
14
+ */
12
15
  class NotificationApiClient {
16
+ /**
17
+ * List all user notifications (in aggregate form) related to the community.
18
+ */
13
19
  static listUserNotification() {
14
- return _client.default.request({
15
- url: _Endpoints.default.UserNotificationList.url({}),
16
- method: _Endpoints.default.UserNotificationList.method
17
- }).then(res => {
18
- if (res.status >= 300) {
19
- console.log(`Unable to retrieve results (Response code: ${res.status}).`);
20
- return Promise.reject(res);
21
- }
22
-
23
- return Promise.resolve(res);
24
- }).catch(error => {
25
- console.log('Unable to retrieve results.');
26
- return Promise.reject(error);
27
- });
20
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.UserNotificationList.url({}), _Endpoints.default.UserNotificationList.method);
28
21
  }
22
+ /**
23
+ * This endpoint marks as read a list of notifications identified by serialization_ids (sids).
24
+ * @param sids
25
+ */
26
+
29
27
 
30
- static markReadNotification() {
31
- return _client.default.request({
32
- url: _Endpoints.default.UserMarkReadNotification.url({}),
33
- method: _Endpoints.default.UserMarkReadNotification.method
34
- }).then(res => {
35
- if (res.status >= 300) {
36
- console.log(`Unable to perform action (Response code: ${res.status}).`);
37
- return Promise.reject(res);
38
- }
39
-
40
- return Promise.resolve(res);
41
- }).catch(error => {
42
- console.log('Unable to perform action.');
43
- return Promise.reject(error);
28
+ static markReadNotification(sids) {
29
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.UserMarkReadNotification.url({}), _Endpoints.default.UserMarkReadNotification.method, {
30
+ sids: sids
44
31
  });
45
32
  }
33
+ /**
34
+ * This endpoint retrieves the number of unseen/unread notifications.
35
+ */
36
+
46
37
 
47
38
  static getUnseenNotification() {
48
- return _client.default.request({
49
- url: _Endpoints.default.UserUnseenNotificationCount.url({}),
50
- method: _Endpoints.default.UserUnseenNotificationCount.method
51
- }).then(res => {
52
- if (res.status >= 300) {
53
- console.log(`Unable to retrieve results (Response code: ${res.status}).`);
54
- return Promise.reject(res);
55
- }
56
-
57
- return Promise.resolve(res);
58
- }).catch(error => {
59
- console.log('Unable to retrieve results.');
60
- return Promise.reject(error);
61
- });
39
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.UserUnseenNotificationCount.url({}), _Endpoints.default.UserUnseenNotificationCount.method);
62
40
  }
41
+ /**
42
+ * This endpoint generates a custom notification starting from the user. The recipients of the notification can be the user's friends/followers or the user himself (based on recipients_type value). Es. connections -> "user" added an item to the wishlist.
43
+ * @param data
44
+ */
63
45
 
64
- static createCustomNotification() {
65
- return _client.default.request({
66
- url: _Endpoints.default.CreateCustomNotification.url({}),
67
- method: _Endpoints.default.CreateCustomNotification.method
68
- }).then(res => {
69
- if (res.status >= 300) {
70
- console.log(`Unable to perform action (Response code: ${res.status}).`);
71
- return Promise.reject(res);
72
- }
73
-
74
- return Promise.resolve(res);
75
- }).catch(error => {
76
- console.log('Unable to perform action.');
77
- return Promise.reject(error);
78
- });
46
+
47
+ static createCustomNotification(data) {
48
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.CreateCustomNotification.url({}), _Endpoints.default.CreateCustomNotification.method, data);
79
49
  }
50
+ /**
51
+ * This endpoint lists all broadcast messages. Broadcast Message is a feature which allows a specific user to send messages and announcements to a larger group of users at once.
52
+ */
53
+
80
54
 
81
55
  static listBroadcastMessages() {
82
- return _client.default.request({
83
- url: _Endpoints.default.BroadcastMessagesList.url({}),
84
- method: _Endpoints.default.BroadcastMessagesList.method
85
- }).then(res => {
86
- if (res.status >= 300) {
87
- console.log(`Unable to retrieve results (Response code: ${res.status}).`);
88
- return Promise.reject(res);
89
- }
90
-
91
- return Promise.resolve(res);
92
- }).catch(error => {
93
- console.log('Unable to retrieve results.');
94
- return Promise.reject(error);
95
- });
56
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.BroadcastMessagesList.url({}), _Endpoints.default.BroadcastMessagesList.method);
96
57
  }
58
+ /**
59
+ * This endpoint retrieves the total number of broadcast messages not yet seen by the user.
60
+ */
61
+
97
62
 
98
63
  static listBroadcastMessagesUnseenCount() {
99
- return _client.default.request({
100
- url: _Endpoints.default.BroadcastMessagesUnseenCount.url({}),
101
- method: _Endpoints.default.BroadcastMessagesUnseenCount.method
102
- }).then(res => {
103
- if (res.status >= 300) {
104
- console.log(`Unable to retrieve results (Response code: ${res.status}).`);
105
- return Promise.reject(res);
106
- }
107
-
108
- return Promise.resolve(res);
109
- }).catch(error => {
110
- console.log('Unable to retrieve results.');
111
- return Promise.reject(error);
112
- });
64
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.BroadcastMessagesUnseenCount.url({}), _Endpoints.default.BroadcastMessagesUnseenCount.method);
113
65
  }
66
+ /**
67
+ * This endpoint retrieves the total number of broadcast messages not yet disposed by the user.
68
+ */
69
+
114
70
 
115
71
  static listBroadcastMessagesUndisposedCount() {
116
- return _client.default.request({
117
- url: _Endpoints.default.BroadcastMessagesUndisposedCount.url({}),
118
- method: _Endpoints.default.BroadcastMessagesUndisposedCount.method
119
- }).then(res => {
120
- if (res.status >= 300) {
121
- console.log(`Unable to retrieve results (Response code: ${res.status}).`);
122
- return Promise.reject(res);
123
- }
124
-
125
- return Promise.resolve(res);
126
- }).catch(error => {
127
- console.log('Unable to retrieve results.');
128
- return Promise.reject(error);
129
- });
72
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.BroadcastMessagesUndisposedCount.url({}), _Endpoints.default.BroadcastMessagesUndisposedCount.method);
130
73
  }
74
+ /**
75
+ * This endpoint marks as viewed/read a broadcast message for a user.
76
+ * @param banner_ids
77
+ */
78
+
131
79
 
132
- static markReadBroadcastMessages() {
133
- return _client.default.request({
134
- url: _Endpoints.default.BroadcastMessagesMarkRead.url({}),
135
- method: _Endpoints.default.BroadcastMessagesMarkRead.method
136
- }).then(res => {
137
- if (res.status >= 300) {
138
- console.log(`Unable to perform action (Response code: ${res.status}).`);
139
- return Promise.reject(res);
140
- }
141
-
142
- return Promise.resolve(res);
143
- }).catch(error => {
144
- console.log('Unable to perform action.');
145
- return Promise.reject(error);
80
+ static markReadBroadcastMessages(banner_ids) {
81
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.BroadcastMessagesMarkRead.url({}), _Endpoints.default.BroadcastMessagesMarkRead.method, {
82
+ banner_ids: banner_ids
146
83
  });
147
84
  }
85
+ /**
86
+ * This endpoint disposes a broadcast message for a user.
87
+ * @param banner_ids
88
+ */
89
+
148
90
 
149
- static disposeBroadcastMessages() {
150
- return _client.default.request({
151
- url: _Endpoints.default.BroadcastMessagesDispose.url({}),
152
- method: _Endpoints.default.BroadcastMessagesDispose.method
153
- }).then(res => {
154
- if (res.status >= 300) {
155
- console.log(`Unable to retrieve results (Response code: ${res.status}).`);
156
- return Promise.reject(res);
157
- }
158
-
159
- return Promise.resolve(res);
160
- }).catch(error => {
161
- console.log('Unable to retrieve results.');
162
- return Promise.reject(error);
91
+ static disposeBroadcastMessages(banner_ids) {
92
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.BroadcastMessagesDispose.url({}), _Endpoints.default.BroadcastMessagesDispose.method, {
93
+ banner_ids: banner_ids
163
94
  });
164
95
  }
165
96
 
@@ -172,16 +103,16 @@ class NotificationService {
172
103
  return NotificationApiClient.listUserNotification();
173
104
  }
174
105
 
175
- static async markReadNotification() {
176
- return NotificationApiClient.markReadNotification();
106
+ static async markReadNotification(sids) {
107
+ return NotificationApiClient.markReadNotification(sids);
177
108
  }
178
109
 
179
110
  static async getUnseenNotification() {
180
111
  return NotificationApiClient.getUnseenNotification();
181
112
  }
182
113
 
183
- static async createCustomNotification() {
184
- return NotificationApiClient.createCustomNotification();
114
+ static async createCustomNotification(data) {
115
+ return NotificationApiClient.createCustomNotification(data);
185
116
  }
186
117
 
187
118
  static async listBroadcastMessages() {
@@ -196,12 +127,12 @@ class NotificationService {
196
127
  return NotificationApiClient.listBroadcastMessagesUndisposedCount();
197
128
  }
198
129
 
199
- static async disposeBroadcastMessages() {
200
- return NotificationApiClient.disposeBroadcastMessages();
130
+ static async disposeBroadcastMessages(banner_ids) {
131
+ return NotificationApiClient.disposeBroadcastMessages(banner_ids);
201
132
  }
202
133
 
203
- static async markReadBroadcastMessages() {
204
- return NotificationApiClient.markReadBroadcastMessages();
134
+ static async markReadBroadcastMessages(banner_ids) {
135
+ return NotificationApiClient.markReadBroadcastMessages(banner_ids);
205
136
  }
206
137
 
207
138
  }
@@ -3,32 +3,30 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = exports.PreferenceApiClient = void 0;
5
5
 
6
- var _client = _interopRequireDefault(require("../../client"));
6
+ var _apiRequest = require("../../utils/apiRequest");
7
7
 
8
8
  var _Endpoints = _interopRequireDefault(require("../../constants/Endpoints"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
+ /**
13
+ * Contains all the endpoints needed to manage dynamic preferences.
14
+ */
12
15
  class PreferenceApiClient {
16
+ /**
17
+ * This endpoint retrieves all available dynamic preferences.
18
+ */
13
19
  static getAllPreferences() {
14
- return _client.default.request({
15
- url: _Endpoints.default.Preferences.url({}),
16
- method: _Endpoints.default.Preferences.method
17
- }).then(res => {
18
- if (res.status >= 300) {
19
- console.log(`Unable to retrieve community preferences (Response code: ${res.status}).`);
20
- return Promise.reject(res);
21
- }
22
-
23
- const data = res.data['results'].reduce((obj, p) => Object.assign({}, obj, {
24
- [`${p.section}.${p.name}`]: p
25
- }), {});
26
- return Promise.resolve(data);
27
- }).catch(error => {
28
- console.log('Unable to retrieve community preferences.');
29
- return Promise.reject(error);
30
- });
20
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.Preferences.url({}), _Endpoints.default.Preferences.method);
31
21
  }
22
+ /**
23
+ * This endpoint searches dynamic preferences.
24
+ * @param search
25
+ * @param section
26
+ * @param keys
27
+ * @param ordering
28
+ */
29
+
32
30
 
33
31
  static searchPreferences(search, section, keys, ordering) {
34
32
  const params = new URLSearchParams(Object.assign({}, search && {
@@ -40,42 +38,18 @@ class PreferenceApiClient {
40
38
  }, ordering && {
41
39
  ordering: ordering
42
40
  }));
43
- return _client.default.request({
44
- url: `${_Endpoints.default.Preferences.url({})}?${params.toString()}`,
45
- method: _Endpoints.default.Preferences.method
46
- }).then(res => {
47
- if (res.status >= 300) {
48
- console.log(`Unable to retrieve community preferences (Response code: ${res.status}).`);
49
- return Promise.reject(res);
50
- }
51
-
52
- const data = res.data['results'].reduce((obj, p) => Object.assign({}, obj, {
53
- [`${p.section}.${p.name}`]: p
54
- }), {});
55
- return Promise.resolve(res);
56
- }).catch(error => {
57
- console.log('Unable to retrieve community preferences.');
58
- return Promise.reject(error);
59
- });
41
+ return (0, _apiRequest.apiRequest)(`${_Endpoints.default.Preferences.url({})}?${params.toString()}`, _Endpoints.default.Preferences.method);
60
42
  }
43
+ /**
44
+ * This endpoint retrieves a specific dynamic preference.
45
+ * @param id
46
+ */
47
+
61
48
 
62
49
  static getSpecificPreference(id) {
63
- return _client.default.request({
64
- url: _Endpoints.default.Preferences.url({
65
- id
66
- }),
67
- method: _Endpoints.default.Preferences.method
68
- }).then(res => {
69
- if (res.status >= 300) {
70
- console.log(`Unable to retrieve community preference (Response code: ${res.status}).`);
71
- return Promise.reject(res);
72
- }
73
-
74
- return Promise.resolve(res);
75
- }).catch(error => {
76
- console.log('Unable to retrieve community preference.');
77
- return Promise.reject(error);
78
- });
50
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.Preferences.url({
51
+ id
52
+ }), _Endpoints.default.Preferences.method);
79
53
  }
80
54
 
81
55
  }