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