import {z} from 'zod' export type CreateApiCustomerInquiriesCustomerInquiryIdResolveArgs = {customerInquiryId: number}; export type CreateApiCustomerInquiriesCustomerInquiryIdResolveOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const link = z.object({link: z.string().optional()}); export const attachmentGet = z.object({uuid: z.string().optional(), url: link.optional(), filename: z.string().optional()}); export const customerInquiryMessageGet = z.object({category: z.enum(["RATING_MESSAGE", "INITIAL_MESSAGE", "REOPEN_MESSAGE", "LOGSTA_MESSAGE", "CUSTOMER_MESSAGE", "EXTERNAL_MESSAGE", "LOGSTA_RESOLVE_MESSAGE", "CUSTOMER_RESOLVE_MESSAGE", "LOGSTA_REMINDER_MESSAGE", "LAST_MESSAGE"]).optional(), created: z.string().optional(), postedAt: z.string().optional(), userEmail: z.string().optional(), username: z.string().optional(), fullName: z.string().optional(), metaInfo: z.record(z.string(), z.string()).optional(), attachments: z.array(attachmentGet).optional(), message: z.string().optional()}); export const customerInquiryGet = z.object({topic: z.enum(["ONBOARDING", "FULFILMENT", "SERVICE", "ACCOUNTING", "TECH_IT", "MISCELLANEOUS_OTHER", "REPORTS"]).optional(), category: z.enum(["INBOUND", "PICKING_AND_PACKING", "SHIPMENT_AND_OUTBOUND", "ARTICLES_ITEMS_IN_ORDER", "DAMAGES", "RETURNS", "STOCK_DISCREPANCIES", "CARRIER_PICKUPS", "TRACKING_NUMBERS", "MISCELLANEOUS_OTHER_FULFILLMENT", "CARRIERS", "INVESTIGATIONS", "ACCOUNT_DETAILS_CHANGES", "MAPPING_BUNDLES_FULFILMENT_PLANS", "MISCELLANEOUS_OTHER_SERVICE", "KEY_ACCOUNTS", "NEW_SHOP", "INVOICE_ENQUIRIES", "REFUNDS_CREDIT_NOTES", "SERVICE_REPORT_ENQUIRIES", "SURCHARGES", "INSURANCE_CUSTOMS", "DUNNING", "CARRIER_RELATED_CHARGES", "CUSTOMS", "ONBOARDING_FEE", "DOUBLE_CHARGES_TRANSFERS", "PAYMENT_METHODS", "SEPA", "PAYMENT_CONFIRMATIONS", "SPECIAL_REQUESTS", "MISCELLANEOUS_OTHER_ACCOUNTING", "SYSTEM_ERRORS", "SHOP_INTEGRATION", "ADDING_USERS", "CHANGES_IN_CONNECTOR_ACCOUNT", "API_KEY_ROTATION", "MISCELLANEOUS_OTHER_TECH_IT", "SALES_ENQUIRY", "TRANSPORT_ENQUIRY", "ACCOUNT_DETAILS_CHANGE", "MAPPING_BUNDLE_FULFILMENT_PLAN", "CONTACTED_SALES_INSTEAD_OF_SERVICE", "KEY_ACCOUNT", "MISCELLANEOUS_OTHER", "ONBOARDING_SELF_SIGNUP", "OTHER_ONBOARDING_ISSUES", "ARTICLE_WEIGHT_REPORT", "CARTONAGE_REPORT", "RETURNS_REPORT", "BUNDLE_REPORT"]).optional(), subCategory: z.enum(["FULFILMENT_WAREHOUSE", "INSURANCE", "CUSTOMS", "LOST_ITEMS", "DAMAGES", "CARRIER_DISPUTES", "MISCELLANEOUS_OTHER", "SHIPPING_PRICES", "OTHER_CHARGES"]).optional(), subject: z.string(), sellerId: z.number().int(), warehouseId: z.number().int(), parentInquiryId: z.number().int().optional(), metaInfo: z.record(z.string(), z.string()).optional(), messages: z.array(customerInquiryMessageGet).optional(), id: z.number().int().optional(), created: z.string().optional(), status: z.enum(["WITH_YOU", "WITH_LOGSTA", "RESOLVED"]).optional(), caseNumber: z.string().optional(), resolvedAt: z.string().optional(), currentRating: z.number().optional(), resolvedBy: z.enum(["LOGSTA", "CLIENT"]).optional()}); 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 }; /** * Resolves customer inquiry and adds resolve message to it * * POST /customerInquiries/{customerInquiryId}/resolve */ export const createApiCustomerInquiriesCustomerInquiryIdResolve = async (args: CreateApiCustomerInquiriesCustomerInquiryIdResolveArgs, options?: CreateApiCustomerInquiriesCustomerInquiryIdResolveOptions) => { const {baseUrl = "https://api.quivo.co", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/customerInquiries/${encodeURIComponent(String(args.customerInquiryId))}/resolve${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(customerInquiryGet, await res.json()) };