import { apiClient } from './apiClient';

export const schedulesService = {
    async getRouteSchedules(routeId: string, onlyPublished = true) {
        const response = await apiClient.get('/api/schedules', {
            params: { route_id: routeId, only_published: onlyPublished }
        });
        return response.data;
    },

    async getStopSchedules(stopId: string, onlyPublished = true) {
        const response = await apiClient.get('/api/schedules', {
            params: { stop_id: stopId, only_published: onlyPublished }
        });
        return response.data;
    },

    async createSchedule(scheduleData: any) {
        const response = await apiClient.post('/api/schedules', scheduleData);
        return response.data;
    },

    async updateSchedule(scheduleId: string, updateData: any) {
        const response = await apiClient.put(`/api/schedules/${scheduleId}`, updateData);
        return response.data;
    },

    async deleteSchedule(scheduleId: string) {
        const response = await apiClient.delete(`/api/schedules/${scheduleId}`);
        return response.data;
    }
};
