bright 0.2.0 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/bright.gemspec +6 -5
- 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/blank_helper.rb +40 -2
- data/lib/bright/helpers/boolean_parser_helper.rb +13 -0
- data/lib/bright/phone_number.rb +14 -2
- data/lib/bright/response_collection.rb +20 -19
- 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 +74 -18
- data/lib/bright/sis_apis/focus.rb +377 -0
- data/lib/bright/sis_apis/infinite_campus.rb +257 -37
- data/lib/bright/sis_apis/power_school.rb +111 -68
- 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 +28 -19
- metadata +33 -15
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
@@ -1,26 +1,35 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative "bright/version"
|
2
|
+
require_relative "bright/errors"
|
3
3
|
|
4
|
-
|
4
|
+
require_relative "bright/helpers/blank_helper.rb"
|
5
|
+
require_relative "bright/helpers/boolean_parser_helper.rb"
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
require_relative "bright/model"
|
8
|
+
require_relative "bright/student"
|
9
|
+
require_relative "bright/address"
|
10
|
+
require_relative "bright/phone_number"
|
11
|
+
require_relative "bright/email_address"
|
12
|
+
require_relative "bright/enrollment"
|
13
|
+
require_relative "bright/school"
|
14
|
+
require_relative "bright/contact"
|
13
15
|
|
14
|
-
require "bright/connection"
|
15
|
-
require "bright/response_collection"
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
require "bright/sis_apis/aeries.rb"
|
21
|
-
require "bright/sis_apis/infinite_campus.rb"
|
22
|
-
require "bright/sis_apis/bright_sis.rb"
|
17
|
+
require_relative "bright/connection"
|
18
|
+
require_relative "bright/response_collection"
|
19
|
+
require_relative "bright/cursor_response_collection"
|
23
20
|
|
24
|
-
|
21
|
+
require_relative "bright/sis_apis/base.rb"
|
22
|
+
require_relative "bright/sis_apis/tsis.rb"
|
23
|
+
require_relative "bright/sis_apis/power_school.rb"
|
24
|
+
require_relative "bright/sis_apis/aeries.rb"
|
25
|
+
require_relative "bright/sis_apis/infinite_campus.rb"
|
26
|
+
require_relative "bright/sis_apis/skyward.rb"
|
27
|
+
require_relative "bright/sis_apis/bright_sis.rb"
|
28
|
+
require_relative "bright/sis_apis/synergy.rb"
|
29
|
+
require_relative "bright/sis_apis/focus.rb"
|
25
30
|
|
31
|
+
module Bright
|
32
|
+
class << self
|
33
|
+
attr_accessor :devmode
|
34
|
+
end
|
26
35
|
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.2'
|
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-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpi
|
@@ -53,40 +53,54 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.5.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: parallel
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
62
|
-
type: :
|
61
|
+
version: '1.2'
|
62
|
+
type: :runtime
|
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: '1.
|
68
|
+
version: '1.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.2.10
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.2.10
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
89
|
+
version: 12.3.3
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
96
|
+
version: 12.3.3
|
83
97
|
description: Bright is a simple Student Information System API abstraction library
|
84
|
-
used in and sponsored by
|
98
|
+
used in and sponsored by Arux Software. It is written by Stephen Heuer, Steven Novotny,
|
85
99
|
and contributors. The aim of the project is to abstract as many parts as possible
|
86
100
|
away from the user to offer a consistent interface across all supported Student
|
87
101
|
Information System APIs.
|
88
102
|
email:
|
89
|
-
-
|
103
|
+
- hello@arux.software
|
90
104
|
executables: []
|
91
105
|
extensions: []
|
92
106
|
extra_rdoc_files: []
|
@@ -100,10 +114,13 @@ files:
|
|
100
114
|
- lib/bright.rb
|
101
115
|
- lib/bright/address.rb
|
102
116
|
- lib/bright/connection.rb
|
117
|
+
- lib/bright/contact.rb
|
118
|
+
- lib/bright/cursor_response_collection.rb
|
103
119
|
- lib/bright/email_address.rb
|
104
120
|
- lib/bright/enrollment.rb
|
105
121
|
- lib/bright/errors.rb
|
106
122
|
- lib/bright/helpers/blank_helper.rb
|
123
|
+
- lib/bright/helpers/boolean_parser_helper.rb
|
107
124
|
- lib/bright/model.rb
|
108
125
|
- lib/bright/phone_number.rb
|
109
126
|
- lib/bright/response_collection.rb
|
@@ -111,8 +128,10 @@ files:
|
|
111
128
|
- lib/bright/sis_apis/aeries.rb
|
112
129
|
- lib/bright/sis_apis/base.rb
|
113
130
|
- lib/bright/sis_apis/bright_sis.rb
|
131
|
+
- lib/bright/sis_apis/focus.rb
|
114
132
|
- lib/bright/sis_apis/infinite_campus.rb
|
115
133
|
- lib/bright/sis_apis/power_school.rb
|
134
|
+
- lib/bright/sis_apis/skyward.rb
|
116
135
|
- lib/bright/sis_apis/synergy.rb
|
117
136
|
- lib/bright/sis_apis/tsis.rb
|
118
137
|
- lib/bright/student.rb
|
@@ -121,7 +140,7 @@ homepage: ''
|
|
121
140
|
licenses:
|
122
141
|
- MIT
|
123
142
|
metadata: {}
|
124
|
-
post_install_message:
|
143
|
+
post_install_message:
|
125
144
|
rdoc_options: []
|
126
145
|
require_paths:
|
127
146
|
- lib
|
@@ -136,9 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
155
|
- !ruby/object:Gem::Version
|
137
156
|
version: '0'
|
138
157
|
requirements: []
|
139
|
-
|
140
|
-
|
141
|
-
signing_key:
|
158
|
+
rubygems_version: 3.3.7
|
159
|
+
signing_key:
|
142
160
|
specification_version: 4
|
143
161
|
summary: Framework and tools for dealing with Student Information Systems
|
144
162
|
test_files: []
|