Class: SchedulerZoomService
- Inherits:
-
Object
- Object
- SchedulerZoomService
- Defined in:
- app/services/scheduler_zoom_service.rb
Constant Summary collapse
- ZOOM_API_BASE =
'https://api.zoom.us/v2'
Instance Method Summary collapse
- #connected? ⇒ Boolean
- #create_meeting(booking) ⇒ Object
- #delete_meeting(zoom_meeting_id) ⇒ Object
-
#initialize(employee) ⇒ SchedulerZoomService
constructor
A new instance of SchedulerZoomService.
Constructor Details
#initialize(employee) ⇒ SchedulerZoomService
Returns a new instance of SchedulerZoomService.
6 7 8 9 |
# File 'app/services/scheduler_zoom_service.rb', line 6 def initialize(employee) @employee = employee @oauth = Zoom::OauthService.new(account: employee.account) if employee.account end |
Instance Method Details
#connected? ⇒ Boolean
11 12 13 |
# File 'app/services/scheduler_zoom_service.rb', line 11 def connected? @oauth&.connected? || false end |
#create_meeting(booking) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/services/scheduler_zoom_service.rb', line 15 def create_meeting(booking) return unless connected? payload = { topic: "#{booking.scheduler_booking_page.name} with #{booking.guest_name}", type: 2, start_time: booking.starts_at.iso8601, duration: booking.duration_minutes, timezone: booking.employee.scheduler_profile&.timezone || 'America/Chicago', settings: { join_before_host: true, waiting_room: false, auto_recording: 'none', meeting_authentication: false } } response = api_post('/users/me/meetings', payload) return unless response booking.update_columns( zoom_meeting_id: response['id'].to_s, zoom_join_url: response['join_url'] ) response rescue StandardError => e Rails.logger.error("SchedulerZoomService#create_meeting failed for #{@employee.email}: #{e.}") nil end |
#delete_meeting(zoom_meeting_id) ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/services/scheduler_zoom_service.rb', line 45 def delete_meeting(zoom_meeting_id) return unless connected? && zoom_meeting_id.present? api_delete("/meetings/#{zoom_meeting_id}") rescue StandardError => e Rails.logger.error("SchedulerZoomService#delete_meeting failed for #{@employee.email}: #{e.}") end |