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

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  CoreLink,
  CoreLink$inboundSchema,
  CoreLink$Outbound,
  CoreLink$outboundSchema,
} from "./corelink.js";

/**
 * The location and content type of related resources
 */
export type ParentAndSelfLinks = {
  self: CoreLink;
  parent: CoreLink;
};

/** @internal */
export const ParentAndSelfLinks$inboundSchema: z.ZodType<
  ParentAndSelfLinks,
  z.ZodTypeDef,
  unknown
> = z.object({
  self: CoreLink$inboundSchema,
  parent: CoreLink$inboundSchema,
});
/** @internal */
export type ParentAndSelfLinks$Outbound = {
  self: CoreLink$Outbound;
  parent: CoreLink$Outbound;
};

/** @internal */
export const ParentAndSelfLinks$outboundSchema: z.ZodType<
  ParentAndSelfLinks$Outbound,
  z.ZodTypeDef,
  ParentAndSelfLinks
> = z.object({
  self: CoreLink$outboundSchema,
  parent: CoreLink$outboundSchema,
});

export function parentAndSelfLinksToJSON(
  parentAndSelfLinks: ParentAndSelfLinks,
): string {
  return JSON.stringify(
    ParentAndSelfLinks$outboundSchema.parse(parentAndSelfLinks),
  );
}
export function parentAndSelfLinksFromJSON(
  jsonString: string,
): SafeParseResult<ParentAndSelfLinks, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ParentAndSelfLinks$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ParentAndSelfLinks' from JSON`,
  );
}
