Unknown model· unknown
from ShareGPT 90K (shared ChatGPT conversations)
Can you write a class in python that syncs my reservations from wix api to airtable
- User
Can you write a class in python that syncs my reservations from wix api to airtable
- Assistant
Certainly! Here is a sample class that should do the job:
codeimport requests import json class WixReservationSyncer: def __init__(self, wix_api_key, airtable_api_key, airtable_base_id, airtable_table_name): self.wix_api_key = wix_api_key self.airtable_api_key = airtable_api_key self.airtable_base_id = airtable_base_id self.airtable_table_name = airtable_table_name def sync(self): # Get the reservations from the Wix API wix_reservations_response = requests.get( "https://www.wix.com/reservations/api/bookings", headers={ "Authorization": f"Bearer {self.wix_api_key}" } ) wix_reservations = wix_reservations_response.json() # Format the reservations for Airtable formatted_reservations = [] for reservation in wix_reservations: formatted_reservation = { "fields": { "Name": reservation["name"], "Email": reservation["email"], "Phone": reservation["phone"], "Date": reservation["date"], "Time": reservation["time"], "Number of Guests": reservation["numberOfGuests"], "Notes": reservation["notes"], } } formatted_reservations.append(formatted_reservation) # Add the reservations to Airtable airtable_response = requests.post( f"https://api.airtable.com/v0/{self.airtable_base_id}/{self.airtable_table_name}", headers={ "Authorization": f"Bearer {self.airtable_api_key}", "Content-Type": "application/json" }, json={ "records": formatted_reservations } )
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.