moodle-api 1.2 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f9519237bf033eda8ececd7cee8e59607d175aa
4
- data.tar.gz: 093320e00f1d0d13ba9942c250965cba429d98a7
3
+ metadata.gz: 9e5edfc4de74aa0771bf2197cc68bdda8d33ce20
4
+ data.tar.gz: 23aa1db0b94479fc0e4938fb2b588b61e442d45d
5
5
  SHA512:
6
- metadata.gz: 5ee05012161283282b2ab7c726cd17985f5697fc4bcb16933e4dcc73bc47f7f9d72e2308283a1dfd8daa0df5937c62e5e5b013f8ce413b3c12daa81985177e92
7
- data.tar.gz: 1a57bc71e6ad4d64940d158e7a7197b8f3824d6b8d9ff6a6daf6c781e63340d34f1c3283b28379f10ccd663e3a2fac8dc9f92c9b338e139154790b0b084fd2bb
6
+ metadata.gz: 8e3966da9448fedc2e7d545b288769360993cb1f0e841cab86951f0c53288a343178b24c0c6aeb9b07f526d5bb74a7778b229e9267d8a3c821f497dbd24aa1d8
7
+ data.tar.gz: 8b70a1714bcafe49ba93960695bb4c8f11d6c7cea0b9145eb091c04093555f7018cff7d2d28c962e32e23848144b2cbcf9cea07386f8bbdada43480ae5d0b485
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - ruby-head
4
+ addons:
5
+ code_climate:
6
+ repo_token: 9e23768891c8bf9f3a4a034023881eb2ca8d1f96f4b4972e5b265be5f612215d
data/README.md CHANGED
@@ -1,4 +1,10 @@
1
- # Moodle
1
+ [![Gem Version](https://badge.fury.io/rb/moodle-api.svg)](http://badge.fury.io/rb/moodle-api)
2
+ [![Code Climate](https://codeclimate.com/repos/559ea924e30ba001ad00a507/badges/bf95c036334b007100d3/gpa.svg)](https://codeclimate.com/repos/559ea924e30ba001ad00a507/feed)
3
+ [![Build Status](https://travis-ci.org/get-smarter/moodle-api.svg?branch=master)](https://travis-ci.org/get-smarter/moodle-api)
4
+ [![Test Coverage](https://codeclimate.com/repos/559ea924e30ba001ad00a507/badges/bf95c036334b007100d3/coverage.svg)](https://codeclimate.com/repos/559ea924e30ba001ad00a507/coverage)
5
+ [![Dependency Status](https://gemnasium.com/get-smarter/moodle-api.svg)](https://gemnasium.com/get-smarter/moodle-api)
6
+
7
+ # Moodle API
2
8
 
3
9
  A ruby wrapper for the Moodle REST API.
4
10
 
@@ -7,7 +13,7 @@ A ruby wrapper for the Moodle REST API.
7
13
  Add this line to your application's Gemfile:
8
14
 
9
15
  ```ruby
10
- gem 'moodle'
16
+ gem 'moodle-api'
11
17
  ```
12
18
 
13
19
  And then execute:
@@ -16,7 +22,7 @@ And then execute:
16
22
 
17
23
  Or install it yourself as:
18
24
 
19
- $ gem install moodle
25
+ $ gem install moodle-api
20
26
 
21
27
  ## Usage
22
28
 
@@ -27,24 +33,22 @@ Different ways to configure gem.
27
33
  ```ruby
28
34
  # Pass block to configure
29
35
  Moodle::Api.configure do|c|
30
- c.host = 'http://dev.vle.getsmarter.co.za'
31
- c.token = '072556801bf07076fff6bff2a463b7c5'
36
+ c.host = 'http://my_moodle_instance.com'
37
+ c.token = 'mytoken'
32
38
  end
33
39
 
34
40
  # Set configuration values individually
35
- Moodle::Api.configuration.host = 'http://dev.vle.getsmarter.co.za'
36
- Moodle::Api.configuration.token = '072556801bf07076fff6bff2a463b7c5'
41
+ Moodle::Api.configuration.host = 'http://my_moodle_instance.com'
42
+ Moodle::Api.configuration.token = 'mytoken'
37
43
 
38
44
  # Pass options hash to configure
39
- Moodle::Api.configure({host: 'http://dev.vle.getsmarter.co.za',
40
- token: '072556801bf07076fff6bff2a463b7c5'})
45
+ Moodle::Api.configure({host: 'http://my_moodle_instance.com',
46
+ token: 'mytoken'})
41
47
 
42
- ```
43
- The client can also be instantiated and used.
48
+ # The client can also be instantiated and used.
49
+ client = Moodle:Client.new({host: 'http://my_moodle_instance.com',
50
+ token: 'mytoken'})
44
51
 
45
- ```ruby
46
- client = Moodle:Client.new({host: 'http://dev.vle.getsmarter.co.za',
47
- token: '072556801bf07076fff6bff2a463b7c5'})
48
52
  client.make_request(:function_name_here, my_params)
49
53
  ```
50
54
 
@@ -63,21 +67,24 @@ New functions created in Moodle will automatically be available in the gem.
63
67
  ### Example
64
68
 
65
69
  ```ruby
66
- Moodle::Api.configure({host: 'http://dev.vle.getsmarter.co.za',
67
- token: '072556801bf07076fff6bff2a463b7c5'})
70
+ Moodle::Api.configure({host: 'http://my_moodle_instance.com',
71
+ token: 'mytoken'})
68
72
 
69
73
  params = { 'criteria[0][key]' => 'firstname', 'criteria[0][value]' => 'Jon' }
74
+
70
75
  Moodle::Api.core_user_get_users(params)
71
76
  ```
72
77
 
73
78
  ### Authentication
74
79
  Moodle uses token authentication, but sometimes you might not have a token. Users are able to generate tokens automatically when calling services using basic authentication.
75
80
  ```ruby
76
- Moodle::Api.configure({host: 'http://dev.vle.getsmarter.co.za',
81
+ Moodle::Api.configure({host: 'http://my_moodle_instance.com',
77
82
  service: 'my_external_service', # ensure you include the shortname of the external service
78
83
  username: 'jonsnow',
79
84
  password: 'defendthewall'})
85
+
80
86
  params = { 'criteria[0][key]' => 'firstname', 'criteria[0][value]' => 'Jon' }
87
+
81
88
  Moodle::Api.core_user_get_users(params)
82
89
  ```
83
90
  The gem will handle generating the token automatically and making the call to `core_user_get_users` with the token. If you want you can also just generate a token using
@@ -117,11 +124,8 @@ I am always keen to learn so please feel free to create an issue with code revie
117
124
 
118
125
  ## TODOS
119
126
 
120
- - Add additional protocals
127
+ - Add additional protocols
121
128
  - Make cassettes easily rerunnable - will require a parser for the response to remove dynamic data or a funky regex in the specs.
122
- - Setup travis
123
- - Setup codeclimate
124
- - Setup codecoverage
125
129
 
126
130
  ## Warning
127
131
 
data/Rakefile CHANGED
@@ -1,4 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
2
7
 
3
8
  task :console do
4
9
  exec "pry -r moodle -I ./lib"
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users_invalid&wstoken=072556801bf07076fff6bff2a463b7c5
5
+ uri: http://my_moodle_instance.com/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users_invalid&wstoken=072556801bf07076fff6bff2a463b7c5
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -43,6 +43,6 @@ http_interactions:
43
43
  * FROM {external_functions} WHERE name = ?\n[array (\n 0 => ''core_user_get_users_invalid'',\n)]"}'
44
44
  http_version: '1.1'
45
45
  adapter_metadata:
46
- effective_url: http://dev.vle.getsmarter.co.za/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users_invalid&wstoken=072556801bf07076fff6bff2a463b7c5
46
+ effective_url: http://my_moodle_instance.com/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users_invalid&wstoken=072556801bf07076fff6bff2a463b7c5
47
47
  recorded_at: Wed, 01 Jul 2015 12:33:57 GMT
48
48
  recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=phoenix_integration
5
+ uri: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=phoenix_integration
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -34,6 +34,6 @@ http_interactions:
34
34
  specified in config.php<\/p>","stacktrace":null,"debuginfo":null,"errorcode":"dbconnectionfailed"}'
35
35
  http_version: '1.1'
36
36
  adapter_metadata:
37
- effective_url: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=phoenix_integration
37
+ effective_url: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=phoenix_integration
38
38
  recorded_at: Tue, 07 Jul 2015 08:26:38 GMT
39
39
  recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=072556801bf07076fff6bff2a463b7c5
5
+ uri: http://my_moodle_instance.com/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=072556801bf07076fff6bff2a463b7c5
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -40,7 +40,7 @@ http_interactions:
40
40
  encoding: UTF-8
41
41
  string: '{"users":[{"id":5329,"username":"ryan.mes@email.co.za","firstname":"Jon","lastname":"Snow","fullname":"Jon
42
42
  Snow","email":"ryan.mes@email.co.za","department":"","firstaccess":1385623936,"lastaccess":1435753716,"description":"","descriptionformat":1,"city":"Cape
43
- Town","profileimageurlsmall":"http:\/\/dev.vle.getsmarter.co.za\/pluginfile.php\/46751\/user\/icon\/f2","profileimageurl":"http:\/\/dev.vle.getsmarter.co.za\/pluginfile.php\/46751\/user\/icon\/f1","customfields":[{"type":"text","value":"GetSmarter","name":"Company","shortname":"company"},{"type":"text","value":"www.getsmarter.co.za","name":"Company
43
+ Town","profileimageurlsmall":"http:\/\/my_moodle_instance.com\/pluginfile.php\/46751\/user\/icon\/f2","profileimageurl":"http:\/\/my_moodle_instance.com\/pluginfile.php\/46751\/user\/icon\/f1","customfields":[{"type":"text","value":"GetSmarter","name":"Company","shortname":"company"},{"type":"text","value":"www.getsmarter.co.za","name":"Company
44
44
  Website","shortname":"companywebsite"},{"type":"text","value":"Lead Developer","name":"Position","shortname":"position"},{"type":"textarea","value":"<p>I
45
45
  am an avid adventure racer!<\/p>","name":"More about me","shortname":"moreaboutme"},{"type":"menu","value":"Short
46
46
  Course","name":"Enrolled in ","shortname":"programme"},{"type":"datetime","value":"0","name":"Date
@@ -56,6 +56,6 @@ http_interactions:
56
56
  names checked","shortname":"certificatenameschecked"}],"preferences":[{"name":"auth_manual_passwordupdatetime","value":"1434626773"},{"name":"block7hidden","value":"0"},{"name":"block9hidden","value":"0"},{"name":"docked_block_instance_7","value":"0"},{"name":"docked_block_instance_9","value":"0"},{"name":"email_bounce_count","value":"0"},{"name":"email_send_count","value":"41"},{"name":"filepicker_recentlicense","value":"allrightsreserved"},{"name":"filepicker_recentrepository","value":"7"},{"name":"htmleditor","value":""},{"name":"login_failed_count_since_success","value":"7"},{"name":"message_beepnewmessage","value":"0"},{"name":"message_blocknoncontacts","value":"0"},{"name":"message_provider_enrol_manual_expiry_notification_loggedin","value":"email"},{"name":"message_provider_enrol_manual_expiry_notification_loggedoff","value":"email"},{"name":"message_provider_enrol_self_expiry_notification_loggedin","value":"email"},{"name":"message_provider_enrol_self_expiry_notification_loggedoff","value":"email"},{"name":"message_provider_mod_assign_assign_notification_loggedin","value":"email"},{"name":"message_provider_mod_assign_assign_notification_loggedoff","value":"email"},{"name":"message_provider_mod_forum_posts_loggedin","value":"email"},{"name":"message_provider_mod_forum_posts_loggedoff","value":"email"},{"name":"message_provider_mod_lesson_graded_essay_loggedin","value":"email"},{"name":"message_provider_mod_lesson_graded_essay_loggedoff","value":"email"},{"name":"message_provider_mod_quiz_attempt_overdue_loggedin","value":"email"},{"name":"message_provider_mod_quiz_attempt_overdue_loggedoff","value":"email"},{"name":"message_provider_mod_quiz_confirmation_loggedin","value":"email"},{"name":"message_provider_mod_quiz_confirmation_loggedoff","value":"email"},{"name":"message_provider_mod_quiz_submission_loggedin","value":"email"},{"name":"message_provider_mod_quiz_submission_loggedoff","value":"email"},{"name":"message_provider_moodle_availableupdate_loggedin","value":"email"},{"name":"message_provider_moodle_availableupdate_loggedoff","value":"email"},{"name":"message_provider_moodle_backup_loggedin","value":"email"},{"name":"message_provider_moodle_backup_loggedoff","value":"email"},{"name":"message_provider_moodle_badgecreatornotice_loggedin","value":"none"},{"name":"message_provider_moodle_badgecreatornotice_loggedoff","value":"email"},{"name":"message_provider_moodle_badgerecipientnotice_loggedin","value":"popup"},{"name":"message_provider_moodle_badgerecipientnotice_loggedoff","value":"popup,email"},{"name":"message_provider_moodle_courserequestapproved_loggedin","value":"email"},{"name":"message_provider_moodle_courserequestapproved_loggedoff","value":"email"},{"name":"message_provider_moodle_courserequested_loggedin","value":"email"},{"name":"message_provider_moodle_courserequested_loggedoff","value":"email"},{"name":"message_provider_moodle_courserequestrejected_loggedin","value":"email"},{"name":"message_provider_moodle_courserequestrejected_loggedoff","value":"email"},{"name":"message_provider_moodle_errors_loggedin","value":"email"},{"name":"message_provider_moodle_errors_loggedoff","value":"email"},{"name":"message_provider_moodle_instantmessage_loggedin","value":"popup"},{"name":"message_provider_moodle_instantmessage_loggedoff","value":"popup,email"},{"name":"message_provider_moodle_notices_loggedin","value":"email"},{"name":"message_provider_moodle_notices_loggedoff","value":"email"},{"name":"userselector_autoselectunique","value":"0"},{"name":"userselector_optionscollapsed","value":"0"},{"name":"userselector_preserveselected","value":"1"},{"name":"userselector_searchanywhere","value":"0"},{"name":"_lastloaded","value":1435753952}]}],"warnings":[]}'
57
57
  http_version: '1.1'
58
58
  adapter_metadata:
59
- effective_url: http://dev.vle.getsmarter.co.za/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=072556801bf07076fff6bff2a463b7c5
59
+ effective_url: http://my_moodle_instance.com/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=072556801bf07076fff6bff2a463b7c5
60
60
  recorded_at: Wed, 01 Jul 2015 12:32:32 GMT
61
61
  recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=local_getsmarter_get_quiz_grades&wstoken=072556801bf07076fff6bff2a463b7c5&courseid=92
5
+ uri: http://my_moodle_instance.com/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=local_getsmarter_get_quiz_grades&wstoken=072556801bf07076fff6bff2a463b7c5&courseid=92
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -41,6 +41,6 @@ http_interactions:
41
41
  string: "[]"
42
42
  http_version: '1.1'
43
43
  adapter_metadata:
44
- effective_url: http://dev.vle.getsmarter.co.za/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=local_getsmarter_get_quiz_grades&wstoken=072556801bf07076fff6bff2a463b7c5&courseid=92
44
+ effective_url: http://my_moodle_instance.com/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=local_getsmarter_get_quiz_grades&wstoken=072556801bf07076fff6bff2a463b7c5&courseid=92
45
45
  recorded_at: Thu, 02 Jul 2015 07:10:48 GMT
46
46
  recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=072556801bf07076fff6bff2a463b7c5
5
+ uri: http://my_moodle_instance.com/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=072556801bf07076fff6bff2a463b7c5
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -54,6 +54,6 @@ http_interactions:
54
54
  Plugins > Web services > External services and Manage tokens."}'
55
55
  http_version: '1.1'
56
56
  adapter_metadata:
57
- effective_url: http://dev.vle.getsmarter.co.za/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=072556801bf07076fff6bff2a463b7c5
57
+ effective_url: http://my_moodle_instance.com/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=072556801bf07076fff6bff2a463b7c5
58
58
  recorded_at: Wed, 01 Jul 2015 12:44:52 GMT
59
59
  recorded_with: VCR 2.9.3
@@ -0,0 +1,46 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://my_moodle_instance.com/webservice/rest/server.php?enrolments%5B0%5D%5Buserid%5D=11157&enrolments%5B0%5D%5Broleid%5D=5&enrolments%5B0%5D%5Bcourseid%5D=282&moodlewsrestformat=json&wsfunction=enrol_manual_enrol_users&wstoken=mytoken
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Typhoeus - https://github.com/typhoeus/typhoeus
12
+ Accept:
13
+ - json
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Date:
20
+ - Tue, 14 Jul 2015 12:07:53 GMT
21
+ Server:
22
+ - Apache
23
+ Cache-Control:
24
+ - private, must-revalidate, pre-check=0, post-check=0, max-age=0
25
+ Expires:
26
+ - Thu, 01 Jan 1970 00:00:00 GMT
27
+ Pragma:
28
+ - no-cache
29
+ Accept-Ranges:
30
+ - none
31
+ Access-Control-Allow-Origin:
32
+ - "*"
33
+ Vary:
34
+ - Accept-Encoding
35
+ Content-Length:
36
+ - '4'
37
+ Content-Type:
38
+ - application/json
39
+ body:
40
+ encoding: UTF-8
41
+ string: 'null'
42
+ http_version: '1.1'
43
+ adapter_metadata:
44
+ effective_url: http://my_moodle_instance.com/webservice/rest/server.php?enrolments%5B0%5D%5Buserid%5D=11157&enrolments%5B0%5D%5Broleid%5D=5&enrolments%5B0%5D%5Bcourseid%5D=282&moodlewsrestformat=json&wsfunction=enrol_manual_enrol_users&wstoken=mytoken
45
+ recorded_at: Tue, 14 Jul 2015 12:07:55 GMT
46
+ recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=invalidtoken
5
+ uri: http://my_moodle_instance.com/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=invalidtoken
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -42,6 +42,6 @@ http_interactions:
42
42
  token - token not found"}'
43
43
  http_version: '1.1'
44
44
  adapter_metadata:
45
- effective_url: http://dev.vle.getsmarter.co.za/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=invalidtoken
45
+ effective_url: http://my_moodle_instance.com/webservice/rest/server.php?criteria%5B0%5D%5Bkey%5D=firstname&criteria%5B0%5D%5Bvalue%5D=Jon&moodlewsrestformat=json&wsfunction=core_user_get_users&wstoken=invalidtoken
46
46
  recorded_at: Wed, 01 Jul 2015 12:34:04 GMT
47
47
  recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=invalidservice
5
+ uri: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=invalidservice
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -34,6 +34,6 @@ http_interactions:
34
34
  specified in config.php<\/p>","stacktrace":null,"debuginfo":null,"errorcode":"dbconnectionfailed"}'
35
35
  http_version: '1.1'
36
36
  adapter_metadata:
37
- effective_url: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=invalidservice
37
+ effective_url: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=invalidservice
38
38
  recorded_at: Tue, 07 Jul 2015 08:35:14 GMT
39
39
  recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=invalidpassword&service=phoenix_integration
5
+ uri: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=invalidpassword&service=phoenix_integration
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -41,9 +41,9 @@ http_interactions:
41
41
  encoding: UTF-8
42
42
  string: '{"error":"The username was not found in the database","stacktrace":"*
43
43
  line 205 of \/login\/token.php: moodle_exception thrown\n","debuginfo":"\nError
44
- code: usernamenotfound","reproductionlink":"http:\/\/dev.vle.getsmarter.co.za\/"}'
44
+ code: usernamenotfound","reproductionlink":"http:\/\/my_moodle_instance.com\/"}'
45
45
  http_version: '1.1'
46
46
  adapter_metadata:
47
- effective_url: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=invalidpassword&service=phoenix_integration
47
+ effective_url: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=invalidpassword&service=phoenix_integration
48
48
  recorded_at: Tue, 07 Jul 2015 09:07:48 GMT
49
49
  recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=
5
+ uri: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -41,9 +41,9 @@ http_interactions:
41
41
  encoding: UTF-8
42
42
  string: '{"error":"No permission to create web service token for the service
43
43
  .","stacktrace":"* line 187 of \/login\/token.php: moodle_exception thrown\n","debuginfo":"\nError
44
- code: cannotcreatetoken","reproductionlink":"http:\/\/dev.vle.getsmarter.co.za\/"}'
44
+ code: cannotcreatetoken","reproductionlink":"http:\/\/my_moodle_instance.com\/"}'
45
45
  http_version: '1.1'
46
46
  adapter_metadata:
47
- effective_url: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=
47
+ effective_url: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=
48
48
  recorded_at: Fri, 03 Jul 2015 11:39:25 GMT
49
49
  recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=invalidservice
5
+ uri: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=invalidservice
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -40,9 +40,9 @@ http_interactions:
40
40
  body:
41
41
  encoding: UTF-8
42
42
  string: '{"error":"Web service is not available (it doesn''t exist or might be disabled)","stacktrace":"* line 86 of \/login\/token.php: moodle_exception
43
- thrown\n","debuginfo":"\nError code: servicenotavailable","reproductionlink":"http:\/\/dev.vle.getsmarter.co.za\/"}'
43
+ thrown\n","debuginfo":"\nError code: servicenotavailable","reproductionlink":"http:\/\/my_moodle_instance.com\/"}'
44
44
  http_version: '1.1'
45
45
  adapter_metadata:
46
- effective_url: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=invalidservice
46
+ effective_url: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=invalidservice
47
47
  recorded_at: Tue, 07 Jul 2015 09:02:43 GMT
48
48
  recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=phoenix_integration&service=
5
+ uri: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=phoenix_integration&service=
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -41,9 +41,9 @@ http_interactions:
41
41
  encoding: UTF-8
42
42
  string: '{"error":"The username was not found in the database","stacktrace":"*
43
43
  line 205 of \/login\/token.php: moodle_exception thrown\n","debuginfo":"\nError
44
- code: usernamenotfound","reproductionlink":"http:\/\/dev.vle.getsmarter.co.za\/"}'
44
+ code: usernamenotfound","reproductionlink":"http:\/\/my_moodle_instance.com\/"}'
45
45
  http_version: '1.1'
46
46
  adapter_metadata:
47
- effective_url: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=phoenix_integration&service=
47
+ effective_url: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=phoenix_integration&service=
48
48
  recorded_at: Fri, 03 Jul 2015 11:38:14 GMT
49
49
  recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/login/token.php?username=invalidusername&password=mypassword&service=phoenix_integration
5
+ uri: http://my_moodle_instance.com/login/token.php?username=invalidusername&password=mypassword&service=phoenix_integration
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -41,9 +41,9 @@ http_interactions:
41
41
  encoding: UTF-8
42
42
  string: '{"error":"The username was not found in the database","stacktrace":"*
43
43
  line 205 of \/login\/token.php: moodle_exception thrown\n","debuginfo":"\nError
44
- code: usernamenotfound","reproductionlink":"http:\/\/dev.vle.getsmarter.co.za\/"}'
44
+ code: usernamenotfound","reproductionlink":"http:\/\/my_moodle_instance.com\/"}'
45
45
  http_version: '1.1'
46
46
  adapter_metadata:
47
- effective_url: http://dev.vle.getsmarter.co.za/login/token.php?username=invalidusername&password=mypassword&service=phoenix_integration
47
+ effective_url: http://my_moodle_instance.com/login/token.php?username=invalidusername&password=mypassword&service=phoenix_integration
48
48
  recorded_at: Tue, 07 Jul 2015 09:06:32 GMT
49
49
  recorded_with: VCR 2.9.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=phoenix_integration
5
+ uri: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=phoenix_integration
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -42,6 +42,6 @@ http_interactions:
42
42
  string: '{"token":"072556801bf07076fff6bff2a463b7c5"}'
43
43
  http_version: '1.1'
44
44
  adapter_metadata:
45
- effective_url: http://dev.vle.getsmarter.co.za/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=phoenix_integration
45
+ effective_url: http://my_moodle_instance.com/login/token.php?username=ryan.mes%40email.co.za&password=mypassword&service=phoenix_integration
46
46
  recorded_at: Fri, 03 Jul 2015 11:41:10 GMT
47
47
  recorded_with: VCR 2.9.3
@@ -37,8 +37,13 @@ module Moodle
37
37
  response_body.is_a?(Hash) && response_body['error']
38
38
  end
39
39
 
40
+ # API calls that return null are considered successful
40
41
  def response_body
41
- JSON.parse(response.body)
42
+ begin
43
+ JSON.parse(response.body)
44
+ rescue JSON::ParserError => e
45
+ response.body
46
+ end
42
47
  end
43
48
  end
44
49
  end
@@ -1,5 +1,5 @@
1
1
  module Moodle
2
2
  module Api
3
- VERSION = "1.2"
3
+ VERSION = "1.3"
4
4
  end
5
5
  end
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'guard-rspec'
34
34
  spec.add_development_dependency 'pry'
35
35
  spec.add_development_dependency 'vcr'
36
+ spec.add_development_dependency 'codeclimate-test-reporter'
36
37
 
37
38
  spec.add_dependency 'typhoeus'
38
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moodle-api
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan-Neal Mes
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: codeclimate-test-reporter
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: typhoeus
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -118,6 +132,7 @@ files:
118
132
  - ".gitignore"
119
133
  - ".rspec"
120
134
  - ".ruby-version"
135
+ - ".travis.yml"
121
136
  - Gemfile
122
137
  - Guardfile
123
138
  - LICENSE.txt
@@ -130,6 +145,7 @@ files:
130
145
  - fixtures/vcr_cassettes/external_service/valid_service.yml
131
146
  - fixtures/vcr_cassettes/external_service/valid_service_empty_array_response.yml
132
147
  - fixtures/vcr_cassettes/external_service/valid_service_not_external.yml
148
+ - fixtures/vcr_cassettes/external_service/valid_service_returning_null.yml
133
149
  - fixtures/vcr_cassettes/external_service/valid_service_with_invalid_token.yml
134
150
  - fixtures/vcr_cassettes/token_service/error_invalid_service_token_service.yml
135
151
  - fixtures/vcr_cassettes/token_service/invalid_password_token_service.yml