bright 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.txt +1 -1
- data/bright.gemspec +3 -2
- data/lib/bright.rb +6 -0
- data/lib/bright/connection.rb +4 -3
- data/lib/bright/email_address.rb +7 -0
- data/lib/bright/helpers/blank_helper.rb +17 -0
- data/lib/bright/phone_number.rb +8 -0
- data/lib/bright/school.rb +13 -4
- data/lib/bright/sis_apis/aeries.rb +2 -2
- data/lib/bright/sis_apis/bright_sis.rb +249 -0
- data/lib/bright/sis_apis/infinite_campus.rb +154 -16
- data/lib/bright/sis_apis/power_school.rb +1 -1
- data/lib/bright/sis_apis/synergy.rb +2 -2
- data/lib/bright/sis_apis/tsis.rb +2 -2
- data/lib/bright/student.rb +31 -14
- data/lib/bright/version.rb +1 -1
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 90f5aa090aca3509db5190f180780fab41aaca20cad1b2c8ad87d840ebc069e4
|
4
|
+
data.tar.gz: 2371c2a573db38ff164e6f89e9721793d4c3e73be4bf76f090990f68964590d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1e87336d8567425a1a18f002ac4b3e25fc07ebac5e4b4248b6b280ddcce7d5aa7c578fb8927e5b8abbf8603f78f88f4dccfece3ced374903328769c17604559
|
7
|
+
data.tar.gz: 9c1a8f380871e59f68d2d3733ac59f4796ae46031f9f5726a4c8707ff7585c7e4d860ff8643b8bb0550792e97751b868295dc12d967702241feb0168e9d9a595
|
data/LICENSE.txt
CHANGED
data/bright.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Bright::VERSION
|
9
9
|
spec.authors = ["Arux Software"]
|
10
10
|
spec.email = ["sheuer@aruxsoftware.com"]
|
11
|
-
spec.summary = "Framework and tools for dealing with Student Information Systems"
|
12
|
-
spec.description = "Bright is a simple Student Information System API abstraction library used in and sponsored by
|
11
|
+
spec.summary = "Framework and tools for dealing with Student Information Systems"
|
12
|
+
spec.description = "Bright is a simple Student Information System API abstraction library used in and sponsored by Eleyo. It is written by Stephen Heuer, Steven Novotny, and contributors. The aim of the project is to abstract as many parts as possible away from the user to offer a consistent interface across all supported Student Information System APIs."
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "httpi", "~> 2.1"
|
22
22
|
spec.add_runtime_dependency "json", ">= 0"
|
23
|
+
spec.add_runtime_dependency 'oauth', ">= 0.5.4"
|
23
24
|
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.7"
|
25
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/bright.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
require "bright/version"
|
2
2
|
require "bright/errors"
|
3
3
|
|
4
|
+
require "bright/helpers/blank_helper.rb"
|
5
|
+
|
4
6
|
require "bright/model"
|
5
7
|
require "bright/student"
|
6
8
|
require "bright/address"
|
9
|
+
require "bright/phone_number"
|
10
|
+
require "bright/email_address"
|
7
11
|
require "bright/enrollment"
|
8
12
|
require "bright/school"
|
9
13
|
|
@@ -14,6 +18,8 @@ require "bright/sis_apis/base.rb"
|
|
14
18
|
require "bright/sis_apis/tsis.rb"
|
15
19
|
require "bright/sis_apis/power_school.rb"
|
16
20
|
require "bright/sis_apis/aeries.rb"
|
21
|
+
require "bright/sis_apis/infinite_campus.rb"
|
22
|
+
require "bright/sis_apis/bright_sis.rb"
|
17
23
|
|
18
24
|
module Bright
|
19
25
|
|
data/lib/bright/connection.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require 'httpi'
|
3
3
|
require 'benchmark'
|
4
|
+
require 'securerandom'
|
4
5
|
|
5
6
|
module Bright
|
6
7
|
class Connection
|
@@ -47,7 +48,7 @@ module Bright
|
|
47
48
|
request.auth.ssl.verify_mode = :none if !@verify_peer
|
48
49
|
configure_proxy(request)
|
49
50
|
configure_timeouts(request)
|
50
|
-
|
51
|
+
|
51
52
|
result = case method
|
52
53
|
when :get
|
53
54
|
raise ArgumentError, "GET requests do not support a request body" if body
|
@@ -80,7 +81,7 @@ module Bright
|
|
80
81
|
def configure_proxy(http)
|
81
82
|
http.proxy = "#{proxy_address}:#{proxy_port}" if proxy_address
|
82
83
|
end
|
83
|
-
|
84
|
+
|
84
85
|
def configure_timeouts(http)
|
85
86
|
http.open_timeout = open_timeout
|
86
87
|
http.read_timeout = read_timeout
|
@@ -116,4 +117,4 @@ module Bright
|
|
116
117
|
logger.send(level, message) if logger
|
117
118
|
end
|
118
119
|
end
|
119
|
-
end
|
120
|
+
end
|
data/lib/bright/school.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Bright
|
2
2
|
class School < Model
|
3
|
-
@attribute_names = [:api_id, :name, :number]
|
3
|
+
@attribute_names = [:api_id, :name, :number, :state_id, :low_grade, :high_grade, :last_modified]
|
4
4
|
attr_accessor *@attribute_names
|
5
|
-
attr_accessor :address
|
6
|
-
|
5
|
+
attr_accessor :address, :phone_number
|
6
|
+
|
7
7
|
def address=(address)
|
8
8
|
if address.is_a?(Address)
|
9
9
|
@address = address
|
@@ -12,6 +12,15 @@ module Bright
|
|
12
12
|
end
|
13
13
|
@address
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
|
+
def phone_number=(phone_number)
|
17
|
+
if phone_number.is_a?(PhoneNumber)
|
18
|
+
@phone_number = phone_number
|
19
|
+
elsif phone_number.is_a?(Hash)
|
20
|
+
@phone_number = PhoneNumber.new(phone_number)
|
21
|
+
end
|
22
|
+
@phone_number
|
23
|
+
end
|
24
|
+
|
16
25
|
end
|
17
26
|
end
|
@@ -54,11 +54,11 @@ module Bright
|
|
54
54
|
students_response_hash.collect{|shsh| Student.new(convert_to_student_data(shsh))}
|
55
55
|
end
|
56
56
|
|
57
|
-
def create_student(student
|
57
|
+
def create_student(student)
|
58
58
|
raise NotImplementedError
|
59
59
|
end
|
60
60
|
|
61
|
-
def update_student(student
|
61
|
+
def update_student(student)
|
62
62
|
raise NotImplementedError
|
63
63
|
end
|
64
64
|
|
@@ -0,0 +1,249 @@
|
|
1
|
+
module Bright
|
2
|
+
module SisApi
|
3
|
+
class BrightSis < Base
|
4
|
+
|
5
|
+
@@description = "Connects to the Bright SIS Data Store"
|
6
|
+
@@doc_url = ""
|
7
|
+
@@api_version = "v1"
|
8
|
+
|
9
|
+
attr_accessor :connection_options
|
10
|
+
|
11
|
+
DEMOGRAPHICS_CONVERSION = {
|
12
|
+
"I"=>"American Indian Or Alaska Native",
|
13
|
+
"A"=>"Asian",
|
14
|
+
"B"=>"Black Or African American",
|
15
|
+
"P"=>"Native Hawaiian Or Other Pacific Islander",
|
16
|
+
"W"=>"White",
|
17
|
+
"M"=>"Other"
|
18
|
+
}
|
19
|
+
|
20
|
+
def initialize(options = {})
|
21
|
+
self.connection_options = options[:connection] || {}
|
22
|
+
# {
|
23
|
+
# :access_token => ""
|
24
|
+
# :uri => ""
|
25
|
+
# }
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_student_by_api_id(api_id, options = {})
|
29
|
+
self.get_students({"uuid" => api_id}, options.merge(:limit => 1, :wrap_in_collection => false)).first
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_student(params = {}, options = {})
|
33
|
+
self.get_students(params, options.merge(:limit => 1, :wrap_in_collection => false)).first
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_students(params = {}, options = {})
|
37
|
+
params[:limit] = params[:limit] || options[:limit] || 100
|
38
|
+
students_response_hash = self.request(:get, 'students', self.map_student_search_params(params))
|
39
|
+
total_results = students_response_hash[:response_headers]["total"].to_i
|
40
|
+
if students_response_hash and students_response_hash["students"]
|
41
|
+
students_hash = [students_response_hash["students"]].flatten
|
42
|
+
|
43
|
+
students = students_hash.compact.collect {|st_hsh|
|
44
|
+
Student.new(convert_to_student_data(st_hsh))
|
45
|
+
}
|
46
|
+
end
|
47
|
+
if options[:wrap_in_collection] != false
|
48
|
+
api = self
|
49
|
+
load_more_call = proc { |page|
|
50
|
+
# pages start at one, so add a page here
|
51
|
+
params[:offset] = (params[:limit].to_i * page)
|
52
|
+
api.get_students(params, {:wrap_in_collection => false})
|
53
|
+
}
|
54
|
+
ResponseCollection.new({
|
55
|
+
:seed_page => students,
|
56
|
+
:total => total_results,
|
57
|
+
:per_page => params[:limit],
|
58
|
+
:load_more_call => load_more_call
|
59
|
+
})
|
60
|
+
else
|
61
|
+
students
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def create_student(student)
|
66
|
+
raise NotImplementedError
|
67
|
+
end
|
68
|
+
|
69
|
+
def update_student(student)
|
70
|
+
raise NotImplementedError
|
71
|
+
end
|
72
|
+
|
73
|
+
def get_schools(params = {}, options = {})
|
74
|
+
params[:limit] = params[:limit] || options[:limit] || 100
|
75
|
+
schools_response_hash = self.request(:get, 'schools', self.map_school_search_params(params))
|
76
|
+
total_results = schools_response_hash[:response_headers]["total"].to_i
|
77
|
+
if schools_response_hash and schools_response_hash["schools"]
|
78
|
+
schools_hash = [schools_response_hash["schools"]].flatten
|
79
|
+
|
80
|
+
schools = schools_hash.compact.collect {|st_hsh|
|
81
|
+
School.new(convert_to_school_data(st_hsh))
|
82
|
+
}
|
83
|
+
end
|
84
|
+
if options[:wrap_in_collection] != false
|
85
|
+
api = self
|
86
|
+
load_more_call = proc { |page|
|
87
|
+
# pages start at one, so add a page here
|
88
|
+
params[:offset] = (params[:limit].to_i * page)
|
89
|
+
api.get_schools(params, {:wrap_in_collection => false})
|
90
|
+
}
|
91
|
+
ResponseCollection.new({
|
92
|
+
:seed_page => schools,
|
93
|
+
:total => total_results,
|
94
|
+
:per_page => params[:limit],
|
95
|
+
:load_more_call => load_more_call
|
96
|
+
})
|
97
|
+
else
|
98
|
+
schools
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def request(method, path, params = {})
|
103
|
+
uri = "#{self.connection_options[:uri]}/#{path}"
|
104
|
+
body = nil
|
105
|
+
if method == :get
|
106
|
+
query = URI.encode_www_form(params)
|
107
|
+
uri += "?#{query}" unless query.strip == ""
|
108
|
+
else
|
109
|
+
body = JSON.dump(params)
|
110
|
+
end
|
111
|
+
puts uri.inspect
|
112
|
+
headers = self.headers_for_auth(uri)
|
113
|
+
|
114
|
+
connection = Bright::Connection.new(uri)
|
115
|
+
response = connection.request(method, body, headers)
|
116
|
+
|
117
|
+
if !response.error?
|
118
|
+
response_hash = JSON.parse(response.body)
|
119
|
+
response_hash[:response_headers] = response.headers
|
120
|
+
else
|
121
|
+
puts "#{response.inspect}"
|
122
|
+
puts "#{response.body}"
|
123
|
+
end
|
124
|
+
response_hash
|
125
|
+
end
|
126
|
+
|
127
|
+
protected
|
128
|
+
|
129
|
+
def headers_for_auth(uri)
|
130
|
+
{"Authorization" => "Token token=#{self.connection_options[:access_token]}"}
|
131
|
+
end
|
132
|
+
|
133
|
+
def map_student_search_params(attrs)
|
134
|
+
filter_params = {}
|
135
|
+
attrs.each do |k,v|
|
136
|
+
case k.to_s
|
137
|
+
when "api_id"
|
138
|
+
filter_params["uuid"] = v
|
139
|
+
when "sis_student_id"
|
140
|
+
filter_params["student_number"] = v
|
141
|
+
when "state_student_id"
|
142
|
+
filter_params["state_id"] = v
|
143
|
+
else
|
144
|
+
filter_params[k] = v
|
145
|
+
end
|
146
|
+
end
|
147
|
+
return filter_params
|
148
|
+
end
|
149
|
+
|
150
|
+
def convert_to_student_data(student_params)
|
151
|
+
return {} if student_params.nil?
|
152
|
+
|
153
|
+
student_data_hsh = {
|
154
|
+
:api_id => student_params["uuid"],
|
155
|
+
:first_name => student_params["first_name"],
|
156
|
+
:middle_name => student_params["middle_name"],
|
157
|
+
:last_name => student_params["last_name"],
|
158
|
+
:sis_student_id => student_params["student_number"],
|
159
|
+
:state_student_id => student_params["state_id"],
|
160
|
+
:grade => student_params["grade"],
|
161
|
+
:grade_school_year => student_params["grade_school_year"],
|
162
|
+
:projected_graduation_year => student_params["graduation_year"],
|
163
|
+
:gender => student_params["gender"],
|
164
|
+
:frl_status => student_params["frl_status"],
|
165
|
+
:image => student_params["picture"],
|
166
|
+
:hispanic_ethnicity => student_params["hispanic_latino"],
|
167
|
+
:last_modified => student_params["updated_at"]
|
168
|
+
}
|
169
|
+
unless student_params["birthdate"].blank?
|
170
|
+
student_data_hsh[:birth_date] = Date.parse(student_params["birthdate"]).to_s
|
171
|
+
end
|
172
|
+
|
173
|
+
DEMOGRAPHICS_CONVERSION.each do |demographics_key, demographics_value|
|
174
|
+
if student_params["race"].to_s.upcase.include?(demographics_key)
|
175
|
+
student_data_hsh[:race] ||= []
|
176
|
+
student_data_hsh[:race] << demographics_value
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
unless student_params["student_street"].blank?
|
181
|
+
student_data_hsh[:addresses] = [{
|
182
|
+
:street => student_params["student_street"],
|
183
|
+
:apt => student_params["student_street_line_2"],
|
184
|
+
:city => student_params["student_city"],
|
185
|
+
:state => student_params["student_state"],
|
186
|
+
:postal_code => student_params["student_zip"]
|
187
|
+
}]
|
188
|
+
end
|
189
|
+
|
190
|
+
unless student_params["student_email"].blank?
|
191
|
+
student_data_hsh[:email_address] = {
|
192
|
+
:email_address => student_params["student_email"]
|
193
|
+
}
|
194
|
+
end
|
195
|
+
|
196
|
+
unless student_params["school"].blank?
|
197
|
+
student_data_hsh[:school] = convert_to_school_data(student_params["school"])
|
198
|
+
end
|
199
|
+
|
200
|
+
return student_data_hsh
|
201
|
+
end
|
202
|
+
|
203
|
+
def map_school_search_params(attrs)
|
204
|
+
filter_params = {}
|
205
|
+
attrs.each do |k,v|
|
206
|
+
case k.to_s
|
207
|
+
when "api_id"
|
208
|
+
filter_params["id"] = v
|
209
|
+
else
|
210
|
+
filter_params[k] = v
|
211
|
+
end
|
212
|
+
end
|
213
|
+
return filter_params
|
214
|
+
end
|
215
|
+
|
216
|
+
def convert_to_school_data(school_params)
|
217
|
+
return {} if school_params.nil?
|
218
|
+
|
219
|
+
school_data_hsh = {
|
220
|
+
:api_id => school_params["id"],
|
221
|
+
:name => school_params["name"],
|
222
|
+
:number => school_params["number"],
|
223
|
+
:state_id => school_params["state_id"],
|
224
|
+
:low_grade => school_params["low_grade"],
|
225
|
+
:high_grade => school_params["high_grade"],
|
226
|
+
:last_modified => school_params["updated_at"]
|
227
|
+
}
|
228
|
+
|
229
|
+
unless school_params["school_address"].blank?
|
230
|
+
school_data_hsh[:address] = {
|
231
|
+
:street => school_params["school_address"],
|
232
|
+
:city => school_params["school_city"],
|
233
|
+
:state => school_params["school_state"],
|
234
|
+
:postal_code => school_params["school_zip"]
|
235
|
+
}
|
236
|
+
end
|
237
|
+
|
238
|
+
unless school_params["school_phone"].blank?
|
239
|
+
school_data_hsh[:phone_number] = {
|
240
|
+
:phone_number => school_params["school_phone"]
|
241
|
+
}
|
242
|
+
end
|
243
|
+
|
244
|
+
return school_data_hsh
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
@@ -1,31 +1,169 @@
|
|
1
|
+
require 'oauth'
|
2
|
+
|
1
3
|
module Bright
|
2
4
|
module SisApi
|
3
5
|
class InfiniteCampus < Base
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
|
7
|
+
@@description = "Connects to the Infinite Campus OneRoster API for accessing student information"
|
8
|
+
@@doc_url = "https://content.infinitecampus.com/sis/Campus.1633/documentation/oneroster-api/"
|
9
|
+
@@api_version = "v1.1"
|
10
|
+
|
11
|
+
attr_accessor :connection_options
|
12
|
+
|
13
|
+
DEMOGRAPHICS_CONVERSION = {
|
14
|
+
"americanIndianOrAlaskaNative"=>"American Indian Or Alaska Native",
|
15
|
+
"asian"=>"Asian",
|
16
|
+
"blackOrAfricanAmerican"=>"Black Or African American",
|
17
|
+
"nativeHawaiianOrOtherPacificIslander"=>"Native Hawaiian Or Other Pacific Islander",
|
18
|
+
"white"=>"White",
|
19
|
+
"hispanicOrLatinoEthnicity"=>"Hispanic Or Latino"
|
20
|
+
}
|
21
|
+
|
22
|
+
def initialize(options = {})
|
23
|
+
self.connection_options = options[:connection] || {}
|
24
|
+
# {
|
25
|
+
# :client_id => "",
|
26
|
+
# :client_secret => "",
|
27
|
+
# :uri => ""
|
28
|
+
# }
|
7
29
|
end
|
8
|
-
|
9
|
-
def
|
10
|
-
|
30
|
+
|
31
|
+
def get_student_by_api_id(api_id, params = {})
|
32
|
+
st_hsh = self.request(:get, "users/#{api_id}", params)
|
33
|
+
Student.new(convert_to_student_data(st_hsh["user"])) if st_hsh and st_hsh["user"]
|
11
34
|
end
|
12
|
-
|
13
|
-
def
|
14
|
-
|
35
|
+
|
36
|
+
def get_student(params = {}, options = {})
|
37
|
+
self.get_students(params, options.merge(:limit => 1, :wrap_in_collection => false)).first
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_students(params = {}, options = {})
|
41
|
+
params[:limit] = params[:limit] || options[:limit] || 100
|
42
|
+
students_response_hash = self.request(:get, 'users', self.map_student_search_params(params))
|
43
|
+
total_results = students_response_hash[:response_headers]["x-total-count"].to_i
|
44
|
+
if students_response_hash and students_response_hash["users"]
|
45
|
+
students_hash = [students_response_hash["users"]].flatten
|
46
|
+
|
47
|
+
students = students_hash.compact.collect {|st_hsh|
|
48
|
+
Student.new(convert_to_student_data(st_hsh))
|
49
|
+
}
|
50
|
+
end
|
51
|
+
if options[:wrap_in_collection] != false
|
52
|
+
api = self
|
53
|
+
load_more_call = proc { |page|
|
54
|
+
# pages start at one, so add a page here
|
55
|
+
params[:offset] = (params[:limit].to_i * page)
|
56
|
+
api.get_students(params, {:wrap_in_collection => false})
|
57
|
+
}
|
58
|
+
ResponseCollection.new({
|
59
|
+
:seed_page => students,
|
60
|
+
:total => total_results,
|
61
|
+
:per_page => params[:limit],
|
62
|
+
:load_more_call => load_more_call
|
63
|
+
})
|
64
|
+
else
|
65
|
+
students
|
66
|
+
end
|
15
67
|
end
|
16
|
-
|
17
|
-
def create_student(student
|
68
|
+
|
69
|
+
def create_student(student)
|
18
70
|
raise NotImplementedError
|
19
71
|
end
|
20
|
-
|
21
|
-
def update_student(student
|
72
|
+
|
73
|
+
def update_student(student)
|
22
74
|
raise NotImplementedError
|
23
75
|
end
|
24
|
-
|
76
|
+
|
25
77
|
def get_schools(params)
|
26
78
|
raise NotImplementedError
|
27
79
|
end
|
28
|
-
|
80
|
+
|
81
|
+
def request(method, path, params = {})
|
82
|
+
uri = "#{self.connection_options[:uri]}/#{path}"
|
83
|
+
body = nil
|
84
|
+
if method == :get
|
85
|
+
query = URI.encode_www_form(params)
|
86
|
+
uri += "?#{query}" unless query.strip == ""
|
87
|
+
else
|
88
|
+
body = JSON.dump(params)
|
89
|
+
end
|
90
|
+
headers = self.headers_for_auth(uri)
|
91
|
+
|
92
|
+
connection = Bright::Connection.new(uri)
|
93
|
+
response = connection.request(method, body, headers)
|
94
|
+
|
95
|
+
if !response.error?
|
96
|
+
response_hash = JSON.parse(response.body)
|
97
|
+
response_hash[:response_headers] = response.headers
|
98
|
+
else
|
99
|
+
puts "#{response.inspect}"
|
100
|
+
puts "#{response.body}"
|
101
|
+
end
|
102
|
+
response_hash
|
103
|
+
end
|
104
|
+
|
105
|
+
protected
|
106
|
+
|
107
|
+
def headers_for_auth(uri)
|
108
|
+
site = URI.parse(self.connection_options[:uri])
|
109
|
+
site = "#{site.scheme}://#{site.host}"
|
110
|
+
consumer = OAuth::Consumer.new(self.connection_options[:client_id], self.connection_options[:client_secret], { :site => site, :scheme => :header })
|
111
|
+
options = {:timestamp => Time.now.to_i, :nonce => SecureRandom.uuid}
|
112
|
+
{"Authorization" => consumer.create_signed_request(:get, uri, nil, options)["Authorization"]}
|
113
|
+
end
|
114
|
+
|
115
|
+
def map_student_search_params(params)
|
116
|
+
params = params.dup
|
117
|
+
default_params = {}
|
118
|
+
|
119
|
+
filter = []
|
120
|
+
params.each do |k,v|
|
121
|
+
case k.to_s
|
122
|
+
when "first_name"
|
123
|
+
filter << "givenName='#{v}'"
|
124
|
+
when "last_name"
|
125
|
+
filter << "familyName='#{v}'"
|
126
|
+
when "email"
|
127
|
+
filter << "email='#{v}'"
|
128
|
+
when "student_id"
|
129
|
+
filter << "identifier='#{v}'"
|
130
|
+
else
|
131
|
+
default_params[k] = v
|
132
|
+
end
|
133
|
+
end
|
134
|
+
unless filter.empty?
|
135
|
+
params = {"filter" => filter.join(" AND ")}
|
136
|
+
end
|
137
|
+
default_params.merge(params).reject{|k,v| v.respond_to?(:empty?) ? v.empty? : v.nil?}
|
138
|
+
end
|
139
|
+
|
140
|
+
def convert_to_student_data(student_params)
|
141
|
+
return {} if student_params.nil?
|
142
|
+
demographics_params = self.request(:get, "demographics/#{student_params["sourcedId"]}")["demographics"]
|
143
|
+
|
144
|
+
student_data_hsh = {
|
145
|
+
:api_id => student_params["sourcedId"],
|
146
|
+
:first_name => student_params["givenName"],
|
147
|
+
:middle_name => student_params["middleName"],
|
148
|
+
:last_name => student_params["familyName"],
|
149
|
+
:sis_student_id => student_params["identifier"],
|
150
|
+
:last_modified => student_params["dateLastModified"]
|
151
|
+
}
|
152
|
+
unless demographics_params["birthdate"].nil?
|
153
|
+
student_data_hsh[:birth_date] = Date.parse(demographics_params["birthdate"]).to_s
|
154
|
+
end
|
155
|
+
unless demographics_params["sex"].to_s[0].nil?
|
156
|
+
student_data_hsh[:gender] = demographics_params["sex"].to_s[0].upcase
|
157
|
+
end
|
158
|
+
DEMOGRAPHICS_CONVERSION.each do |demographics_key, demographics_value|
|
159
|
+
if demographics_params[demographics_key] == "true"
|
160
|
+
student_data_hsh[:race] ||= []
|
161
|
+
student_data_hsh[:race] << demographics_value
|
162
|
+
end
|
163
|
+
end
|
164
|
+
return student_data_hsh
|
165
|
+
end
|
166
|
+
|
29
167
|
end
|
30
168
|
end
|
31
|
-
end
|
169
|
+
end
|
@@ -5,7 +5,7 @@ module Bright
|
|
5
5
|
INVALID_SEARCH_CHAR_RE = /[\,\;]/
|
6
6
|
|
7
7
|
@@description = "Connects to the PowerSchool API for accessing student information"
|
8
|
-
@@doc_url = ""
|
8
|
+
@@doc_url = "http://psimages.sunnysideschools.org/api-developer-guide-1.6.0/"
|
9
9
|
@@api_version = "1.6.0"
|
10
10
|
|
11
11
|
attr_accessor :connection_options, :expansion_options
|
@@ -14,11 +14,11 @@ module Bright
|
|
14
14
|
raise NotImplementedError
|
15
15
|
end
|
16
16
|
|
17
|
-
def create_student(student
|
17
|
+
def create_student(student)
|
18
18
|
raise NotImplementedError
|
19
19
|
end
|
20
20
|
|
21
|
-
def update_student(student
|
21
|
+
def update_student(student)
|
22
22
|
raise NotImplementedError
|
23
23
|
end
|
24
24
|
|
data/lib/bright/sis_apis/tsis.rb
CHANGED
@@ -76,11 +76,11 @@ module Bright
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
def create_student(student
|
79
|
+
def create_student(student)
|
80
80
|
raise NotImplementedError, "TSIS does not support creating students"
|
81
81
|
end
|
82
82
|
|
83
|
-
def update_student(student
|
83
|
+
def update_student(student)
|
84
84
|
raise NotImplementedError, "TSIS does not support updating students"
|
85
85
|
end
|
86
86
|
|
data/lib/bright/student.rb
CHANGED
@@ -2,38 +2,38 @@ require 'securerandom'
|
|
2
2
|
|
3
3
|
module Bright
|
4
4
|
class Student < Model
|
5
|
-
@attribute_names = [:client_id, :api_id, :first_name, :middle_name, :last_name, :nick_name,
|
6
|
-
:birth_date, :grade, :projected_graduation_year, :gender,
|
7
|
-
:hispanic_ethnicity, :race, :image, :primary_language, :secondary_language,
|
8
|
-
:homeless_code, :frl_status, :sis_student_id,
|
5
|
+
@attribute_names = [:client_id, :api_id, :first_name, :middle_name, :last_name, :nick_name,
|
6
|
+
:birth_date, :grade, :grade_school_year, :projected_graduation_year, :gender,
|
7
|
+
:hispanic_ethnicity, :race, :image, :primary_language, :secondary_language,
|
8
|
+
:homeless_code, :frl_status, :sis_student_id,
|
9
9
|
:state_student_id, :last_modified]
|
10
10
|
attr_accessor *@attribute_names
|
11
|
-
|
11
|
+
|
12
12
|
def self.attribute_names
|
13
13
|
@attribute_names
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
# TODO:: map contact info (addresses, email, phone, etc)
|
17
|
-
attr_accessor :enrollment, :addresses
|
17
|
+
attr_accessor :enrollment, :addresses, :email_address, :school
|
18
18
|
|
19
19
|
def initialize(*args)
|
20
20
|
super
|
21
21
|
self.client_id ||= SecureRandom.uuid
|
22
22
|
self
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def name
|
26
26
|
"#{self.first_name} #{self.middle_name} #{self.last_name}".gsub(/\s+/, " ").strip
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def <=>(other)
|
30
30
|
(self.sis_student_id and self.sis_student_id == other.sis_student_id) or
|
31
31
|
(self.state_student_id and self.state_student_id == other.state_student_id) or
|
32
32
|
(self.first_name == other.first_name and self.middle_name == other.middle_name and self.last_name == other.last_name and self.birth_date == other.birth_date)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
alias id client_id
|
36
|
-
|
36
|
+
|
37
37
|
def addresses=(array)
|
38
38
|
if array.size <= 0 or array.first.is_a?(Address)
|
39
39
|
@addresses = array
|
@@ -43,11 +43,28 @@ module Bright
|
|
43
43
|
end
|
44
44
|
@addresses ||= []
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
def addresses
|
48
48
|
@addresses ||= []
|
49
49
|
end
|
50
|
-
end
|
51
|
-
end
|
52
50
|
|
51
|
+
def email_address=(email)
|
52
|
+
if email.is_a?(EmailAddress)
|
53
|
+
@email_address = email
|
54
|
+
elsif email.is_a?(Hash)
|
55
|
+
@email_address = EmailAddress.new(email)
|
56
|
+
end
|
57
|
+
@email_address
|
58
|
+
end
|
59
|
+
|
60
|
+
def school=(school_val)
|
61
|
+
if school_val.is_a?(School)
|
62
|
+
@school = school_val
|
63
|
+
elsif school_val.is_a?(Hash)
|
64
|
+
@school = School.new(school_val)
|
65
|
+
end
|
66
|
+
@school
|
67
|
+
end
|
53
68
|
|
69
|
+
end
|
70
|
+
end
|
data/lib/bright/version.rb
CHANGED
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: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arux Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpi
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: oauth
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.5.4
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.5.4
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +81,7 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '10.0'
|
69
83
|
description: Bright is a simple Student Information System API abstraction library
|
70
|
-
used in and sponsored by
|
84
|
+
used in and sponsored by Eleyo. It is written by Stephen Heuer, Steven Novotny,
|
71
85
|
and contributors. The aim of the project is to abstract as many parts as possible
|
72
86
|
away from the user to offer a consistent interface across all supported Student
|
73
87
|
Information System APIs.
|
@@ -86,13 +100,17 @@ files:
|
|
86
100
|
- lib/bright.rb
|
87
101
|
- lib/bright/address.rb
|
88
102
|
- lib/bright/connection.rb
|
103
|
+
- lib/bright/email_address.rb
|
89
104
|
- lib/bright/enrollment.rb
|
90
105
|
- lib/bright/errors.rb
|
106
|
+
- lib/bright/helpers/blank_helper.rb
|
91
107
|
- lib/bright/model.rb
|
108
|
+
- lib/bright/phone_number.rb
|
92
109
|
- lib/bright/response_collection.rb
|
93
110
|
- lib/bright/school.rb
|
94
111
|
- lib/bright/sis_apis/aeries.rb
|
95
112
|
- lib/bright/sis_apis/base.rb
|
113
|
+
- lib/bright/sis_apis/bright_sis.rb
|
96
114
|
- lib/bright/sis_apis/infinite_campus.rb
|
97
115
|
- lib/bright/sis_apis/power_school.rb
|
98
116
|
- lib/bright/sis_apis/synergy.rb
|
@@ -119,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
137
|
version: '0'
|
120
138
|
requirements: []
|
121
139
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.7.6
|
123
141
|
signing_key:
|
124
142
|
specification_version: 4
|
125
143
|
summary: Framework and tools for dealing with Student Information Systems
|