Module: MagisterData

Included in:
Magister
Defined in:
lib/magister/data.rb

Overview

Functions for getting or setting data from/to the magister apis

Instance Method Summary collapse

Instance Method Details

#get_classes(dateFrom, dateTo) ⇒ Object

Get all the scheduled classes between 2 dates

Parameters:

  • dateFrom (String)

    the start of the selection

  • dateTo (String)

    the end of the selection

Since:

  • 1.0.0



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/magister/data.rb', line 27

def get_classes(dateFrom, dateTo)
    if validate_date(dateFrom) && validate_date(dateTo)
        data = @profile.authenticatedRequest("/personen/{*id*}/afspraken?status=1&van=#{dateFrom}&tot=#{dateTo}")
        classes = Array.new
        data["Items"].each do |classItem|
            classes.push MagClass.new(classItem)
        end
        classes
    else
        puts "Invalid date, Format is yyyy-mm-dd"
    end
end

#get_grades(count = 5, page = 0) ⇒ Object

Get a certain ammount of grades.

Parameters:

  • count (String) (defaults to: 5)

    The ammount of grades to get

  • page (String) (defaults to: 0)

    What page to get from

Since:

  • 1.1.0



44
45
46
47
48
49
50
51
# File 'lib/magister/data.rb', line 44

def get_grades(count = 5, page = 0)
    data = @profile.authenticatedRequest("/personen/{*id*}/cijfers/laatste?top=#{count}&skip=#{count * page}")
    grades = Array.new
    data["items"].each do |grade|
        grades.push Grade.new(grade)
    end
    grades
end