Class: GoogleAPIMiddleMan::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/google-api-middle_man.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Agent

Returns a new instance of Agent.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/google-api-middle_man.rb', line 11

def initialize(config)
  [:application_name, :key_location, :google_service_email].each do |key|
    unless config.has_key?(key) || config.has_key?(key.to_s)
      raise MissingConfigOptions, "config is missing #{key}"
    end
  end

  @application_name = config[:application_name] || config['application_name']
  @key_location = config[:key_location] || config['key_location']
  @google_service_email = config[:google_service_email] || config['google_service_email']

  @client = Google::APIClient.new(application_name: @application_name)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



9
10
11
# File 'lib/google-api-middle_man.rb', line 9

def client
  @client
end

Instance Method Details

#calendar_events(calendar_id) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/google-api-middle_man.rb', line 25

def calendar_events(calendar_id)
  @client.authorization = .authorize

  options = events_list_options_hash.merge('calendarId' => calendar_id)

  result = @client.execute(api_method: calendar_service.events.list, parameters: options)

  result.data
end