import {z} from 'zod' export type GetApiApiExternalBuyerBuyerIdAttributeBuyerAttributeArgs = {buyerId: string, buyerAttribute: 'Id' | 'Name' | 'CommonName' | 'ParentName' | 'ParentBuyerId' | 'Type' | 'Classifications' | 'Url' | 'LinkedinSlug' | 'Zip' | 'CountryCode' | 'StateCode' | 'StateName' | 'City' | 'County' | 'Address' | 'Street1' | 'Street2' | 'MainPhoneNumber' | 'EmailDomains' | 'Population' | 'BudgetAmount' | 'BudgetSbita' | 'BudgetUrl' | 'BudgetLatestYear' | 'BudgetConfidence' | 'SchoolDistrictType' | 'HigherEdFullTimeEnrollment' | 'HigherEdInstitutionType' | 'DepartmentName' | 'DepartmentCode' | 'AgencyName' | 'OfficeCodeArray' | 'AgencyCode' | 'AiAdoptionScore' | 'AiAdoptionSummary' | 'StartupFriendlinessScore' | 'StartupFriendlinessSummary' | 'ProcurementHellScore' | 'AngelProcurementSummary' | 'IpedsIdNumeric' | 'TotalEnrollment' | 'NcesId' | 'NcesStateDistrictId' | 'CensusIdPid6' | 'CensusIdGidId' | 'SgcId' | 'HigherEdGraduationRate' | 'HigherEdRetentionRate' | 'HigherEdAcceptanceRate' | 'HigherEdYieldRate' | 'HigherEdGraduationEnrollment' | 'HigherEdUndergradEnrollment' | 'HigherEdOnlineOnlyEnrollment' | 'HigherEdControlOfInstitution' | 'HigherEdForProfitStatus' | 'HigherEdLevelOfInstitution' | 'HigherEdRecruitmentAdmissionsCrmArray' | 'HigherEdEndowment' | 'HigherEdMascot' | 'HigherEdNumberOfOnCampusResidents' | 'HigherEdNumberOfFullTimeEmployees' | 'HigherEdSisModernizationStatus' | 'HigherEdPrimaryRegionalAccreditor' | 'HigherEdAccreditationSummary' | 'HigherEdAccreditationStatus' | 'DapipId' | 'HigherEdNextAccreditationReviewDate' | 'HigherEdSystem' | 'CommunityCollegeSystem' | 'Sis' | 'LmsArray' | 'SchoolDistrictLocale' | 'SchoolDistrictFullTimeEquivalentTeachers' | 'LowestGradeOffered' | 'HighestGradeOffered' | 'SchoolDistrictNumberOfSchools' | 'SchoolDistrictElementarySchools' | 'SchoolDistrictMiddleSchools' | 'SchoolDistrictHighSchools' | 'SchoolDistrictTotalStaff' | 'SchoolDistrictMedianHouseholdIncome' | 'SchoolDistrictSector' | 'RegionalEducationServiceAgencyName' | 'RegionalEducationServiceAgencyBuyerId' | 'SchoolManagementOrganizationName' | 'SchoolManagementOrganizationBuyerId' | 'EnglishLearners' | 'BlackPercentage' | 'LatinoPercentage' | 'WhitePercentage' | 'StudentTeacherRatio' | 'SchoolSector' | 'SchoolLevel' | 'AlternativeSchool' | 'SchoolCurriculumProgramArray' | 'ReligiousAffiliation' | 'StudentGenderComposition' | 'SchoolVirtualStatus' | 'Subentity' | 'FiscalYearStartDate' | 'FreeOrReducedLunchEligiblePercentage' | 'FdId' | 'FireDepartmentType' | 'FireDepartmentOrganizationType' | 'FireDepartmentPrimaryAgency' | 'FireDepartmentNumberOfStations' | 'FireDepartmentActiveFirefightersCareer' | 'FireDepartmentActiveFirefightersVolunteer' | 'FireDepartmentActiveFirefightersPaidPerCall' | 'FireDepartmentNonFirefightingCivilian' | 'FireDepartmentNonFirefightingVolunteer' | 'PoliceOri' | 'PoliceOfficerCt' | 'Psap' | 'StateAgencySector' | 'EmployeeFte' | 'PropensityToSpendScore' | 'PropensityToSpendSummary' | 'BudgetChangeAnalysisSourceUrls' | 'PropensityToSpend' | 'YoyChangeInEnrollment' | 'EnrollmentTrend' | 'EnrollmentTrendBasedOnFte' | 'SpecialEducationEnrollment' | 'SpecialEducationEnrollmentPercentage' | 'PerPupilExpenditure' | 'MathProficiencyPercentage' | 'ElaProficiencyPercentage' | 'TitleIFunding' | 'TitleIiFunding' | 'TitleIiiFunding' | 'TitleIvFunding' | 'TitleVFunding' | 'FederalGrantComplianceRisk' | 'FederalGrantComplianceCapSummary' | 'BuyerLocationLatitude' | 'BuyerLocationLongitude'}; export type GetApiApiExternalBuyerBuyerIdAttributeBuyerAttributeOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const buyerAttributeResponse = z.object({buyerData: 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 Buyer Attribute * * GET /api/external/buyer/{buyerId}/attribute/{buyerAttribute} */ export const getApiApiExternalBuyerBuyerIdAttributeBuyerAttribute = async (args: GetApiApiExternalBuyerBuyerIdAttributeBuyerAttributeArgs, options?: GetApiApiExternalBuyerBuyerIdAttributeBuyerAttributeOptions) => { const {baseUrl = "https://dashboard.starbridge.ai", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/external/buyer/${encodeURIComponent(String(args.buyerId))}/attribute/${encodeURIComponent(String(args.buyerAttribute))}${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(buyerAttributeResponse, await res.json()) };