import {z} from 'zod' export type GetApiPublicV1CampaignsCampaignIdProspectsArgs = {limit?: number | undefined, offset?: number | undefined, search?: string | undefined, status?: string | undefined, sort?: string | undefined, campaignId: string}; export type GetApiPublicV1CampaignsCampaignIdProspectsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiPublicV1CampaignsCampaignIdProspectsResponse = z.object({statusCode: z.number().optional(), status: z.boolean().optional(), message: z.string().optional(), data: z.object({prospects: z.array(z.object({campaign_id: z.string().optional(), campaign_name: z.string().optional(), id: z.string().optional(), first_name: z.string().nullable().optional(), last_name: z.string().nullable().optional(), linkedin_public_id: z.string().nullable().optional(), profile_picture: z.string().nullable().optional(), sub_title: z.string().nullable().optional(), company_name: z.string().nullable().optional(), company_website: z.string().nullable().optional(), company_logo: z.string().nullable().optional(), current_position_title: z.string().nullable().optional(), email: z.string().nullable().optional(), phone_number: z.string().nullable().optional(), city: z.string().nullable().optional(), state: z.string().nullable().optional(), country: z.string().nullable().optional(), industry: z.string().nullable().optional(), status: z.string().optional(), interest_level: z.string().nullable().optional(), icp_fit: z.string().nullable().optional(), icp_fit_justification: z.string().nullable().optional(), accepted_connection_request: z.boolean().optional(), responded: z.boolean().optional(), created_at: z.string().optional()})).optional(), pagination: z.object({limit: z.number().optional(), offset: z.number().optional(), total: z.number().optional(), hasMore: z.boolean().optional()}).optional()}).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * List prospects in a campaign with filtering and pagination. Workspace admins and owners can access campaigns created on behalf of other workspace members. * * GET /public/v1/campaigns/{campaignId}/prospects */ export const getApiPublicV1CampaignsCampaignIdProspects = async (args: GetApiPublicV1CampaignsCampaignIdProspectsArgs, options?: GetApiPublicV1CampaignsCampaignIdProspectsOptions) => { const {baseUrl = "https://api.joinvalley.co", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.search != null) query.append("search", String(args.search)) if (args.status != null) query.append("status", String(args.status)) if (args.sort != null) query.append("sort", String(args.sort)) if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/public/v1/campaigns/${encodeURIComponent(String(args.campaignId))}/prospects${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiPublicV1CampaignsCampaignIdProspectsResponse, await res.json()) };