import { Paginacion, paginacionToSearchParams, Paging } from "./common.js"; export interface PriceListQuery { paginacion?: Paginacion; filter?: string; } export interface PriceList { PriceListNumber: number; Description: string; CommonCurrency: boolean; IvaIncluded: boolean; InternalTaxIncluded: boolean; ValidityDateSince: string; ValidityDateUntil: string; Disabled: boolean; } export interface PriceListResponse { Paging: Paging; Data: PriceList[]; } export async function getPriceLists( host: string, headers: HeadersInit, options: PriceListQuery ): Promise { let searchParams = new URLSearchParams(); paginacionToSearchParams(options.paginacion, searchParams); if (options.filter) { searchParams.set("filter", options.filter); } const res = await fetch( `${host}/api/Aperture/PriceList?${searchParams.toString()}`, { headers } ); const json = await res.json(); console.debug(json); if (json.Message) { throw new Error(`Tango: ${json.Message}`); } return json; }