@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,216 +3,137 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = exports.CommentApiClient = void 0;
5
5
 
6
- var _client = _interopRequireDefault(require("../../client"));
7
-
8
6
  var _Endpoints = _interopRequireDefault(require("../../constants/Endpoints"));
9
7
 
8
+ var _apiRequest = require("../../utils/apiRequest");
9
+
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
+ /**
13
+ * Contains all the endpoints needed to manage comments.
14
+ */
12
15
  class CommentApiClient {
13
- static getAllComments() {
14
- return _client.default.request({
15
- url: _Endpoints.default.Comments.url({}),
16
- method: _Endpoints.default.Comments.method
17
- }).then(res => {
18
- if (res.status >= 300) {
19
- console.log(`Unable to retrieve comments (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 comments.');
26
- return Promise.reject(error);
27
- });
16
+ /**
17
+ * This endpoint retrieves all comments.
18
+ * @param params
19
+ */
20
+ static getAllComments(params) {
21
+ const p = new URLSearchParams(params);
22
+ return (0, _apiRequest.apiRequest)(`${_Endpoints.default.Comments.url({})}?${p.toString()}`, _Endpoints.default.Comments.method);
28
23
  }
24
+ /**
25
+ * This endpoint creates a comment.
26
+ * @param data
27
+ */
29
28
 
30
- static createComment() {
31
- return _client.default.request({
32
- url: _Endpoints.default.NewComment.url({}),
33
- method: _Endpoints.default.NewComment.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.data);
41
- }).catch(error => {
42
- console.log('Unable to perform action.');
43
- return Promise.reject(error);
44
- });
29
+
30
+ static createComment(data) {
31
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.NewComment.url({}), _Endpoints.default.NewComment.method, data);
45
32
  }
33
+ /**
34
+ * This endpoint retrieves a specific comment using ID.
35
+ * @param id
36
+ */
37
+
46
38
 
47
39
  static getASpecificComment(id) {
48
- return _client.default.request({
49
- url: _Endpoints.default.Comment.url({
50
- id
51
- }),
52
- method: _Endpoints.default.Comment.method
53
- }).then(res => {
54
- if (res.status >= 300) {
55
- console.log(`Unable to perform action (Response code: ${res.status}).`);
56
- return Promise.reject(res);
57
- }
58
-
59
- return Promise.resolve(res.data);
60
- }).catch(error => {
61
- console.log('Unable to perform action.');
62
- return Promise.reject(error);
40
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.Comment.url({
41
+ id
42
+ }), _Endpoints.default.Comment.method);
43
+ }
44
+ /**
45
+ * This endpoint updates a specific comment.
46
+ * @param id
47
+ * @param text
48
+ */
49
+
50
+
51
+ static updateComment(id, text) {
52
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.UpdateComment.url({
53
+ id
54
+ }), _Endpoints.default.UpdateComment.method, {
55
+ text: text
63
56
  });
64
57
  }
58
+ /**
59
+ * This endpoint deletes a specific comment using ID.
60
+ * @param id
61
+ */
65
62
 
66
- static updateComment(id) {
67
- return _client.default.request({
68
- url: _Endpoints.default.UpdateComment.url({
69
- id
70
- }),
71
- method: _Endpoints.default.UpdateComment.method
72
- }).then(res => {
73
- if (res.status >= 300) {
74
- console.log(`Unable to perform action (Response code: ${res.status}).`);
75
- return Promise.reject(res);
76
- }
77
-
78
- return Promise.resolve(res.data);
79
- }).catch(error => {
80
- console.log('Unable to perform action.');
81
- return Promise.reject(error);
82
- });
83
- }
84
63
 
85
64
  static deleteComment(id) {
86
- return _client.default.request({
87
- url: _Endpoints.default.DeleteComment.url({
88
- id
89
- }),
90
- method: _Endpoints.default.DeleteComment.method
91
- }).then(res => {
92
- if (res.status >= 300) {
93
- console.log(`Unable to perform action (Response code: ${res.status}).`);
94
- return Promise.reject(res);
95
- }
96
-
97
- return Promise.resolve(res.data);
98
- }).catch(error => {
99
- console.log('Unable to perform action.');
100
- return Promise.reject(error);
101
- });
65
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.DeleteComment.url({
66
+ id
67
+ }), _Endpoints.default.DeleteComment.method);
102
68
  }
69
+ /**
70
+ * This endpoint restores a specific comment using ID.
71
+ * @param id
72
+ */
73
+
103
74
 
104
75
  static restoreComment(id) {
105
- return _client.default.request({
106
- url: _Endpoints.default.RestoreComment.url({
107
- id
108
- }),
109
- method: _Endpoints.default.RestoreComment.method
110
- }).then(res => {
111
- if (res.status >= 300) {
112
- console.log(`Unable to perform action (Response code: ${res.status}).`);
113
- return Promise.reject(res);
114
- }
115
-
116
- return Promise.resolve(res.data);
117
- }).catch(error => {
118
- console.log('Unable to perform action.');
119
- return Promise.reject(error);
120
- });
76
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.RestoreComment.url({
77
+ id
78
+ }), _Endpoints.default.RestoreComment.method);
121
79
  }
80
+ /**
81
+ * This endpoint retrieves all votes for a specific comment.
82
+ * @param id
83
+ */
84
+
122
85
 
123
86
  static getSpecificCommentVotesList(id) {
124
- return _client.default.request({
125
- url: _Endpoints.default.CommentVotesList.url({
126
- id
127
- }),
128
- method: _Endpoints.default.CommentVotesList.method
129
- }).then(res => {
130
- if (res.status >= 300) {
131
- console.log(`Unable to retrieve votes (Response code: ${res.status}).`);
132
- return Promise.reject(res);
133
- }
134
-
135
- return Promise.resolve(res.data);
136
- }).catch(error => {
137
- console.log('Unable to retrieve votes.');
138
- return Promise.reject(error);
139
- });
87
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.CommentVotesList.url({
88
+ id
89
+ }), _Endpoints.default.CommentVotesList.method);
140
90
  }
91
+ /**
92
+ * This endpoint upvotes a specific comment.
93
+ * @param id
94
+ */
95
+
141
96
 
142
97
  static upvoteComment(id) {
143
- return _client.default.request({
144
- url: _Endpoints.default.CommentVote.url({
145
- id
146
- }),
147
- method: _Endpoints.default.CommentVote.method
148
- }).then(res => {
149
- if (res.status >= 300) {
150
- console.log(`Unable to perform action (Response code: ${res.status}).`);
151
- return Promise.reject(res);
152
- }
153
-
154
- return Promise.resolve(res.data);
155
- }).catch(error => {
156
- console.log('Unable to perform action.');
157
- return Promise.reject(error);
158
- });
98
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.CommentVote.url({
99
+ id
100
+ }), _Endpoints.default.CommentVote.method);
159
101
  }
102
+ /**
103
+ * This endpoint retrieves a List of Flags for a Specific Comment.
104
+ * @param id
105
+ */
106
+
160
107
 
161
108
  static getSpecificCommentFlags(id) {
162
- return _client.default.request({
163
- url: _Endpoints.default.CommentFlagList.url({
164
- id
165
- }),
166
- method: _Endpoints.default.CommentFlagList.method
167
- }).then(res => {
168
- if (res.status >= 300) {
169
- console.log(`Unable to retrieve flags list (Response code: ${res.status}).`);
170
- return Promise.reject(res);
171
- }
172
-
173
- return Promise.resolve(res.data);
174
- }).catch(error => {
175
- console.log('Unable to retrieve flags list.');
176
- return Promise.reject(error);
109
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.CommentFlagList.url({
110
+ id
111
+ }), _Endpoints.default.CommentFlagList.method);
112
+ }
113
+ /**
114
+ * This endpoint flags a specific comment.
115
+ * @param id
116
+ * @param flagType
117
+ */
118
+
119
+
120
+ static flagComment(id, flagType) {
121
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.FlagComment.url({
122
+ id
123
+ }), _Endpoints.default.FlagComment.method, {
124
+ flagType: flagType
177
125
  });
178
126
  }
127
+ /**
128
+ * This endpoint retrieves, if exists, a flag for this contribute created by the user logged.
129
+ * @param id
130
+ */
179
131
 
180
- static flagComment(id) {
181
- return _client.default.request({
182
- url: _Endpoints.default.FlagComment.url({
183
- id
184
- }),
185
- method: _Endpoints.default.FlagComment.method
186
- }).then(res => {
187
- if (res.status >= 300) {
188
- console.log(`Unable to perform action (Response code: ${res.status}).`);
189
- return Promise.reject(res);
190
- }
191
-
192
- return Promise.resolve(res.data);
193
- }).catch(error => {
194
- console.log('Unable to perform action.');
195
- return Promise.reject(error);
196
- });
197
- }
198
132
 
199
133
  static getSpecificCommentFlagStatus(id) {
200
- return _client.default.request({
201
- url: _Endpoints.default.CommentFlagStatus.url({
202
- id
203
- }),
204
- method: _Endpoints.default.CommentFlagStatus.method
205
- }).then(res => {
206
- if (res.status >= 300) {
207
- console.log(`Unable to retrieve flags status (Response code: ${res.status}).`);
208
- return Promise.reject(res);
209
- }
210
-
211
- return Promise.resolve(res.data);
212
- }).catch(error => {
213
- console.log('Unable to retrieve flags status.');
214
- return Promise.reject(error);
215
- });
134
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.CommentFlagStatus.url({
135
+ id
136
+ }), _Endpoints.default.CommentFlagStatus.method);
216
137
  }
217
138
 
218
139
  }
@@ -220,20 +141,20 @@ class CommentApiClient {
220
141
  exports.CommentApiClient = CommentApiClient;
221
142
 
222
143
  class CommentService {
223
- static async getAllComments() {
224
- return CommentApiClient.getAllComments();
144
+ static async getAllComments(params) {
145
+ return CommentApiClient.getAllComments(params);
225
146
  }
226
147
 
227
- static async createComment() {
228
- return CommentApiClient.createComment();
148
+ static async createComment(data) {
149
+ return CommentApiClient.createComment(data);
229
150
  }
230
151
 
231
152
  static async getASpecificComment(id) {
232
153
  return CommentApiClient.getASpecificComment(id);
233
154
  }
234
155
 
235
- static async updateComment(id) {
236
- return CommentApiClient.updateComment(id);
156
+ static async updateComment(id, text) {
157
+ return CommentApiClient.updateComment(id, text);
237
158
  }
238
159
 
239
160
  static async deleteComment(id) {
@@ -256,8 +177,8 @@ class CommentService {
256
177
  return CommentApiClient.getSpecificCommentFlags(id);
257
178
  }
258
179
 
259
- static async flagComment(id) {
260
- return CommentApiClient.flagComment(id);
180
+ static async flagComment(id, flagType) {
181
+ return CommentApiClient.flagComment(id, flagType);
261
182
  }
262
183
 
263
184
  static async getSpecificCommentFlagStatus(id) {
@@ -3,64 +3,44 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = exports.CustomAdvApiClient = 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 custom advs.
14
+ */
12
15
  class CustomAdvApiClient {
16
+ /**
17
+ * This endpoint retrieves a specific custom adv.
18
+ * @param id
19
+ */
13
20
  static getASpecificCustomAdv(id) {
14
- return _client.default.request({
15
- url: _Endpoints.default.CustomAdv.url({
16
- id
17
- }),
18
- method: _Endpoints.default.CustomAdv.method
19
- }).then(res => {
20
- if (res.status >= 300) {
21
- console.log(`Unable to retrieve custom adv (Response code: ${res.status}).`);
22
- return Promise.reject(res);
23
- }
24
-
25
- return Promise.resolve(res);
26
- }).catch(error => {
27
- console.log('Unable to retrieve custom adv.');
28
- return Promise.reject(error);
29
- });
21
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.CustomAdv.url({
22
+ id
23
+ }), _Endpoints.default.CustomAdv.method);
30
24
  }
25
+ /**
26
+ * This endpoint retrieves all custom advs.
27
+ * @param params
28
+ */
31
29
 
32
- static getAllCustomAdv() {
33
- return _client.default.request({
34
- url: _Endpoints.default.CustomAdvList.url({}),
35
- method: _Endpoints.default.CustomAdvList.method
36
- }).then(res => {
37
- if (res.status >= 300) {
38
- console.log(`Unable to retrieve custom advs (Response code: ${res.status}).`);
39
- return Promise.reject(res);
40
- }
41
-
42
- return Promise.resolve(res);
43
- }).catch(error => {
44
- console.log('Unable to retrieve custom advs.');
45
- return Promise.reject(error);
46
- });
30
+
31
+ static getAllCustomAdv(params) {
32
+ const p = new URLSearchParams(params);
33
+ return (0, _apiRequest.apiRequest)(`${_Endpoints.default.CustomAdvList.url({})}?${p.toString()}`, _Endpoints.default.CustomAdvList.method);
47
34
  }
35
+ /**
36
+ * This endpoint performs search of a Custom Adv
37
+ * @param params
38
+ */
39
+
48
40
 
49
- static searchCustomAdv() {
50
- return _client.default.request({
51
- url: _Endpoints.default.CustomAdvSearch.url({}),
52
- method: _Endpoints.default.CustomAdvSearch.method
53
- }).then(res => {
54
- if (res.status >= 300) {
55
- console.log(`Unable to retrieve custom advs (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 custom advs.');
62
- return Promise.reject(error);
63
- });
41
+ static searchCustomAdv(params) {
42
+ const p = new URLSearchParams(params);
43
+ return (0, _apiRequest.apiRequest)(`${_Endpoints.default.CustomAdvSearch.url({})}?${p.toString()}`, _Endpoints.default.CustomAdvSearch.method);
64
44
  }
65
45
 
66
46
  }
@@ -72,12 +52,12 @@ class CustomAdvService {
72
52
  return CustomAdvApiClient.getASpecificCustomAdv(id);
73
53
  }
74
54
 
75
- static async getAllCustomAdv() {
76
- return CustomAdvApiClient.getAllCustomAdv();
55
+ static async getAllCustomAdv(params) {
56
+ return CustomAdvApiClient.getAllCustomAdv(params);
77
57
  }
78
58
 
79
- static async searchCustomAdv() {
80
- return CustomAdvApiClient.searchCustomAdv();
59
+ static async searchCustomAdv(params) {
60
+ return CustomAdvApiClient.searchCustomAdv(params);
81
61
  }
82
62
 
83
63
  }
@@ -3,64 +3,44 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = exports.CustomPageApiClient = void 0;
5
5
 
6
- var _client = _interopRequireDefault(require("../../client"));
7
-
8
6
  var _Endpoints = _interopRequireDefault(require("../../constants/Endpoints"));
9
7
 
8
+ var _apiRequest = require("../../utils/apiRequest");
9
+
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
 
12
+ /**
13
+ * Contains all the endpoints needed to manage custom pages.
14
+ */
12
15
  class CustomPageApiClient {
16
+ /**
17
+ * This endpoint retrieves a specific custom page.
18
+ * @param id
19
+ */
13
20
  static getASpecificCustomPage(id) {
14
- return _client.default.request({
15
- url: _Endpoints.default.CustomPage.url({
16
- id
17
- }),
18
- method: _Endpoints.default.CustomPage.method
19
- }).then(res => {
20
- if (res.status >= 300) {
21
- console.log(`Unable to retrieve custom page (Response code: ${res.status}).`);
22
- return Promise.reject(res);
23
- }
24
-
25
- return Promise.resolve(res);
26
- }).catch(error => {
27
- console.log('Unable to retrieve custom page.');
28
- return Promise.reject(error);
29
- });
21
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.CustomPage.url({
22
+ id
23
+ }), _Endpoints.default.CustomPage.method);
30
24
  }
25
+ /**
26
+ * This endpoint retrieves all custom pages.
27
+ * @param params
28
+ */
31
29
 
32
- static getAllCustomPages() {
33
- return _client.default.request({
34
- url: _Endpoints.default.GetCustomPages.url({}),
35
- method: _Endpoints.default.GetCustomPages.method
36
- }).then(res => {
37
- if (res.status >= 300) {
38
- console.log(`Unable to retrieve custom pages (Response code: ${res.status}).`);
39
- return Promise.reject(res);
40
- }
41
-
42
- return Promise.resolve(res);
43
- }).catch(error => {
44
- console.log('Unable to retrieve custom pages.');
45
- return Promise.reject(error);
46
- });
30
+
31
+ static getAllCustomPages(params) {
32
+ const p = new URLSearchParams(params);
33
+ return (0, _apiRequest.apiRequest)(`${_Endpoints.default.GetCustomPages.url({})}?${p.toString()}`, _Endpoints.default.GetCustomPages.method);
47
34
  }
35
+ /**
36
+ * This endpoint performs search of a Custom Page
37
+ * @param params
38
+ */
39
+
48
40
 
49
- static searchCustomPages() {
50
- return _client.default.request({
51
- url: _Endpoints.default.CustomPageSearch.url({}),
52
- method: _Endpoints.default.CustomPageSearch.method
53
- }).then(res => {
54
- if (res.status >= 300) {
55
- console.log(`Unable to retrieve custom pages (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 custom pages.');
62
- return Promise.reject(error);
63
- });
41
+ static searchCustomPages(params) {
42
+ const p = new URLSearchParams(params);
43
+ return (0, _apiRequest.apiRequest)(`${_Endpoints.default.CustomPageSearch.url({})}?${p.toString()}`, _Endpoints.default.CustomPageSearch.method);
64
44
  }
65
45
 
66
46
  }
@@ -72,12 +52,12 @@ class CustomPageService {
72
52
  return CustomPageApiClient.getASpecificCustomPage(id);
73
53
  }
74
54
 
75
- static async getAllCustomPages() {
76
- return CustomPageApiClient.getAllCustomPages();
55
+ static async getAllCustomPages(params) {
56
+ return CustomPageApiClient.getAllCustomPages(params);
77
57
  }
78
58
 
79
- static async searchCustomPages() {
80
- return CustomPageApiClient.searchCustomPages();
59
+ static async searchCustomPages(params) {
60
+ return CustomPageApiClient.searchCustomPages(params);
81
61
  }
82
62
 
83
63
  }
@@ -3,62 +3,37 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = exports.DataPortabilityApiClient = 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 data portability.
14
+ */
12
15
  class DataPortabilityApiClient {
16
+ /**
17
+ * This endpoint generates data portability.
18
+ */
13
19
  static generateDataPortability() {
14
- return _client.default.request({
15
- url: _Endpoints.default.GenerateDataPortability.url({}),
16
- method: _Endpoints.default.GenerateDataPortability.method
17
- }).then(res => {
18
- if (res.status >= 300) {
19
- console.log(`Unable to generate data (Response code: ${res.status}).`);
20
- return Promise.reject(res);
21
- }
22
-
23
- return Promise.resolve(res);
24
- }).catch(error => {
25
- console.log('Unable to generate data.');
26
- return Promise.reject(error);
27
- });
20
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.GenerateDataPortability.url({}), _Endpoints.default.GenerateDataPortability.method);
28
21
  }
22
+ /**
23
+ * This endpoint downloads data portability.
24
+ */
25
+
29
26
 
30
27
  static downloadDataPortability() {
31
- return _client.default.request({
32
- url: _Endpoints.default.DataPortabilityDownload.url({}),
33
- method: _Endpoints.default.DataPortabilityDownload.method
34
- }).then(res => {
35
- if (res.status >= 300) {
36
- console.log(`Unable to download data (Response code: ${res.status}).`);
37
- return Promise.reject(res);
38
- }
39
-
40
- return Promise.resolve(res);
41
- }).catch(error => {
42
- console.log('Unable to download data.');
43
- return Promise.reject(error);
44
- });
28
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.DataPortabilityDownload.url({}), _Endpoints.default.DataPortabilityDownload.method);
45
29
  }
30
+ /**
31
+ * This endpoint retrieves data portability status.
32
+ */
33
+
46
34
 
47
35
  static dataPortabilityStatus() {
48
- return _client.default.request({
49
- url: _Endpoints.default.DataPortabilityStatus.url({}),
50
- method: _Endpoints.default.DataPortabilityStatus.method
51
- }).then(res => {
52
- if (res.status >= 300) {
53
- console.log(`Unable to retrieve data status (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 data status.');
60
- return Promise.reject(error);
61
- });
36
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.DataPortabilityStatus.url({}), _Endpoints.default.DataPortabilityStatus.method);
62
37
  }
63
38
 
64
39
  }