/*
 * 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 { PageLink, PageLink$inboundSchema } from "./pagelink.js";

/**
 * Hypermedia controls (HATEOAS) for navigating between pages in a paginated collection of results.
 *
 * @remarks
 * Links for the current page, next page, and previous page, with optional first and last page links.
 */
export type PageLinks = {
  /**
   * A URL that references a specific page in the pagination process. This is typically used for navigation
   *
   * @remarks
   * between paginated results.
   */
  first?: PageLink | null | undefined;
  /**
   * A URL that references a specific page in the pagination process. This is typically used for navigation
   *
   * @remarks
   * between paginated results.
   */
  self?: PageLink | null | undefined;
  /**
   * A URL that references a specific page in the pagination process. This is typically used for navigation
   *
   * @remarks
   * between paginated results.
   */
  next?: PageLink | null | undefined;
};

/** @internal */
export const PageLinks$inboundSchema: z.ZodType<
  PageLinks,
  z.ZodTypeDef,
  unknown
> = z.object({
  first: z.nullable(PageLink$inboundSchema).optional(),
  self: z.nullable(PageLink$inboundSchema).optional(),
  next: z.nullable(PageLink$inboundSchema).optional(),
});

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