import { SpotifyApi } from "../SpotifyApi.js"; export default class EndpointsBase { constructor(protected api: SpotifyApi) { } protected async getRequest(url: string): Promise { return await this.api.makeRequest("GET", url); } protected async postRequest(url: string, body?: TBody, contentType: string | undefined = undefined): Promise { return await this.api.makeRequest("POST", url, body, contentType); } protected async putRequest(url: string, body?: TBody, contentType: string | undefined = undefined): Promise { return await this.api.makeRequest("PUT", url, body, contentType); } protected async deleteRequest(url: string, body?: TBody): Promise { return await this.api.makeRequest("DELETE", url, body); } protected paramsFor(args: any) { const params = new URLSearchParams(); for (let key of Object.getOwnPropertyNames(args)) { if (args[key] || (args[key] === 0) || (!args[key] && typeof args[key] === 'boolean')) { params.append(key, args[key].toString()); } } return [...params].length > 0 ? `?${params.toString()}` : ""; } }