/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const Provider = { Atlassian: "atlassian", Dropbox: "dropbox", Microsoft: "microsoft", Salesforce: "salesforce", Slack: "slack", Hubspot: "hubspot", } as const; export type Provider = ClosedEnum; export type OAuthCredentials = { provider: Provider; /** * The unique name of your authenticator, used to identify it and distinguish it from others. This name must be unique. Attempting to reuse the same name will result in an error. */ name: string; clientId: string; clientSecret: string; domain?: string | null | undefined; }; /** @internal */ export const Provider$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Provider); /** @internal */ export const Provider$outboundSchema: z.ZodNativeEnum = Provider$inboundSchema; /** @internal */ export const OAuthCredentials$inboundSchema: z.ZodType< OAuthCredentials, z.ZodTypeDef, unknown > = z.object({ provider: Provider$inboundSchema, name: z.string(), client_id: z.string(), client_secret: z.string(), domain: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "client_id": "clientId", "client_secret": "clientSecret", }); }); /** @internal */ export type OAuthCredentials$Outbound = { provider: string; name: string; client_id: string; client_secret: string; domain?: string | null | undefined; }; /** @internal */ export const OAuthCredentials$outboundSchema: z.ZodType< OAuthCredentials$Outbound, z.ZodTypeDef, OAuthCredentials > = z.object({ provider: Provider$outboundSchema, name: z.string(), clientId: z.string(), clientSecret: z.string(), domain: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { clientId: "client_id", clientSecret: "client_secret", }); }); export function oAuthCredentialsToJSON( oAuthCredentials: OAuthCredentials, ): string { return JSON.stringify( OAuthCredentials$outboundSchema.parse(oAuthCredentials), ); } export function oAuthCredentialsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OAuthCredentials$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OAuthCredentials' from JSON`, ); }