class Googlecal::Base
Constants
- OOB_URL
TODO: not sure what this is for, needs documentation
Attributes
credentials[RW]
default_calendar[RW]
Public Class Methods
new(application_name, calendar_id = 'primary', authenticate_with_env = false, credentials_path = File.join(Dir.home, '.credentials',"calendar-ruby-quickstart.yaml"), client_secrets_path = 'client_secret.json', scope = Google::Apis::CalendarV3::AUTH_CALENDAR)
click to toggle source
Initialize a new googlecal instance and authenticate with google with file paths
Attributes¶ ↑
-
:application_name:
- Name of application in gooogle console that you need to setup -
:authenticate_with_env:
- Optionally authenticate with enviroment variables instead of client_secrets_path -
:credentials_path:
- The file path to loading credentials path -
:client_secrets_path:
- The file path to json file holding client secrets -
:scope:
-The access scope for the use of the google api session
# File lib/googlecal/base.rb, line 20 def initialize(application_name, calendar_id = 'primary', authenticate_with_env = false, credentials_path = File.join(Dir.home, '.credentials',"calendar-ruby-quickstart.yaml"), client_secrets_path = 'client_secret.json', scope = Google::Apis::CalendarV3::AUTH_CALENDAR) # authenticate with google if authenticate_with_env # set credentials @credentials = authorize_with_env(scope) else # set credentials @credentials = authorize(credentials_path, client_secrets_path, scope) end @@calendar_service = setup_calendar_service(application_name, @credentials) @@calendar_id = calendar_id end
Public Instance Methods
create_event(calendar_id = 'primary', **opts)
click to toggle source
# File lib/googlecal/base.rb, line 43 def create_event(calendar_id = 'primary', **opts) event = Google::Apis::CalendarV3::Event.new( summary: opts[:summary] || '', location: opts[:location] || '', start: { date_time: Time.now.iso8601, time_zone: 'America/Los_Angeles', }, end
events(calendar_id = 'primary', **opts)
click to toggle source
# File lib/googlecal/base.rb, line 38 def events(calendar_id = 'primary', **opts) @@calendar_service.list_events(calendar_id, max_results: 10) end