Module: CourseSubjects
- Included in:
- Spartacus
- Defined in:
- lib/client/course_subjects.rb
Instance Method Summary collapse
-
#create_course_subject(name, display_name, occupation_name, options = {}) ⇒ CourseSubject
Create a course subject.
-
#update_course_subject(id, options = {}) ⇒ CourseSubject
Update a course subject.
Instance Method Details
#create_course_subject(name, display_name, occupation_name, options = {}) ⇒ CourseSubject
Create a course subject
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/client/course_subjects.rb', line 15 def create_course_subject(name, display_name, occupation_name, ={}) whitelist = ['default_goal_options', 'director_id', 'director_slug'] = convert_keys() course_subject_params = whitelist_params(, whitelist) course_subject_params.merge!({ name: name, display_name: display_name, occupation_name: occupation_name }) url = "#{@api_base_path}/course_subjects" handle_timeouts do response = self.class.post(url, headers: auth_header, body: { course_subject: course_subject_params }) convert_response(response, "course_subject") end end |
#update_course_subject(id, options = {}) ⇒ CourseSubject
Update a course subject
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/client/course_subjects.rb', line 44 def update_course_subject(id, ={}) whitelist = ['name', 'display_name', 'occupation_name', 'default_goal_options', 'director_id', 'director_slug'] = convert_keys() course_subject_params = whitelist_params(, whitelist) url = "#{@api_base_path}/course_subjects/#{id}" handle_timeouts do response = self.class.put(url, headers: auth_header, body: { course_subject: course_subject_params }) convert_response(response, "course_subject") end end |