opendata

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package opendata provides functions to fetch data from the UniBo Open Data portal.

It is useful in particular to get degrees (see GetDegrees).

Index

Constants

View Source
const (
	// PackageDegreeProgrammesId is the id of the package containing the degrees.
	PackageDegreeProgrammesId = "degree-programmes"

	// ResourceDegreeProgrammesAlias is the alias of the resource containing the
	// degrees.
	ResourceDegreeProgrammesAlias = "corsi_latest_it"
)

Variables

This section is empty.

Functions

func GetDegrees

func GetDegrees() ([]degree.Degree, error)

GetDegrees fetches and returns the degrees available in the open data for the current year.

Internally it uses PackageDegreeProgrammesId and ResourceDegreeProgrammesAlias constants to get the wanted package and resource and then parses the csv file to get the degrees.

If you'd like to get the package and resource yourself (maybe you want to download the csv file), you can use FetchPackage and Resources.GetByAlias.

Types

type Package

type Package struct {
	Success bool `json:"success"`
	Result  struct {
		Resources Resources
	}
}

Package represents a package in the UniBO Open Data portal.

func FetchPackage

func FetchPackage(id string) (*Package, error)

FetchPackage retrieves the package with the given id from the Unibo Open Data portal.

If the package is found, it returns a pointer to the package. Otherwise, it returns nil and an error.

type Resource

type Resource struct {
	Frequency string `json:"frequency"`
	Url       string `json:"url"`
	Id        string `json:"id"`
	PackageId string `json:"package_id"`
	LastMod   string `json:"last_modified"`
	Alias     string `json:"alias"`
}

Resource represents a resource in the UniBO Open Data portal.

type Resources

type Resources []Resource

func (Resources) GetByAlias

func (r Resources) GetByAlias(alias string) (*Resource, bool)

GetByAlias returns the resource with the given alias, if it exists in the Resources slice.

If the resource is found, it returns a pointer to the resource and true. Otherwise, it returns nil and false.

Jump to

Keyboard shortcuts

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