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

import * as z from "zod";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import * as components from "../components/index.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type TriggerWorkflowRequest = {
  /**
   * The unique identifier of the account.
   */
  accountId: string;
  /**
   * The unique identifier of the workflow.
   */
  workflowId: string;
  triggerWorkflow: components.TriggerWorkflow;
};

/** @internal */
export const TriggerWorkflowRequest$inboundSchema: z.ZodType<
  TriggerWorkflowRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  accountId: z.string(),
  workflowId: z.string(),
  TriggerWorkflow: z.lazy(() => components.TriggerWorkflow$inboundSchema),
}).transform((v) => {
  return remap$(v, {
    "TriggerWorkflow": "triggerWorkflow",
  });
});

/** @internal */
export type TriggerWorkflowRequest$Outbound = {
  accountId: string;
  workflowId: string;
  TriggerWorkflow: components.TriggerWorkflow$Outbound;
};

/** @internal */
export const TriggerWorkflowRequest$outboundSchema: z.ZodType<
  TriggerWorkflowRequest$Outbound,
  z.ZodTypeDef,
  TriggerWorkflowRequest
> = z.object({
  accountId: z.string(),
  workflowId: z.string(),
  triggerWorkflow: z.lazy(() => components.TriggerWorkflow$outboundSchema),
}).transform((v) => {
  return remap$(v, {
    triggerWorkflow: "TriggerWorkflow",
  });
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace TriggerWorkflowRequest$ {
  /** @deprecated use `TriggerWorkflowRequest$inboundSchema` instead. */
  export const inboundSchema = TriggerWorkflowRequest$inboundSchema;
  /** @deprecated use `TriggerWorkflowRequest$outboundSchema` instead. */
  export const outboundSchema = TriggerWorkflowRequest$outboundSchema;
  /** @deprecated use `TriggerWorkflowRequest$Outbound` instead. */
  export type Outbound = TriggerWorkflowRequest$Outbound;
}

export function triggerWorkflowRequestToJSON(
  triggerWorkflowRequest: TriggerWorkflowRequest,
): string {
  return JSON.stringify(
    TriggerWorkflowRequest$outboundSchema.parse(triggerWorkflowRequest),
  );
}

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