moodle_rb 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,11 +3,12 @@ module MoodleRb
3
3
  include HTTParty
4
4
  include Utility
5
5
 
6
- attr_reader :token
6
+ attr_reader :token, :query_options
7
7
  ROOT_CATEGORY = 0
8
8
 
9
- def initialize(token, url)
9
+ def initialize(token, url, query_options)
10
10
  @token = token
11
+ @query_options = query_options
11
12
  self.class.base_uri url
12
13
  end
13
14
 
@@ -16,7 +17,7 @@ module MoodleRb
16
17
  '/webservice/rest/server.php',
17
18
  {
18
19
  :query => query_hash('core_course_get_categories', token)
19
- }
20
+ }.merge(query_options)
20
21
  )
21
22
  check_for_errors(response)
22
23
  response.parsed_response
@@ -47,7 +48,7 @@ module MoodleRb
47
48
  }
48
49
  }
49
50
  }
50
- }
51
+ }.merge(query_options)
51
52
  )
52
53
  check_for_errors(response)
53
54
  response.parsed_response.first
@@ -66,7 +67,7 @@ module MoodleRb
66
67
  }
67
68
  }
68
69
  }
69
- }
70
+ }.merge(query_options)
70
71
  )
71
72
  check_for_errors(response)
72
73
  response.parsed_response.first
@@ -85,7 +86,7 @@ module MoodleRb
85
86
  }
86
87
  }
87
88
  }
88
- }
89
+ }.merge(query_options)
89
90
  )
90
91
  check_for_errors(response)
91
92
  response.parsed_response.nil?
@@ -3,11 +3,12 @@ module MoodleRb
3
3
  include HTTParty
4
4
  include Utility
5
5
 
6
- attr_reader :token, :url
6
+ attr_reader :token, :url, :query_options
7
7
 
8
- def initialize(token, url)
8
+ def initialize(token, url, query_options)
9
9
  @token = token
10
10
  @url = url
11
+ @query_options = query_options
11
12
  self.class.base_uri url
12
13
  end
13
14
 
@@ -16,30 +17,30 @@ module MoodleRb
16
17
  '/webservice/rest/server.php',
17
18
  {
18
19
  :query => query_hash('core_webservice_get_site_info', token)
19
- }
20
+ }.merge(query_options)
20
21
  )
21
22
  check_for_errors(response)
22
23
  response.parsed_response
23
24
  end
24
25
 
25
26
  def courses
26
- MoodleRb::Courses.new(token, url)
27
+ MoodleRb::Courses.new(token, url, query_options)
27
28
  end
28
29
 
29
30
  def categories
30
- MoodleRb::Categories.new(token, url)
31
+ MoodleRb::Categories.new(token, url, query_options)
31
32
  end
32
33
 
33
34
  def users
34
- MoodleRb::Users.new(token, url)
35
+ MoodleRb::Users.new(token, url, query_options)
35
36
  end
36
37
 
37
38
  def enrolments
38
- MoodleRb::Enrolments.new(token, url)
39
+ MoodleRb::Enrolments.new(token, url, query_options)
39
40
  end
40
41
 
41
42
  def grades
42
- MoodleRb::Grades.new(token, url)
43
+ MoodleRb::Grades.new(token, url, query_options)
43
44
  end
44
45
  end
45
46
  end
@@ -3,10 +3,11 @@ module MoodleRb
3
3
  include HTTParty
4
4
  include Utility
5
5
 
6
- attr_reader :token
6
+ attr_reader :token, :query_options
7
7
 
8
- def initialize(token, url)
8
+ def initialize(token, url, query_options)
9
9
  @token = token
10
+ @query_options = query_options
10
11
  self.class.base_uri url
11
12
  end
12
13
 
@@ -15,7 +16,7 @@ module MoodleRb
15
16
  '/webservice/rest/server.php',
16
17
  {
17
18
  :query => query_hash('core_course_get_courses', token)
18
- }
19
+ }.merge(query_options)
19
20
  )
20
21
  check_for_errors(response)
21
22
  response.parsed_response
@@ -45,7 +46,7 @@ module MoodleRb
45
46
  }
46
47
  }
47
48
  }
48
- }
49
+ }.merge(query_options)
49
50
  )
50
51
  check_for_errors(response)
51
52
  response.parsed_response.first
@@ -63,7 +64,7 @@ module MoodleRb
63
64
  }
64
65
  }
65
66
  }
66
- }
67
+ }.merge(query_options)
67
68
  )
68
69
  check_for_errors(response)
69
70
  response.parsed_response.first
@@ -79,7 +80,7 @@ module MoodleRb
79
80
  '0' => id
80
81
  }
81
82
  }
82
- }
83
+ }.merge(query_options)
83
84
  )
84
85
  check_for_errors(response)
85
86
  response.parsed_response
@@ -93,7 +94,7 @@ module MoodleRb
93
94
  :body => {
94
95
  :courseid => course_id
95
96
  }
96
- }
97
+ }.merge(query_options)
97
98
  )
98
99
  check_for_errors(response)
99
100
  response.parsed_response
@@ -3,11 +3,12 @@ module MoodleRb
3
3
  include HTTParty
4
4
  include Utility
5
5
 
6
- attr_reader :token
6
+ attr_reader :token, :query_options
7
7
  STUDENT_ROLE_ID = 5
8
8
 
9
- def initialize(token, url)
9
+ def initialize(token, url, query_options)
10
10
  @token = token
11
+ @query_options = query_options
11
12
  self.class.base_uri url
12
13
  end
13
14
 
@@ -27,7 +28,7 @@ module MoodleRb
27
28
  }
28
29
  }
29
30
  }
30
- }
31
+ }.merge(query_options)
31
32
  )
32
33
  check_for_errors(response)
33
34
  response.code == 200 && response.parsed_response.nil?
@@ -3,10 +3,11 @@ module MoodleRb
3
3
  include HTTParty
4
4
  include Utility
5
5
 
6
- attr_reader :token
6
+ attr_reader :token, :query_options
7
7
 
8
- def initialize(token, url)
8
+ def initialize(token, url, query_options)
9
9
  @token = token
10
+ @query_options = query_options
10
11
  self.class.base_uri url
11
12
  end
12
13
 
@@ -18,7 +19,7 @@ module MoodleRb
18
19
  :body => {
19
20
  :assignmentids => api_array(assignment_id)
20
21
  }
21
- }
22
+ }.merge(query_options)
22
23
  )
23
24
  check_for_errors(response)
24
25
  response.parsed_response['assignments']
@@ -33,7 +34,7 @@ module MoodleRb
33
34
  :courseid => course_id,
34
35
  :userids => api_array(user_ids)
35
36
  }
36
- }
37
+ }.merge(query_options)
37
38
  )
38
39
  check_for_errors(response)
39
40
  response.parsed_response['items']
@@ -3,10 +3,11 @@ module MoodleRb
3
3
  include HTTParty
4
4
  include Utility
5
5
 
6
- attr_reader :token
6
+ attr_reader :token, :query_options
7
7
 
8
- def initialize(token, url)
8
+ def initialize(token, url, query_options)
9
9
  @token = token
10
+ @query_options = query_options
10
11
  self.class.base_uri url
11
12
  end
12
13
 
@@ -25,7 +26,7 @@ module MoodleRb
25
26
  '0' => params
26
27
  }
27
28
  }
28
- }
29
+ }.merge(query_options)
29
30
  )
30
31
  check_for_errors(response)
31
32
  response.parsed_response.first
@@ -44,7 +45,7 @@ module MoodleRb
44
45
  }
45
46
  }
46
47
  }
47
- }
48
+ }.merge(query_options)
48
49
  )
49
50
  check_for_errors(response)
50
51
  response.parsed_response['users'] &&
@@ -61,7 +62,7 @@ module MoodleRb
61
62
  '0' => id
62
63
  }
63
64
  }
64
- }
65
+ }.merge(query_options)
65
66
  )
66
67
  check_for_errors(response)
67
68
  response.parsed_response.nil?
@@ -75,7 +76,7 @@ module MoodleRb
75
76
  :body => {
76
77
  :userid => user_id
77
78
  }
78
- }
79
+ }.merge(query_options)
79
80
  )
80
81
  check_for_errors(response)
81
82
  response.parsed_response
@@ -91,7 +92,7 @@ module MoodleRb
91
92
  :body => {
92
93
  :criteria => key_value_query_format(params)
93
94
  }
94
- }
95
+ }.merge(query_options)
95
96
  )
96
97
  check_for_errors(response)
97
98
  response.parsed_response['users']
@@ -110,7 +111,7 @@ module MoodleRb
110
111
  '0' => params
111
112
  }
112
113
  }
113
- }
114
+ }.merge(query_options)
114
115
  )
115
116
  check_for_errors(response)
116
117
  response.response.code == '200'
@@ -1,5 +1,5 @@
1
1
  module MoodleRb
2
- VERSION = '1.0.3' unless defined?(self::VERSION)
2
+ VERSION = '1.0.4' unless defined?(self::VERSION)
3
3
 
4
4
  def self.version
5
5
  VERSION
data/lib/moodle_rb.rb CHANGED
@@ -10,7 +10,7 @@ require 'moodle_rb/grades'
10
10
  require 'moodle_rb/users'
11
11
 
12
12
  module MoodleRb
13
- def self.new(token, url)
14
- Client.new(token, url)
13
+ def self.new(token, url, query_options = {})
14
+ Client.new(token, url, query_options)
15
15
  end
16
16
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moodle_rb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 3
10
- version: 1.0.3
9
+ - 4
10
+ version: 1.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sam Giffney
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2016-06-21 00:00:00 Z
18
+ date: 2017-04-10 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: bundler