package com.example.modifier.http.api

import com.example.modifier.http.ktorClient
import com.example.modifier.http.response.DeviceResponse
import io.ktor.client.call.body
import io.ktor.client.plugins.resources.get
import io.ktor.resources.Resource

@Resource("api/device")
class DeviceApi() {

    @Resource("{id}")
    class Id(val parent: DeviceApi = DeviceApi(), val id: String) {

    }

    companion object {
        suspend fun getDevice(deviceId: String): DeviceResponse {
            try {
                return ktorClient.get(Id(id = deviceId))
                    .body<DeviceResponse>()
            } catch (_: Exception) {
            }
            return DeviceResponse(
                id = deviceId,
                pinCountry = null,
                clashProfile = null
            )
        }
    }
}