38 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
		
		
			
		
	
	
			38 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
|  | // src/services/recargoZonaService.ts
 | ||
|  | import apiClient from '../apiClient'; | ||
|  | import type { RecargoZonaDto } from '../../models/dtos/Distribucion/RecargoZonaDto'; | ||
|  | import type { CreateRecargoZonaDto } from '../../models/dtos/Distribucion/CreateRecargoZonaDto'; | ||
|  | import type { UpdateRecargoZonaDto } from '../../models/dtos/Distribucion/UpdateRecargoZonaDto'; | ||
|  | 
 | ||
|  | const getRecargosPorPublicacion = async (idPublicacion: number): Promise<RecargoZonaDto[]> => { | ||
|  |     const response = await apiClient.get<RecargoZonaDto[]>(`/publicaciones/${idPublicacion}/recargos`); | ||
|  |     return response.data; | ||
|  | }; | ||
|  | 
 | ||
|  | const getRecargoZonaById = async (idPublicacion: number, idRecargo: number): Promise<RecargoZonaDto> => { | ||
|  |     const response = await apiClient.get<RecargoZonaDto>(`/publicaciones/${idPublicacion}/recargos/${idRecargo}`); | ||
|  |     return response.data; | ||
|  | }; | ||
|  | 
 | ||
|  | const createRecargoZona = async (idPublicacion: number, data: CreateRecargoZonaDto): Promise<RecargoZonaDto> => { | ||
|  |     const response = await apiClient.post<RecargoZonaDto>(`/publicaciones/${idPublicacion}/recargos`, data); | ||
|  |     return response.data; | ||
|  | }; | ||
|  | 
 | ||
|  | const updateRecargoZona = async (idPublicacion: number, idRecargo: number, data: UpdateRecargoZonaDto): Promise<void> => { | ||
|  |     await apiClient.put(`/publicaciones/${idPublicacion}/recargos/${idRecargo}`, data); | ||
|  | }; | ||
|  | 
 | ||
|  | const deleteRecargoZona = async (idPublicacion: number, idRecargo: number): Promise<void> => { | ||
|  |     await apiClient.delete(`/publicaciones/${idPublicacion}/recargos/${idRecargo}`); | ||
|  | }; | ||
|  | 
 | ||
|  | const recargoZonaService = { | ||
|  |     getRecargosPorPublicacion, | ||
|  |     getRecargoZonaById, | ||
|  |     createRecargoZona, | ||
|  |     updateRecargoZona, | ||
|  |     deleteRecargoZona, | ||
|  | }; | ||
|  | 
 | ||
|  | export default recargoZonaService; |