Class: GoogleAPIMiddleMan::Agent
- Inherits:
-
Object
- Object
- GoogleAPIMiddleMan::Agent
- Defined in:
- lib/google-api-middle_man.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #calendar_events(calendar_id) ⇒ Object
-
#initialize(config) ⇒ Agent
constructor
A new instance of Agent.
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
#client ⇒ Object (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. = service_account. = .merge('calendarId' => calendar_id) result = @client.execute(api_method: calendar_service.events.list, parameters: ) result.data end |