import "reflect-metadata";
import { Controller, Get, Post, Patch, Route, Path, Body } from "@tsoa/runtime";
import itemBundlesService from "~/services/item/bundles";

@Route("itemBundles")
export class ItemBundlesController extends Controller {
	/**
	 * Retrieves list of all item bundles
	 */
	@Get()
	public async getList(): Promise<any[]> {
		const data = await itemBundlesService.getList();
		return Array.isArray(data) ? data : [data];
	}

	/**
	 * Adds an item to a bundle
	 */
	@Post("/addItem")
	public async addItemToBundle(@Body() body: any): Promise<any> {
		return await itemBundlesService.addItemToBundle(body);
	}

	/**
	 * Creates a new item bundle
	 */
	@Post()
	public async create(@Body() body: any): Promise<any> {
		return await itemBundlesService.create(body);
	}

	/**
	 * Partially updates an item bundle
	 */
	@Patch("/:id")
	public async patch(@Path() id: string | number, @Body() body: any): Promise<any> {
		return await itemBundlesService.patch(id, body);
	}
}
