Class: Academical::Api::Teachers

Inherits:
Object
  • Object
show all
Defined in:
lib/academical/api/teachers.rb

Overview

A teacher in a school.

Instance Method Summary collapse

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, options = {})
  body = options.fetch(:body, {})
  body[:name] = name
  body[:school_id] = school_id

  @client.post("/teachers/", body, options)
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, options = {})
  body = options.fetch(:body, {})

  @client.delete("/teachers/#{id}", body, options)
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, options = {})
  body = options.fetch(:query, {})

  @client.get("/teachers/#{id}", body, options)
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, options = {})
  body = options.fetch(:body, {})
  body[:id] = id
  body[:name] = name
  body[:school_id] = school_id

  @client.put("/teachers/#{id}", body, options)
end