import {z} from 'zod' export type LocationAltAddrDetailDto = {acapCode?: string | undefined, accoCode?: string | undefined, altAddressOne?: string | undefined, altAddressTwo?: string | undefined, altPhone?: string | undefined, cdpEMail?: string | undefined, city?: string | undefined, companyNameForPO?: string | undefined, exportCode?: string | undefined, importCode?: string | undefined, locationCode: string, payrollExportCode?: string | undefined, stateProvince: string, zip: string}; export type LocationConceptInfoDetailDto = {conceptCode: string, conceptName: string, locationCode: string, remove?: ('N' | 'Y') | undefined}; export type LocationDeliverInfoDetailDto = {activeFlag?: ('N' | 'Y') | undefined, delete?: ('N' | 'Y') | undefined, deliverToCode: string, deliverToName: string, locationCode: string}; export type LocationDetailsDetailDto = {allowAutoPost: 'N' | 'Y', allowAutoTransfer?: ('N' | 'Y') | undefined, autoCreatePOSRecipe?: ('N' | 'Y') | undefined, autoPostDaysOffset?: number | undefined, autoPostMethod?: ('A' | 'X') | undefined, autoPostTime?: string | undefined, autoPrepForDepletion?: ('N' | 'Y') | undefined, baseCurrency?: string | undefined, biziqCompDate?: string | undefined, borrowCnsEndDate?: string | undefined, borrowCnsLocationCode?: string | undefined, buffetQuantityAlertPercent?: number | undefined, dailyPrepReview?: ('N' | 'Y') | undefined, earliestPostDateTimeBasedOn?: ('C' | 'E') | undefined, gmtOffset?: number | undefined, grandOpeningDate?: string | undefined, locationCode: string, lotTracking?: ('N' | 'Y') | undefined, market?: string | undefined, missingPrepCheck?: ('N' | 'Y') | undefined, optimalDaysOnHand?: number | undefined, ownershipEntity?: string | undefined, posFilePath?: string | undefined, posType?: string | undefined, productionQuantityAlertPercent?: number | undefined, purchaseType?: ('C' | 'D' | 'M') | undefined, secMrktPurchase?: ('N' | 'Y') | undefined, smartPicklist?: ('N' | 'Y') | undefined, software?: string | undefined, timezone?: number | undefined}; export type LocationHoursOfOperationDetailDto = {closingTime?: string | undefined, closingTimeCleanup?: string | undefined, corporateFlag: 'N' | 'Y', dayOfWeek: number, locationCode: string, openingTime?: string | undefined, openingTimeSetup?: string | undefined}; export type LocationLaborDetailDto = {businessDayBegins?: string | undefined, corporateFlag: 'N' | 'Y', locationCode: string}; export type LocationNameAddrDetailDto = {activeFlag?: ('N' | 'Y') | undefined, addressOne: string, addressTwo?: string | undefined, city: string, country?: string | undefined, eMail?: string | undefined, fax?: string | undefined, franchiseCode?: string | undefined, locationADRemoteName?: string | undefined, locationCode: string, locationName: string, phone?: string | undefined, prefix?: string | undefined, stateProvince?: string | undefined, zip?: string | undefined}; export type LocationPostDetailDto = {enabledFlag: 'N' | 'Y', locationCode: string, postingGrp: string}; export type LocationSafeLogDetailDto = {locationCode: string, safeLogName: string, expectedValue: number, currencyCode: string, activeFlag?: ('N' | 'Y') | undefined, noteRequiredForVarianceFlag?: ('N' | 'Y') | undefined, varianceThreshold?: number | undefined}; export type LocationTimeClockInTwxDetailDto = {allowTimeClockInMTX?: boolean | undefined, allowTimeClockInTWX?: boolean | undefined, locationCode: string, minutesEarly?: number | undefined, minutesLate?: number | undefined, prefix?: string | undefined, contentReportingEmail?: string | undefined}; export type LocationDetails = {locationAltAddressDetails?: Array | undefined, locationCode?: string | undefined, locationConceptInfoDetails?: Array | undefined, locationDeliverInfoDetails?: Array | undefined, locationDetailDetails?: Array | undefined, locationHoursOfOperationDetails?: Array | undefined, locationLaborDetails?: Array | undefined, locationNameAddressDetails?: Array | undefined, locationPostDetails?: Array | undefined, locationSafeLogDetails?: Array | undefined, locationTimeClockInTwxDetails?: Array | undefined}; export type CreateApiLocationV1SaveLocationArgs = {authenticationtoken: string, password: string, sitename: string, userid: string, 'X-B3-TraceId'?: string | undefined, body: LocationDetails}; export type CreateApiLocationV1SaveLocationOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const createApiLocationV1SaveLocationResponse = 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 }; /** * saveLocationV1 * * POST /location/v1/saveLocation */ export const createApiLocationV1SaveLocation = async (args: CreateApiLocationV1SaveLocationArgs, options: CreateApiLocationV1SaveLocationOptions) => { 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(/\/+$/, '')}/location/v1/saveLocation${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(createApiLocationV1SaveLocationResponse, await res.json()) };