UNPKG

@simpleapps-com/augur-api

Version:

TypeScript client library for Augur microservices API endpoints

72 lines 2.81 kB
import { z } from 'zod'; import { BaseResponseSchema, BaseGetParamsSchema } from '../../../core/schemas'; // Address schemas export const AddressSchema = z.object({ addressId: z.coerce.number(), customerId: z.coerce.number(), addressName: z.string(), address1: z.string(), address2: z.string().optional(), city: z.string(), state: z.string(), zipCode: z.string(), country: z.string(), phoneNumber: z.string().optional(), faxNumber: z.string().optional(), isPrimary: z.boolean().optional(), }); export const AddressListParamsSchema = BaseGetParamsSchema.extend({ q: z.string(), limit: z.coerce.number().optional(), offset: z.coerce.number().optional(), }); // Address sub-schema - based on ShipTo.json export const AddressSubSchema = z.object({ id: z.coerce.number(), name: z.string().nullable(), mailAddress1: z.string().nullable(), mailAddress2: z.string().nullable(), mailCity: z.string().nullable(), mailState: z.string().nullable(), mailPostalCode: z.string().nullable(), mailCountry: z.string().nullable(), physAddress1: z.string().nullable(), physAddress2: z.string().nullable(), physCity: z.string().nullable(), physState: z.string().nullable(), physPostalCode: z.string().nullable(), physCountry: z.string().nullable(), }); // Ship-to address schema - based on ShipTo.json export const ShipToAddressSchema = z.object({ shipToId: z.coerce.number(), customerId: z.coerce.number(), companyId: z.string().max(8), defaultBranch: z.string().max(8), defaultCarrierId: z.coerce.number().nullable(), address: AddressSubSchema, }); export const ShipToAddressCreateParamsSchema = z.object({ shipToName: z.string().min(1), address1: z.string().min(1), address2: z.string().optional(), city: z.string().min(1), state: z.string().min(1), zipCode: z.string().min(1), country: z.string().min(1), contactName: z.string().optional(), phoneNumber: z.string().optional(), deliveryInstructions: z.string().optional(), isDefault: z.boolean().optional(), }); // Ship-to list parameters schema - based on ShipTo.json export const ShipToAddressListParamsSchema = BaseGetParamsSchema.extend({ limit: z.coerce.number().min(1).optional().default(10), offset: z.coerce.number().min(0).optional().default(0), orderBy: z.string().optional().default('date_created|DESC'), }); // Response schemas using BaseResponseSchema (8-field format) export const AddressListResponseSchema = BaseResponseSchema(z.array(AddressSchema)); export const ShipToAddressListResponseSchema = BaseResponseSchema(z.array(ShipToAddressSchema)); export const ShipToAddressResponseSchema = BaseResponseSchema(ShipToAddressSchema); //# sourceMappingURL=addresses.js.map