/*
 * 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 OrderUpdate = {
  /**
   * 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 OrderUpdate$Outbound = {
  billing_name?: string | null | undefined;
  billing_address?: AddressInput$Outbound | null | undefined;
};

/** @internal */
export const OrderUpdate$outboundSchema: z.ZodMiniType<
  OrderUpdate$Outbound,
  OrderUpdate
> = 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 orderUpdateToJSON(orderUpdate: OrderUpdate): string {
  return JSON.stringify(OrderUpdate$outboundSchema.parse(orderUpdate));
}
