bright 0.2.0 → 1.0
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.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/bright.gemspec +3 -3
- data/lib/bright/address.rb +6 -8
- data/lib/bright/connection.rb +49 -42
- data/lib/bright/contact.rb +53 -0
- data/lib/bright/cursor_response_collection.rb +45 -0
- data/lib/bright/errors.rb +13 -3
- data/lib/bright/helpers/boolean_parser_helper.rb +13 -0
- data/lib/bright/phone_number.rb +14 -2
- data/lib/bright/response_collection.rb +7 -7
- data/lib/bright/sis_apis/aeries.rb +34 -33
- data/lib/bright/sis_apis/base.rb +31 -5
- data/lib/bright/sis_apis/bright_sis.rb +70 -16
- data/lib/bright/sis_apis/infinite_campus.rb +254 -36
- data/lib/bright/sis_apis/power_school.rb +107 -66
- data/lib/bright/sis_apis/skyward.rb +276 -0
- data/lib/bright/sis_apis/tsis.rb +42 -40
- data/lib/bright/student.rb +27 -1
- data/lib/bright/version.rb +1 -1
- data/lib/bright.rb +8 -1
- metadata +17 -14
data/lib/bright/sis_apis/tsis.rb
CHANGED
@@ -5,12 +5,12 @@ module Bright
|
|
5
5
|
module SisApi
|
6
6
|
class TSIS < Base
|
7
7
|
DATE_FORMAT = '%m/%d/%Y'
|
8
|
-
|
8
|
+
|
9
9
|
@@description = "Connects to the TIES API for accessing TIES TSIS student information"
|
10
10
|
@@doc_url = "#unkown"
|
11
|
-
|
11
|
+
|
12
12
|
attr_accessor :connection_options
|
13
|
-
|
13
|
+
|
14
14
|
def initialize(options = {})
|
15
15
|
self.connection_options = options[:connection] || {}
|
16
16
|
# {
|
@@ -20,17 +20,17 @@ module Bright
|
|
20
20
|
# :uri => ""
|
21
21
|
# }
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def get_student_by_api_id(api_id, params = {})
|
25
25
|
self.get_student(params.merge({:sis_student_id => api_id}))
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def get_student(params = {}, options = {})
|
29
29
|
params = self.apply_options(params, options.merge({:per_page => 1}))
|
30
30
|
|
31
31
|
# Students only gets you students that are enrolled in a school for a given school year.
|
32
32
|
students_response_hash = self.request(:get, 'Students/', self.map_search_params(params))
|
33
|
-
found_student = nil
|
33
|
+
found_student = nil
|
34
34
|
if students_response_hash["Return"] and students_response_hash["Return"].first
|
35
35
|
found_student = Student.new(convert_to_student_data(students_response_hash["Return"].first))
|
36
36
|
end
|
@@ -43,10 +43,10 @@ module Bright
|
|
43
43
|
end
|
44
44
|
found_student
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
def get_students(params = {}, options = {})
|
48
48
|
params = self.apply_options(params, options)
|
49
|
-
|
49
|
+
|
50
50
|
if params[:schoolyear]
|
51
51
|
# Students only gets you students that are enrolled in a school for a given school year.
|
52
52
|
response_hash = self.request(:get, self.apply_page_to_url('Students/', options[:page]), self.map_search_params(params))
|
@@ -54,10 +54,10 @@ module Bright
|
|
54
54
|
# Students/Family can get you students that are not enrolled in a school for a given school year.
|
55
55
|
response_hash = self.request(:get, self.apply_page_to_url('Students/Family/', options[:page]), self.map_search_params(params))
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
students = response_hash["Return"].collect{|hsh| Student.new(convert_to_student_data(hsh))}
|
59
59
|
total_results = response_hash["TotalCount"].to_i
|
60
|
-
|
60
|
+
|
61
61
|
if options[:wrap_in_collection] != false
|
62
62
|
api = self
|
63
63
|
load_more_call = proc { |page|
|
@@ -66,24 +66,24 @@ module Bright
|
|
66
66
|
}
|
67
67
|
|
68
68
|
ResponseCollection.new({
|
69
|
-
:seed_page => students,
|
69
|
+
:seed_page => students,
|
70
70
|
:total => total_results,
|
71
|
-
:per_page => options[:per_page],
|
71
|
+
:per_page => options[:per_page],
|
72
72
|
:load_more_call => load_more_call
|
73
73
|
})
|
74
74
|
else
|
75
75
|
students
|
76
76
|
end
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
def create_student(student)
|
80
80
|
raise NotImplementedError, "TSIS does not support creating students"
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
def update_student(student)
|
84
84
|
raise NotImplementedError, "TSIS does not support updating students"
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
def get_schools(params = {}, options = {})
|
88
88
|
params = self.apply_options(params, options)
|
89
89
|
|
@@ -110,7 +110,7 @@ module Bright
|
|
110
110
|
schools
|
111
111
|
end
|
112
112
|
end
|
113
|
-
|
113
|
+
|
114
114
|
def request(method, path, params = {})
|
115
115
|
uri = "#{self.connection_options[:uri]}/#{path}"
|
116
116
|
body = nil
|
@@ -120,22 +120,24 @@ module Bright
|
|
120
120
|
else
|
121
121
|
body = query
|
122
122
|
end
|
123
|
-
|
124
|
-
headers = self.headers_for_auth(uri)
|
125
123
|
|
126
|
-
|
127
|
-
|
124
|
+
response = connection_retry_wrapper {
|
125
|
+
connection = Bright::Connection.new(uri)
|
126
|
+
headers = self.headers_for_auth
|
127
|
+
connection.request(method, body, headers)
|
128
|
+
}
|
129
|
+
|
128
130
|
if !response.error?
|
129
131
|
response_hash = JSON.parse(response.body)
|
130
132
|
end
|
131
133
|
response_hash
|
132
134
|
end
|
133
|
-
|
135
|
+
|
134
136
|
protected
|
135
|
-
|
137
|
+
|
136
138
|
def map_search_params(params)
|
137
139
|
params = params.dup
|
138
|
-
|
140
|
+
|
139
141
|
params["studentname"] = params.delete(:name)
|
140
142
|
params["studentname"] ||= "#{params.delete(:last_name)}, #{params.delete(:first_name)} #{params.delete(:middle_name)}".strip
|
141
143
|
params["studentids"] = params.delete(:sis_student_id)
|
@@ -147,10 +149,10 @@ module Bright
|
|
147
149
|
k = k.to_s.gsub(/[^A-Za-z]/, "").downcase
|
148
150
|
[k,v]
|
149
151
|
end]
|
150
|
-
|
152
|
+
|
151
153
|
params.reject{|k,v| v.respond_to?(:empty?) ? v.empty? : v.nil?}
|
152
154
|
end
|
153
|
-
|
155
|
+
|
154
156
|
def convert_to_student_data(attrs)
|
155
157
|
catt = {}
|
156
158
|
if attrs["StudentName"]
|
@@ -170,7 +172,7 @@ module Bright
|
|
170
172
|
catt[:middle_name] = attrs["MiddleName"].strip
|
171
173
|
catt[:last_name] = (attrs["LastName"] || attrs["SurName"]).strip
|
172
174
|
end
|
173
|
-
|
175
|
+
|
174
176
|
catt[:state_student_id] = (attrs["StateId"] || attrs["StudentStateId"]).to_s
|
175
177
|
catt[:sis_student_id] = attrs["StudentId"].to_s
|
176
178
|
catt[:api_id] = attrs["StudentId"].to_s
|
@@ -180,18 +182,18 @@ module Bright
|
|
180
182
|
|
181
183
|
bd = attrs["BirthDate"] || attrs["StudentBirthDate"]
|
182
184
|
if !(bd.nil? or bd.empty?)
|
183
|
-
begin
|
185
|
+
begin
|
184
186
|
catt[:birth_date] = Date.strptime(bd, DATE_FORMAT)
|
185
187
|
rescue => e
|
186
188
|
puts "#{e.inspect} #{bd}"
|
187
189
|
end
|
188
190
|
end
|
189
|
-
|
191
|
+
|
190
192
|
catt[:addresses] = [self.convert_to_address_data(attrs["Address"])] if attrs["Address"]
|
191
|
-
|
193
|
+
|
192
194
|
catt.reject{|k,v| v.respond_to?(:empty?) ? v.empty? : v.nil?}
|
193
195
|
end
|
194
|
-
|
196
|
+
|
195
197
|
def convert_to_address_data(attrs)
|
196
198
|
cattrs = {}
|
197
199
|
|
@@ -204,38 +206,38 @@ module Bright
|
|
204
206
|
cattrs[:state] = attrs["State"]
|
205
207
|
cattrs[:postal_code] = attrs["Zip"]
|
206
208
|
cattrs[:type] = attrs["Type"].to_s.downcase
|
207
|
-
|
209
|
+
|
208
210
|
cattrs.reject{|k,v| v.respond_to?(:empty?) ? v.empty? : v.nil?}
|
209
211
|
end
|
210
|
-
|
212
|
+
|
211
213
|
def convert_to_school_data(attrs)
|
212
214
|
cattrs = {}
|
213
|
-
|
215
|
+
|
214
216
|
cattrs[:name] = attrs["Name"]
|
215
217
|
cattrs[:api_id] = cattrs[:number] = attrs["SchoolId"]
|
216
218
|
cattrs[:address] = convert_to_address_data(attrs)
|
217
|
-
|
219
|
+
|
218
220
|
cattrs.reject{|k,v| v.respond_to?(:empty?) ? v.empty? : v.nil?}
|
219
221
|
end
|
220
|
-
|
222
|
+
|
221
223
|
def apply_options(params, options)
|
222
224
|
options[:per_page] = params[:rpp] ||= params.delete(:per_page) || options[:per_page] || 100
|
223
225
|
options[:page] = params.delete(:page) || options[:page]
|
224
226
|
params[:schoolyear] ||= params.delete(:school_year) || options[:school_year]
|
225
227
|
params
|
226
228
|
end
|
227
|
-
|
229
|
+
|
228
230
|
def apply_page_to_url(url, page)
|
229
231
|
"#{url}#{url[-1] == "/" ? "" : "/"}#{page}"
|
230
232
|
end
|
231
|
-
|
233
|
+
|
232
234
|
def headers_for_auth(uri)
|
233
235
|
t = Time.now.utc.httpdate
|
234
236
|
string_to_sign = "GET\n#{t}\n#{uri}"
|
235
|
-
|
237
|
+
|
236
238
|
signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), self.connection_options[:secret], string_to_sign)).strip
|
237
239
|
authorization = "TIES" + " " + self.connection_options[:key] + ":" + signature
|
238
|
-
|
240
|
+
|
239
241
|
{
|
240
242
|
'Authorization' => authorization,
|
241
243
|
'DistrictNumber' => self.connection_options[:district_id],
|
@@ -245,4 +247,4 @@ module Bright
|
|
245
247
|
end
|
246
248
|
end
|
247
249
|
end
|
248
|
-
end
|
250
|
+
end
|
data/lib/bright/student.rb
CHANGED
@@ -14,7 +14,7 @@ module Bright
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# TODO:: map contact info (addresses, email, phone, etc)
|
17
|
-
attr_accessor :enrollment, :addresses, :email_address, :school
|
17
|
+
attr_accessor :enrollment, :addresses, :email_address, :phone_numbers, :school, :contacts
|
18
18
|
|
19
19
|
def initialize(*args)
|
20
20
|
super
|
@@ -48,6 +48,19 @@ module Bright
|
|
48
48
|
@addresses ||= []
|
49
49
|
end
|
50
50
|
|
51
|
+
def phone_numbers=(array)
|
52
|
+
if array.size <= 0 or array.first.is_a?(PhoneNumber)
|
53
|
+
@phone_numbers = array
|
54
|
+
elsif array.first.is_a?(Hash)
|
55
|
+
@phone_numbers = array.collect{|a| PhoneNumber.new(a)}
|
56
|
+
end
|
57
|
+
@phone_numbers ||= []
|
58
|
+
end
|
59
|
+
|
60
|
+
def phone_numbers
|
61
|
+
@phone_numbers ||= []
|
62
|
+
end
|
63
|
+
|
51
64
|
def email_address=(email)
|
52
65
|
if email.is_a?(EmailAddress)
|
53
66
|
@email_address = email
|
@@ -66,5 +79,18 @@ module Bright
|
|
66
79
|
@school
|
67
80
|
end
|
68
81
|
|
82
|
+
def contacts=(array)
|
83
|
+
if array.size <= 0 or array.first.is_a?(Contact)
|
84
|
+
@contacts = array
|
85
|
+
elsif array.first.is_a?(Hash)
|
86
|
+
@contacts = array.collect{|a| Contact.new(a)}
|
87
|
+
end
|
88
|
+
@contacts ||= []
|
89
|
+
end
|
90
|
+
|
91
|
+
def contacts
|
92
|
+
@contacts ||= []
|
93
|
+
end
|
94
|
+
|
69
95
|
end
|
70
96
|
end
|
data/lib/bright/version.rb
CHANGED
data/lib/bright.rb
CHANGED
@@ -2,6 +2,7 @@ require "bright/version"
|
|
2
2
|
require "bright/errors"
|
3
3
|
|
4
4
|
require "bright/helpers/blank_helper.rb"
|
5
|
+
require "bright/helpers/boolean_parser_helper.rb"
|
5
6
|
|
6
7
|
require "bright/model"
|
7
8
|
require "bright/student"
|
@@ -10,17 +11,23 @@ require "bright/phone_number"
|
|
10
11
|
require "bright/email_address"
|
11
12
|
require "bright/enrollment"
|
12
13
|
require "bright/school"
|
14
|
+
require "bright/contact"
|
15
|
+
|
13
16
|
|
14
17
|
require "bright/connection"
|
15
18
|
require "bright/response_collection"
|
19
|
+
require "bright/cursor_response_collection"
|
16
20
|
|
17
21
|
require "bright/sis_apis/base.rb"
|
18
22
|
require "bright/sis_apis/tsis.rb"
|
19
23
|
require "bright/sis_apis/power_school.rb"
|
20
24
|
require "bright/sis_apis/aeries.rb"
|
21
25
|
require "bright/sis_apis/infinite_campus.rb"
|
26
|
+
require "bright/sis_apis/skyward.rb"
|
22
27
|
require "bright/sis_apis/bright_sis.rb"
|
23
28
|
|
24
29
|
module Bright
|
25
|
-
|
30
|
+
class << self
|
31
|
+
attr_accessor :devmode
|
32
|
+
end
|
26
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bright
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: '1.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arux Software
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpi
|
@@ -56,32 +56,32 @@ dependencies:
|
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.2.10
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.2.10
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 12.3.3
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 12.3.3
|
83
83
|
description: Bright is a simple Student Information System API abstraction library
|
84
|
-
used in and sponsored by
|
84
|
+
used in and sponsored by Arux Software. It is written by Stephen Heuer, Steven Novotny,
|
85
85
|
and contributors. The aim of the project is to abstract as many parts as possible
|
86
86
|
away from the user to offer a consistent interface across all supported Student
|
87
87
|
Information System APIs.
|
@@ -100,10 +100,13 @@ files:
|
|
100
100
|
- lib/bright.rb
|
101
101
|
- lib/bright/address.rb
|
102
102
|
- lib/bright/connection.rb
|
103
|
+
- lib/bright/contact.rb
|
104
|
+
- lib/bright/cursor_response_collection.rb
|
103
105
|
- lib/bright/email_address.rb
|
104
106
|
- lib/bright/enrollment.rb
|
105
107
|
- lib/bright/errors.rb
|
106
108
|
- lib/bright/helpers/blank_helper.rb
|
109
|
+
- lib/bright/helpers/boolean_parser_helper.rb
|
107
110
|
- lib/bright/model.rb
|
108
111
|
- lib/bright/phone_number.rb
|
109
112
|
- lib/bright/response_collection.rb
|
@@ -113,6 +116,7 @@ files:
|
|
113
116
|
- lib/bright/sis_apis/bright_sis.rb
|
114
117
|
- lib/bright/sis_apis/infinite_campus.rb
|
115
118
|
- lib/bright/sis_apis/power_school.rb
|
119
|
+
- lib/bright/sis_apis/skyward.rb
|
116
120
|
- lib/bright/sis_apis/synergy.rb
|
117
121
|
- lib/bright/sis_apis/tsis.rb
|
118
122
|
- lib/bright/student.rb
|
@@ -121,7 +125,7 @@ homepage: ''
|
|
121
125
|
licenses:
|
122
126
|
- MIT
|
123
127
|
metadata: {}
|
124
|
-
post_install_message:
|
128
|
+
post_install_message:
|
125
129
|
rdoc_options: []
|
126
130
|
require_paths:
|
127
131
|
- lib
|
@@ -136,9 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
140
|
- !ruby/object:Gem::Version
|
137
141
|
version: '0'
|
138
142
|
requirements: []
|
139
|
-
|
140
|
-
|
141
|
-
signing_key:
|
143
|
+
rubygems_version: 3.2.3
|
144
|
+
signing_key:
|
142
145
|
specification_version: 4
|
143
146
|
summary: Framework and tools for dealing with Student Information Systems
|
144
147
|
test_files: []
|