prt

package
v0.0.0-...-efa4506 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2018 License: GPL-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const StatusAPI = "https://prtstatus.wvu.edu/api/%s?format=json"

StatusAPI is the endpoint for the PRT status

Variables

This section is empty.

Functions

This section is empty.

Types

type Status

type Status struct {
	// Status can be an integer from 1 through 7 meaning the following:
	// 1 - normal, 2 - down between A and B, 3 - down for maintenance, 4 - down, 5 - special event, 6 - down at A, 7 - closed
	// However, PRT operators seem to play favorites with just 1, 5, and 7 even though others are more applicable
	Status int `json:"status"`
	// Message will contain the message text as entered by the PRT operators
	Message string `json:"message"`
	// Timestamp is a 64-bit integer of a Unix timestamp of the status event
	Timestamp int64 `json:"timestamp"`
	// Stations is a string array of the stations the event occurred at
	Stations []string `json:"stations"`
	// BussesDispatched is a boolean true if the event required busses to be dispatched
	BussesDispatched bool `json:"bussesDispatched"`
	// Duration is a so far unused string variable
	Duration string `json:"duration"`
}

Status is a PRT status update

func (*Status) CompareTo

func (status *Status) CompareTo(b *Status) int

CompareTo compares a Status update A with B, useful for sorting chronologically

func (*Status) GetStatusText

func (status *Status) GetStatusText() string

GetStatusText returns a simple English representation of the PRT's status

func (*Status) IsClosed

func (status *Status) IsClosed() bool

IsClosed returns if the PRT is closed

func (*Status) IsDown

func (status *Status) IsDown() bool

IsDown returns if the PRT is not functioning

func (*Status) IsOpen

func (status *Status) IsOpen() bool

IsOpen returns if the PRT is open

func (*Status) ToMap

func (status *Status) ToMap() map[string]string

ToMap returns a key-value map[string]string of the event

type StatusClient

type StatusClient struct {
	// contains filtered or unexported fields
}

StatusClient is the client used in go to intermediate status request

func NewClient

func NewClient(c ...*http.Client) *StatusClient

NewClient returns a new StatusClient to use to query for PRT status updates

func (*StatusClient) GetCurrentStatus

func (c *StatusClient) GetCurrentStatus() (*Status, string, error)

GetCurrentStatus retuns the current status from the live status API

func (*StatusClient) GetStatus

func (c *StatusClient) GetStatus(t time.Time) (*Status, string, error)

GetStatus returns a status from the live status API relative to the supplied time

Jump to

Keyboard shortcuts

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