lemmy-js-client 0.17.0-rc.3 → 0.17.0-rc.30

Sign up to get free protection for your applications and to get access to all the features.
package/dist/http.js CHANGED
@@ -48,7 +48,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
50
  exports.LemmyHttp = void 0;
51
+ var class_transformer_1 = require("class-transformer");
51
52
  var node_fetch_1 = require("node-fetch");
53
+ var comment_1 = require("./interfaces/api/comment");
54
+ var community_1 = require("./interfaces/api/community");
55
+ var person_1 = require("./interfaces/api/person");
56
+ var post_1 = require("./interfaces/api/post");
57
+ var site_1 = require("./interfaces/api/site");
52
58
  var others_1 = require("./interfaces/others");
53
59
  var HttpType;
54
60
  (function (HttpType) {
@@ -74,753 +80,919 @@ var LemmyHttp = /** @class */ (function () {
74
80
  }
75
81
  /**
76
82
  * Gets the site, and your user data.
83
+ *
84
+ * `HTTP.GET /site`
77
85
  */
78
86
  LemmyHttp.prototype.getSite = function (form) {
79
87
  return __awaiter(this, void 0, void 0, function () {
80
88
  return __generator(this, function (_a) {
81
- return [2 /*return*/, this.wrapper(HttpType.Get, "/site", form)];
89
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/site", form, site_1.GetSiteResponse)];
82
90
  });
83
91
  });
84
92
  };
85
93
  /**
86
94
  * Create your site.
95
+ *
96
+ * `HTTP.POST /site`
87
97
  */
88
98
  LemmyHttp.prototype.createSite = function (form) {
89
99
  return __awaiter(this, void 0, void 0, function () {
90
100
  return __generator(this, function (_a) {
91
- return [2 /*return*/, this.wrapper(HttpType.Post, "/site", form)];
101
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/site", form, site_1.SiteResponse)];
92
102
  });
93
103
  });
94
104
  };
95
105
  /**
96
106
  * Edit your site.
107
+ *
108
+ * `HTTP.PUT /site`
97
109
  */
98
110
  LemmyHttp.prototype.editSite = function (form) {
99
111
  return __awaiter(this, void 0, void 0, function () {
100
112
  return __generator(this, function (_a) {
101
- return [2 /*return*/, this.wrapper(HttpType.Put, "/site", form)];
113
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/site", form, site_1.SiteResponse)];
102
114
  });
103
115
  });
104
116
  };
105
117
  /**
106
118
  * Leave the Site admins.
119
+ *
120
+ * `HTTP.POST /user/leave_admin`
107
121
  */
108
122
  LemmyHttp.prototype.leaveAdmin = function (form) {
109
123
  return __awaiter(this, void 0, void 0, function () {
110
124
  return __generator(this, function (_a) {
111
- return [2 /*return*/, this.wrapper(HttpType.Post, "/user/leave_admin", form)];
125
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/user/leave_admin", form, site_1.GetSiteResponse)];
112
126
  });
113
127
  });
114
128
  };
115
129
  /**
116
130
  * Get your site configuration.
131
+ *
132
+ * `HTTP.GET /site/config`
117
133
  */
118
134
  LemmyHttp.prototype.getSiteConfig = function (form) {
119
135
  return __awaiter(this, void 0, void 0, function () {
120
136
  return __generator(this, function (_a) {
121
- return [2 /*return*/, this.wrapper(HttpType.Get, "/site/config", form)];
137
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/site/config", form, site_1.GetSiteConfigResponse)];
122
138
  });
123
139
  });
124
140
  };
125
141
  /**
126
142
  * Save your site config.
143
+ *
144
+ * `HTTP.PUT /site/config`
127
145
  */
128
146
  LemmyHttp.prototype.saveSiteConfig = function (form) {
129
147
  return __awaiter(this, void 0, void 0, function () {
130
148
  return __generator(this, function (_a) {
131
- return [2 /*return*/, this.wrapper(HttpType.Put, "/site/config", form)];
149
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/site/config", form, site_1.GetSiteConfigResponse)];
132
150
  });
133
151
  });
134
152
  };
135
153
  /**
136
154
  * Get the modlog.
155
+ *
156
+ * `HTTP.GET /modlog`
137
157
  */
138
158
  LemmyHttp.prototype.getModlog = function (form) {
139
159
  return __awaiter(this, void 0, void 0, function () {
140
160
  return __generator(this, function (_a) {
141
- return [2 /*return*/, this.wrapper(HttpType.Get, "/modlog", form)];
161
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/modlog", form, site_1.GetModlogResponse)];
142
162
  });
143
163
  });
144
164
  };
145
165
  /**
146
166
  * Search lemmy.
167
+ *
168
+ * `HTTP.GET /search`
147
169
  */
148
170
  LemmyHttp.prototype.search = function (form) {
149
171
  return __awaiter(this, void 0, void 0, function () {
150
172
  return __generator(this, function (_a) {
151
- return [2 /*return*/, this.wrapper(HttpType.Get, "/search", form)];
173
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/search", form, site_1.SearchResponse)];
152
174
  });
153
175
  });
154
176
  };
155
177
  /**
156
178
  * Fetch a non-local / federated object.
179
+ *
180
+ * `HTTP.GET /resolve_object`
157
181
  */
158
182
  LemmyHttp.prototype.resolveObject = function (form) {
159
183
  return __awaiter(this, void 0, void 0, function () {
160
184
  return __generator(this, function (_a) {
161
- return [2 /*return*/, this.wrapper(HttpType.Get, "/resolve_object", form)];
185
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/resolve_object", form, site_1.ResolveObjectResponse)];
162
186
  });
163
187
  });
164
188
  };
165
189
  /**
166
190
  * Create a new community.
191
+ *
192
+ * `HTTP.POST /community`
167
193
  */
168
194
  LemmyHttp.prototype.createCommunity = function (form) {
169
195
  return __awaiter(this, void 0, void 0, function () {
170
196
  return __generator(this, function (_a) {
171
- return [2 /*return*/, this.wrapper(HttpType.Post, "/community", form)];
197
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/community", form, community_1.CommunityResponse)];
172
198
  });
173
199
  });
174
200
  };
175
201
  /**
176
202
  * Get / fetch a community.
203
+ *
204
+ * `HTTP.GET /community`
177
205
  */
178
206
  LemmyHttp.prototype.getCommunity = function (form) {
179
207
  return __awaiter(this, void 0, void 0, function () {
180
208
  return __generator(this, function (_a) {
181
- return [2 /*return*/, this.wrapper(HttpType.Get, "/community", form)];
209
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/community", form, community_1.GetCommunityResponse)];
182
210
  });
183
211
  });
184
212
  };
185
213
  /**
186
214
  * Edit a community.
215
+ *
216
+ * `HTTP.PUT /community`
187
217
  */
188
218
  LemmyHttp.prototype.editCommunity = function (form) {
189
219
  return __awaiter(this, void 0, void 0, function () {
190
220
  return __generator(this, function (_a) {
191
- return [2 /*return*/, this.wrapper(HttpType.Put, "/community", form)];
221
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/community", form, community_1.CommunityResponse)];
192
222
  });
193
223
  });
194
224
  };
195
225
  /**
196
226
  * List communities, with various filters.
227
+ *
228
+ * `HTTP.GET /community/list`
197
229
  */
198
230
  LemmyHttp.prototype.listCommunities = function (form) {
199
231
  return __awaiter(this, void 0, void 0, function () {
200
232
  return __generator(this, function (_a) {
201
- return [2 /*return*/, this.wrapper(HttpType.Get, "/community/list", form)];
233
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/community/list", form, community_1.ListCommunitiesResponse)];
202
234
  });
203
235
  });
204
236
  };
205
237
  /**
206
238
  * Follow / subscribe to a community.
239
+ *
240
+ * `HTTP.POST /community/follow`
207
241
  */
208
242
  LemmyHttp.prototype.followCommunity = function (form) {
209
243
  return __awaiter(this, void 0, void 0, function () {
210
244
  return __generator(this, function (_a) {
211
- return [2 /*return*/, this.wrapper(HttpType.Post, "/community/follow", form)];
245
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/community/follow", form, community_1.CommunityResponse)];
212
246
  });
213
247
  });
214
248
  };
215
249
  /**
216
250
  * Block a community.
251
+ *
252
+ * `HTTP.POST /community/block`
217
253
  */
218
254
  LemmyHttp.prototype.blockCommunity = function (form) {
219
255
  return __awaiter(this, void 0, void 0, function () {
220
256
  return __generator(this, function (_a) {
221
- return [2 /*return*/, this.wrapper(HttpType.Post, "/community/block", form)];
257
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/community/block", form, community_1.BlockCommunityResponse)];
222
258
  });
223
259
  });
224
260
  };
225
261
  /**
226
262
  * Delete a community.
263
+ *
264
+ * `HTTP.POST /community/delete`
227
265
  */
228
266
  LemmyHttp.prototype.deleteCommunity = function (form) {
229
267
  return __awaiter(this, void 0, void 0, function () {
230
268
  return __generator(this, function (_a) {
231
- return [2 /*return*/, this.wrapper(HttpType.Post, "/community/delete", form)];
269
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/community/delete", form, community_1.CommunityResponse)];
232
270
  });
233
271
  });
234
272
  };
235
273
  /**
236
274
  * A moderator remove for a community.
275
+ *
276
+ * `HTTP.POST /community/remove`
237
277
  */
238
278
  LemmyHttp.prototype.removeCommunity = function (form) {
239
279
  return __awaiter(this, void 0, void 0, function () {
240
280
  return __generator(this, function (_a) {
241
- return [2 /*return*/, this.wrapper(HttpType.Post, "/community/remove", form)];
281
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/community/remove", form, community_1.CommunityResponse)];
242
282
  });
243
283
  });
244
284
  };
245
285
  /**
246
286
  * Transfer your community to an existing moderator.
287
+ *
288
+ * `HTTP.POST /community/transfer`
247
289
  */
248
290
  LemmyHttp.prototype.transferCommunity = function (form) {
249
291
  return __awaiter(this, void 0, void 0, function () {
250
292
  return __generator(this, function (_a) {
251
- return [2 /*return*/, this.wrapper(HttpType.Post, "/community/transfer", form)];
293
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/community/transfer", form, community_1.GetCommunityResponse)];
252
294
  });
253
295
  });
254
296
  };
255
297
  /**
256
298
  * Ban a user from a community.
299
+ *
300
+ * `HTTP.POST /community/ban_user`
257
301
  */
258
302
  LemmyHttp.prototype.banFromCommunity = function (form) {
259
303
  return __awaiter(this, void 0, void 0, function () {
260
304
  return __generator(this, function (_a) {
261
- return [2 /*return*/, this.wrapper(HttpType.Post, "/community/ban_user", form)];
305
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/community/ban_user", form, community_1.BanFromCommunityResponse)];
262
306
  });
263
307
  });
264
308
  };
265
309
  /**
266
310
  * Add a moderator to your community.
311
+ *
312
+ * `HTTP.POST /community/mod`
267
313
  */
268
314
  LemmyHttp.prototype.addModToCommunity = function (form) {
269
315
  return __awaiter(this, void 0, void 0, function () {
270
316
  return __generator(this, function (_a) {
271
- return [2 /*return*/, this.wrapper(HttpType.Post, "/community/mod", form)];
317
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/community/mod", form, community_1.AddModToCommunityResponse)];
272
318
  });
273
319
  });
274
320
  };
275
321
  /**
276
322
  * Create a post.
323
+ *
324
+ * `HTTP.POST /post`
277
325
  */
278
326
  LemmyHttp.prototype.createPost = function (form) {
279
327
  return __awaiter(this, void 0, void 0, function () {
280
328
  return __generator(this, function (_a) {
281
- return [2 /*return*/, this.wrapper(HttpType.Post, "/post", form)];
329
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/post", form, post_1.PostResponse)];
282
330
  });
283
331
  });
284
332
  };
285
333
  /**
286
334
  * Get / fetch a post.
335
+ *
336
+ * `HTTP.GET /post`
287
337
  */
288
338
  LemmyHttp.prototype.getPost = function (form) {
289
339
  return __awaiter(this, void 0, void 0, function () {
290
340
  return __generator(this, function (_a) {
291
- return [2 /*return*/, this.wrapper(HttpType.Get, "/post", form)];
341
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/post", form, post_1.GetPostResponse)];
292
342
  });
293
343
  });
294
344
  };
295
345
  /**
296
346
  * Edit a post.
347
+ *
348
+ * `HTTP.PUT /post`
297
349
  */
298
350
  LemmyHttp.prototype.editPost = function (form) {
299
351
  return __awaiter(this, void 0, void 0, function () {
300
352
  return __generator(this, function (_a) {
301
- return [2 /*return*/, this.wrapper(HttpType.Put, "/post", form)];
353
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/post", form, post_1.PostResponse)];
302
354
  });
303
355
  });
304
356
  };
305
357
  /**
306
358
  * Delete a post.
359
+ *
360
+ * `HTTP.POST /post/delete`
307
361
  */
308
362
  LemmyHttp.prototype.deletePost = function (form) {
309
363
  return __awaiter(this, void 0, void 0, function () {
310
364
  return __generator(this, function (_a) {
311
- return [2 /*return*/, this.wrapper(HttpType.Post, "/post/delete", form)];
365
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/post/delete", form, post_1.PostResponse)];
312
366
  });
313
367
  });
314
368
  };
315
369
  /**
316
370
  * A moderator remove for a post.
371
+ *
372
+ * `HTTP.POST /post/remove`
317
373
  */
318
374
  LemmyHttp.prototype.removePost = function (form) {
319
375
  return __awaiter(this, void 0, void 0, function () {
320
376
  return __generator(this, function (_a) {
321
- return [2 /*return*/, this.wrapper(HttpType.Post, "/post/remove", form)];
377
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/post/remove", form, post_1.PostResponse)];
378
+ });
379
+ });
380
+ };
381
+ /**
382
+ * Mark a post as read.
383
+ *
384
+ * `HTTP.POST /post/mark_as_read`
385
+ */
386
+ LemmyHttp.prototype.markPostAsRead = function (form) {
387
+ return __awaiter(this, void 0, void 0, function () {
388
+ return __generator(this, function (_a) {
389
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/post/mark_as_read", form, post_1.PostResponse)];
322
390
  });
323
391
  });
324
392
  };
325
393
  /**
326
394
  * A moderator can lock a post ( IE disable new comments ).
395
+ *
396
+ * `HTTP.POST /post/lock`
327
397
  */
328
398
  LemmyHttp.prototype.lockPost = function (form) {
329
399
  return __awaiter(this, void 0, void 0, function () {
330
400
  return __generator(this, function (_a) {
331
- return [2 /*return*/, this.wrapper(HttpType.Post, "/post/lock", form)];
401
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/post/lock", form, post_1.PostResponse)];
332
402
  });
333
403
  });
334
404
  };
335
405
  /**
336
406
  * A moderator can sticky a post ( IE stick it to the top of a community ).
407
+ *
408
+ * `HTTP.POST /post/sticky`
337
409
  */
338
410
  LemmyHttp.prototype.stickyPost = function (form) {
339
411
  return __awaiter(this, void 0, void 0, function () {
340
412
  return __generator(this, function (_a) {
341
- return [2 /*return*/, this.wrapper(HttpType.Post, "/post/sticky", form)];
413
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/post/sticky", form, post_1.PostResponse)];
342
414
  });
343
415
  });
344
416
  };
345
417
  /**
346
418
  * Get / fetch posts, with various filters.
419
+ *
420
+ * `HTTP.GET /post/list`
347
421
  */
348
422
  LemmyHttp.prototype.getPosts = function (form) {
349
423
  return __awaiter(this, void 0, void 0, function () {
350
424
  return __generator(this, function (_a) {
351
- return [2 /*return*/, this.wrapper(HttpType.Get, "/post/list", form)];
425
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/post/list", form, post_1.GetPostsResponse)];
352
426
  });
353
427
  });
354
428
  };
355
429
  /**
356
430
  * Like / vote on a post.
431
+ *
432
+ * `HTTP.POST /post/like`
357
433
  */
358
434
  LemmyHttp.prototype.likePost = function (form) {
359
435
  return __awaiter(this, void 0, void 0, function () {
360
436
  return __generator(this, function (_a) {
361
- return [2 /*return*/, this.wrapper(HttpType.Post, "/post/like", form)];
437
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/post/like", form, post_1.PostResponse)];
362
438
  });
363
439
  });
364
440
  };
365
441
  /**
366
442
  * Save a post.
443
+ *
444
+ * `HTTP.PUT /post/save`
367
445
  */
368
446
  LemmyHttp.prototype.savePost = function (form) {
369
447
  return __awaiter(this, void 0, void 0, function () {
370
448
  return __generator(this, function (_a) {
371
- return [2 /*return*/, this.wrapper(HttpType.Put, "/post/save", form)];
449
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/post/save", form, post_1.PostResponse)];
372
450
  });
373
451
  });
374
452
  };
375
453
  /**
376
454
  * Report a post.
455
+ *
456
+ * `HTTP.POST /post/report`
377
457
  */
378
458
  LemmyHttp.prototype.createPostReport = function (form) {
379
459
  return __awaiter(this, void 0, void 0, function () {
380
460
  return __generator(this, function (_a) {
381
- return [2 /*return*/, this.wrapper(HttpType.Post, "/post/report", form)];
461
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/post/report", form, post_1.PostReportResponse)];
382
462
  });
383
463
  });
384
464
  };
385
465
  /**
386
466
  * Resolve a post report. Only a mod can do this.
467
+ *
468
+ * `HTTP.PUT /post/report/resolve`
387
469
  */
388
470
  LemmyHttp.prototype.resolvePostReport = function (form) {
389
471
  return __awaiter(this, void 0, void 0, function () {
390
472
  return __generator(this, function (_a) {
391
- return [2 /*return*/, this.wrapper(HttpType.Put, "/post/report/resolve", form)];
473
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/post/report/resolve", form, post_1.PostReportResponse)];
392
474
  });
393
475
  });
394
476
  };
395
477
  /**
396
478
  * List post reports.
479
+ *
480
+ * `HTTP.GET /post/report/list`
397
481
  */
398
482
  LemmyHttp.prototype.listPostReports = function (form) {
399
483
  return __awaiter(this, void 0, void 0, function () {
400
484
  return __generator(this, function (_a) {
401
- return [2 /*return*/, this.wrapper(HttpType.Get, "/post/report/list", form)];
485
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/post/report/list", form, post_1.ListPostReportsResponse)];
402
486
  });
403
487
  });
404
488
  };
405
489
  /**
406
490
  * Fetch metadata for any given site.
491
+ *
492
+ * `HTTP.GET /post/site_metadata`
407
493
  */
408
494
  LemmyHttp.prototype.getSiteMetadata = function (form) {
409
495
  return __awaiter(this, void 0, void 0, function () {
410
496
  return __generator(this, function (_a) {
411
- return [2 /*return*/, this.wrapper(HttpType.Get, "/post/site_metadata", form)];
497
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/post/site_metadata", form, post_1.GetSiteMetadataResponse)];
412
498
  });
413
499
  });
414
500
  };
415
501
  /**
416
502
  * Create a comment.
503
+ *
504
+ * `HTTP.POST /comment`
417
505
  */
418
506
  LemmyHttp.prototype.createComment = function (form) {
419
507
  return __awaiter(this, void 0, void 0, function () {
420
508
  return __generator(this, function (_a) {
421
- return [2 /*return*/, this.wrapper(HttpType.Post, "/comment", form)];
509
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/comment", form, comment_1.CommentResponse)];
422
510
  });
423
511
  });
424
512
  };
425
513
  /**
426
514
  * Edit a comment.
515
+ *
516
+ * `HTTP.PUT /comment`
427
517
  */
428
518
  LemmyHttp.prototype.editComment = function (form) {
429
519
  return __awaiter(this, void 0, void 0, function () {
430
520
  return __generator(this, function (_a) {
431
- return [2 /*return*/, this.wrapper(HttpType.Put, "/comment", form)];
521
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/comment", form, comment_1.CommentResponse)];
432
522
  });
433
523
  });
434
524
  };
435
525
  /**
436
526
  * Delete a comment.
527
+ *
528
+ * `HTTP.POST /comment/delete`
437
529
  */
438
530
  LemmyHttp.prototype.deleteComment = function (form) {
439
531
  return __awaiter(this, void 0, void 0, function () {
440
532
  return __generator(this, function (_a) {
441
- return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/delete", form)];
533
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/delete", form, comment_1.CommentResponse)];
442
534
  });
443
535
  });
444
536
  };
445
537
  /**
446
538
  * A moderator remove for a comment.
539
+ *
540
+ * `HTTP.POST /comment/remove`
447
541
  */
448
542
  LemmyHttp.prototype.removeComment = function (form) {
449
543
  return __awaiter(this, void 0, void 0, function () {
450
544
  return __generator(this, function (_a) {
451
- return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/remove", form)];
545
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/remove", form, comment_1.CommentResponse)];
452
546
  });
453
547
  });
454
548
  };
455
549
  /**
456
550
  * Mark a comment as read.
551
+ *
552
+ * `HTTP.POST /comment/mark_as_read`
457
553
  */
458
554
  LemmyHttp.prototype.markCommentAsRead = function (form) {
459
555
  return __awaiter(this, void 0, void 0, function () {
460
556
  return __generator(this, function (_a) {
461
- return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/mark_as_read", form)];
557
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/mark_as_read", form, comment_1.CommentResponse)];
462
558
  });
463
559
  });
464
560
  };
465
561
  /**
466
562
  * Like / vote on a comment.
563
+ *
564
+ * `HTTP.POST /comment/like`
467
565
  */
468
566
  LemmyHttp.prototype.likeComment = function (form) {
469
567
  return __awaiter(this, void 0, void 0, function () {
470
568
  return __generator(this, function (_a) {
471
- return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/like", form)];
569
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/like", form, comment_1.CommentResponse)];
472
570
  });
473
571
  });
474
572
  };
475
573
  /**
476
574
  * Save a comment.
575
+ *
576
+ * `HTTP.PUT /comment/save`
477
577
  */
478
578
  LemmyHttp.prototype.saveComment = function (form) {
479
579
  return __awaiter(this, void 0, void 0, function () {
480
580
  return __generator(this, function (_a) {
481
- return [2 /*return*/, this.wrapper(HttpType.Put, "/comment/save", form)];
581
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/comment/save", form, comment_1.CommentResponse)];
482
582
  });
483
583
  });
484
584
  };
485
585
  /**
486
586
  * Get / fetch comments.
587
+ *
588
+ * `HTTP.GET /comment/list`
487
589
  */
488
590
  LemmyHttp.prototype.getComments = function (form) {
489
591
  return __awaiter(this, void 0, void 0, function () {
490
592
  return __generator(this, function (_a) {
491
- return [2 /*return*/, this.wrapper(HttpType.Get, "/comment/list", form)];
593
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/comment/list", form, comment_1.GetCommentsResponse)];
492
594
  });
493
595
  });
494
596
  };
495
597
  /**
496
598
  * Report a comment.
599
+ *
600
+ * `HTTP.POST /comment/report`
497
601
  */
498
602
  LemmyHttp.prototype.createCommentReport = function (form) {
499
603
  return __awaiter(this, void 0, void 0, function () {
500
604
  return __generator(this, function (_a) {
501
- return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/report", form)];
605
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/comment/report", form, comment_1.CommentReportResponse)];
502
606
  });
503
607
  });
504
608
  };
505
609
  /**
506
610
  * Resolve a comment report. Only a mod can do this.
611
+ *
612
+ * `HTTP.PUT /comment/report/resolve`
507
613
  */
508
614
  LemmyHttp.prototype.resolveCommentReport = function (form) {
509
615
  return __awaiter(this, void 0, void 0, function () {
510
616
  return __generator(this, function (_a) {
511
- return [2 /*return*/, this.wrapper(HttpType.Put, "/comment/report/resolve", form)];
617
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/comment/report/resolve", form, comment_1.CommentReportResponse)];
512
618
  });
513
619
  });
514
620
  };
515
621
  /**
516
622
  * List comment reports.
623
+ *
624
+ * `HTTP.GET /comment/report/list`
517
625
  */
518
626
  LemmyHttp.prototype.listCommentReports = function (form) {
519
627
  return __awaiter(this, void 0, void 0, function () {
520
628
  return __generator(this, function (_a) {
521
- return [2 /*return*/, this.wrapper(HttpType.Get, "/comment/report/list", form)];
629
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/comment/report/list", form, comment_1.ListCommentReportsResponse)];
522
630
  });
523
631
  });
524
632
  };
525
633
  /**
526
634
  * Get / fetch private messages.
635
+ *
636
+ * `HTTP.GET /private_message/list`
527
637
  */
528
638
  LemmyHttp.prototype.getPrivateMessages = function (form) {
529
639
  return __awaiter(this, void 0, void 0, function () {
530
640
  return __generator(this, function (_a) {
531
- return [2 /*return*/, this.wrapper(HttpType.Get, "/private_message/list", form)];
641
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/private_message/list", form, person_1.PrivateMessagesResponse)];
532
642
  });
533
643
  });
534
644
  };
535
645
  /**
536
646
  * Create a private message.
647
+ *
648
+ * `HTTP.POST /private_message`
537
649
  */
538
650
  LemmyHttp.prototype.createPrivateMessage = function (form) {
539
651
  return __awaiter(this, void 0, void 0, function () {
540
652
  return __generator(this, function (_a) {
541
- return [2 /*return*/, this.wrapper(HttpType.Post, "/private_message", form)];
653
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/private_message", form, person_1.PrivateMessageResponse)];
542
654
  });
543
655
  });
544
656
  };
545
657
  /**
546
658
  * Edit a private message.
659
+ *
660
+ * `HTTP.PUT /private_message`
547
661
  */
548
662
  LemmyHttp.prototype.editPrivateMessage = function (form) {
549
663
  return __awaiter(this, void 0, void 0, function () {
550
664
  return __generator(this, function (_a) {
551
- return [2 /*return*/, this.wrapper(HttpType.Put, "/private_message", form)];
665
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/private_message", form, person_1.PrivateMessageResponse)];
552
666
  });
553
667
  });
554
668
  };
555
669
  /**
556
670
  * Delete a private message.
671
+ *
672
+ * `HTTP.POST /private_message/delete`
557
673
  */
558
674
  LemmyHttp.prototype.deletePrivateMessage = function (form) {
559
675
  return __awaiter(this, void 0, void 0, function () {
560
676
  return __generator(this, function (_a) {
561
- return [2 /*return*/, this.wrapper(HttpType.Post, "/private_message/delete", form)];
677
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/private_message/delete", form, person_1.PrivateMessageResponse)];
562
678
  });
563
679
  });
564
680
  };
565
681
  /**
566
682
  * Mark a private message as read.
683
+ *
684
+ * `HTTP.POST /private_message/mark_as_read`
567
685
  */
568
686
  LemmyHttp.prototype.markPrivateMessageAsRead = function (form) {
569
687
  return __awaiter(this, void 0, void 0, function () {
570
688
  return __generator(this, function (_a) {
571
- return [2 /*return*/, this.wrapper(HttpType.Post, "/private_message/mark_as_read", form)];
689
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/private_message/mark_as_read", form, person_1.PrivateMessageResponse)];
572
690
  });
573
691
  });
574
692
  };
575
693
  /**
576
694
  * Register a new user.
695
+ *
696
+ * `HTTP.POST /user/register`
577
697
  */
578
698
  LemmyHttp.prototype.register = function (form) {
579
699
  return __awaiter(this, void 0, void 0, function () {
580
700
  return __generator(this, function (_a) {
581
- return [2 /*return*/, this.wrapper(HttpType.Post, "/user/register", form)];
701
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/user/register", form, person_1.LoginResponse)];
582
702
  });
583
703
  });
584
704
  };
585
705
  /**
586
706
  * Log into lemmy.
707
+ *
708
+ * `HTTP.POST /user/login`
587
709
  */
588
710
  LemmyHttp.prototype.login = function (form) {
589
711
  return __awaiter(this, void 0, void 0, function () {
590
712
  return __generator(this, function (_a) {
591
- return [2 /*return*/, this.wrapper(HttpType.Post, "/user/login", form)];
713
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/user/login", form, person_1.LoginResponse)];
592
714
  });
593
715
  });
594
716
  };
595
717
  /**
596
718
  * Get the details for a person.
719
+ *
720
+ * `HTTP.GET /user`
597
721
  */
598
722
  LemmyHttp.prototype.getPersonDetails = function (form) {
599
723
  return __awaiter(this, void 0, void 0, function () {
600
724
  return __generator(this, function (_a) {
601
- return [2 /*return*/, this.wrapper(HttpType.Get, "/user", form)];
725
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/user", form, person_1.GetPersonDetailsResponse)];
602
726
  });
603
727
  });
604
728
  };
605
729
  /**
606
730
  * Get mentions for your user.
731
+ *
732
+ * `HTTP.GET /user/mention`
607
733
  */
608
734
  LemmyHttp.prototype.getPersonMentions = function (form) {
609
735
  return __awaiter(this, void 0, void 0, function () {
610
736
  return __generator(this, function (_a) {
611
- return [2 /*return*/, this.wrapper(HttpType.Get, "/user/mention", form)];
737
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/user/mention", form, person_1.GetPersonMentionsResponse)];
612
738
  });
613
739
  });
614
740
  };
615
741
  /**
616
742
  * Mark a person mention as read.
743
+ *
744
+ * `HTTP.POST /user/mention/mark_as_read`
617
745
  */
618
746
  LemmyHttp.prototype.markPersonMentionAsRead = function (form) {
619
747
  return __awaiter(this, void 0, void 0, function () {
620
748
  return __generator(this, function (_a) {
621
- return [2 /*return*/, this.wrapper(HttpType.Post, "/user/mention/mark_as_read", form)];
749
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/user/mention/mark_as_read", form, person_1.PersonMentionResponse)];
622
750
  });
623
751
  });
624
752
  };
625
753
  /**
626
754
  * Get comment replies.
755
+ *
756
+ * `HTTP.GET /user/replies`
627
757
  */
628
758
  LemmyHttp.prototype.getReplies = function (form) {
629
759
  return __awaiter(this, void 0, void 0, function () {
630
760
  return __generator(this, function (_a) {
631
- return [2 /*return*/, this.wrapper(HttpType.Get, "/user/replies", form)];
761
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/user/replies", form, person_1.GetRepliesResponse)];
632
762
  });
633
763
  });
634
764
  };
635
765
  /**
636
766
  * Ban a person from your site.
767
+ *
768
+ * `HTTP.POST /user/ban`
637
769
  */
638
770
  LemmyHttp.prototype.banPerson = function (form) {
639
771
  return __awaiter(this, void 0, void 0, function () {
640
772
  return __generator(this, function (_a) {
641
- return [2 /*return*/, this.wrapper(HttpType.Post, "/user/ban", form)];
773
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/user/ban", form, person_1.BanPersonResponse)];
642
774
  });
643
775
  });
644
776
  };
645
777
  /**
646
778
  * Get a list of banned users
779
+ *
780
+ * `HTTP.GET /user/banned`
647
781
  */
648
782
  LemmyHttp.prototype.getBannedPersons = function (form) {
649
783
  return __awaiter(this, void 0, void 0, function () {
650
784
  return __generator(this, function (_a) {
651
- return [2 /*return*/, this.wrapper(HttpType.Get, "/user/banned", form)];
785
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/user/banned", form, person_1.BannedPersonsResponse)];
652
786
  });
653
787
  });
654
788
  };
655
789
  /**
656
790
  * Block a person.
791
+ *
792
+ * `HTTP.POST /user/block`
657
793
  */
658
794
  LemmyHttp.prototype.blockPerson = function (form) {
659
795
  return __awaiter(this, void 0, void 0, function () {
660
796
  return __generator(this, function (_a) {
661
- return [2 /*return*/, this.wrapper(HttpType.Post, "/user/block", form)];
797
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/user/block", form, person_1.BlockPersonResponse)];
662
798
  });
663
799
  });
664
800
  };
665
801
  /**
666
802
  * Fetch a Captcha.
803
+ *
804
+ * `HTTP.GET /user/get_captcha`
667
805
  */
668
806
  LemmyHttp.prototype.getCaptcha = function () {
669
807
  return __awaiter(this, void 0, void 0, function () {
670
808
  return __generator(this, function (_a) {
671
- return [2 /*return*/, this.wrapper(HttpType.Get, "/user/get_captcha", {})];
809
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/user/get_captcha", {}, person_1.GetCaptchaResponse)];
672
810
  });
673
811
  });
674
812
  };
675
813
  /**
676
814
  * Delete your account.
815
+ *
816
+ * `HTTP.POST /user/delete_account`
677
817
  */
678
818
  LemmyHttp.prototype.deleteAccount = function (form) {
679
819
  return __awaiter(this, void 0, void 0, function () {
680
820
  return __generator(this, function (_a) {
681
- return [2 /*return*/, this.wrapper(HttpType.Post, "/user/delete_account", form)];
821
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/user/delete_account", form, person_1.DeleteAccountResponse)];
682
822
  });
683
823
  });
684
824
  };
685
825
  /**
686
826
  * Reset your password.
827
+ *
828
+ * `HTTP.POST /user/password_reset`
687
829
  */
688
830
  LemmyHttp.prototype.passwordReset = function (form) {
689
831
  return __awaiter(this, void 0, void 0, function () {
690
832
  return __generator(this, function (_a) {
691
- return [2 /*return*/, this.wrapper(HttpType.Post, "/user/password_reset", form)];
833
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/user/password_reset", form, person_1.PasswordResetResponse)];
692
834
  });
693
835
  });
694
836
  };
695
837
  /**
696
838
  * Change your password from an email / token based reset.
839
+ *
840
+ * `HTTP.POST /user/password_change`
697
841
  */
698
842
  LemmyHttp.prototype.passwordChange = function (form) {
699
843
  return __awaiter(this, void 0, void 0, function () {
700
844
  return __generator(this, function (_a) {
701
- return [2 /*return*/, this.wrapper(HttpType.Post, "/user/password_change", form)];
845
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/user/password_change", form, person_1.LoginResponse)];
702
846
  });
703
847
  });
704
848
  };
705
849
  /**
706
850
  * Mark all replies as read.
851
+ *
852
+ * `HTTP.POST /user/mark_all_as_read`
707
853
  */
708
854
  LemmyHttp.prototype.markAllAsRead = function (form) {
709
855
  return __awaiter(this, void 0, void 0, function () {
710
856
  return __generator(this, function (_a) {
711
- return [2 /*return*/, this.wrapper(HttpType.Post, "/user/mark_all_as_read", form)];
857
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/user/mark_all_as_read", form, person_1.GetRepliesResponse)];
712
858
  });
713
859
  });
714
860
  };
715
861
  /**
716
862
  * Save your user settings.
863
+ *
864
+ * `HTTP.PUT /user/save_user_settings`
717
865
  */
718
866
  LemmyHttp.prototype.saveUserSettings = function (form) {
719
867
  return __awaiter(this, void 0, void 0, function () {
720
868
  return __generator(this, function (_a) {
721
- return [2 /*return*/, this.wrapper(HttpType.Put, "/user/save_user_settings", form)];
869
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/user/save_user_settings", form, person_1.LoginResponse)];
722
870
  });
723
871
  });
724
872
  };
725
873
  /**
726
874
  * Change your user password.
875
+ *
876
+ * `HTTP.PUT /user/change_password`
727
877
  */
728
878
  LemmyHttp.prototype.changePassword = function (form) {
729
879
  return __awaiter(this, void 0, void 0, function () {
730
880
  return __generator(this, function (_a) {
731
- return [2 /*return*/, this.wrapper(HttpType.Put, "/user/change_password", form)];
881
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/user/change_password", form, person_1.LoginResponse)];
732
882
  });
733
883
  });
734
884
  };
735
885
  /**
736
886
  * Get counts for your reports
887
+ *
888
+ * `HTTP.GET /user/report_count`
737
889
  */
738
890
  LemmyHttp.prototype.getReportCount = function (form) {
739
891
  return __awaiter(this, void 0, void 0, function () {
740
892
  return __generator(this, function (_a) {
741
- return [2 /*return*/, this.wrapper(HttpType.Get, "/user/report_count", form)];
893
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/user/report_count", form, person_1.GetReportCountResponse)];
742
894
  });
743
895
  });
744
896
  };
745
897
  /**
746
898
  * Get your unread counts
899
+ *
900
+ * `HTTP.GET /user/unread_count`
747
901
  */
748
902
  LemmyHttp.prototype.getUnreadCount = function (form) {
749
903
  return __awaiter(this, void 0, void 0, function () {
750
904
  return __generator(this, function (_a) {
751
- return [2 /*return*/, this.wrapper(HttpType.Get, "/user/unread_count", form)];
905
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/user/unread_count", form, person_1.GetUnreadCountResponse)];
752
906
  });
753
907
  });
754
908
  };
755
909
  /**
756
910
  * Verify your email
911
+ *
912
+ * `HTTP.POST /user/verify_email`
757
913
  */
758
914
  LemmyHttp.prototype.verifyEmail = function (form) {
759
915
  return __awaiter(this, void 0, void 0, function () {
760
916
  return __generator(this, function (_a) {
761
- return [2 /*return*/, this.wrapper(HttpType.Post, "/user/verify_email", form)];
917
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/user/verify_email", form, person_1.VerifyEmailResponse)];
762
918
  });
763
919
  });
764
920
  };
765
921
  /**
766
922
  * Add an admin to your site.
923
+ *
924
+ * `HTTP.POST /admin/add`
767
925
  */
768
926
  LemmyHttp.prototype.addAdmin = function (form) {
769
927
  return __awaiter(this, void 0, void 0, function () {
770
928
  return __generator(this, function (_a) {
771
- return [2 /*return*/, this.wrapper(HttpType.Post, "/admin/add", form)];
929
+ return [2 /*return*/, this.wrapper(HttpType.Post, "/admin/add", form, person_1.AddAdminResponse)];
772
930
  });
773
931
  });
774
932
  };
775
933
  /**
776
934
  * Get the unread registration applications count.
935
+ *
936
+ * `HTTP.GET /admin/registration_application/count`
777
937
  */
778
938
  LemmyHttp.prototype.getUnreadRegistrationApplicationCount = function (form) {
779
939
  return __awaiter(this, void 0, void 0, function () {
780
940
  return __generator(this, function (_a) {
781
- return [2 /*return*/, this.wrapper(HttpType.Get, "/admin/registration_application/count", form)];
941
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/admin/registration_application/count", form, site_1.GetUnreadRegistrationApplicationCountResponse)];
782
942
  });
783
943
  });
784
944
  };
785
945
  /**
786
- * List the unread registration applications.
946
+ * List the registration applications.
947
+ *
948
+ * `HTTP.GET /admin/registration_application/list`
787
949
  */
788
950
  LemmyHttp.prototype.listRegistrationApplications = function (form) {
789
951
  return __awaiter(this, void 0, void 0, function () {
790
952
  return __generator(this, function (_a) {
791
- return [2 /*return*/, this.wrapper(HttpType.Get, "/admin/registration_application/list", form)];
953
+ return [2 /*return*/, this.wrapper(HttpType.Get, "/admin/registration_application/list", form, site_1.ListRegistrationApplicationsResponse)];
792
954
  });
793
955
  });
794
956
  };
795
957
  /**
796
958
  * Approve a registration application
959
+ *
960
+ * `HTTP.PUT /admin/registration_application/approve`
797
961
  */
798
962
  LemmyHttp.prototype.approveRegistrationApplication = function (form) {
799
963
  return __awaiter(this, void 0, void 0, function () {
800
964
  return __generator(this, function (_a) {
801
- return [2 /*return*/, this.wrapper(HttpType.Put, "/admin/registration_application/approve", form)];
965
+ return [2 /*return*/, this.wrapper(HttpType.Put, "/admin/registration_application/approve", form, site_1.RegistrationApplicationResponse)];
802
966
  });
803
967
  });
804
968
  };
805
969
  LemmyHttp.prototype.buildFullUrl = function (endpoint) {
806
970
  return "".concat(this.apiUrl).concat(endpoint);
807
971
  };
808
- LemmyHttp.prototype.wrapper = function (type_, endpoint, form) {
972
+ LemmyHttp.prototype.wrapper = function (type_, endpoint, form, responseClass) {
809
973
  return __awaiter(this, void 0, void 0, function () {
810
974
  var getUrl;
811
975
  return __generator(this, function (_a) {
812
976
  if (type_ == HttpType.Get) {
813
977
  getUrl = "".concat(this.buildFullUrl(endpoint), "?").concat(encodeGetParams(form));
814
- return [2 /*return*/, (0, node_fetch_1.default)(getUrl, {
978
+ return [2 /*return*/, ((0, node_fetch_1.default)(getUrl, {
815
979
  method: "GET",
816
980
  headers: this.headers,
817
- }).then(function (d) { return d.json(); })];
981
+ })
982
+ // TODO test this
983
+ .then(function (d) {
984
+ return d
985
+ .text()
986
+ .then(function (a) {
987
+ return (0, class_transformer_1.deserialize)(responseClass, a);
988
+ });
989
+ }))];
818
990
  }
819
991
  else {
820
992
  return [2 /*return*/, (0, node_fetch_1.default)(this.buildFullUrl(endpoint), {
821
993
  method: type_,
822
994
  headers: __assign({ "Content-Type": "application/json" }, this.headers),
823
- body: JSON.stringify(form),
995
+ body: (0, class_transformer_1.serialize)(form),
824
996
  }).then(function (d) { return d.json(); })];
825
997
  }
826
998
  return [2 /*return*/];
@@ -831,7 +1003,10 @@ var LemmyHttp = /** @class */ (function () {
831
1003
  }());
832
1004
  exports.LemmyHttp = LemmyHttp;
833
1005
  function encodeGetParams(p) {
834
- return Object.entries(p)
1006
+ // Necessary to remove the Options
1007
+ var serialized = JSON.parse((0, class_transformer_1.serialize)(p));
1008
+ return (Object.entries(serialized)
1009
+ // TODO test this, it might serialize the undefineds
835
1010
  .map(function (kv) { return kv.map(encodeURIComponent).join("="); })
836
- .join("&");
1011
+ .join("&"));
837
1012
  }