1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { fetch } from "https://esm.town/v/std/fetch";
import { resyPublicAPIKey } from "https://esm.town/v/vtdocs/resyPublicAPIKey";
export const resyVenueIdFromSlugAndCity = async (
resyToken: string,
slug: string,
city: string,
): Promise<{
id: number;
}> => {
const venueRes = await fetch(
`https://api.resy.com/3/venue?url_slug=${slug}&location=${city}`,
{
"headers": {
"authorization":
`ResyAPI api_key="${resyPublicAPIKey}"`,
"x-resy-auth-token": resyToken,
"x-resy-universal-auth": resyToken,
},
},
);
const venueJSON = await venueRes.json();
if (!venueJSON.id) {
throw new Error(`couldn't find venue for ${slug} in ${city}: ${venueJSON}`);
}
return { id: venueJSON.id.resy };
};