Class: PowerAPI::Data::Student
- Inherits:
-
Object
- Object
- PowerAPI::Data::Student
- Defined in:
- lib/powerapi/data/student.rb
Instance Method Summary collapse
- #fetch_transcript ⇒ Object
- #information ⇒ Object
-
#initialize(soap_url, soap_session, populate = true) ⇒ Student
constructor
A new instance of Student.
- #parse_transcript(transcript) ⇒ Object
- #populate ⇒ Object
- #sections ⇒ Object
Constructor Details
#initialize(soap_url, soap_session, populate = true) ⇒ Student
Returns a new instance of Student.
4 5 6 7 8 9 10 11 |
# File 'lib/powerapi/data/student.rb', line 4 def initialize(soap_url, soap_session, populate=true) @soap_url = soap_url @soap_session = soap_session if populate self.populate() end end |
Instance Method Details
#fetch_transcript ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/powerapi/data/student.rb', line 18 def fetch_transcript() student_client = Savon.client( endpoint: @soap_url + "/pearson-rest/services/PublicPortalServiceJSON?response=application/json", namespace: "http://publicportal.rest.powerschool.pearson.com/xsd", digest_auth: ["pearson", "m0bApP5"] ) transcript_params = { userSessionVO: { userId: @soap_session[:user_id], serviceTicket: @soap_session[:service_ticket], serverInfo: { apiVersion: @soap_session[:server_info][:api_version] }, serverCurrentTime: "2012-12-26T21:47:23.792Z", # I really don't know. userType: "2" }, studentIDs: @soap_session[:student_i_ds], qil: { includes: "1" } } transcript = student_client.call(:get_student_data, message: transcript_params).to_xml JSON.parse(transcript) end |
#information ⇒ Object
68 69 70 71 72 |
# File 'lib/powerapi/data/student.rb', line 68 def information if @student_data != nil @student_data["student"] end end |
#parse_transcript(transcript) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/powerapi/data/student.rb', line 46 def parse_transcript(transcript) @student_data = transcript["return"]["studentDataVOs"] @student_data["student"].delete("@type") assignment_categories = PowerAPI::Parser.assignment_categories(@student_data["assignmentCategories"]) assignment_scores = PowerAPI::Parser.assignment_scores(@student_data["assignmentScores"]) final_grades = PowerAPI::Parser.final_grades(@student_data["finalGrades"]) reporting_terms = PowerAPI::Parser.reporting_terms(@student_data["reportingTerms"]) teachers = PowerAPI::Parser.teachers(@student_data["teachers"]) assignments = PowerAPI::Parser.assignments(@student_data["assignments"], assignment_categories, assignment_scores) @sections = PowerAPI::Parser.sections(@student_data["sections"], assignments, final_grades, reporting_terms, teachers) return 0 end |
#populate ⇒ Object
13 14 15 16 |
# File 'lib/powerapi/data/student.rb', line 13 def populate() transcript = self.fetch_transcript self.parse_transcript(transcript) end |
#sections ⇒ Object
64 65 66 |
# File 'lib/powerapi/data/student.rb', line 64 def sections @sections end |