import { HOST, Paginacion, paginacionToSearchParams, Paging, } from "./common.js"; export interface CustomerQuery { paginacion?: Paginacion; } export interface Customer { Code: string; BusinessName: string; TradeName: string; Address: string; PostalCode: string; City: string; ProvinceCode: string; TradeAddress: string; PhoneNumbers: string; Email: string; MobilePhoneNumber: string; WebPage: string; IvaCategoryCode: string; DocumentType: string; DocumentNumber: string; PriceListNumber: number; Discount: number; Observations: string; DisabledDate: string; SellerCode: string; CreditQuota: number; LocalAccountBalance: number; ForeignAccountBalance: number; ForeignCurrencyClause: boolean; CreditQuotaCurrencyCode: string; UpdateDatetime?: null; LastUpdateUtc?: string; ShippingAddresses: ShippingAddress[]; CustomerComments: CustomerComment[]; SaleConditionCode: number; TransportCode: string; } export interface CustomerComment { Line: number; Text: string; } export interface ShippingAddress { Code: string; Address: string; ProvinceCode: string; City: string; PostalCode: string; PhoneNumber1: string; PhoneNumber2: string; DefaultAddress: string; Enabled: string; DeliveryHours: string; DeliversMonday: string; DeliversTuesday: string; DeliversWednesday: string; DeliversThursday: string; DeliversFriday: string; DeliversSaturday: string; DeliversSunday: string; } export interface CustomerResponse { Paging: Paging; Data: Customer[]; } export async function getCustomers( token: string, options: CustomerQuery ): Promise { let searchParams = new URLSearchParams(); paginacionToSearchParams(options.paginacion, searchParams); const res = await fetch( `${HOST}/api/Aperture/Customer?${searchParams.toString()}`, { headers: { accesstoken: token, }, } ); const json = await res.json(); console.debug(json); if (json.Message) { throw new Error(`Tango: ${json.Message}`); } return json; }