Edits history of script submission #21033 for ' Create waitlist on-my-way (yelp)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Yelp = {
      apiKey: string;
    };
    /**
     * Create waitlist on-my-way
     * Create a waitlist on-my-way visit in a restaurant.
     */
    export async function main(
      auth: Yelp,
      business_id: string,
      body: {
        phone: string;
        party_size: number;
        name: string;
        arrival_range_max: number;
        arrival_range_min: number;
        party_notes?: string;
      },
    ) {
      const url = new URL(
        `https://api.yelp.com/v3/businesses/${business_id}/waitlist/on-my-way`,
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.apiKey,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago