nylas-ruby
nylas-ruby copied to clipboard
Free/busy blocks with empty time slots breaks `calendars.availability` request
Describe the bug
When passing the result of calling the free/busy endpoint to calendars.availability, I recieve a Nylas::InvalidRequest error with the message free_busy.0.time_slots: Missing data for required field.
To Reproduce
# nylas here is just the value returned from Nylas::API.new
# start_time and end_time should be on a day where the user has no calendar events/busy blocks.
nylas.calendars.availability(
**{ duration_minutes: duration_minutes,
interval_minutes: interval_minutes || duration_minutes,
start_time: start_time,
end_time: end_time,
emails: emails,
free_busy: nylas.free_busy(
emails: emails,
start_time: start_time.to_i,
end_time: end_time.to_i
),
open_hours: open_hours,
calendars: [
...
] })
)
Expected behavior
I expected to receive a list of available times for the user. It isn't quite clear to me why this should break on a day that has no busy blocks. I was able to achieve this by using nylas.free_busy(...).reject { |block| block.time_slots.blank? }.
SDK Version: 5.13.0
Additional context Using Ruby 3.0.2
Thanks for opening this issue, I'll take a look as to why this is breaking on blanks and have a solution soon.