webuntis 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -3
- data/lib/webuntis.rb +107 -3
- data/lib/webuntis/version.rb +1 -1
- metadata +9 -9
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# WebUntis
|
2
2
|
|
3
|
-
|
3
|
+
This gem makes calls to the [WebUntis][wu] JSON-RPC API.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,18 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
Using it should be quite easy. For example, to print a list of all active
|
22
|
+
teachers, you just do this:
|
23
|
+
|
24
|
+
``` ruby
|
25
|
+
require "webuntis"
|
26
|
+
|
27
|
+
wu = WebUntis.new("demo_inf", "student", "", server="demo.webuntis.com")
|
28
|
+
wu.authorize
|
29
|
+
wu.teachers.each do |teacher|
|
30
|
+
puts teacher["longName"] if teacher["active"]
|
31
|
+
end
|
32
|
+
```
|
22
33
|
|
23
34
|
## Contributing
|
24
35
|
|
@@ -27,3 +38,5 @@ TODO: Write usage instructions here
|
|
27
38
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
39
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
40
|
5. Create a new Pull Request
|
41
|
+
|
42
|
+
[wu]: http://www.grupet.at/en/produkte/webuntis/uebersicht_webuntis.php
|
data/lib/webuntis.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require "webuntis/version"
|
2
2
|
require "httparty"
|
3
3
|
require "securerandom"
|
4
|
-
require "pp"
|
5
4
|
|
6
5
|
class WebUntis
|
7
6
|
include HTTParty # http://www.youtube.com/watch?v=6Zbi0XmGtMw
|
@@ -20,8 +19,7 @@ class WebUntis
|
|
20
19
|
# @param school [String] The school name (e.g. htl-stp)
|
21
20
|
# @param user [String] The user name
|
22
21
|
# @param password [String] The user's password
|
23
|
-
# @param server [String] The server to use, without +/WebUntis+ (e.g.
|
24
|
-
# demo.webuntis.com).
|
22
|
+
# @param server [String] The server to use, without +/WebUntis+ (e.g. demo.webuntis.com).
|
25
23
|
def initialize(school, user, password, server="demo.webuntis.com")
|
26
24
|
@school = school
|
27
25
|
@user = user
|
@@ -42,6 +40,112 @@ class WebUntis
|
|
42
40
|
alias authorize authenticate
|
43
41
|
alias login authenticate
|
44
42
|
|
43
|
+
# Gets a list of teachers. Requires Authentication.
|
44
|
+
# @return [Array] Array of hashes.
|
45
|
+
def teachers()
|
46
|
+
require_authentication!
|
47
|
+
options = make_options("getTeachers")
|
48
|
+
response = self.class.post("/WebUntis/jsonrpc.do;jsessionid=#{@session_id}?school=#{@school}", options)
|
49
|
+
raise response["error"]["message"] unless response["error"].nil?
|
50
|
+
response["result"]
|
51
|
+
end
|
52
|
+
|
53
|
+
# Gets a list of classes for the school year with ID +schoolyear+.
|
54
|
+
# @param schoolyear [Integer] The ID of the school year, whatever that could be. Defaults to +nil+ (current schoolyear)
|
55
|
+
# @return [Array] Array of hashes.
|
56
|
+
def classes(schoolyear=nil)
|
57
|
+
require_authentication!
|
58
|
+
options = make_options("getKlassen", (schoolyear.nil? ? {} : {schoolyear: schoolyear}))
|
59
|
+
response = self.class.post("/WebUntis/jsonrpc.do;jsessionid=#{@session_id}?school=#{@school}", options)
|
60
|
+
raise response["error"]["message"] unless response["error"].nil?
|
61
|
+
response["result"]
|
62
|
+
end
|
63
|
+
alias klassen classes
|
64
|
+
|
65
|
+
# Gets a list of subjects.
|
66
|
+
# @return [Array] Array of hashes.
|
67
|
+
def subjects()
|
68
|
+
require_authentication!
|
69
|
+
options = make_options("getSubjects")
|
70
|
+
response = self.class.post("/WebUntis/jsonrpc.do;jsessionid=#{@session_id}?school=#{@school}", options)
|
71
|
+
raise response["error"]["message"] unless response["error"].nil?
|
72
|
+
response["result"]
|
73
|
+
end
|
74
|
+
|
75
|
+
# Gets a list of rooms.
|
76
|
+
# @return [Array] Array of hashes.
|
77
|
+
def rooms()
|
78
|
+
require_authentication!
|
79
|
+
options = make_options("getRooms")
|
80
|
+
response = self.class.post("/WebUntis/jsonrpc.do;jsessionid=#{@session_id}?school=#{@school}", options)
|
81
|
+
raise response["error"]["message"] unless response["error"].nil?
|
82
|
+
response["result"]
|
83
|
+
end
|
84
|
+
|
85
|
+
# Gets a list of departments.
|
86
|
+
# @return [Array] Array of hashes.
|
87
|
+
def departments()
|
88
|
+
require_authentication!
|
89
|
+
options = make_options("getDepartments")
|
90
|
+
response = self.class.post("/WebUntis/jsonrpc.do;jsessionid=#{@session_id}?school=#{@school}", options)
|
91
|
+
raise response["error"]["message"] unless response["error"].nil?
|
92
|
+
response["result"]
|
93
|
+
end
|
94
|
+
|
95
|
+
# Gets a list of holidays.
|
96
|
+
# Dates are stored as an integer in the format yyyymmdd (e.g. 20141026)
|
97
|
+
# @return [Array] Array of hashes.
|
98
|
+
def holidays()
|
99
|
+
require_authentication!
|
100
|
+
options = make_options("getHolidays")
|
101
|
+
response = self.class.post("/WebUntis/jsonrpc.do;jsessionid=#{@session_id}?school=#{@school}", options)
|
102
|
+
raise response["error"]["message"] unless response["error"].nil?
|
103
|
+
response["result"]
|
104
|
+
end
|
105
|
+
|
106
|
+
# Gets the timegrid units.
|
107
|
+
# Times are stored as an integer in the format hhmm (e.g. 750, 1030)
|
108
|
+
# @return [Array] Array of hashes.
|
109
|
+
def timegrid()
|
110
|
+
require_authentication!
|
111
|
+
options = make_options("getTimegridUnits")
|
112
|
+
response = self.class.post("/WebUntis/jsonrpc.do;jsessionid=#{@session_id}?school=#{@school}", options)
|
113
|
+
raise response["error"]["message"] unless response["error"].nil?
|
114
|
+
response["result"]
|
115
|
+
end
|
116
|
+
|
117
|
+
# Gets information about lesson types, period codes and their colours.
|
118
|
+
# Lession types (lstypes): +ls+: lesson; +oh+: office hour; +sb+: standby;
|
119
|
+
# +bs+: break supervision; +ex+: examination
|
120
|
+
# @return [Array] Array of hashes.
|
121
|
+
def status_data()
|
122
|
+
require_authentication!
|
123
|
+
options = make_options("getStatusData")
|
124
|
+
response = self.class.post("/WebUntis/jsonrpc.do;jsessionid=#{@session_id}?school=#{@school}", options)
|
125
|
+
raise response["error"]["message"] unless response["error"].nil?
|
126
|
+
response["result"]
|
127
|
+
end
|
128
|
+
|
129
|
+
# Gets the current school year.
|
130
|
+
# @return [Hash] The current school year object as a hash.
|
131
|
+
def current_schoolyear()
|
132
|
+
require_authentication!
|
133
|
+
options = make_options("getCurrentSchoolyear")
|
134
|
+
response = self.class.post("/WebUntis/jsonrpc.do;jsessionid=#{@session_id}?school=#{@school}", options)
|
135
|
+
raise response["error"]["message"] unless response["error"].nil?
|
136
|
+
response["result"]
|
137
|
+
end
|
138
|
+
|
139
|
+
# Gets all available school years.
|
140
|
+
# @return [Array] Array of hashes.
|
141
|
+
def schoolyears()
|
142
|
+
require_authentication!
|
143
|
+
options = make_options("getSchoolyears")
|
144
|
+
response = self.class.post("/WebUntis/jsonrpc.do;jsessionid=#{@session_id}?school=#{@school}", options)
|
145
|
+
raise response["error"]["message"] unless response["error"].nil?
|
146
|
+
response["result"]
|
147
|
+
end
|
148
|
+
|
45
149
|
# Ends the session. Requires Authentication.
|
46
150
|
def logout()
|
47
151
|
require_authentication!
|
data/lib/webuntis/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webuntis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '0'
|
38
38
|
type: :development
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
type: :development
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
@@ -103,18 +103,18 @@ require_paths:
|
|
103
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
104
|
none: false
|
105
105
|
requirements:
|
106
|
-
- -
|
106
|
+
- - '>='
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
110
|
none: false
|
111
111
|
requirements:
|
112
|
-
- -
|
112
|
+
- - '>='
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 1.8.
|
117
|
+
rubygems_version: 1.8.29
|
118
118
|
signing_key:
|
119
119
|
specification_version: 3
|
120
120
|
summary: Makes calls to the WebUntis API.
|