import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';

export abstract class BaseEndpoint {
  protected client: AxiosInstance;
  protected basePath: string;

  constructor(client: AxiosInstance, basePath: string) {
    this.client = client;
    this.basePath = basePath;
  }

  protected async get<T = any>(path: string, config?: AxiosRequestConfig): Promise<T> {
    const response: AxiosResponse<T> = await this.client.get(`${this.basePath}${path}`, config);
    return response.data;
  }

  protected async post<T = any>(path: string, data?: any, config?: AxiosRequestConfig): Promise<T> {
    const response: AxiosResponse<T> = await this.client.post(`${this.basePath}${path}`, data, config);
    return response.data;
  }

  protected async put<T = any>(path: string, data?: any, config?: AxiosRequestConfig): Promise<T> {
    const response: AxiosResponse<T> = await this.client.put(`${this.basePath}${path}`, data, config);
    return response.data;
  }

  protected async delete<T = any>(path: string, config?: AxiosRequestConfig): Promise<T> {
    const response: AxiosResponse<T> = await this.client.delete(`${this.basePath}${path}`, config);
    return response.data;
  }
} 