Module: PsUtilities::PreBuiltPost
- Included in:
- Connection
- Defined in:
- lib/ps_utilities/pre_built_post.rb
Instance Method Summary collapse
-
#create_students(params) ⇒ Hash
(also: #create_student)
this method CREATES or INSERTS a new student into PowerSchool one kid params: { students: [7531, student_id: 23456, email: “[email protected]”] }.
-
#update_students(params) ⇒ Object
(also: #update_student)
this updates and existing student record within PowerSchool (see #create_students).
Instance Method Details
#create_students(params) ⇒ Hash Also known as: create_student
create_students REQUIRED params are: :student_id (chosen by the school same as local_id within PS), :last_name, :first_name, :entry_date, :exit_date, :school_number, :grade_level
create_students OPTIONAL params include: :school_id, :username, :middle_name, physical address objects, mailing address objects, demographics objects, contacts objects, schedule setup objects, intial enrollment objects (disctrict and school), :contact_info, :phone, :u_studentsuserfields (powerschool defined extensions) & :u_students_extension (school defined db extensions)
create_students INVALID (ignored) params are: :id (dcid - chosen by the PS system)
this method CREATES or INSERTS a new student into PowerSchool one kid params: { students: [7531, student_id: 23456, email: “[email protected]”] }
or multiple students (with ps and your school’s database extensions) params: { students:
[ { dcid: 9753, student_id: 65432 },
{ dcid: 7531, student_id: 23456, email: "[email protected]",
u_studentsuserfields: {transcriptaddrcity: "Bex"},
u_students_extension: {preferredname: "Joe"}
}
]
} { “results”: {
"update_count": 2
"result": [
{ "client_uid": 124,
"status": "SUCCESS",
"action": "INSERT",
"success_message" :{
"id": 442,
"ref": "https://server/ws/v1/student/442" }
},
{ ... }
]
}
}
37 38 39 40 41 42 43 44 |
# File 'lib/ps_utilities/pre_built_post.rb', line 37 def create_students(params) action = "INSERT" kids_api_array = build_kids_api_array(action, params) = { body: { students: { student: kids_api_array } }.to_json } answer = api(:post, "/ws/v1/student", ) return answer.parsed_response if answer.code.to_s.eql? "200" return {"errorMessage"=>"#{answer.response}"} end |
#update_students(params) ⇒ Object Also known as: update_student
update_students REQUIRED params are: :id (dcid) and :student_id (local_id)
update_students INVALID (ignored) params are: :grade_level, :entry_date, :exit_date, :school_number, :school_id
this updates and existing student record within PowerSchool (see #create_students)
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ps_utilities/pre_built_post.rb', line 51 def update_students(params) action = "UPDATE" kids_api_array = build_kids_api_array(action, params) return kids_api_array if kids_api_array.empty? = { body: { students: { student: kids_api_array } }.to_json } answer = api(:post, "/ws/v1/student", ) return answer.parsed_response if answer.code.to_s.eql? "200" return {"errorMessage"=>"#{answer.response}"} end |