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

export interface PedimentoPayments {
	id: number;
	pedimento_id: number;
	tenant_id: number;
	acknowledgment?: string | null;
	operation_number?: string | null;
	bank_code?: number | null;
	cashier?: string | null;
	date?: string | null;
	time?: string | null;
	shift?: string | null;
	total_cash_paid?: number | null;
	total_contributions?: number | null;
	counter_payment?: number | null;
	pece_code?: string | null;	
	created_at: string;
}

export interface CreatePedimentoPaymentsData {
	acknowledgment?: string | null;
	operation_number?: string | null;
	bank_code?: number | null;
	cashier?: string | null;
	date?: string | null;
	time?: string | null;
	shift?: string | null;
	total_cash_paid?: number | null;
	total_contributions?: number | null;
	counter_payment?: number | null;
	pece_code?: string | null;	
}

export interface UpdatePedimentoPaymentsData {
	acknowledgment?: string | null;
	operation_number?: string | null;
	bank_code?: number | null;
	cashier?: string | null;
	date?: string | null;
	time?: string | null;
	shift?: string | null;
	total_cash_paid?: number | null;
	total_contributions?: number | null;
	counter_payment?: number | null;
	pece_code?: string | null;	
}

export const pedimentoPaymentsApi = {
	get: (pedimentoId: number) =>
		api.get<PedimentoPayments>(`/v1/a76/pedimentos/${pedimentoId}/payments/`),

	create: (pedimentoId: number, data: CreatePedimentoPaymentsData) =>
		api.post<PedimentoPayments>(`/v1/a76/pedimentos/${pedimentoId}/payments/`, data),

	update: (pedimentoId: number, data: UpdatePedimentoPaymentsData) =>
		api.put<PedimentoPayments>(`/v1/a76/pedimentos/${pedimentoId}/payments/`, data),

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