//native
type Yelp = {
apiKey: string;
};
/**
* Cancel a visit
* Cancel an on-my-way or a waitlist visit by the given encrypted visit identifier.
**Curl example with OAuth authentication:**
```sh
root@test:~# curl -X POST "https://api.yelp.com/v3/visits/{VISIT_ID}/cancel" --header 'accept: application/json' --header "Authorization: Bearer ${API_TOKEN}"
```
If the visit is canceled successfully, the client will receive an empty 204 response.
**Note:** In order to use this endpoint, the caller should be an onboarded Yelp Waitlist partner
*/
export async function main(auth: Yelp, visit_id: string) {
const url = new URL(`https://api.yelp.com/v3/visits/${visit_id}/cancel`);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago