Class: Nylas::SchedulerCollection
- Inherits:
-
Collection
- Object
- Collection
- Nylas::SchedulerCollection
- Defined in:
- lib/nylas/scheduler_collection.rb
Overview
Additional methods for some of Scheduler's other functionality
Instance Attribute Summary
Attributes inherited from Collection
Instance Method Summary collapse
-
#book_time_slot(slug, timeslot) ⇒ SchedulerBookingConfirmation
Book a time slot.
-
#cancel_booking(slug, edit_hash, reason) ⇒ Hash
Cancel a booking.
-
#confirm_booking(slug, edit_hash) ⇒ SchedulerBookingConfirmation
Confirm a booking.
-
#get_available_time_slots(slug) ⇒ Array<SchedulerTimeSlot>
Retrieve available time slots.
-
#get_google_availability ⇒ Hash
Retrieve Google availability.
-
#get_office_365_availability ⇒ Hash
Retrieve Office 365 availability.
-
#get_page_slug(slug) ⇒ Scheduler
Retrieve public config for a scheduling page.
Methods inherited from Collection
#count, #create, #each, #execute, #expanded, #find, #find_each, #find_model, #find_raw, #ids, #initialize, #limit, #more_pages?, #new, #next_page, #offset, #raw, #resources_path, #search, #to_be_executed, #where
Constructor Details
This class inherits a constructor from Nylas::Collection
Instance Method Details
#book_time_slot(slug, timeslot) ⇒ SchedulerBookingConfirmation
Book a time slot
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/nylas/scheduler_collection.rb', line 51 def book_time_slot(slug, timeslot) payload = timeslot.to_h # The booking endpoint requires additional_values and additional_emails # to exist regardless if they are empty or not payload[:additional_values] = {} unless payload[:additional_values] payload[:additional_emails] = [] unless payload[:additional_emails] booking_response = api.execute( method: :post, path: "/schedule/#{slug}/timeslots", payload: JSON.dump(payload) ) SchedulerBookingConfirmation.new(**booking_response.merge(api: api)) end |
#cancel_booking(slug, edit_hash, reason) ⇒ Hash
Cancel a booking
71 72 73 74 75 76 77 |
# File 'lib/nylas/scheduler_collection.rb', line 71 def cancel_booking(slug, edit_hash, reason) api.execute( method: :post, path: "/schedule/#{slug}/#{edit_hash}/cancel", payload: JSON.dump(reason: reason) ) end |
#confirm_booking(slug, edit_hash) ⇒ SchedulerBookingConfirmation
Confirm a booking
83 84 85 86 87 88 89 90 91 |
# File 'lib/nylas/scheduler_collection.rb', line 83 def confirm_booking(slug, edit_hash) booking_response = api.execute( method: :post, path: "/schedule/#{slug}/#{edit_hash}/confirm", payload: {} ) SchedulerBookingConfirmation.new(**booking_response.merge(api: api)) end |
#get_available_time_slots(slug) ⇒ Array<SchedulerTimeSlot>
Retrieve available time slots
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nylas/scheduler_collection.rb', line 34 def get_available_time_slots(slug) response = api.execute( method: :get, path: "/schedule/#{slug}/timeslots" ) timeslots = [] response.each do |available_slot| timeslots.push(SchedulerTimeSlot.new(**available_slot.merge(api: api))) end timeslots end |
#get_google_availability ⇒ Hash
Retrieve Google availability
9 10 11 |
# File 'lib/nylas/scheduler_collection.rb', line 9 def get_google_availability execute_provider_availability("google") end |
#get_office_365_availability ⇒ Hash
Retrieve Office 365 availability
15 16 17 |
# File 'lib/nylas/scheduler_collection.rb', line 15 def get_office_365_availability execute_provider_availability("o365") end |
#get_page_slug(slug) ⇒ Scheduler
Retrieve public config for a scheduling page
22 23 24 25 26 27 28 29 |
# File 'lib/nylas/scheduler_collection.rb', line 22 def get_page_slug(slug) page_response = api.execute( method: :get, path: "/schedule/#{slug}/info" ) Scheduler.new(**page_response.merge(api: api)) end |