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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.sonymusic.dx.dxuiservice.model.TrackModel;
import com.sonymusic.dx.dxuiservice.service.TrackService;

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 = "Track", description = "Track UI Service")
@RestController
@RequestMapping("track")
public class TrackController {

	@Autowired
	TrackService trackService;

	@Operation(summary = "Get Track details by TrackNo and TrackExt", responses = {
			@ApiResponse(responseCode = "200", description = "OK"),
			@ApiResponse(responseCode = "400", description = "Bad request") })
	@GetMapping("/by-trackno")
	public TrackModel getTrackByTrackNo(@RequestParam String trackExt, @RequestParam String trackNo)
			throws ParseException {
		return trackService.getTrackByTrackNo(trackNo, trackExt);
	}

	@Operation(summary = "Get Track details by ISRC", responses = {
			@ApiResponse(responseCode = "200", description = "OK"),
			@ApiResponse(responseCode = "400", description = "Bad request") })
	@GetMapping("/by-isrc/{isrcNo}")
	public TrackModel getTrackByISRC(@PathVariable String isrcNo) throws ParseException {
		return trackService.getTrackByIsrc(isrcNo);
	}

}
