Class: Academical::Api::Schools

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

Overview

All schools that are using Academical

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Schools

Returns a new instance of Schools.



8
9
10
# File 'lib/academical/api/schools.rb', line 8

def initialize(client)
  @client = client
end

Instance Method Details

#create(name, nickname, locale, timezone, departments, identity_providers, app_ui, terms, options = {}) ⇒ Object

Creates a new school object in Academical. All required parameters must be provided

‘/schools/’ POST

name - Name of the school nickname - Nickname of the school locale - Locale of the school timezone - Timezone of the school departments - A list of Department objects. Each department should specify a name and faculty_name identity_providers - A list of Identify Providers to use with this school app_ui - Object describing UI specific parameters for our planner app terms - A list containing Term objects. Each term should define a name, a start date and end date.



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/academical/api/schools.rb', line 90

def create(name, nickname, locale, timezone, departments, identity_providers, app_ui, terms, options = {})
  body = options.fetch(:body, {})
  body[:name] = name
  body[:nickname] = nickname
  body[:locale] = locale
  body[:timezone] = timezone
  body[:departments] = departments
  body[:identity_providers] = identity_providers
  body[:app_ui] = app_ui
  body[:terms] = terms

  @client.post("/schools/", body, options)
end

#delete(id, options = {}) ⇒ Object

Delete a school from the API given its ID

‘/schools/:id’ DELETE

id - ID of the school



28
29
30
31
32
# File 'lib/academical/api/schools.rb', line 28

def delete(id, options = {})
  body = options.fetch(:body, {})

  @client.delete("/schools/#{id}", body, options)
end

#get(id, options = {}) ⇒ Object

Returns a school object given its ID

‘/schools/:id’ GET

id - ID of the school



17
18
19
20
21
# File 'lib/academical/api/schools.rb', line 17

def get(id, options = {})
  body = options.fetch(:query, {})

  @client.get("/schools/#{id}", body, options)
end

#schedules(id, options = {}) ⇒ Object

Returns a list of schedules that have been created in a given school

‘/schools/:id/schedules’ GET

id - ID of the school



39
40
41
42
43
# File 'lib/academical/api/schools.rb', line 39

def schedules(id, options = {})
  body = options.fetch(:query, {})

  @client.get("/schools/#{id}/schedules", body, options)
end

#sections(id, options = {}) ⇒ Object

Returns a list of sections for a given school

‘/schools/:id/sections’ GET

id - ID of the school



61
62
63
64
65
# File 'lib/academical/api/schools.rb', line 61

def sections(id, options = {})
  body = options.fetch(:query, {})

  @client.get("/schools/#{id}/sections", body, options)
end

#students(id, options = {}) ⇒ Object

Returns a list of students for a given school

‘/schools/:id/students’ GET

id - ID of the school



50
51
52
53
54
# File 'lib/academical/api/schools.rb', line 50

def students(id, options = {})
  body = options.fetch(:query, {})

  @client.get("/schools/#{id}/students", body, options)
end

#teachers(id, options = {}) ⇒ Object

Return a list of teachers for a given school

‘/schools/:id/teachers’ GET

id - ID of the school



72
73
74
75
76
# File 'lib/academical/api/schools.rb', line 72

def teachers(id, options = {})
  body = options.fetch(:query, {})

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

#update(id, name, nickname, locale, timezone, departments, identity_providers, app_ui, terms, options = {}) ⇒ Object

Update a new school in Academical. You must provide all of the required parameters

‘/schools/:id/’ PUT

id - Generated ID for the school name - Name of the school nickname - Nickname of the school locale - Locale of the school timezone - Timezone of the school departments - A list of Department objects. Each department should specify a name and faculty_name identity_providers - A list of Identify Providers to use with this school app_ui - Object describing UI specific parameters for our planner app terms - A list containing Term objects. Each term should define a name, a start date and end date.



117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/academical/api/schools.rb', line 117

def update(id, name, nickname, locale, timezone, departments, identity_providers, app_ui, terms, options = {})
  body = options.fetch(:body, {})
  body[:name] = name
  body[:nickname] = nickname
  body[:locale] = locale
  body[:timezone] = timezone
  body[:departments] = departments
  body[:identity_providers] = identity_providers
  body[:app_ui] = app_ui
  body[:terms] = terms

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