UNPKG

typerinth

Version:

A TypeScript library for interacting with the Modrinth API.

29 lines (28 loc) 939 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Route_1 = require("../Route"); const errors_1 = require("../../errors"); class GetMultipleUsersRoute extends Route_1.Route { userIds; constructor(baseUrl, ua, cacheManager, userIds) { super(baseUrl, ua, cacheManager); this.userIds = userIds; } getCacheKey() { return `users:${this.userIds.join(',')}`; } getUrl() { const url = Route_1.Route.addPathSegment(this.baseUrl, `/users`); url.searchParams.append('ids', `[${this.userIds.map((id) => `"${id}"`).join(', ')}]`); return url; } parseData(data) { if (!data) throw new errors_1.UnexpectedApiError('Unexpected empty response'); if (data.error) { throw new errors_1.ApiError(data.error, data.description); } return data; } } exports.default = GetMultipleUsersRoute;