night-api
Version:
Ce paquet Npm fourni une interface pour intéragir avec [Night-API](https://night-api.com)
45 lines • 1.78 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const functions_1 = __importDefault(require("../../functions"));
const constants_1 = require("../constants");
class Jokes {
token;
constructor(token) {
this.token = token;
this.functions = new functions_1.default(this.token);
}
;
async random(options = null) {
if (options && typeof options !== 'object')
throw new TypeError('The options must be an object');
if (options && typeof options.disallow !== 'string' && !Array.isArray(options.disallow))
throw new TypeError('The options "disallow" must be an array or a string');
return await this.functions.get(constants_1.Endpoints.Jokes._, { query: options });
}
;
async byID(id) {
if (!id)
throw new Error('The joke ID is missing');
if (isNaN(id))
throw new Error('The ID must be a Number');
return await this.functions.get(`${constants_1.Endpoints.Jokes._}/${id}`);
}
;
async byCategory(category) {
if (!category)
throw new Error('The joke Type is missing');
if (typeof category !== 'string')
throw new TypeError('The options "category" must be an string');
if (!constants_1.Lists.JokesCategory.includes(category.toLowerCase()))
throw new TypeError('Invalid "category" type provided');
return await this.functions.get(`${constants_1.Endpoints.Jokes._}/${category}`);
}
;
}
;
;
exports.default = Jokes;
//# sourceMappingURL=Jokes.js.map