Skip to content

Commit 54f52d1

Browse files
Fetch each sponsor's detail to get real per-sponsor description
The list endpoint /sponsors returns abbreviated records where the description field comes back duplicated across all sponsors. Follow up with a GET /sponsors/{id} per row to retrieve real per-sponsor fields, falling back to the list row if the detail call fails. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent cdfc983 commit 54f52d1

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

‎scripts/fetch-zoho.mjs‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,36 @@ async function main() {
156156
const token = await mintAccessToken();
157157

158158
console.log("Fetching sponsors…");
159-
const sponsorsRaw = await zohoGet(
159+
const sponsorsListRaw = await zohoGet(
160160
`/portals/${portalId}/events/${eventId}/sponsors`,
161161
token,
162162
);
163163

164+
// The list endpoint returns abbreviated records — in particular `description`
165+
// tends to come back duplicated across sponsors. Fetch each sponsor's detail
166+
// endpoint to get the real per-sponsor fields, falling back to the list row
167+
// if the detail call fails.
168+
const sponsorsList = pickArray(sponsorsListRaw);
169+
const sponsorsRaw = [];
170+
for (const row of sponsorsList) {
171+
if (!row?.id) {
172+
sponsorsRaw.push(row);
173+
continue;
174+
}
175+
try {
176+
const detail = await zohoGet(
177+
`/portals/${portalId}/events/${eventId}/sponsors/${row.id}`,
178+
token,
179+
);
180+
sponsorsRaw.push(detail?.sponsor ?? detail ?? row);
181+
} catch (err) {
182+
console.warn(
183+
` ! detail fetch failed for sponsor ${row.id}: ${err.message} — falling back to list row`,
184+
);
185+
sponsorsRaw.push(row);
186+
}
187+
}
188+
164189
console.log("Fetching tickets…");
165190
const ticketsRaw = await zohoGet(
166191
`/portals/${portalId}/events/${eventId}/ticket_classes`,
@@ -173,7 +198,7 @@ async function main() {
173198
event: "TechBash 2026",
174199
source: "Zoho Backstage v3",
175200
fetchedAt,
176-
sponsors: pickArray(sponsorsRaw).map(sanitizeSponsor),
201+
sponsors: sponsorsRaw.map(sanitizeSponsor),
177202
};
178203

179204
const tickets = {

0 commit comments

Comments
 (0)