/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { HubspotData, HubspotData$inboundSchema, HubspotData$Outbound, HubspotData$outboundSchema, } from "./hubspotdata.js"; import { OAuthRefreshTokenCredentials, OAuthRefreshTokenCredentials$inboundSchema, OAuthRefreshTokenCredentials$Outbound, OAuthRefreshTokenCredentials$outboundSchema, } from "./oauthrefreshtokencredentials.js"; export type AuthenticatorHubspotConnection = { provider: "hubspot"; data: HubspotData; hubId: string; hubDomain: string; credentials: OAuthRefreshTokenCredentials; }; /** @internal */ export const AuthenticatorHubspotConnection$inboundSchema: z.ZodType< AuthenticatorHubspotConnection, z.ZodTypeDef, unknown > = z.object({ provider: z.literal("hubspot"), data: HubspotData$inboundSchema, hub_id: z.string(), hub_domain: z.string(), credentials: OAuthRefreshTokenCredentials$inboundSchema, }).transform((v) => { return remap$(v, { "hub_id": "hubId", "hub_domain": "hubDomain", }); }); /** @internal */ export type AuthenticatorHubspotConnection$Outbound = { provider: "hubspot"; data: HubspotData$Outbound; hub_id: string; hub_domain: string; credentials: OAuthRefreshTokenCredentials$Outbound; }; /** @internal */ export const AuthenticatorHubspotConnection$outboundSchema: z.ZodType< AuthenticatorHubspotConnection$Outbound, z.ZodTypeDef, AuthenticatorHubspotConnection > = z.object({ provider: z.literal("hubspot"), data: HubspotData$outboundSchema, hubId: z.string(), hubDomain: z.string(), credentials: OAuthRefreshTokenCredentials$outboundSchema, }).transform((v) => { return remap$(v, { hubId: "hub_id", hubDomain: "hub_domain", }); }); export function authenticatorHubspotConnectionToJSON( authenticatorHubspotConnection: AuthenticatorHubspotConnection, ): string { return JSON.stringify( AuthenticatorHubspotConnection$outboundSchema.parse( authenticatorHubspotConnection, ), ); } export function authenticatorHubspotConnectionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AuthenticatorHubspotConnection$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AuthenticatorHubspotConnection' from JSON`, ); }