/**
 * API Client para Validación de Pedimentos
 */
import { api } from '$lib/api';

export interface PedimentoValidation {
	id: number;
	pedimento_id: number;
	tenant_id: number;
	validator?: string | null;
	validation_ack?: string | null;
	pre_ack?: string | null;
	line_signature?: string | null;
	electronic_signature?: string | null;
	certificate_number?: string | null;
	validator_id?: number | null;
	responsible_id?: number | null;
	created_at: string;
}

export interface CreatePedimentoValidationData {
	validator?: string | null;
	validation_ack?: string | null;
	pre_ack?: string | null;
	line_signature?: string | null;
	electronic_signature?: string | null;
	certificate_number?: string | null;
	validator_id?: number | null;
	responsible_id?: number | null;
}

export interface UpdatePedimentoValidationData {
	validator?: string | null;
	validation_ack?: string | null;
	pre_ack?: string | null;
	line_signature?: string | null;
	electronic_signature?: string | null;
	certificate_number?: string | null;
	validator_id?: number | null;
	responsible_id?: number | null;
}

export const pedimentoValidationApi = {
	get: (pedimentoId: number) =>
		api.get<PedimentoValidation>(`/v1/a76/pedimentos/${pedimentoId}/validation/`),

	create: (pedimentoId: number, data: CreatePedimentoValidationData) =>
		api.post<PedimentoValidation>(`/v1/a76/pedimentos/${pedimentoId}/validation/`, data),

	update: (pedimentoId: number, data: UpdatePedimentoValidationData) =>
		api.put<PedimentoValidation>(`/v1/a76/pedimentos/${pedimentoId}/validation/`, data),

	delete: (pedimentoId: number) =>
		api.delete(`/v1/a76/pedimentos/${pedimentoId}/validation/`)
};
