Class: Moodle::Api::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/moodle/api/request.rb

Overview

Handles making the request to the Moodle API and interpreting the results. The Moodle API is not consistent in the way it returns responses so the type of response is determined, successful responses are returned, failures are parsed and raised in a generic fashion.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



11
12
13
# File 'lib/moodle/api/request.rb', line 11

def response
  @response
end

Instance Method Details

#post(path, options = {}) ⇒ Object



13
14
15
16
# File 'lib/moodle/api/request.rb', line 13

def post(path,  options = {})
  @response = Typhoeus.post(path, options)
  resolve_response if response.success?
end