package dp.kotul.templategroupsbackend.controller

import dp.kotul.starter.global.DefaultApiResponses
import dp.kotul.templategroupsbackend.facade.CreativeFacade
import dp.kotul.templategroupsbackend.model.request.TemplateGroupGenerateCreativeRequest
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@Api(tags = ["Creatives"], description = "Provides API for creatives operations")
@DefaultApiResponses
@RestController
@RequestMapping("/creatives", produces = [MediaType.APPLICATION_JSON_VALUE])
class CreativeController(val creativeFacade: CreativeFacade) {

    @ApiOperation(value = "Generate creatives", notes = "Generate creatives defined by template group generate creative request")
    @PostMapping("/generate")
    fun generateCreatives(
            @ApiParam(value = "Template group generate creative request", required = true) @RequestBody templateGroupGenerateCreativeRequest: TemplateGroupGenerateCreativeRequest,
            @ApiParam(value = "Language ID", required = false) @RequestParam laeId: Int?
    ) {
        creativeFacade.generateCreatives(templateGroupGenerateCreativeRequest, laeId)
    }
}
