A Closer Look at the Bookings Code

Look at the Zoho Bookings API Doc! And at our code below:

string bookings_to_crm(string booking_ID)
{
bookingRequest = invokeurl
[
 url :"https://www.zohoapis.com/bookings/v1/json/getappointment?booking_id=" + booking_ID
 type :GET
 connection:"zohobookings"
];
// info bookingRequest;
bookingInfo = bookingRequest.get("response").get("returnvalue");
// --------------
// Now we can run our actions with the booking record we fetched
Email = bookingInfo.get("customer_email");
info Email;
Contact = zoho.crm.searchRecords("Contacts","(Email:equals:" + Email + ")").get(0);
// info Contact;
ContactID = Contact.get("id").toNumber();
bookingDate = bookingInfo.get("start_time");
service = bookingInfo.get("service_name");
staff = bookingInfo.get("staff_name");
TimeZone = "-07:00";
JustDate = bookingDate.getPrefix(" ").toDate().toString("yyyy-MM-dd");
// info JustDate;
JustTime = bookingDate.getSuffix(" ");
// info JustTime;
appointmentReformat = (JustDate + "T" + JustTime + TimeZone).remove(" ");
info appointmentReformat;
Cmap = Map();
Cmap.put("Booking_Date",appointmentReformat);
Cmap.put("Booking_Service",service);
UpdateContact = zoho.crm.updateRecord("Contacts",ContactID,Cmap);
info UpdateContact;
return "GOT IT";
}
Back to Lesson