Reputation: 15
Is there anyway to get the UUID of a scheduled meeting in calendly? I'm not able to generate it via API JSON response because the user will be booking the appointment via a scheduled_url
(which is a redirect link from a GET response).
require 'httparty'
class CalendlyController < ApplicationController
skip_before_action :check_auth
def user_event_types
user_uri = ENV['CALENDLY_USER_URI'] # Replace with specific user URI
calendly_api_url = "https://api.calendly.com/event_types?user=#{user_uri}"
headers = {
'Content-Type' => 'application/json',
'Authorization' => "Bearer #{ENV['CALENDLY_TOKEN']}"
}
response = HTTParty.get(calendly_api_url, headers: headers)
data = JSON.parse(response.body)
render json: data
end
end
My sample response to this kind of API request is something like this:
{
"resource": {
"uri": "https://api.calendly.com/event_types/AAAAAAAAAAAAAAAA",
"name": "15 Minute Meeting",
"active": true,
"booking_method": "instant",
"slug": "acmesales",
"scheduling_url": "https://calendly.com/acmesales",
"duration": 30,
"kind": "solo",
"pooling_type": "round_robin",
"type": "StandardEventType",
"color": "#fff200",
"created_at": "2019-01-02T03:04:05.678123Z",
"updated_at": "2019-08-07T06:05:04.321123Z",
"internal_note": "Internal note",
"description_plain": "15 Minute Meeting",
"description_html": "<p>15 Minute Meeting</p>",
"profile": {
"type": "User",
"name": "Tamara Jones",
"owner": "https://api.calendly.com/users/AAAAAAAAAAAAAAAA"
},
}
As you can see above, I don't really have a controller for creating a scheduled event since the calendly site does it for me automatically when I redirect them to the scheduling_url
from the JSON response.
I'm trying to make a GET request to https://api.calendly.com/scheduled_events/{uuid}
so I can extract the details of the event since I'll be using some of those values/attributes for my database.
Another concern as well, I have an Appointment table/entity in my database, ideally it should be created (via POST) every after successful booking. However, like I mentioned earlier, the appointment is being created via the calendly link and not via a post request/controller. So I was thinking of pulling those event details I mentioned above instead and use those to instantiate/create an appointment table/entity every time an appointment is booked through the calendly scheduling_url. Unless there is a better/more efficient way to do it?
For more info, below is are my models and associations (I'm using Rails and React btw):
class Dietitian < ApplicationRecord
has_many :appointments
has_many :patients, through: :appointments
end
class Appointment < ApplicationRecord
belongs_to :dietitian
belongs_to :patient
has_one :record
end
class Patient < ApplicationRecord
has_many :appointments
has_many :records
has_many :dietitians, through: :appointments
end
class Record < ApplicationRecord
belongs_to :appointment
belongs_to :patient
end
Upvotes: 0
Views: 698