package com.sonymusic.dx.dxuiservice.controllers;

import java.text.ParseException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sonymusic.dx.dxuiservice.model.ProductModel;
import com.sonymusic.dx.dxuiservice.service.ProductService;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "Product", description = "Product UI Service")
@RestController
@RequestMapping("product")
public class ProductController {

	@Autowired
	ProductService productService;

	@Operation(summary = "Get Product details by Product Number", responses = {
			@ApiResponse(responseCode = "200", description = "OK"),
			@ApiResponse(responseCode = "400", description = "Bad request") })
	@GetMapping("/{productNo}")
	public ProductModel getProductById(@PathVariable("productNo") String productNo) throws ParseException {
		return productService.getProductById(productNo);
	}

}
