/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { Event, Event$inboundSchema } from "../components/event.js"; import { HTTPMetadata, HTTPMetadata$inboundSchema, } from "../components/httpmetadata.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetEventsSecurity = { systemAccessAuth: string; }; /** * Determines the date-based API version associated with your API call. If none is provided, your application's [minimum API version](https://docs.gusto.com/embedded-payroll/docs/api-versioning#minimum-api-version) is used. */ export const GetEventsHeaderXGustoAPIVersion = { TwoThousandAndTwentyFiveMinus06Minus15: "2025-06-15", } as const; /** * Determines the date-based API version associated with your API call. If none is provided, your application's [minimum API version](https://docs.gusto.com/embedded-payroll/docs/api-versioning#minimum-api-version) is used. */ export type GetEventsHeaderXGustoAPIVersion = ClosedEnum< typeof GetEventsHeaderXGustoAPIVersion >; /** * A string indicating whether to sort resulting events in ascending (asc) or descending (desc) chronological order. Events are sorted by their `timestamp`. Defaults to asc if left empty. */ export const QueryParamSortOrder = { Asc: "asc", Desc: "desc", } as const; /** * A string indicating whether to sort resulting events in ascending (asc) or descending (desc) chronological order. Events are sorted by their `timestamp`. Defaults to asc if left empty. */ export type QueryParamSortOrder = ClosedEnum; export type GetEventsRequest = { /** * Determines the date-based API version associated with your API call. If none is provided, your application's [minimum API version](https://docs.gusto.com/embedded-payroll/docs/api-versioning#minimum-api-version) is used. */ xGustoAPIVersion?: GetEventsHeaderXGustoAPIVersion | undefined; /** * A cursor for pagination. Returns all events occuring after the specified UUID (exclusive). Events are sorted according to the provided sort_order param. */ startingAfterUuid?: string | undefined; /** * The UUID of the company. If not specified, will return all events for all companies. */ resourceUuid?: string | undefined; /** * Limits the number of objects returned in a single response, between 1 and 100. The default is 25 */ limit?: string | undefined; /** * A string containing the exact event name (e.g. `employee.created`), or use a wildcard match to filter for a group of events (e.g. `employee.*`, `*.created`, `notification.*.created` etc.) */ eventType?: string | undefined; /** * A string indicating whether to sort resulting events in ascending (asc) or descending (desc) chronological order. Events are sorted by their `timestamp`. Defaults to asc if left empty. */ sortOrder?: QueryParamSortOrder | undefined; }; export type GetEventsResponse = { httpMeta: HTTPMetadata; /** * Successful */ eventList?: Array | undefined; }; /** @internal */ export type GetEventsSecurity$Outbound = { SystemAccessAuth: string; }; /** @internal */ export const GetEventsSecurity$outboundSchema: z.ZodType< GetEventsSecurity$Outbound, z.ZodTypeDef, GetEventsSecurity > = z.object({ systemAccessAuth: z.string(), }).transform((v) => { return remap$(v, { systemAccessAuth: "SystemAccessAuth", }); }); export function getEventsSecurityToJSON( getEventsSecurity: GetEventsSecurity, ): string { return JSON.stringify( GetEventsSecurity$outboundSchema.parse(getEventsSecurity), ); } /** @internal */ export const GetEventsHeaderXGustoAPIVersion$outboundSchema: z.ZodNativeEnum< typeof GetEventsHeaderXGustoAPIVersion > = z.nativeEnum(GetEventsHeaderXGustoAPIVersion); /** @internal */ export const QueryParamSortOrder$outboundSchema: z.ZodNativeEnum< typeof QueryParamSortOrder > = z.nativeEnum(QueryParamSortOrder); /** @internal */ export type GetEventsRequest$Outbound = { "X-Gusto-API-Version": string; starting_after_uuid?: string | undefined; resource_uuid?: string | undefined; limit?: string | undefined; event_type?: string | undefined; sort_order?: string | undefined; }; /** @internal */ export const GetEventsRequest$outboundSchema: z.ZodType< GetEventsRequest$Outbound, z.ZodTypeDef, GetEventsRequest > = z.object({ xGustoAPIVersion: GetEventsHeaderXGustoAPIVersion$outboundSchema.default( "2025-06-15", ), startingAfterUuid: z.string().optional(), resourceUuid: z.string().optional(), limit: z.string().optional(), eventType: z.string().optional(), sortOrder: QueryParamSortOrder$outboundSchema.optional(), }).transform((v) => { return remap$(v, { xGustoAPIVersion: "X-Gusto-API-Version", startingAfterUuid: "starting_after_uuid", resourceUuid: "resource_uuid", eventType: "event_type", sortOrder: "sort_order", }); }); export function getEventsRequestToJSON( getEventsRequest: GetEventsRequest, ): string { return JSON.stringify( GetEventsRequest$outboundSchema.parse(getEventsRequest), ); } /** @internal */ export const GetEventsResponse$inboundSchema: z.ZodType< GetEventsResponse, z.ZodTypeDef, unknown > = z.object({ HttpMeta: HTTPMetadata$inboundSchema, "Event-List": z.array(Event$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "HttpMeta": "httpMeta", "Event-List": "eventList", }); }); export function getEventsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetEventsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetEventsResponse' from JSON`, ); }