import { QueryCustomer, queryCustomerToSearchParams, Paginacion, paginacionToSearchParams, Paging, } from "./common.js"; export interface PriceByCustomerQuery { paginacion?: Paginacion; /// Filtro por el código del cliente ("Code" en Customer.) filter?: string; SKUCode?: string; customer?: QueryCustomer; } export interface Precio { SKUCode: string; CustomerCode: string; Price: number; PriceListNumber: number; } export interface PreciosResponse { Paging: Paging; Data: Precio[]; } export async function getPricesByCustomer( host: string, headers: HeadersInit, options: PriceByCustomerQuery ): Promise { let searchParams = new URLSearchParams(); paginacionToSearchParams(options.paginacion, searchParams); if (options.filter) { searchParams.set("filter", options.filter); } if (options.SKUCode) { searchParams.set("SKUCode", options.SKUCode); } if (options.customer) { queryCustomerToSearchParams(options.customer, searchParams); } const res = await fetch( `${host}/api/Aperture/PriceByCustomer?${searchParams.toString()}`, { headers } ); const json = await res.json(); console.debug(json); if (json.Message) { throw new Error(`Tango: ${json.Message}`); } return json; }