Class: Bright::SisApi::InfiniteCampus
- Inherits:
-
Base
show all
- Defined in:
- lib/bright/sis_apis/infinite_campus.rb
Constant Summary
collapse
- DEMOGRAPHICS_CONVERSION =
{
"americanIndianOrAlaskaNative"=>"American Indian Or Alaska Native",
"asian"=>"Asian",
"blackOrAfricanAmerican"=>"Black Or African American",
"nativeHawaiianOrOtherPacificIslander"=>"Native Hawaiian Or Other Pacific Islander",
"white"=>"White",
"hispanicOrLatinoEthnicity"=>"Hispanic Or Latino"
}
- @@description =
"Connects to the Infinite Campus OneRoster API for accessing student information"
- @@doc_url =
"https://content.infinitecampus.com/sis/Campus.1633/documentation/oneroster-api/"
- @@api_version =
"v1.1"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#filter_students_by_params
Constructor Details
Returns a new instance of InfiniteCampus.
22
23
24
25
26
27
28
29
|
# File 'lib/bright/sis_apis/infinite_campus.rb', line 22
def initialize(options = {})
self.connection_options = options[:connection] || {}
end
|
Instance Attribute Details
#connection_options ⇒ Object
Returns the value of attribute connection_options.
11
12
13
|
# File 'lib/bright/sis_apis/infinite_campus.rb', line 11
def connection_options
@connection_options
end
|
Instance Method Details
#create_student(student) ⇒ Object
69
70
71
|
# File 'lib/bright/sis_apis/infinite_campus.rb', line 69
def create_student(student)
raise NotImplementedError
end
|
#get_schools(params) ⇒ Object
77
78
79
|
# File 'lib/bright/sis_apis/infinite_campus.rb', line 77
def get_schools(params)
raise NotImplementedError
end
|
#get_student(params = {}, options = {}) ⇒ Object
36
37
38
|
# File 'lib/bright/sis_apis/infinite_campus.rb', line 36
def get_student(params = {}, options = {})
self.get_students(params, options.merge(:limit => 1, :wrap_in_collection => false)).first
end
|
#get_student_by_api_id(api_id, params = {}) ⇒ Object
31
32
33
34
|
# File 'lib/bright/sis_apis/infinite_campus.rb', line 31
def get_student_by_api_id(api_id, params = {})
st_hsh = self.request(:get, "users/#{api_id}", params)
Student.new(convert_to_student_data(st_hsh["user"])) if st_hsh and st_hsh["user"]
end
|
#get_students(params = {}, options = {}) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/bright/sis_apis/infinite_campus.rb', line 40
def get_students(params = {}, options = {})
params[:limit] = params[:limit] || options[:limit] || 100
students_response_hash = self.request(:get, 'users', self.map_student_search_params(params))
total_results = students_response_hash[:response_headers]["x-total-count"].to_i
if students_response_hash and students_response_hash["users"]
students_hash = [students_response_hash["users"]].flatten
students = students_hash.compact.collect {|st_hsh|
Student.new(convert_to_student_data(st_hsh))
}
end
if options[:wrap_in_collection] != false
api = self
load_more_call = proc { |page|
params[:offset] = (params[:limit].to_i * page)
api.get_students(params, {:wrap_in_collection => false})
}
ResponseCollection.new({
:seed_page => students,
:total => total_results,
:per_page => params[:limit],
:load_more_call => load_more_call
})
else
students
end
end
|
#request(method, path, params = {}) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/bright/sis_apis/infinite_campus.rb', line 81
def request(method, path, params = {})
uri = "#{self.connection_options[:uri]}/#{path}"
body = nil
if method == :get
query = URI.encode_www_form(params)
uri += "?#{query}" unless query.strip == ""
else
body = JSON.dump(params)
end
= self.(uri)
connection = Bright::Connection.new(uri)
response = connection.request(method, body, )
if !response.error?
response_hash = JSON.parse(response.body)
response_hash[:response_headers] = response.
else
puts "#{response.inspect}"
puts "#{response.body}"
end
response_hash
end
|
#update_student(student) ⇒ Object
73
74
75
|
# File 'lib/bright/sis_apis/infinite_campus.rb', line 73
def update_student(student)
raise NotImplementedError
end
|