Class: Academical::Api::Teachers
- Inherits:
-
Object
- Object
- Academical::Api::Teachers
- Defined in:
- lib/academical/api/teachers.rb
Overview
A teacher in a school.
Instance Method Summary collapse
-
#create(name, school_id, options = {}) ⇒ Object
Create a new teacher in Academical.
-
#delete(id, options = {}) ⇒ Object
Delete a teacher given its ID.
-
#get(id, options = {}) ⇒ Object
Get a teacher given its ID.
-
#initialize(client) ⇒ Teachers
constructor
A new instance of Teachers.
-
#update(id, name, school_id, options = {}) ⇒ Object
Update a teacher in Academical.
Constructor Details
#initialize(client) ⇒ Teachers
Returns a new instance of Teachers.
8 9 10 |
# File 'lib/academical/api/teachers.rb', line 8 def initialize(client) @client = client end |
Instance Method Details
#create(name, school_id, options = {}) ⇒ Object
Create a new teacher in Academical. You must provide all of the required values
‘/teachers/’ POST
name - Object with the name of the teacher school_id - ID of the school which this teacher belongs to
40 41 42 43 44 45 46 |
# File 'lib/academical/api/teachers.rb', line 40 def create(name, school_id, = {}) body = .fetch(:body, {}) body[:name] = name body[:school_id] = school_id @client.post("/teachers/", body, ) end |
#delete(id, options = {}) ⇒ Object
Delete a teacher given its ID
‘/teachers/:id’ DELETE
id - ID of the teacher
28 29 30 31 32 |
# File 'lib/academical/api/teachers.rb', line 28 def delete(id, = {}) body = .fetch(:body, {}) @client.delete("/teachers/#{id}", body, ) end |
#get(id, options = {}) ⇒ Object
Get a teacher given its ID
‘/teachers/:id’ GET
id - ID of the teacher
17 18 19 20 21 |
# File 'lib/academical/api/teachers.rb', line 17 def get(id, = {}) body = .fetch(:query, {}) @client.get("/teachers/#{id}", body, ) end |
#update(id, name, school_id, options = {}) ⇒ Object
Update a teacher in Academical. You must provide all of the required parameters
‘/teachers/:id’ PUT
id - ID of the teacher name - Object with the name of the teacher school_id - ID of the school which this teacher belongs to
55 56 57 58 59 60 61 62 |
# File 'lib/academical/api/teachers.rb', line 55 def update(id, name, school_id, = {}) body = .fetch(:body, {}) body[:id] = id body[:name] = name body[:school_id] = school_id @client.put("/teachers/#{id}", body, ) end |