Class: ZoomLauncher::CLI

Inherits:
GoogleAuth show all
Defined in:
lib/zoom_launcher/cli.rb

Constant Summary collapse

CALENDAR =
'primary'
ARGUMENTS =
{
  single_events: true,
  order_by: 'startTime',
  time_min: Time.now.iso8601,
  q: 'zoom.us',
  max_results: 5
}.freeze

Constants inherited from GoogleAuth

GoogleAuth::OOB_URI

Instance Method Summary collapse

Instance Method Details

#authObject



39
40
41
42
43
# File 'lib/zoom_launcher/cli.rb', line 39

def auth
  calendar.authorization = user_credentials_for(
    Google::Apis::CalendarV3::AUTH_CALENDAR
  )
end

#launchObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/zoom_launcher/cli.rb', line 18

def launch
  auth
  if next_event.meeting_url
    puts "Your next Zoom meeting is \"#{next_event.summary.bold}\"."
    is_was = next_event.already_started? ? 'was' : 'is'
    puts "It #{is_was} scheduled to start #{next_event.start_time_in_words}."
    puts

    if next_event.more_than_five_minutes_from_now?
      puts "Here's the Zoom URL: #{next_event.meeting_url.to_s.bold}"
    else
      puts "Opening #{next_event.meeting_url.to_s.bold}..."
      `open #{next_event.zoom_url || next_event.meeting_url}`
    end
    puts "Oh, and here's the URL in case you need it: #{next_event.html_link}"
  else
    puts "Can't find any upcoming Zoom meetings"
  end
end

#logoutObject



46
47
48
# File 'lib/zoom_launcher/cli.rb', line 46

def logout
  FileUtils.rm_rf token_store_path
end