import {z} from 'zod' export type GetApiV2TeamsTeamNanoidMemberUserNanoidSummaryArgs = {team_nanoid: string, user_nanoid: string}; export type GetApiV2TeamsTeamNanoidMemberUserNanoidSummaryOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiV2TeamsTeamNanoidMemberUserNanoidSummaryResponse = z.object({success: z.literal(true), data: z.object({user: z.object({nanoid: z.string().min(15).max(15), avatar: z.string(), first_name: z.string(), middle_name: z.string(), last_name: z.string(), email: z.string(), blockchain_address: z.string(), phone: z.string(), dob: z.string().nullable(), address: z.object({line_1: z.string(), line_2: z.string(), city: z.string(), state: z.string(), country: z.string(), zip_code: z.string(), timezone: z.string()}), social: z.object({linkedin: z.string(), discord: z.string(), website: z.string(), x: z.string()}), certifications: z.array(z.object({nanoid: z.string().min(15).max(15), title: z.string(), website: z.string(), year: z.number(), file: z.string()})), onboarding: z.object({onboarded: z.boolean(), step: z.enum(["initial", "details", "compliance_process", "security", "signing", "complete", "riseid", "signer", "v1_migration_in_progress", "v1_migration_need_rsk", "v1_migration_need_kyc"]).nullable(), role: z.enum(["payer", "payee", "viewer", "admin", "delegate_admin", "non_delegate_admin"]).nullable(), moderation_status: z.enum(["pending", "submitted", "approved", "rejected"]).nullable()})}), relationship_type: z.enum(["team_employee", "contractor", "aor_contractor"]), company: z.object({nanoid: z.string().min(15).max(15), avatar: z.string(), name: z.string(), website: z.string(), blockchain_address: z.string(), address: z.object({line_1: z.string(), line_2: z.string(), city: z.string(), state: z.string(), country: z.string(), zip_code: z.string(), timezone: z.string()}), admin_contact: z.object({fullname: z.string(), phone: z.string(), email: z.string()}).nullable(), incorporation_country: z.string(), incorporation_type: z.enum(["sole_proprietorship", "private_limited_company", "limited_liability_company", "s-corporation", "c-corporation", "public_limited_company", "limited_partnership", "holding_company", "non_government_organisation", "statutory_company", "subsidiary_company", "unlimited_partnership", "charitable_incorporated_organisation", "chartered_company", "association", "non_profit_organisation", "im_not_sure"]), private_data: z.object({tax_id: z.string()})}).optional(), pay_schedules: z.array(z.object({nanoid: z.string().min(15).max(15), type: z.enum(["milestone", "recurring"]), amount: z.string(), payments_amount: z.number(), start_date: z.unknown(), end_date: z.unknown()}))})}); 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 }; /** * Get team member summary * * GET /v2/teams/{team_nanoid}/member/{user_nanoid}/summary */ export const getApiV2TeamsTeamNanoidMemberUserNanoidSummary = async (args: GetApiV2TeamsTeamNanoidMemberUserNanoidSummaryArgs, options?: GetApiV2TeamsTeamNanoidMemberUserNanoidSummaryOptions) => { const {baseUrl = "https://b2b-api.dev-riseworks.io", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/teams/${encodeURIComponent(String(args.team_nanoid))}/member/${encodeURIComponent(String(args.user_nanoid))}/summary${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(getApiV2TeamsTeamNanoidMemberUserNanoidSummaryResponse, await res.json()) };