Skip to content

TheMoonThatRises/StudentVue.swift

Repository files navigation

StudentVue.swift

Supported Platforms MIT

Swift library for interacting with StudentVue's api. This project was heavily influenced by StudentVue.js and relied on information provided by their documentation. This library is still a work in progress and if you encounter an issue, feel free to create an issue or submit a pull request.

Installation

.package(url: "https://github.com/TheMoonThatRises/StudentVue.swift", from: "0.1.6")

Basic usage

Logging in as a student

To create a client instance, use:

import StudentVue

let client = StudentVue(domain: "something.edupoint.com", username: "123456789", password: "password")

With the client initialized, you can access information from the official api by using the provided functions such as getGradeBook, getClassSchedule, getSchoolInfo, and many more. If one of the functions fails to parse or you want to access information in which a data structure is not created, you can call the makeServiceRequest and parse the XML manually.

let gradebook = try await client.api.getGradeBook()

Static functions

For some functions, logging in is not required, such as getting district zip codes.

let districts = try await client.api.getDistricts(zip: "a zip code")

You can also use the scraper which gives more information and functionality, but is not fully implemented. With the following example you can assess whether or not a username and password combination are valid. The line below that will you out of StudentVue. More and easier functionality will be added to the scraper in the future.

try await client.scraper.login() // Log into StudentVue. NOTE: login returns gradebook html

try await client.scraper.logout() // Log out of StudentVue. Returns boolean indicating success

You can use the built-in scraper parser to parse specific endpoints. These structs are in the StudentVueScraper class and has the html parameter for html to parse. Some will include client which is of class StudentVue which may be used to access additional helper pieces of information.

try await StudentVueScraper.GradeBook(html: try await client.scraper.login(), client: client) // Returns gradebook in an array of `ClassData`

If you require a struct to be Hashable (for iterating in UI), you can create an extension like this:

extension StudentVueApi.DistrictInfo: Hashable {
    public func hash(into hasher: inout Hasher) {
        hasher.combine(districtID)
    }

    public static func == (lhs: StudentVueApi.DistrictInfo, rhs: StudentVueApi.DistrictInfo) -> Bool {
        lhs.districtID == rhs.districtID
    }
}

Todo List

  • A website for documentation
  • More complete structures for returned data
    • Use the WSDL file to help with the data structure
  • Use a proper SOAP handler instead of the "hacky" solution
  • More complete scraper parser - In progress

Library Used