btime

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package btime is a library for the berkeleytime api. See https://www.berkeleytime.com/landing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catalog

type Catalog struct {
	Level       Items `json:"level"`
	Haas        Items `json:"haas"`
	University  Items `json:"university"`
	Engineering Items `json:"engineering"`
	Department  Items `json:"department"`
	Ls          Items `json:"ls"`
	Semester    Items `json:"semester"`
	Units       Items `json:"units"`

	// TODO: find out what type these should be
	Time       []interface{} `json:"time"`
	Length     []interface{} `json:"length"`
	Chemistry  []interface{} `json:"chemistry"`
	Enrollment []interface{} `json:"enrollment"`

	DefaultPlaylists string `json:"default_playlists"`
	DefaultCourse    string `json:"default_course"`
	// contains filtered or unexported fields
}

Catalog is a json struct for a catalog

func New

func New() (*Catalog, error)

New creates a new catalog

func (*Catalog) AllItems

func (c *Catalog) AllItems() []Item

AllItems returns a slice of all of the items in the catalog.

func (*Catalog) Courses

func (c *Catalog) Courses() []school.Course

Courses returns a slice of Results in a generic Course interface format. Returns nil on error.

func (*Catalog) DefaultFilter

func (c *Catalog) DefaultFilter() (Results, error)

DefaultFilter makes a filter request to the catalog's default filter parameters

func (*Catalog) Get

func (c *Catalog) Get(id int) school.Course

Get will get a course given an id.

func (*Catalog) Len added in v0.0.4

func (c *Catalog) Len() int

Len gets the length of the catalog

type Course

type Course struct {
	Course struct {
		Units              string  `json:"units"`
		Description        string  `json:"description"`
		Title              string  `json:"title"`
		Prerequisites      string  `json:"prerequisites"`
		Abbreviation       string  `json:"abbreviation"`
		EnrolledPercentage float64 `json:"enrolled_percentage"`
		Department         string  `json:"department"`
		EnrolledMax        int     `json:"enrolled_max"`
		Waitlisted         int     `json:"waitlisted"`
		Enrolled           int     `json:"enrolled"`
		GradeAverage       float64 `json:"grade_average"`
		CourseNumber       string  `json:"course_number"`
		ID                 int     `json:"id"`
		LetterAverage      string  `json:"letter_average"`
	} `json:"course"`
	Marketplace struct {
	} `json:"marketplace"`
	LastEnrollmentUpdate string   `json:"last_enrollment_update"`
	Requirements         []string `json:"requirements"`
	Favorited            bool     `json:"favorited"`
	Ongoing              bool     `json:"ongoing"`
	CoverPhoto           string   `json:"cover_photo"`
	Sections             []struct {
		Kind          string `json:"kind"`
		LocationName  string `json:"location_name"`
		Waitlisted    int    `json:"waitlisted"`
		FinalEnd      string `json:"final_end"`
		StartTime     string `json:"start_time"`
		SectionNumber string `json:"section_number"`
		FinalStart    string `json:"final_start"`
		WordDays      string `json:"word_days"`
		Ccn           string `json:"ccn"`
		EnrolledMax   int    `json:"enrolled_max"`
		EndTime       string `json:"end_time"`
		FinalDay      string `json:"final_day"`
		Enrolled      int    `json:"enrolled"`
		Instructor    string `json:"instructor"`
		ID            int    `json:"id"`
	} `json:"sections"`
	OngoingSections []struct {
		Kind          string `json:"kind"`
		LocationName  string `json:"location_name"`
		Waitlisted    int    `json:"waitlisted"`
		FinalEnd      string `json:"final_end"`
		StartTime     string `json:"start_time"`
		SectionNumber string `json:"section_number"`
		FinalStart    string `json:"final_start"`
		WordDays      string `json:"word_days"`
		Ccn           string `json:"ccn"`
		EnrolledMax   int    `json:"enrolled_max"`
		EndTime       string `json:"end_time"`
		FinalDay      string `json:"final_day"`
		Enrolled      int    `json:"enrolled"`
		Instructor    string `json:"instructor"`
		ID            int    `json:"id"`
	} `json:"ongoing_sections"`
}

Course is the course info sent back as json.

type Item

type Item struct {
	Name     string `json:"name"`
	Semester string `json:"semester"`
	Category string `json:"category"`
	Year     string `json:"year"`
	ID       int    `json:"id"`
}

Item is an item on the catalog

type Items

type Items []Item

Items is a slice of Item structs

func (Items) Search

func (its Items) Search(term string) *Item

Search the list of items given a search term.

type Result

type Result struct {
	Title              string  `json:"title"`
	Description        string  `json:"description"`
	ResultID           int     `json:"id"`
	Units              string  `json:"units"`
	OpenSeats          int     `json:"open_seats"`
	Abbreviation       string  `json:"abbreviation"`
	EnrolledPercentage float64 `json:"enrolled_percentage"`
	CourseNumber       string  `json:"course_number"`
	FavoriteCount      int     `json:"favorite_count"`
	Waitlisted         int     `json:"waitlisted"`
	Enrolled           int     `json:"enrolled"`

	GradeAverage  float64 `json:"grade_average"`
	LetterAverage string  `json:"letter_average"`
}

Result is the result from the filter endpoint.

func (*Result) Course

func (r *Result) Course() (*Course, error)

Course will get the course associated with the filter result.

func (*Result) ID

func (r *Result) ID() int

ID returns the id

func (*Result) Name

func (r *Result) Name() string

Name returns the courses Title

func (*Result) SeatsOpen

func (r *Result) SeatsOpen() int

SeatsOpen returns the OpenSeats field and is here for interface implimentation

type Results

type Results []Result

Results is a slice of result structs

func Filter

func Filter(opts ...interface{}) (Results, error)

Filter will return the results from a filter request given filter option IDs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL