package de.tsschulz.timeclock.data.booking

import de.tsschulz.timeclock.data.api.CalendarDto
import de.tsschulz.timeclock.data.api.SickCreateRequest
import de.tsschulz.timeclock.data.api.SickEntryDto
import de.tsschulz.timeclock.data.api.SickTypeDto
import de.tsschulz.timeclock.data.api.TimeClockApiClient
import de.tsschulz.timeclock.data.api.TimefixCreateRequest
import de.tsschulz.timeclock.data.api.TimefixDto
import de.tsschulz.timeclock.data.api.VacationCreateRequest
import de.tsschulz.timeclock.data.api.VacationDto
import de.tsschulz.timeclock.data.api.WorkdaysDto
import de.tsschulz.timeclock.data.api.WorklogEntryDto

class BookingRepository(
    private val api: TimeClockApiClient,
) {
    suspend fun getVacations(): List<VacationDto> = api.getVacations()
    suspend fun createVacation(type: Int, start: String, end: String?) =
        api.createVacation(VacationCreateRequest(type, start, end))
    suspend fun deleteVacation(id: String) = api.deleteVacation(id)

    suspend fun getSickEntries(): List<SickEntryDto> = api.getSickEntries()
    suspend fun getSickTypes(): List<SickTypeDto> = api.getSickTypes()
    suspend fun createSick(typeId: String, start: String, end: String?) =
        api.createSick(SickCreateRequest(typeId, start, end ?: start))
    suspend fun deleteSick(id: String) = api.deleteSick(id)

    suspend fun getTimefixes(): List<TimefixDto> = api.getTimefixes()
    suspend fun getWorklogEntries(date: String): List<WorklogEntryDto> = api.getWorklogEntries(date)
    suspend fun createTimefix(worklogId: String, date: String, time: String, action: String) =
        api.createTimefix(TimefixCreateRequest(worklogId, date, time, action))
    suspend fun deleteTimefix(id: String) = api.deleteTimefix(id)

    suspend fun getWorkdays(year: Int): WorkdaysDto = api.getWorkdays(year)
    suspend fun getCalendar(year: Int, month: Int): CalendarDto = api.getCalendar(year, month)
}
