Search
Code52
export const resyBot = async (opts: { slug: string; // amaro-bar}): Promise<string> => { const { slug, city, day, start, end, partySize, email, password } = opts; // Avoid duplicate bookings by looking for a successful booking for the current parameters const key = [ slug, } const auth = await resyAuth(email, password); const venue = await resyVenueIdFromSlugAndCity( auth.token, // If there are no matching slots, an error is thrown const matchingSlot = await resyGetMatchingSlot( auth.token, // At this point, there's a bookable slot (but it could still be sniped from us!) const { bookToken } = await resyGetSlotBookingToken( auth.token, } const bookingMetadata = await resyBookSlot( auth.token,export default async function (interval: Interval) { const bookingInfo = await resyBot( { slug: 'amaro-bar',};export const Resy_getFavorites = async (params: { authToken: string;}): Promise<Favorites> => { const url = "https://api.resy.com"; const response = await fetch(`${url}/3/user/favorites`, { headers: { }); const data = await response.json(); return data;An `object` containing:* `authToken` - Your authentication token, normally generated from [@rlesser.Resy_authenticate](https://www.val.town/v/rlesser.Resy_authenticate).See other [Resy vals](https://www.val.town/search?q=const+Resy_) I've made. Migrated from folder: Resy/Resy_getFavoritesexport const resyBot = async (opts: { slug: string; // amaro-bar let { slug, city, day, start, end, partySize, email, password } = opts; email ??= Deno.env.get("RESY_EMAIL"); password ??= Deno.env.get("RESY_PASSWORD"); let resyBotData = await blob.getJSON("resyBotData"); // Avoid duplicate bookings by looking for a successful booking for the current parameters const key = [ slug, } const auth = await resyAuth(email, password); const venue = await resyVenueIdFromSlugAndCity( auth.token, // If there are no matching slots, an error is thrown const matchingSlot = await resyGetMatchingSlot( auth.token, // At this point, there's a bookable slot (but it could still be sniped from us!) const { bookToken } = await resyGetSlotBookingToken( auth.token, } const bookingMetadata = await resyBookSlot( auth.token,export const resyBookSlot = async ( token: string, // (in testing, there was a rare internal server error) const retryLimit = 5; let retryCount = 0; try { const bookRes = await fetch(`https://api.resy.com/3/book`, { method: "POST", } if (!bookJSON.resy_token || !bookJSON.reservation_id) { throw new Error(`failed to book: ${bookJSON}`); return { resyToken: bookJSON.resy_token, reservationId: bookJSON.reservation_id,export const resyGetMatchingSlot = async ( token: string,}> => { const startTime = new Date(`${day} ${start}`); const endTime = new Date(`${day} ${end}`); const slotsRes = await fetch( `https://api.resy.com/4/find?lat=0&long=0&day=${day}&party_size=${partySize}&venue_id=${venueId}`, ); const slotsJSON = await slotsRes.json(); if (slotsJSON.results.venues[0].slots.length === 0) { } const availableSlots = slotsJSON.results.venues[0].slots; const matchingSlots = availableSlots.filter((slot) => { const time = new Date(slot.date.start); return time >= startTime && time <= endTime; // (This idea was copied from @alp.bookReservationOnResy) const middleSlotIndex = Math.floor(matchingSlots.length / 2); const slot = matchingSlots.at(middleSlotIndex); return {export default async function (interval: Interval) { const bookingInfo = await resyBot( { slug: 'amaro-bar',export const Resy_setNotify = async (params: { authToken: string;}) => { const url = "https://api.resy.com"; const response = await fetch(`${url}/3/notify`, { method: "POST", }); const data = await response.json(); return data;};export const Resy_getVenueCalendar = async (params: { venue_id: number;}): Promise<VenueCalendar> => { const url = "https://api.resy.com"; const query = new URLSearchParams({ venue_id: String(params.venue_id), }); const response = await fetch(`${url}/4/venue/calendar?${query.toString()}`, { headers: { }); const data = await response.json(); return data;};export const Resy_authenticate = async (params: AuthParams): Promise<{ AuthResponse;}> => { const url = "https://api.resy.com"; const body = `email=${encodeURIComponent(params.email)}&password=${ encodeURIComponent(params.password) }`; const response = await fetch(`${url}/3/auth/password`, { method: "POST", }); const data = await response.json(); return data;An `object` containing:* `venue_id` - The Resy venue id, either fetched from the website's network data or from [@rlesser_getFavorites](https://www.val.town/v/rlesser.Resy_getFavorites) *(Todo: add venue id from url function)*.* `num_seats` - The number of seats you are checking for availability for. Use 2 as a default if you just want to know when the restaurant is closed.See other [Resy vals](https://www.val.town/search?q=const+Resy_) I've made. Migrated from folder: Resy/Resy_getVenueCalendarSee other [Resy vals](https://www.val.town/search?q=const+Resy_) I've made. Migrated from folder: Resy/Resy_authenticateexport const resyBot = async (opts: { slug: string; // amaro-bar}): Promise<string> => { const { slug, city, day, start, end, partySize, email, password } = opts; // Avoid duplicate bookings by looking for a successful booking for the current parameters const key = [ slug, } const auth = await resyAuth(email, password); const venue = await resyVenueIdFromSlugAndCity( auth.token, // If there are no matching slots, an error is thrown const matchingSlot = await resyGetMatchingSlot( auth.token, // At this point, there's a bookable slot (but it could still be sniped from us!) const { bookToken } = await resyGetSlotBookingToken( auth.token, } const bookingMetadata = await resyBookSlot( auth.token,Vals
No vals found
Users
No users found