I have managed to get Faraday making a POST request to a Google Calander from a .rb file. I'd like to use this functionality in my app to check Free/Busy responses on calendars before displaying a list of availble time slots to my user, after they select the date.
response = Faraday.post do |req|
req.url 'https://www.googleapis.com/calendar/v3/freeBusy?key=myapikey'
req.headers['Content-Type'] = 'application/json'
req.body = '{ "items": [ { "id": mycalendar } ], "timeMin": "2011-02-14T00:09:35Z", "timeMax": "2011-02-14T00:09:40Z" }'
end
Is it best to put the function in an appointments model, and then have an AJAX call when the user selects the date? Or would I be better to pre-cache it all in a local table?
Thanks for any help!