compass

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

README

Compass API

GitHub go.mod Go version Go Reference GitHub Actions Workflow Status

Note: This library is under active development as we expand it to cover more of compass.

A Go library for interacting with Compass's API. This library allows you to:

  • Get Staff
  • Get Classes
  • Get Locations

[!NOTE] More Functions coming soon.

Installation

You need a working Go environment. We officially support only currently supported Go versions according to Go project's release policy.

go get github.com/compassedu/api

Getting Started package main

import (
	"fmt"
	"log"
	"os"
	"time"

	"github.com/compassedu/api"
)

func main() {
	// Construct a new API object
	api, err := compass.New(os.Getenv("USERNAME"), os.Getenv("PASSWORD"), os.Getenv("SCHOOLID"))
	if err != nil {
		log.Fatal(err)
	}
	// Fetch classes for today
	c, err := api.GetClasses(time.Now(), time.Now())
	if err != nil {
		log.Fatal(err)
	}
	// Print Classes
	fmt.Println(c)
}

Refer to the API documentation for how to use this package in-depth.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// supplied username
	//
	// e.g. JOHNDOE08
	APIUsername string
	// supplied password
	//
	// e.g. *****
	APIPassword string
	// supplied school prefix
	//
	// e.g. ui
	APISchoolPrefix string
	// the base url that will be requested
	//
	// e.g. ui.compass.education
	BaseURL string
	// the cookies which are created
	APICookies string
	// your user id
	APIUserId float64
}

func New

func New(username string, password string, schoolId string) (*API, error)

New creates a new Compass API client.

func (*API) GetAllLocations

func (c *API) GetAllLocations() ([]types.LC, error)

Retrieves locations.

The function takes the provided session 'cookies' & 'schoolId' to make a request to the Compass Education API and fetch locations.

Returns:

  • []types.LC: A slice of locations in the form of 'types.LC'.
  • error: An error, if any, that occurred during the API request or processing of the response.

func (*API) GetAllStaff

func (c *API) GetAllStaff() ([]types.User, error)

Retrieves staff.

The function takes the provided session 'cookies' & 'schoolId' to make a request to the Compass Education API and fetch staff.

Returns:

  • []types.User: A slice of staff in the form of 'types.User'.
  • error: An error, if any, that occurred during the API request or processing of the response.

func (*API) GetClasses

func (c *API) GetClasses(start time.Time, end time.Time) ([]types.CalendarTransport, error)

Retrieves calendar events for a specified user within a date range.

The function takes the provided session 'cookies', 'schoolId', 'userId', 'startDate', and 'endDate' to make a request to the Compass Education API and fetch calendar events for the specified user within the given date range.

Parameters:

  • startDate: The start date of the range for which calendar events are requested.
  • endDate: The end date of the range for which calendar events are requested.

Returns:

  • []types.CalendarTransport: A slice of calendar events in the form of 'types.CalendarTransport'.
  • error: An error, if any, that occurred during the API request or processing of the response.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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