import { Paginacion, paginacionToSearchParams, Paging } from "./common.js"; export interface PriceQuery { paginacion?: Paginacion; /** * Filtrar por PriceListNumber */ filter?: string; SKUCode?: string; } export interface Price { PriceListNumber: number; SKUCode: string; Price: number; ValidityDateSince: string; ValidityDateUntil: string; } export interface PriceResponse { Paging: Paging; Data: Price[]; } export async function getPrices( host: string, token: string, options: PriceQuery ): 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); } const res = await fetch( `${host}/api/Aperture/Price?${searchParams.toString()}`, { headers: { accesstoken: token, }, } ); const json = await res.json(); console.debug(json); if (json.Message) { throw new Error(`Tango: ${json.Message}`); } return json; }