/*
 * 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 { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  CustomerPaymentMethod,
  CustomerPaymentMethod$inboundSchema,
} from "./customerpaymentmethod.js";

export type CustomerPaymentMethodCreateSucceededResponse = {
  status: "succeeded";
  paymentMethod: CustomerPaymentMethod;
};

/** @internal */
export const CustomerPaymentMethodCreateSucceededResponse$inboundSchema:
  z.ZodMiniType<CustomerPaymentMethodCreateSucceededResponse, unknown> = z.pipe(
    z.object({
      status: z.literal("succeeded"),
      payment_method: CustomerPaymentMethod$inboundSchema,
    }),
    z.transform((v) => {
      return remap$(v, {
        "payment_method": "paymentMethod",
      });
    }),
  );

export function customerPaymentMethodCreateSucceededResponseFromJSON(
  jsonString: string,
): SafeParseResult<
  CustomerPaymentMethodCreateSucceededResponse,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      CustomerPaymentMethodCreateSucceededResponse$inboundSchema.parse(
        JSON.parse(x),
      ),
    `Failed to parse 'CustomerPaymentMethodCreateSucceededResponse' from JSON`,
  );
}
