kyodo.dorks
Version:
TypeScript API wrapper for Kyodo: Communities & Chats
61 lines (60 loc) • 2.44 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.DorksPostManager = void 0;
const basic_1 = require("../schemas/responses/basic");
const circle_1 = require("../schemas/responses/circle");
const exceptions_1 = require("../utils/exceptions");
const utils_1 = require("../utils/utils");
class DorksPostManager {
constructor(config, httpWorkflow) {
this.get = async (id) => {
return (await this.httpWorkflow.sendGet({
path: `${this.endpoint}/posts/${id}`
}, circle_1.GetPostResponseSchema)).post;
};
this.create = async (title, content, cover, backgroundUrl) => {
return (await this.httpWorkflow.sendXSigPost({
path: `${this.endpoint}/posts`,
body: JSON.stringify({
title,
content,
config: {
mediaMap: (0, utils_1.parseMediaMap)(cover, true),
backgroundUrl
}
})
}, circle_1.GetPostResponseSchema)).post;
};
this.getManyFrom = async (startLimit = { start: 0, limit: 15 }, userId = '') => {
return (await this.httpWorkflow.sendGet({
path: `${this.endpoint}/posts?type=0&limit=${startLimit.limit}&pt=&uid=${userId}&parentId=&q=&v=2`
}, circle_1.GetPostsResponseSchema)).posts;
};
this.sendComment = async (postId, content, title = '-') => {
return await this.httpWorkflow.sendXSigPost({
path: `${this.endpoint}/posts`,
body: JSON.stringify({
title,
content,
config: {
parentPostId: postId
}
})
}, basic_1.BasicResponseSchema);
};
this.likeStatus = async (postId) => {
return await this.httpWorkflow.sendXSigPost({
path: `${this.endpoint}/posts/${postId}/like`,
body: JSON.stringify({})
}, basic_1.BasicResponseSchema);
};
if (!config.enviroment.circleId)
exceptions_1.KyodoDorksAPIError.throw(1);
this.endpoint = `/v1/${config.enviroment.circleId}/s`;
this.config = config;
this.httpWorkflow = httpWorkflow;
}
;
}
exports.DorksPostManager = DorksPostManager;
;
;