UNPKG

trender-client

Version:
121 lines (120 loc) 4.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const Constante_1 = require("../utils/Constante"); const RequestEmitter_1 = tslib_1.__importDefault(require("../utils/RequestEmitter")); const PostUserManager_1 = tslib_1.__importDefault(require("./PostUserManager")); class PostManager extends RequestEmitter_1.default { constructor(params) { super(params); Object.defineProperty(this, "user", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.user = new PostUserManager_1.default(params); } file(user_id, post_id, file_name) { return `${Constante_1.cdnsiteurl}/posts/${user_id}/${post_id}/${file_name}`; } uploadFile(files) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const formdata = new FormData(); formdata.append("posts", files); const request = yield this.uploadFiles(`/upload?type=posts`, formdata); const response = request; return response; }); } create(options) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const request = yield this.postRequest(`/posts`, options); const response = request; return response; }); } delete(target_id) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const request = yield this.deleteRequest(`/posts/${target_id}`); const response = request; return response; }); } unPin(target_id) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const request = yield this.deleteRequest(`/posts/${target_id}/pin`); const response = request; return response; }); } pin(target_id) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const request = yield this.postRequest(`/posts/${target_id}/pin`, {}); const response = request; return response; }); } getPinPost(target_id) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const request = yield this.getRequest(`/posts/${target_id}/pin`); const response = request; return response; }); } like(target_id) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const request = yield this.postRequest(`/posts/${target_id}/likes`, {}); const response = request; return response; }); } unlike(target_id) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const request = yield this.deleteRequest(`/posts/${target_id}/likes`); const response = request; return response; }); } getLikesPost(target_id) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const request = yield this.getRequest(`/posts/${target_id}/likes`); const response = request; return response; }); } report(target_id, reason, description) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const request = yield this.postRequest(`/posts/${target_id}/reports`, { reason: reason, description: description }); const response = request; return response; }); } fetchOne(post_id) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const request = yield this.getRequest(`/posts/${post_id}`); const response = request; return response; }); } comments(post_id, options) { var _a, _b; return tslib_1.__awaiter(this, void 0, void 0, function* () { const request = yield this.getRequest(`/posts/${post_id}/comments?skip=${(_a = options === null || options === void 0 ? void 0 : options.skip) !== null && _a !== void 0 ? _a : 0}&limit=${(_b = options === null || options === void 0 ? void 0 : options.limit) !== null && _b !== void 0 ? _b : 30}`); const response = request; return response; }); } fetch(options) { var _a, _b; return tslib_1.__awaiter(this, void 0, void 0, function* () { const request = yield this.getRequest(`/posts?skip=${(_a = options === null || options === void 0 ? void 0 : options.skip) !== null && _a !== void 0 ? _a : 0}&limit=${(_b = options === null || options === void 0 ? void 0 : options.limit) !== null && _b !== void 0 ? _b : 30}`); const response = request; return response; }); } } exports.default = PostManager;