Class: Moodle::Api::Client
- Inherits:
-
Object
- Object
- Moodle::Api::Client
- Defined in:
- lib/moodle/api/client.rb
Instance Attribute Summary collapse
-
#filter_params ⇒ Object
readonly
Returns the value of attribute filter_params.
-
#token_service ⇒ Object
writeonly
Sets the attribute token_service.
-
#web_service_name ⇒ Object
readonly
Returns the value of attribute web_service_name.
Instance Method Summary collapse
- #configuration ⇒ Object
- #configure(options = {}, &block) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #make_request(web_service_name, filter_params = {}) ⇒ Object
- #request_params ⇒ Object
- #reset_configuration ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
7 8 9 |
# File 'lib/moodle/api/client.rb', line 7 def initialize = {} configure() end |
Instance Attribute Details
#filter_params ⇒ Object (readonly)
Returns the value of attribute filter_params.
4 5 6 |
# File 'lib/moodle/api/client.rb', line 4 def filter_params @filter_params end |
#token_service=(value) ⇒ Object (writeonly)
Sets the attribute token_service
5 6 7 |
# File 'lib/moodle/api/client.rb', line 5 def token_service=(value) @token_service = value end |
#web_service_name ⇒ Object (readonly)
Returns the value of attribute web_service_name.
4 5 6 |
# File 'lib/moodle/api/client.rb', line 4 def web_service_name @web_service_name end |
Instance Method Details
#configuration ⇒ Object
35 36 37 |
# File 'lib/moodle/api/client.rb', line 35 def configuration @configuration ||= Configuration.new end |
#configure(options = {}, &block) ⇒ Object
27 28 29 |
# File 'lib/moodle/api/client.rb', line 27 def configure = {}, &block configuration.configure(, &block) end |
#make_request(web_service_name, filter_params = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/moodle/api/client.rb', line 11 def make_request web_service_name, filter_params = {} @web_service_name = web_service_name @filter_params = filter_params Request.new.post(configuration.web_service_api_url, request_params) end |
#request_params ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/moodle/api/client.rb', line 18 def request_params { params: filter_params.merge!({ moodlewsrestformat: configuration.format, wsfunction: web_service_name, wstoken: configuration.token }), headers: { 'Accept' => 'json' } } end |
#reset_configuration ⇒ Object
31 32 33 |
# File 'lib/moodle/api/client.rb', line 31 def reset_configuration configuration.reset end |