Class: Unistats
Instance Method Summary collapse
-
#authenticated? ⇒ Boolean
Checks whether provided API authentication credentials for the Unistats API are correct, returning true or false.
-
#course(institution, course, recursive = true, options = {}) ⇒ Object
- Returns information about a specific course at an institution as an object parsed from JSON Params:
institution
- the UKPRN identifier for an institution
course
- the KIS ID for a course, unique to a course provider (UKPRN)
recursive
-
(boolean) sets whether to use the other course data methods to find out more details about this course (e.g. statistics, stages).
- the KIS ID for a course, unique to a course provider (UKPRN)
- the UKPRN identifier for an institution
- Returns information about a specific course at an institution as an object parsed from JSON Params:
-
#course_accreditations(institution, course, options = {}) ⇒ Object
- Returns information on accreditations for a specific course at an institution as an object parsed from JSON Params:
institution
- the UKPRN identifier for an institution
course
-
the KIS ID for a course, unique to a course provider (UKPRN).
- the UKPRN identifier for an institution
- Returns information on accreditations for a specific course at an institution as an object parsed from JSON Params:
-
#course_stages(institution, course, options = {}) ⇒ Object
- Returns information on stages of a specific course at an institution as an object parsed from JSON Params:
institution
- the UKPRN identifier for an institution
course
-
the KIS idea for a course, unique to a course provider (UKPRN).
- the UKPRN identifier for an institution
- Returns information on stages of a specific course at an institution as an object parsed from JSON Params:
-
#course_statistics(institution, course, options = {}) ⇒ Object
- Returns statistics aboout a specific course at an institution as an object parsed from JSON Params:
institution
- the UKPRN identifier for an institution
course
-
the KIS idea for a course, unique to a course provider (UKPRN).
- the UKPRN identifier for an institution
- Returns statistics aboout a specific course at an institution as an object parsed from JSON Params:
-
#courses(institution, pageIndex = 0, options = {}) ⇒ Object
- Returns information about courses at an institution as an object parsed from JSON, in pages of 25 entries Params:
institution
- the UKPRN identifier for an institution
pageIndex
-
the page number to view, starting from 0.
- the UKPRN identifier for an institution
- Returns information about courses at an institution as an object parsed from JSON, in pages of 25 entries Params:
-
#initialize(access_token) ⇒ Unistats
constructor
- Initialises the Unistats class and configures authentication with an access token - obtain one at dataportal.unistats.ac.uk/Account/Register Params:
access_token
-
an access token for the Unistats API.
- Initialises the Unistats class and configures authentication with an access token - obtain one at dataportal.unistats.ac.uk/Account/Register Params:
-
#institution(institution, options = {}) ⇒ Object
- Returns information about a specified institution as an object parsed from JSON Params:
institution
-
the UKPRN identifier for an institution.
- Returns information about a specified institution as an object parsed from JSON Params:
-
#institutions(pageIndex = 0, options = {}) ⇒ Object
- Returns a list of institutions registered on Unistats in pages of 25 entries as an object parsed from JSON Params:
pageIndex
-
the page number to view, starting from 0.
- Returns a list of institutions registered on Unistats in pages of 25 entries as an object parsed from JSON Params:
Constructor Details
#initialize(access_token) ⇒ Unistats
Initialises the Unistats class and configures authentication with an access token - obtain one at dataportal.unistats.ac.uk/Account/Register Params:
access_token
-
an access token for the Unistats API
14 15 16 |
# File 'lib/unistats.rb', line 14 def initialize(access_token) self.class.basic_auth access_token, nil end |
Instance Method Details
#authenticated? ⇒ Boolean
Checks whether provided API authentication credentials for the Unistats API are correct, returning true or false
20 21 22 23 24 25 26 27 28 |
# File 'lib/unistats.rb', line 20 def authenticated? response = institutions case response.code when 401 false else true end end |
#course(institution, course, recursive = true, options = {}) ⇒ Object
Returns information about a specific course at an institution as an object parsed from JSON Params:
institution
-
the UKPRN identifier for an institution
course
-
the KIS ID for a course, unique to a course provider (UKPRN)
recursive
-
(boolean) sets whether to use the other course data methods
to find out more details about this course (e.g. statistics, stages)
64 65 66 67 68 69 70 71 72 |
# File 'lib/unistats.rb', line 64 def course(institution, course, recursive=true, ={}) response = self.class.get("/Institution/#{institution}/Course/#{course}.json", ) if recursive response.merge!({:accreditations => course_accreditations(institution, course)}) response.merge!({:stages => course_stages(institution, course)}) response.merge!({:statistics => course_statistics(institution, course)}) end response end |
#course_accreditations(institution, course, options = {}) ⇒ Object
Returns information on accreditations for a specific course at an institution as an object parsed from JSON Params:
institution
-
the UKPRN identifier for an institution
course
-
the KIS ID for a course, unique to a course provider (UKPRN)
79 80 81 |
# File 'lib/unistats.rb', line 79 def course_accreditations(institution, course, ={}) self.class.get("/Institution/#{institution}/Course/#{course}/Accreditation.json", ) end |
#course_stages(institution, course, options = {}) ⇒ Object
Returns information on stages of a specific course at an institution as an object parsed from JSON Params:
institution
-
the UKPRN identifier for an institution
course
-
the KIS idea for a course, unique to a course provider (UKPRN)
88 89 90 |
# File 'lib/unistats.rb', line 88 def course_stages(institution, course, ={}) self.class.get("/Institution/#{institution}/Course/#{course}/Stages.json", ) end |
#course_statistics(institution, course, options = {}) ⇒ Object
Returns statistics aboout a specific course at an institution as an object parsed from JSON Params:
institution
-
the UKPRN identifier for an institution
course
-
the KIS idea for a course, unique to a course provider (UKPRN)
97 98 99 |
# File 'lib/unistats.rb', line 97 def course_statistics(institution, course, ={}) self.class.get("/Institution/#{institution}/Course/#{course}/Statistics.json", ) end |
#courses(institution, pageIndex = 0, options = {}) ⇒ Object
Returns information about courses at an institution as an object parsed from JSON, in pages of 25 entries Params:
institution
-
the UKPRN identifier for an institution
pageIndex
-
the page number to view, starting from 0
52 53 54 55 |
# File 'lib/unistats.rb', line 52 def courses(institution, pageIndex=0, ={}) .merge!({:query => {:pageIndex => pageIndex}}) self.class.get("/Institution/#{institution}/Courses.json", ) end |
#institution(institution, options = {}) ⇒ Object
Returns information about a specified institution as an object parsed from JSON Params:
institution
-
the UKPRN identifier for an institution
43 44 45 |
# File 'lib/unistats.rb', line 43 def institution(institution, ={}) self.class.get("/Institution/#{institution}.json", ) end |
#institutions(pageIndex = 0, options = {}) ⇒ Object
Returns a list of institutions registered on Unistats in pages of 25 entries as an object parsed from JSON Params:
pageIndex
-
the page number to view, starting from 0
34 35 36 37 |
# File 'lib/unistats.rb', line 34 def institutions(pageIndex=0, ={}) .merge!({:query => {:pageIndex => pageIndex}}) self.class.get("/Institutions.json", ) end |