Skip to content

Commit 1a64858

Browse files
authored
Adjust to Pretalx 2025.01's new API (#83)
1 parent cc0e8c4 commit 1a64858

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/lib/Pretalx.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ export interface Talk {
2626
};
2727
}
2828

29-
// Reference: https://docs.pretalx.org/api/resources/talks/
29+
// Reference: https://docs.pretalx.org/api/resources/#tag/submissions
3030
type TalksResponse = PaginatedResponse<{
3131
code: string;
32-
slot?: {
33-
end: string;
34-
room: { en: string };
35-
room_id: number;
32+
slots: Array<{
3633
start: string;
37-
};
34+
end: string;
35+
room: { name: { en: string }, id: number };
36+
}>;
3837
state:
3938
| "accepted"
4039
| "canceled"
@@ -50,24 +49,27 @@ type TalksResponse = PaginatedResponse<{
5049
export const getTalks = async (event: string): Promise<Talk[]> => {
5150
const talks: Talk[] = [];
5251

53-
const url = `${origin}/api/events/${event}/talks/?limit=100`;
52+
const url = `${origin}/api/events/${event}/submissions/?state=confirmed&expand=slots,slots.room`;
5453
for await (const page of pages<TalksResponse>(url))
55-
for (const { code, slot, state, title } of page)
54+
for (const { code, slots, state, title } of page) {
55+
// TODO: handle there being more than one slot
56+
const slot = slots[0];
5657
talks.push({
5758
id: code,
5859
title,
5960
url: `${origin}/${event}/talk/${code}/`,
60-
...(slot && state === "confirmed"
61+
...(slot
6162
? {
6263
scheduled: {
6364
beginning: DateTime.fromISO(slot.start),
6465
end: DateTime.fromISO(slot.end),
65-
roomId: slot.room_id.toString(),
66-
roomName: slot.room.en,
66+
roomId: slot.room.id.toString(),
67+
roomName: slot.room.name.en,
6768
},
6869
}
6970
: {}),
7071
});
72+
}
7173

7274
return talks;
7375
};

0 commit comments

Comments
 (0)