Class: Academical::Api::Sections
- Inherits:
-
Object
- Object
- Academical::Api::Sections
- Defined in:
- lib/academical/api/sections.rb
Overview
Represents the section of a course in a school
Instance Method Summary collapse
-
#create(course_name, course_code, section_number, section_id, term, seats, school_id, events, departments, credits, options = {}) ⇒ Object
Creates a new section object in Academical.
-
#delete(id, options = {}) ⇒ Object
Delete a section given its ID.
-
#get(id, options = {}) ⇒ Object
Returns a section object given its ID.
-
#initialize(client) ⇒ Sections
constructor
A new instance of Sections.
-
#schedules(id, options = {}) ⇒ Object
List of all the schedules with a given section.
-
#teachers(id, options = {}) ⇒ Object
Returns the list of teachers given a section ID.
-
#update(id, course_name, course_code, section_number, section_id, term, seats, school_id, events, departments, credits, options = {}) ⇒ Object
Update the attributes of a section given its ID as a part of the body of the request.
Constructor Details
#initialize(client) ⇒ Sections
Returns a new instance of Sections.
8 9 10 |
# File 'lib/academical/api/sections.rb', line 8 def initialize(client) @client = client end |
Instance Method Details
#create(course_name, course_code, section_number, section_id, term, seats, school_id, events, departments, credits, options = {}) ⇒ Object
Creates a new section object in Academical. All required parameters must be provided.
‘/sections/’ POST
course_name - Name of the course course_code - The code of the course which this section belongs to section_number - Section number of the course. This is X of Y sections for course K section_id - Unique identifier for the section term - The term object this section will be taking place in seats - Object describing the number of available, taken and total seats for the section school_id - ID of the school this section belongs to events - A list of events this section takes place on departments - List of departments this section belongs to. credits - Number of credits this course is worth
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/academical/api/sections.rb', line 48 def create(course_name, course_code, section_number, section_id, term, seats, school_id, events, departments, credits, = {}) body = .fetch(:body, {}) body[:course_name] = course_name body[:course_code] = course_code body[:section_number] = section_number body[:section_id] = section_id body[:term] = term body[:seats] = seats body[:school_id] = school_id body[:events] = events body[:departments] = departments body[:credits] = credits @client.post("/sections/", body, ) end |
#delete(id, options = {}) ⇒ Object
Delete a section given its ID
‘/sections/:id’ DELETE
id - ID of the section
28 29 30 31 32 |
# File 'lib/academical/api/sections.rb', line 28 def delete(id, = {}) body = .fetch(:body, {}) @client.delete("/sections/#{id}", body, ) end |
#get(id, options = {}) ⇒ Object
Returns a section object given its ID
‘/sections/:id’ GET
id - ID of the section
17 18 19 20 21 |
# File 'lib/academical/api/sections.rb', line 17 def get(id, = {}) body = .fetch(:query, {}) @client.get("/sections/#{id}", body, ) end |
#schedules(id, options = {}) ⇒ Object
List of all the schedules with a given section
‘/sections/:id/schedules’ GET
id - ID of the section
111 112 113 114 115 |
# File 'lib/academical/api/sections.rb', line 111 def schedules(id, = {}) body = .fetch(:query, {}) @client.get("/sections/#{id}/schedules", body, ) end |
#teachers(id, options = {}) ⇒ Object
Returns the list of teachers given a section ID
‘/sections/:id/teachers’ GET
id - ID of the section
100 101 102 103 104 |
# File 'lib/academical/api/sections.rb', line 100 def teachers(id, = {}) body = .fetch(:query, {}) @client.get("/sections/#{id}/teachers", body, ) end |
#update(id, course_name, course_code, section_number, section_id, term, seats, school_id, events, departments, credits, options = {}) ⇒ Object
Update the attributes of a section given its ID as a part of the body of the request
‘/sections/:id’ PUT
id - ID of the section course_name - Name of the course course_code - The code of the course which this section belongs to section_number - Section number of the course. This is X of Y sections for course K section_id - Unique identifier for the section term - The term object this section will be taking place in seats - Object describing the number of available, taken and total seats for the section school_id - ID of the school this section belongs to events - A list of events this section takes place on departments - List of departments this section belongs to. credits - Number of credits this course is worth
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/academical/api/sections.rb', line 79 def update(id, course_name, course_code, section_number, section_id, term, seats, school_id, events, departments, credits, = {}) body = .fetch(:body, {}) body[:course_name] = course_name body[:course_code] = course_code body[:section_number] = section_number body[:section_id] = section_id body[:term] = term body[:seats] = seats body[:school_id] = school_id body[:events] = events body[:departments] = departments body[:credits] = credits @client.put("/sections/#{id}", body, ) end |