kyodo.dorks
Version:
TypeScript API wrapper for Kyodo: Communities & Chats
48 lines (47 loc) • 2.32 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DorksUserManager = void 0;
const basic_1 = require("../schemas/responses/basic");
const impl_1 = require("../schemas/responses/impl");
const exceptions_1 = require("../utils/exceptions");
class DorksUserManager {
constructor(config, httpWorkflow, account) {
this.endpoint = '/v1/g/s';
this.__editProfileBuilder = async (jsonPayload) => {
return await this.httpWorkflow.sendXSigPost({
path: `${this.endpoint}/users/${this.__account.user.id}`,
body: jsonPayload
}, basic_1.BasicResponseSchema);
};
this.get = async (id) => {
return await this.httpWorkflow.sendGet({
path: `${this.endpoint}/users/${id}`
}, impl_1.GetUserResponseSchema);
};
this.getMany = async (startLimit = { start: 0, limit: 15 }, filter = 'all', role) => {
if (!this.config.enviroment.circleId)
exceptions_1.KyodoDorksAPIError.throw(1);
return (await this.httpWorkflow.sendGet({
path: `${this.endpoint}/users?limit=${startLimit.limit}&start=${startLimit.start}&role=${role || ''}&q=&filter=${filter}`
}, impl_1.GetUsersResponseSchema)).users;
};
this.nickname = async (nickname) => { return await this.__editProfileBuilder(JSON.stringify({ nickname })); };
this.bio = async (bio) => { return await this.__editProfileBuilder(JSON.stringify({ bio })); };
this.avatar = async (avatar) => { return await this.__editProfileBuilder(JSON.stringify({ avatar })); };
this.banner = async (banner) => { return await this.__editProfileBuilder(JSON.stringify({ banner })); };
this.followStatus = async (userId) => {
return await this.httpWorkflow.sendXSigPost({
path: `${this.endpoint}/users/${userId}/follow/status`,
body: JSON.stringify({})
}, basic_1.BasicResponseSchema);
};
if (config.enviroment.circleId)
this.endpoint = `/v1/${config.enviroment.circleId}/s`;
this.config = config;
this.httpWorkflow = httpWorkflow;
this.__account = account;
}
;
}
exports.DorksUserManager = DorksUserManager;
;