tphan25 / vttimetable

This is an API for accessing Virginia Tech's Timetable of courses using Golang. You can set up a query based on multiple form parameters and return courses that would match that description.
0 stars 0 forks source link

As another project maintainer, I'd like to be able to import this project as a module, so that I can make queries and get course results from the timetable with ease in other Golang projects. #8

Closed tphan25 closed 4 years ago

tphan25 commented 4 years ago

Transform this project so that it is importable by another project separately.

tphan25 commented 4 years ago

The project is now importable at github.com/tphan25/vttimetable.

timetableURL := "https://banweb.banner.vt.edu/ssb/prod/HZSKVTSC.P_ProcRequest"
cq := vttimetable.CreateEmptyQuery().SetCampus("0").SetCrn("828").SetTermYear("201909")
resp, err := vttimetable.SendQuery(timetableURL, cq)
if err != nil {
    fmt.Println(err)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
    fmt.Println(err)
}
err = ioutil.WriteFile("foo.txt", body, 0644)
if err != nil {
    fmt.Println(err)
}
courses, err := vttimetable.ReadInput(bytes.NewReader(body))
if err != nil {
    fmt.Println(err)
}
for _, course := range courses {
    fmt.Println(course)
}

A sample file, will probably create helper methods so that some users may not need to interact with all of the response data.