@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,174 +3,112 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = exports.LoyaltyApiClient = 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 loyalty program.
14
+ */
12
15
  class LoyaltyApiClient {
16
+ /**
17
+ * This endpoint retrieves all prizes.
18
+ */
13
19
  static getPrizes() {
14
- return _client.default.request({
15
- url: _Endpoints.default.GetPrizes.url({}),
16
- method: _Endpoints.default.GetPrizes.method
17
- }).then(res => {
18
- if (res.status >= 300) {
19
- console.log(`Unable to retrieve prizes (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 prizes.');
26
- return Promise.reject(error);
27
- });
20
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.GetPrizes.url({}), _Endpoints.default.GetPrizes.method);
28
21
  }
22
+ /**
23
+ * This endpoint creates a prize.
24
+ * @param data
25
+ */
29
26
 
30
- static createPrize() {
31
- return _client.default.request({
32
- url: _Endpoints.default.CreatePrize.url({}),
33
- method: _Endpoints.default.CreatePrize.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);
44
- });
27
+
28
+ static createPrize(data) {
29
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.CreatePrize.url({}), _Endpoints.default.CreatePrize.method, data);
45
30
  }
31
+ /**
32
+ * This endpoint retrieves a specific prize
33
+ * @param id
34
+ */
35
+
46
36
 
47
37
  static getSpecificPrize(id) {
48
- return _client.default.request({
49
- url: _Endpoints.default.GetSpecificPrize.url({
50
- id
51
- }),
52
- method: _Endpoints.default.GetSpecificPrize.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);
60
- }).catch(error => {
61
- console.log('Unable to perform action.');
62
- return Promise.reject(error);
63
- });
38
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.GetSpecificPrize.url({
39
+ id
40
+ }), _Endpoints.default.GetSpecificPrize.method);
64
41
  }
42
+ /**
43
+ * This endpoint updates a specific prize.
44
+ * @param id
45
+ * @param data
46
+ */
65
47
 
66
- static updatePrize(id) {
67
- return _client.default.request({
68
- url: _Endpoints.default.UpdatePrize.url({
69
- id
70
- }),
71
- method: _Endpoints.default.UpdatePrize.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);
79
- }).catch(error => {
80
- console.log('Unable to perform action.');
81
- return Promise.reject(error);
82
- });
48
+
49
+ static updatePrize(id, data) {
50
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.UpdatePrize.url({
51
+ id
52
+ }), _Endpoints.default.UpdatePrize.method, data != null ? data : null);
83
53
  }
54
+ /**
55
+ * This endpoint patches a specific prize.
56
+ * @param id
57
+ * @param data
58
+ */
84
59
 
85
- static patchPrize(id) {
86
- return _client.default.request({
87
- url: _Endpoints.default.PatchPrize.url({
88
- id
89
- }),
90
- method: _Endpoints.default.PatchPrize.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);
98
- }).catch(error => {
99
- console.log('Unable to perform action.');
100
- return Promise.reject(error);
101
- });
60
+
61
+ static patchPrize(id, data) {
62
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.PatchPrize.url({
63
+ id
64
+ }), _Endpoints.default.PatchPrize.method, data != null ? data : null);
102
65
  }
66
+ /**
67
+ * This endpoint retrieves all requests of loyalty prizes.
68
+ */
103
69
 
104
- static getPrizeRequests() {
105
- return _client.default.request({
106
- url: _Endpoints.default.GetPrizeRequests.url({}),
107
- method: _Endpoints.default.GetPrizeRequests.method
108
- }).then(res => {
109
- if (res.status >= 300) {
110
- console.log(`Unable to retrieve prize requests (Response code: ${res.status}).`);
111
- return Promise.reject(res);
112
- }
113
-
114
- return Promise.resolve(res);
115
- }).catch(error => {
116
- console.log('Unable to retrieve prize requests.');
117
- return Promise.reject(error);
118
- });
70
+
71
+ static getAllPrizeRequests() {
72
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.GetPrizeRequests.url({}), _Endpoints.default.GetPrizeRequests.method);
119
73
  }
74
+ /**
75
+ * This endpoint creates a request for a loyalty prize
76
+ * @param prize
77
+ */
120
78
 
121
- static createPrizeRequest() {
122
- return _client.default.request({
123
- url: _Endpoints.default.CreatePrizeRequest.url({}),
124
- method: _Endpoints.default.CreatePrizeRequest.method
125
- }).then(res => {
126
- if (res.status >= 300) {
127
- console.log(`Unable to perform action (Response code: ${res.status}).`);
128
- return Promise.reject(res);
129
- }
130
-
131
- return Promise.resolve(res);
132
- }).catch(error => {
133
- console.log('Unable to perform action.');
134
- return Promise.reject(error);
79
+
80
+ static createPrizeRequest(prize) {
81
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.CreatePrizeRequest.url({}), _Endpoints.default.CreatePrizeRequest.method, {
82
+ prize: prize
135
83
  });
136
84
  }
85
+ /**
86
+ * This endpoint retrieves a specific request for a loyalty prize.
87
+ * @param id
88
+ */
89
+
137
90
 
138
91
  static getSpecificPrizeRequest(id) {
139
- return _client.default.request({
140
- url: _Endpoints.default.GetSpecificPrizeRequest.url({
141
- id
142
- }),
143
- method: _Endpoints.default.GetSpecificPrizeRequest.method
144
- }).then(res => {
145
- if (res.status >= 300) {
146
- console.log(`Unable to retrieve prize request (Response code: ${res.status}).`);
147
- return Promise.reject(res);
148
- }
149
-
150
- return Promise.resolve(res);
151
- }).catch(error => {
152
- console.log('Unable to retrieve prize request.');
153
- return Promise.reject(error);
154
- });
92
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.GetSpecificPrizeRequest.url({
93
+ id
94
+ }), _Endpoints.default.GetSpecificPrizeRequest.method);
155
95
  }
96
+ /**
97
+ * This endpoint patches a specific request for a loyalty prize.
98
+ * You can use this endpoint to to change status in an admin list/table interface.
99
+ * @param id
100
+ * @param status
101
+ */
156
102
 
157
- static patchPrizeRequest(id) {
158
- return _client.default.request({
159
- url: _Endpoints.default.PatchPrizeRequest.url({
160
- id
161
- }),
162
- method: _Endpoints.default.PatchPrizeRequest.method
163
- }).then(res => {
164
- if (res.status >= 300) {
165
- console.log(`Unable to perform action(Response code: ${res.status}).`);
166
- return Promise.reject(res);
167
- }
168
-
169
- return Promise.resolve(res);
170
- }).catch(error => {
171
- console.log('Unable to perform action.');
172
- return Promise.reject(error);
173
- });
103
+
104
+ static patchPrizeRequest(id, status) {
105
+ var _status;
106
+
107
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.PatchPrizeRequest.url({
108
+ id
109
+ }), _Endpoints.default.PatchPrizeRequest.method, (_status = {
110
+ status: status
111
+ }) != null ? _status : null);
174
112
  }
175
113
 
176
114
  }
@@ -182,36 +120,36 @@ class LoyaltyService {
182
120
  return LoyaltyApiClient.getPrizes();
183
121
  }
184
122
 
185
- static async createPrize() {
186
- return LoyaltyApiClient.createPrize();
123
+ static async createPrize(data) {
124
+ return LoyaltyApiClient.createPrize(data);
187
125
  }
188
126
 
189
127
  static async getSpecificPrize(id) {
190
128
  return LoyaltyApiClient.getSpecificPrize(id);
191
129
  }
192
130
 
193
- static async updatePrize(id) {
194
- return LoyaltyApiClient.updatePrize(id);
131
+ static async updatePrize(id, data) {
132
+ return LoyaltyApiClient.updatePrize(id, data);
195
133
  }
196
134
 
197
- static async patchPrize(id) {
198
- return LoyaltyApiClient.patchPrize(id);
135
+ static async patchPrize(id, data) {
136
+ return LoyaltyApiClient.patchPrize(id, data);
199
137
  }
200
138
 
201
- static async getPrizeRequests() {
202
- return LoyaltyApiClient.getPrizeRequests();
139
+ static async getAllPrizeRequests() {
140
+ return LoyaltyApiClient.getAllPrizeRequests();
203
141
  }
204
142
 
205
- static async createPrizeRequest() {
206
- return LoyaltyApiClient.createPrizeRequest();
143
+ static async createPrizeRequest(prize) {
144
+ return LoyaltyApiClient.createPrizeRequest(prize);
207
145
  }
208
146
 
209
147
  static async getSpecificPrizeRequest(id) {
210
148
  return LoyaltyApiClient.getSpecificPrizeRequest(id);
211
149
  }
212
150
 
213
- static async patchPrizeRequest(id) {
214
- return LoyaltyApiClient.patchPrizeRequest(id);
151
+ static async patchPrizeRequest(id, status) {
152
+ return LoyaltyApiClient.patchPrizeRequest(id, status);
215
153
  }
216
154
 
217
155
  }
@@ -3,138 +3,96 @@
3
3
  exports.__esModule = true;
4
4
  exports.default = exports.MediaApiClient = 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 medias.
14
+ */
12
15
  class MediaApiClient {
13
- static chunkUploadMedia() {
14
- return _client.default.request({
15
- url: _Endpoints.default.ComposerChunkUploadMedia.url({}),
16
- method: _Endpoints.default.ComposerChunkUploadMedia.method
17
- }).then(res => {
18
- if (res.status >= 300) {
19
- console.log(`Unable to perform action (Response code: ${res.status}).`);
20
- return Promise.reject(res);
21
- }
22
-
23
- return Promise.resolve(res);
24
- }).catch(error => {
25
- console.log('Unable to perform action.');
26
- return Promise.reject(error);
27
- });
16
+ /**
17
+ * This endpoint performs the chunk upload of a media with type image or document.
18
+ * The client must split the file into chunks and send to the server in series. After all the chunks have been uploaded the client must call the Chunk Upload Complete endpoint with the given upload_id parameter to finalize the upload and retrieve the Media.
19
+ * To perform chunk upload the request must contain Content-Range header with the information about the chunk.
20
+ * @param data
21
+ */
22
+ static chunkUploadMedia(data) {
23
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.ComposerChunkUploadMedia.url({}), _Endpoints.default.ComposerChunkUploadMedia.method, {
24
+ 'Content-Range': 'bytes 1433600-1638399/2124437'
25
+ }, data);
28
26
  }
27
+ /**
28
+ * This endpoint completes the chunk upload and create the media.
29
+ * @param data
30
+ */
29
31
 
30
- static chunkUploadMediaComplete() {
31
- return _client.default.request({
32
- url: _Endpoints.default.ComposerChunkUploadMediaComplete.url({}),
33
- method: _Endpoints.default.ComposerChunkUploadMediaComplete.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);
44
- });
32
+
33
+ static chunkUploadMediaComplete(data) {
34
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.ComposerChunkUploadMediaComplete.url({}), _Endpoints.default.ComposerChunkUploadMediaComplete.method, data);
45
35
  }
36
+ /**
37
+ * This endpoint creates a media.
38
+ * @param data
39
+ */
46
40
 
47
- static createMedia() {
48
- return _client.default.request({
49
- url: _Endpoints.default.ComposerMediaCreate.url({}),
50
- method: _Endpoints.default.ComposerMediaCreate.method
51
- }).then(res => {
52
- if (res.status >= 300) {
53
- console.log(`Unable to perform action (Response code: ${res.status}).`);
54
- return Promise.reject(res);
55
- }
56
-
57
- return Promise.resolve(res);
58
- }).catch(error => {
59
- console.log('Unable to perform action.');
60
- return Promise.reject(error);
61
- });
41
+
42
+ static createMedia(data) {
43
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.ComposerMediaCreate.url({}), _Endpoints.default.ComposerMediaCreate.method, data);
62
44
  }
45
+ /**
46
+ * This endpoint saves a click on a specific media using ID.
47
+ * @param id
48
+ * @param ip
49
+ */
63
50
 
64
- static clickMedia(id) {
65
- return _client.default.request({
66
- url: _Endpoints.default.MediaClickTracker.url({
67
- id
68
- }),
69
- method: _Endpoints.default.MediaClickTracker.method
70
- }).then(res => {
71
- if (res.status >= 300) {
72
- console.log(`Unable to perform action (Response code: ${res.status}).`);
73
- return Promise.reject(res);
74
- }
75
-
76
- return Promise.resolve(res);
77
- }).catch(error => {
78
- console.log('Unable to perform action.');
79
- return Promise.reject(error);
80
- });
51
+
52
+ static clickMedia(id, ip) {
53
+ var _ip;
54
+
55
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.MediaClickTracker.url({
56
+ id
57
+ }), _Endpoints.default.MediaClickTracker.method, (_ip = {
58
+ ip: ip
59
+ }) != null ? _ip : null);
81
60
  }
61
+ /**
62
+ * This endpoint retrieves a specific media using ID.
63
+ * @param id
64
+ */
65
+
82
66
 
83
67
  static getSpecificMedia(id) {
84
- return _client.default.request({
85
- url: _Endpoints.default.GetMedia.url({
86
- id
87
- }),
88
- method: _Endpoints.default.GetMedia.method
89
- }).then(res => {
90
- if (res.status >= 300) {
91
- console.log(`Unable to retrieve media (Response code: ${res.status}).`);
92
- return Promise.reject(res);
93
- }
94
-
95
- return Promise.resolve(res);
96
- }).catch(error => {
97
- console.log('Unable to retrieve media.');
98
- return Promise.reject(error);
99
- });
68
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.GetMedia.url({
69
+ id
70
+ }), _Endpoints.default.GetMedia.method);
100
71
  }
101
-
102
- static updateMedia(id) {
103
- return _client.default.request({
104
- url: _Endpoints.default.UpdateMedia.url({
105
- id
106
- }),
107
- method: _Endpoints.default.UpdateMedia.method
108
- }).then(res => {
109
- if (res.status >= 300) {
110
- console.log(`Unable to perform action (Response code: ${res.status}).`);
111
- return Promise.reject(res);
112
- }
113
-
114
- return Promise.resolve(res);
115
- }).catch(error => {
116
- console.log('Unable to perform action.');
117
- return Promise.reject(error);
72
+ /**
73
+ * This endpoint updates a media.
74
+ * @param id
75
+ * @param image
76
+ */
77
+
78
+
79
+ static updateMedia(id, image) {
80
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.UpdateMedia.url({
81
+ id
82
+ }), _Endpoints.default.UpdateMedia.method, {
83
+ image: image
118
84
  });
119
85
  }
86
+ /**
87
+ * This endpoint deletes a media.
88
+ * @param id
89
+ */
90
+
120
91
 
121
92
  static deleteMedia(id) {
122
- return _client.default.request({
123
- url: _Endpoints.default.DeleteMedia.url({
124
- id
125
- }),
126
- method: _Endpoints.default.DeleteMedia.method
127
- }).then(res => {
128
- if (res.status >= 300) {
129
- console.log(`Unable to perform action(Response code: ${res.status}).`);
130
- return Promise.reject(res);
131
- }
132
-
133
- return Promise.resolve(res);
134
- }).catch(error => {
135
- console.log('Unable to perform action.');
136
- return Promise.reject(error);
137
- });
93
+ return (0, _apiRequest.apiRequest)(_Endpoints.default.DeleteMedia.url({
94
+ id
95
+ }), _Endpoints.default.DeleteMedia.method);
138
96
  }
139
97
 
140
98
  }
@@ -142,28 +100,28 @@ class MediaApiClient {
142
100
  exports.MediaApiClient = MediaApiClient;
143
101
 
144
102
  class MediaService {
145
- static async chunkUploadMedia() {
146
- return MediaApiClient.chunkUploadMedia();
103
+ static async chunkUploadMedia(data) {
104
+ return MediaApiClient.chunkUploadMedia(data);
147
105
  }
148
106
 
149
- static async chunkUploadMediaComplete() {
150
- return MediaApiClient.chunkUploadMediaComplete();
107
+ static async chunkUploadMediaComplete(data) {
108
+ return MediaApiClient.chunkUploadMediaComplete(data);
151
109
  }
152
110
 
153
- static async createMedia() {
154
- return MediaApiClient.createMedia();
111
+ static async createMedia(data) {
112
+ return MediaApiClient.createMedia(data);
155
113
  }
156
114
 
157
- static async clickMedia(id) {
158
- return MediaApiClient.clickMedia(id);
115
+ static async clickMedia(id, ip) {
116
+ return MediaApiClient.clickMedia(id, ip);
159
117
  }
160
118
 
161
119
  static async getSpecificMedia(id) {
162
120
  return MediaApiClient.getSpecificMedia(id);
163
121
  }
164
122
 
165
- static async updateMedia(id) {
166
- return MediaApiClient.updateMedia(id);
123
+ static async updateMedia(id, image) {
124
+ return MediaApiClient.updateMedia(id, image);
167
125
  }
168
126
 
169
127
  static async deleteMedia(id) {