package gaf3.core.services.api

import gaf3.core.cloud.feign.GafFeignConfiguration
import gaf3.core.data.JsonResult
import gaf3.core.data.PagedData
import gaf3.core.services.api.domain.*
import org.springframework.cloud.openfeign.FeignClient
import org.springframework.web.bind.annotation.*

@FeignClient(name = "\${feign.name}", url = "\${feign.url}", configuration = [GafFeignConfiguration::class] )
interface CodeService {
    @GetMapping(path = ["/gaf/code/categories"])
    fun listCategories(): PagedData<CodeItem>

    @GetMapping(path = ["/gaf/code/{pid}/items"])
    fun listCodes(@PathVariable pid: String): PagedData<CodeItem>

    @GetMapping(path = ["/gaf/code/items"])
    fun findItems(filter: CodeItem? = null, skip: Int = 0, limit: Int = 100): PagedData<CodeItem>

    @PostMapping(path = ["/gaf/code/items"])
    fun create(@RequestParam pid: String, @RequestBody data: CodeForm): CodeItem

    @DeleteMapping(path = ["/gaf/code/items/{id}"])
    fun delete(@PathVariable id: String): JsonResult<Void>

    @PostMapping(path = ["/gaf/code/items/{id}"])
    fun update(@PathVariable id: String, @RequestBody data: CodeForm): CodeItem

    @GetMapping(path = ["/gaf/code/items/{id}"])
    fun fetch(@PathVariable id: String): CodeItem?

    @GetMapping(path = ["/gaf/code/{pid}/{code}"])
    fun fetchByCode(@PathVariable pid: String, @PathVariable code: String): CodeItem?
}