import {z} from 'zod' export type ContactPayload = {Email: string, Title?: string | undefined, LastName: string, FirstName?: string | undefined, Department?: string | undefined}; export type AddressWebEndpoint = {Street: string, Address_Line2?: string | undefined, Country: string, City: string, Postal_Code: string, Region_Or_State: string, Email: string}; export type AddonProductDetail = {product_type?: string | undefined, product_sku?: string | undefined, product_name?: string | undefined, product_quantity?: number | undefined, differential_quantity?: number | undefined, product_price?: number | undefined, product_discount?: number | undefined, product_pricebook_name?: string | undefined, product_quantity_operation_flag?: string | undefined, Coupon_Code_qty__c?: string | undefined, Effective_Addl_Line_Disc__c?: string | undefined}; export type ProductDetail = {product_type?: string | undefined, product_sku?: string | undefined, product_name?: string | undefined, product_quantity?: number | undefined, product_price?: number | undefined, product_pricebook_name?: string | undefined, differential_quantity?: number | undefined, product_discount?: number | undefined, product_quantity_operation_flag?: string | undefined, Coupon_Code_qty__c?: string | undefined, Effective_Addl_Line_Disc__c?: string | undefined, addon_products?: Array | undefined}; export type BillingAccountDetails = {currency_code?: string | undefined, bill_type?: string | undefined, bill_cycle_name?: string | undefined, bill_cycle_type?: string | undefined, billing_account_category_name?: string | undefined}; export type OrderDetail = {product_details?: Array | undefined, billing_account_detail?: BillingAccountDetails | undefined}; export type PaymentMethodPayloadWeb = {payment_method_type?: string | undefined, card_type?: string | undefined, first_name?: string | undefined, last_name?: string | undefined, card_number?: string | undefined, cvv?: string | undefined, expire_date?: string | undefined, postal_code?: string | undefined, reference?: string | undefined, card_reference?: string | undefined, primary_payment_method_no?: string | undefined}; export type Purchase = {AccountId?: string | undefined, ExternalAccountId?: string | undefined, ContactId: string, SubscriptionID?: string | undefined, Contacts?: Array | undefined, BillingAddress?: AddressWebEndpoint | undefined, VerticalMarket: string, AccountType?: string | undefined, ReferralAccountID?: string | undefined, INOCAccountID?: string | undefined, EndUserCompanyName: string, CurrencyCode: string, BillingCountryCode: string, order_detail?: OrderDetail | undefined, ReqType?: string | undefined, paymentMethod?: PaymentMethodPayloadWeb | undefined, Recurrence?: string | undefined, TaxID?: string | undefined, VAT_Number__c?: string | undefined, IntegrationCategory?: string | undefined, ExtensionRequestFlag?: string | undefined, SFDC_OrderId?: string | undefined, SFDC_OrderAmount?: string | undefined, QREM_DFI__c?: string | undefined, Term_Discount_p__c?: string | undefined, Additional_Discount__c?: string | undefined, Note?: string | undefined, Purchase_Order_Number?: string | undefined, PaymentMethodType?: string | undefined, OrderEffectiveDate?: string | undefined, SBQQ__PaymentTerm__c?: string | undefined, GSTIN?: string | undefined}; export type CreateApiApiV1ReflectPurchaseConfirmEntArgs = {body: Purchase}; export type CreateApiApiV1ReflectPurchaseConfirmEntOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiApiV1ReflectPurchaseConfirmEntResponse = 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 }; /** * POST /api/v1/Reflect/PurchaseConfirmEnt */ export const createApiApiV1ReflectPurchaseConfirmEnt = async (args: CreateApiApiV1ReflectPurchaseConfirmEntArgs, options?: CreateApiApiV1ReflectPurchaseConfirmEntOptions) => { const {baseUrl = "https://api.qsc.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/Reflect/PurchaseConfirmEnt${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(createApiApiV1ReflectPurchaseConfirmEntResponse, await res.json()) };