package com.isidroid.job.data.mapper

import com.isidroid.job.constant.JobStatus
import com.isidroid.job.data.source.remote.api.response.CreateJobResponse
import com.isidroid.job.model.PrintJob

internal fun CreateJobResponse.transform() = PrintJob(
    id = id,
    accessCode = accessCode,
    accessToken = accessToken,
    spotId = spotId,
    profileId = profileId,
    status = 0,
    createdAt = created,
)

private fun String.transformToStatus() = when (this) {
    "New" -> JobStatus.CREATED
    "Canceled" -> JobStatus.CANCELED
    "Ready" -> JobStatus.READY
    "Accepted" -> JobStatus.ACCEPTED
    "Rejected" -> JobStatus.REJECTED
    "Printing" -> JobStatus.PRINTING
    "Completed" -> JobStatus.COMPLETED
    "Error" -> JobStatus.ERROR
    else -> -1
}
