import {z} from 'zod' export type GetApiPublicUserMobileListArgs = {list_count?: number | undefined, list_format?: ('standard' | 'http' | 'https' | 'socks5' | 'socks5h') | undefined, proxy_user_id?: string | undefined, list_session_type?: ('sticky' | 'rotating') | undefined, country_id?: string | undefined, city_id?: number | undefined, city_alias?: string | undefined, zip_code_id?: number | undefined, subdivision_id?: number | undefined, list_smartpath_enabled?: boolean | undefined, list_session_ttl?: string | undefined, list_mode?: ('general' | 'size' | 'speed') | undefined}; export type GetApiPublicUserMobileListOptions = {baseUrl?: string | undefined, APIPrivateKey?: string | undefined, APIPublicKey?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiPublicUserMobileListResponse = z.object({data: z.array(z.string()).optional(), message: z.string().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 }; /** * Generated Mobile List * * GET /public/user/mobile/list */ export const getApiPublicUserMobileList = async (args: GetApiPublicUserMobileListArgs, options?: GetApiPublicUserMobileListOptions) => { const {baseUrl = "https://api.byteful.com/1.0", fetch: fetchFn = fetch, APIPrivateKey, APIPublicKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.list_count != null) query.append("list_count", String(args.list_count)) if (args.list_format != null) query.append("list_format", String(args.list_format)) if (args.proxy_user_id != null) query.append("proxy_user_id", String(args.proxy_user_id)) if (args.list_session_type != null) query.append("list_session_type", String(args.list_session_type)) if (args.country_id != null) query.append("country_id", String(args.country_id)) if (args.city_id != null) query.append("city_id", String(args.city_id)) if (args.city_alias != null) query.append("city_alias", String(args.city_alias)) if (args.zip_code_id != null) query.append("zip_code_id", String(args.zip_code_id)) if (args.subdivision_id != null) query.append("subdivision_id", String(args.subdivision_id)) if (args.list_smartpath_enabled != null) query.append("list_smartpath_enabled", String(args.list_smartpath_enabled)) if (args.list_session_ttl != null) query.append("list_session_ttl", String(args.list_session_ttl)) if (args.list_mode != null) query.append("list_mode", String(args.list_mode)) if (APIPrivateKey !== undefined) headers.set("X-API-Private-Key", APIPrivateKey) if (APIPublicKey !== undefined) headers.set("X-API-Public-Key", APIPublicKey) const url = `${baseUrl.replace(/\/+$/, '')}/public/user/mobile/list${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(getApiPublicUserMobileListResponse, await res.json()) };