api

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const InventoryTransactionKey contextKey = 0

InventoryTransactionKey is the context key for the inventory database transaction for a request

View Source
const SkywardTransactionKey contextKey = 1

SkywardTransactionKey is the context key for the skyward database transaction for a request

View Source
const UserKey contextKey = 2

UserKey is the context key for the user for a request

Variables

View Source
var ChargeURLBase = "/charges/edit?type=id&search="

ChargeURLBase is the base URL used for charge links

View Source
var DeviceURLBase = "/edit?type=id&search="

DeviceURLBase is the base URL used for device links

Functions

func CheckoutDevice

func CheckoutDevice(ctx context.Context, otherID, bagTag, extraNote string) error

CheckoutDevice checks out the device with the given bagTag to the student with the given otherID. extraNote, if non-empty, will be appended to the notes field

Types

type AuthConfig

type AuthConfig struct {
	ADConfig *auth.Config
	Group    string
}

AuthConfig holds configuration for connecting to an authentication source

type Charge added in v1.2.0

type Charge struct {
	ID         int
	AmountPaid float32
	// contains filtered or unexported fields
}

Charge represents an inventory charge

func (*Charge) AmountCharged added in v1.2.0

func (c *Charge) AmountCharged() float32

AmountCharged is the total amount charged

func (*Charge) Description added in v1.6.1

func (c *Charge) Description() string

Description is a list of the reasons for the charge

type Error

type Error struct {
	Description  string
	Err          error
	RequestError bool
}

Error wraps errors in the API

func (*Error) Error

func (e *Error) Error() string

type Issue added in v1.4.0

type Issue struct {
	Description    string   `json:"description,omitempty"`
	Link           string   `json:"link,omitempty"`
	LinkType       LinkType `json:"link_type,omitempty"`
	LinkValue      float32  `json:"link_value,omitempty"`
	LinkAdditional string   `json:"link_additional,omitempty"`
}

Issue represents an issue with a student

type LinkType added in v1.4.0

type LinkType string

LinkType is the type of a link

const (
	LinkTypeDevice LinkType = "device"
	LinkTypeCharge LinkType = "charge"
)

Link types

type Status added in v1.2.0

type Status struct {
	Type   StatusType `json:"type"`
	Issues []*Issue   `json:"issues,omitempty"`
}

Status represents the status of a student

type StatusType added in v1.4.0

type StatusType string

StatusType is the type of Chromebook a student will receive

const (
	StatusTypeNone     StatusType = "none"
	StatusTypeRedBag   StatusType = "red_bag"
	StatusTypeBlackBag StatusType = "black_bag"
)

Status types

type Student

type Student struct {
	FirstName                 string
	LastName                  string
	OtherID                   string
	Grade                     int
	T2E2Status                *string
	EconomicallyDisadvantaged bool
}

Student represents a Skyward Student

func GetStudent added in v1.2.0

func GetStudent(ctx context.Context, otherID string) (*Student, error)

GetStudent returns the Student with the given otherID

func GetStudentList

func GetStudentList(ctx context.Context) ([]*Student, error)

GetStudentList returns a list of all Students

func (Student) Name added in v1.2.0

func (s Student) Name() string

Name returns to formalized name of the Student

func (*Student) Status added in v1.2.0

func (s *Student) Status(ctx context.Context) (*Status, error)

Status returns the Status of the student

type User

type User struct {
	Username    string `json:"username"`
	DisplayName string `json:"display_name"`
}

User represents an Active Directory User

func Authenticate

func Authenticate(config *AuthConfig, username, password string) (*User, error)

Authenticate authenticates the given username and password against the given config, returning user information if successful, nil if unsuccessful, or an error if one occurred.

Jump to

Keyboard shortcuts

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