/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v4-mini";
import { remap as remap$ } from "../../lib/primitives.js";
import {
  AddressInput,
  AddressInput$Outbound,
  AddressInput$outboundSchema,
} from "./addressinput.js";

/**
 * Schema to update an order.
 */
export type CustomerOrderUpdate = {
  /**
   * The name of the customer that should appear on the invoice.
   */
  billingName?: string | null | undefined;
  /**
   * The address of the customer that should appear on the invoice. Country and state fields cannot be updated.
   */
  billingAddress?: AddressInput | null | undefined;
};

/** @internal */
export type CustomerOrderUpdate$Outbound = {
  billing_name?: string | null | undefined;
  billing_address?: AddressInput$Outbound | null | undefined;
};

/** @internal */
export const CustomerOrderUpdate$outboundSchema: z.ZodMiniType<
  CustomerOrderUpdate$Outbound,
  CustomerOrderUpdate
> = z.pipe(
  z.object({
    billingName: z.optional(z.nullable(z.string())),
    billingAddress: z.optional(z.nullable(AddressInput$outboundSchema)),
  }),
  z.transform((v) => {
    return remap$(v, {
      billingName: "billing_name",
      billingAddress: "billing_address",
    });
  }),
);

export function customerOrderUpdateToJSON(
  customerOrderUpdate: CustomerOrderUpdate,
): string {
  return JSON.stringify(
    CustomerOrderUpdate$outboundSchema.parse(customerOrderUpdate),
  );
}
