import {z} from 'zod' export type VendorLocationScheduleOverrideDetails = {deliverDayFriday?: string | undefined, deliverDayMonday?: string | undefined, deliverDaySaturday?: string | undefined, deliverDaySunday?: string | undefined, deliverDayThursday?: string | undefined, deliverDayTuesday?: string | undefined, deliverDayWednesday?: string | undefined, endDate: string, locationCode: string, name: string, note?: string | undefined, oldStartDate: string, orderByTimeFriday?: string | undefined, orderByTimeMonday?: string | undefined, orderByTimeSaturday?: string | undefined, orderByTimeSunday?: string | undefined, orderByTimeThursday?: string | undefined, orderByTimeTuesday?: string | undefined, orderByTimeWednesday?: string | undefined, orderDayFridayFlag?: ('N' | 'Y') | undefined, orderDayMondayFlag?: ('N' | 'Y') | undefined, orderDaySaturdayFlag?: ('N' | 'Y') | undefined, orderDaySundayFlag?: ('N' | 'Y') | undefined, orderDayThursdayFlag?: ('N' | 'Y') | undefined, orderDayTuesdayFlag?: ('N' | 'Y') | undefined, orderDayWednesdayFlag?: ('N' | 'Y') | undefined, recordType: 'A/M/D', startDate: string, vendorCode: string}; export type VendorLocationHeaderDto = {active?: ('N' | 'Y') | undefined, childID?: string | undefined, deleteFlag?: ('N' | 'Y') | undefined, exportCode?: string | undefined, locationCode: string, tradingPartnerID?: string | undefined, vendorCode: string, vendorDistrictID?: string | undefined}; export type VendorLocationOtherDetailsDto = {contactName?: string | undefined, contactPhone?: string | undefined, contactTitle?: string | undefined, locationCode: string, message?: string | undefined, notes?: string | undefined, vendorCode: string}; export type VendorLocationScheduleDetailDto = {deliverDayFriday?: string | undefined, deliverDayMonday?: string | undefined, deliverDaySaturday?: string | undefined, deliverDaySunday?: string | undefined, deliverDayThursday?: string | undefined, deliverDayTuesday?: string | undefined, deliverDayWednesday?: string | undefined, locationCode: string, orderByTimeFriday?: string | undefined, orderByTimeMonday?: string | undefined, orderByTimeSaturday?: string | undefined, orderByTimeSunday?: string | undefined, orderByTimeThursday?: string | undefined, orderByTimeTuesday?: string | undefined, orderByTimeWednesday?: string | undefined, orderDayFridayFlag?: ('N' | 'Y') | undefined, orderDayMondayFlag?: ('N' | 'Y') | undefined, orderDaySaturdayFlag?: ('N' | 'Y') | undefined, orderDaySundayFlag?: ('N' | 'Y') | undefined, orderDayThursdayFlag?: ('N' | 'Y') | undefined, orderDayTuesdayFlag?: ('N' | 'Y') | undefined, orderDayWednesdayFlag?: ('N' | 'Y') | undefined, vendorCode: string}; export type VendorLocationTransmissionDetailDto = {accountNumber?: string | undefined, accrualFlag?: ('N' | 'Y') | undefined, allowSimpleReceiptFlag?: ('N' | 'Y') | undefined, autoReconcileEinvoiceFlag?: ('N' | 'Y') | undefined, allowVOFlag?: ('N' | 'Y') | undefined, codFlag?: ('N' | 'Y') | undefined, electronicInvoiceFlag?: ('N' | 'Y') | undefined, enforceMinimums?: ('N' | 'Y') | undefined, locationCode: string, minimumCases?: string | undefined, minimumValue?: string | undefined, orderAlert?: string | undefined, orderVendorUnitofMeasure?: string | undefined, referenceNumber?: string | undefined, userName?: string | undefined, userPassword?: string | undefined, vendorCode: string, voEMail?: string | undefined, voFax?: string | undefined, voMode?: ('E-Mail Excel' | 'E-Mail PDF' | 'E-Mail PDF - Custom' | 'E-Mail Text' | 'FTP' | 'Fax' | 'Phone' | 'Secure FTP' | 'Web Services') | undefined}; export type VendorLocationDetails = {scheduleOverrideRowList?: Array | undefined, vendorLocationHeaderDetails?: VendorLocationHeaderDto | undefined, vendorLocationOtherDetail?: VendorLocationOtherDetailsDto | undefined, vendorLocationScheduleDetail?: VendorLocationScheduleDetailDto | undefined, vendorLocationTransmissionDetail?: VendorLocationTransmissionDetailDto | undefined}; export type VendorLocationDetailsList = {locationCode: string, vendorLocationDetails?: Array | undefined}; export type CreateApiVendorlocationV1SaveVendorLocationArgs = {authenticationtoken: string, password: string, sitename: string, userid: string, 'X-B3-TraceId'?: string | undefined, body: VendorLocationDetailsList}; export type CreateApiVendorlocationV1SaveVendorLocationOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const createApiVendorlocationV1SaveVendorLocationResponse = z.object({}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * saveVendorLocation * * POST /vendorlocation/v1/saveVendorLocation */ export const createApiVendorlocationV1SaveVendorLocation = async (args: CreateApiVendorlocationV1SaveVendorLocationArgs, options: CreateApiVendorlocationV1SaveVendorLocationOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.authenticationtoken != null) headers.set("authenticationtoken", String(args.authenticationtoken)) if (args.password != null) headers.set("password", String(args.password)) if (args.sitename != null) headers.set("sitename", String(args.sitename)) if (args.userid != null) headers.set("userid", String(args.userid)) if (args['X-B3-TraceId'] != null) headers.set("X-B3-TraceId", String(args['X-B3-TraceId'])) const url = `${baseUrl.replace(/\/+$/, '')}/vendorlocation/v1/saveVendorLocation${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiVendorlocationV1SaveVendorLocationResponse, await res.json()) };