ONSCHED API (Booking app)
https://docs.onsched.com/docs/getting-started
To view onsched data we can access 2 dashboards:​
- Sandbox (for staging and dev purposes): https://sandbox-dashboard.onsched.com
- Dashboard (for production): https://dashboard.onsched.com/
When user hits /plugins/appointments/standalone url, system calls onsched API to create location, service and resource.
First at app/controllers/settings_controller.rb system initialize the onsched location, service and resource:
def init_appointments_app
AppointmentsApp.init!(@backend_app, current_user, params)
end
- ONSCHED create Location: https://docs.onsched.com/reference/post_setup-v1-locations
- ONSCHED create Service: https://docs.onsched.com/reference/post_setup-v1-services
- ONSCHED create Resource: https://docs.onsched.com/reference/post_setup-v1-resources
lib/apps/appointments/setup.rb
def init
create_location
create_service
create_resource
end
All the created onsched data will be stored at APPs external_data attribute
app.external_data["booking_app"]
CALENDAR AVAILABILITY​
To create availability, we use the
CREATE_AVAILABILITYfunction. It leads tocreateaction inappointments_controller.rb. This action calls thecreate_allocationmethod insetup.rb, which makes a POST request to Onsched create allocation endpoint. (https://docs.onsched.com/reference/post_setup-v1-resources-id-allocations)To update availability, we use the
UPDATE_AVAILABILITYfunction. It leads to anupdateaction inappointments_controller.rb. This action calls theupdate_allocationmethod insetup.rb, which makes a PUT request to Onsched update allocation endpoint. (https://docs.onsched.com/reference/put_setup-v1-resources-allocations-id)To delete availability, we use the
DELETE_AVAILABILITYfunction. It leads todestroyaction inappointments_controller.rb. This action calls thedelete_allocationmethod insetup.rb, which makes a DELETE request to Onsched delete allocation endpoint. (https://docs.onsched.com/reference/delete_setup-v1-resources-allocations-id)
CALENDAR TIMEZONE​
- To change the timezone, we use the
UPDATE_LOCATION_TIMEZONEfunction. It leads toupdate_location_timezoneaction inappointments_controller.rb. This action calls theupdate_locationmethod insetup.rb, which makes a PUT request to Onsched update location object endpoint. (https://docs.onsched.com/reference/put_setup-v1-locations-id)
CALENDAR DURATION​
- To change the availability duration, we use the
UPDATE_SERVICE_DURATIONfunction. It leads toupdate_service_durationaction inappointments_controller.rb. This action calls theupdate_locationmethod insetup.rb, which makes a PUT request to Onsched update service object endpoint. (https://docs.onsched.com/reference/put_setup-v1-services-id)