/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { BaseResponse } from '../models/BaseResponse';
import type { CreateGeneralCanvasRequest } from '../models/CreateGeneralCanvasRequest';
import type { UpdateCanvasMetadataRequest } from '../models/UpdateCanvasMetadataRequest';
import { request as __request } from '../core/request';
import { OpenAPI } from '../core/OpenAPI';

export class CanvasMetadataService {
    /**
     * List all canvases for a project
     * @param projectId Project ID
     * @param canvasType Filter by type: general, asset, storyboard
     * @param includeDeleted Include deleted canvases
     * @returns BaseResponse List of canvas metadata
     * @throws ApiError
     */
    public static async listProjectCanvases(
        projectId: string,
        canvasType?: 'general' | 'asset' | 'storyboard',
        includeDeleted?: boolean,
    ): Promise<BaseResponse> {
        const result = await __request(OpenAPI, {
            method: 'GET',
            url: `/api/v1/projects/${projectId}/canvases`,
            query: {
                'canvas_type': canvasType,
                'include_deleted': includeDeleted,
            },
        });
        return result as BaseResponse;
    }

    /**
     * Create a new general canvas
     * @param projectId Project ID
     * @param requestBody Canvas creation request
     * @returns BaseResponse Created canvas metadata
     * @throws ApiError
     */
    public static async createGeneralCanvas(
        projectId: string,
        requestBody: CreateGeneralCanvasRequest,
    ): Promise<BaseResponse> {
        const result = await __request(OpenAPI, {
            method: 'POST',
            url: `/api/v1/projects/${projectId}/canvases`,
            body: requestBody,
        });
        return result as BaseResponse;
    }

    /**
     * Get canvas metadata by ID
     * @param canvasId Canvas ID
     * @returns BaseResponse Canvas metadata
     * @throws ApiError
     */
    public static async getCanvasMetadata(
        canvasId: string,
    ): Promise<BaseResponse> {
        const result = await __request(OpenAPI, {
            method: 'GET',
            url: `/api/v1/canvases/${canvasId}/metadata`,
        });
        return result as BaseResponse;
    }

    /**
     * Update canvas metadata
     * @param canvasId Canvas ID
     * @param requestBody Update request
     * @returns BaseResponse Updated canvas metadata
     * @throws ApiError
     */
    public static async updateCanvasMetadata(
        canvasId: string,
        requestBody: UpdateCanvasMetadataRequest,
    ): Promise<BaseResponse> {
        const result = await __request(OpenAPI, {
            method: 'PUT',
            url: `/api/v1/canvases/${canvasId}/metadata`,
            body: requestBody,
        });
        return result as BaseResponse;
    }

    /**
     * Delete a canvas
     * @param canvasId Canvas ID
     * @param hardDelete Permanently delete (true) or soft delete (false)
     * @returns BaseResponse Success confirmation
     * @throws ApiError
     */
    public static async deleteCanvas(
        canvasId: string,
        hardDelete?: boolean,
    ): Promise<BaseResponse> {
        const result = await __request(OpenAPI, {
            method: 'DELETE',
            url: `/api/v1/canvases/${canvasId}`,
            query: {
                'hard_delete': hardDelete,
            },
        });
        return result as BaseResponse;
    }

    /**
     * Get canvas associated with an asset
     * @param assetId Asset ID
     * @returns BaseResponse Canvas metadata
     * @throws ApiError
     */
    public static async getAssetCanvas(
        assetId: string,
    ): Promise<BaseResponse> {
        const result = await __request(OpenAPI, {
            method: 'GET',
            url: `/api/v1/assets/${assetId}/canvas`,
        });
        return result as BaseResponse;
    }

    /**
     * Get canvas associated with a storyboard
     * @param storyboardId Storyboard ID
     * @returns BaseResponse Canvas metadata
     * @throws ApiError
     */
    public static async getStoryboardCanvas(
        storyboardId: string,
    ): Promise<BaseResponse> {
        const result = await __request(OpenAPI, {
            method: 'GET',
            url: `/api/v1/storyboards/${storyboardId}/canvas`,
        });
        return result as BaseResponse;
    }

    /**
     * Batch update canvas order
     * @param projectId Project ID
     * @param requestBody List of {id, order_index} objects
     * @returns BaseResponse Success confirmation
     * @throws ApiError
     */
    public static async reorderCanvases(
        projectId: string,
        requestBody: Array<{ id: string; order_index: number }>,
    ): Promise<BaseResponse> {
        const result = await __request(OpenAPI, {
            method: 'PUT',
            url: `/api/v1/projects/${projectId}/canvases/reorder`,
            body: requestBody,
        });
        return result as BaseResponse;
    }
}
