atb

package module
v0.0.0-...-c1221da Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// TimeDeparture is the 'dir' used when the dtime and ddate represents
	// the departure time.
	TimeDeparture int = 1

	// TimeArrival is the 'dir' used when the dtime and ddate represents
	// the arrival time.
	TimeArrival = 2
)
View Source
const DeparturesURL = `https://rp.atb.no/scripts/TravelMagic/TravelMagicWE.dll/svar`

DeparturesURL is the URL for the 'departures' endpoint.

View Source
const SuggestionsURL = "https://rp.atb.no/scripts/TravelMagic/TravelMagicWE.dll/StageJSON"

SuggestionsURL is the URL for the 'suggestions' endpoint.

Variables

This section is empty.

Functions

func GetSuggestions

func GetSuggestions(query string) ([]string, error)

GetSuggestions queries the SuggestionsURL to get bus-stops matching the given query.

Types

type Departure

type Departure struct {
	Start    time.Time     `json:"start"`
	End      time.Time     `json:"end"`
	Changes  int           `json:"changes"`
	Fare     string        `json:"fare"`
	Duration time.Duration `json:"duration"`
	Route    []Transport   `json:"route"`
}

Departure ...

func GetDepartures

func GetDepartures(dir int, from, to, dtime, ddate string) ([]Departure, error)

GetDepartures ...

func GetDeparturesNow

func GetDeparturesNow(from, to string) ([]Departure, error)

GetDeparturesNow ...

func GetDeparturesReq

func GetDeparturesReq(req DepartureReq) (deps []Departure, err error)

GetDeparturesReq ...

type DepartureReq

type DepartureReq struct {
	//	Dir           int
	From          string
	To            string
	Time          string
	Date          string
	IsArrivalTime bool // Used for non-realtime requests.
	IsRealtime    bool
}

DepartureReq holds information used in the departure request.

type RealtimeDeparture

type RealtimeDeparture struct {
	Transport  Transport `json:"transport"`
	IsRealtime bool      `json:"is_realtime"`
	LocationID int       `json:"location_id"`
	Towards    string    `json:"towards"`
}

RealtimeDeparture contains the data describing a realtime departure response.

func GetRealtimeDepartures

func GetRealtimeDepartures(from string) (rdeps []RealtimeDeparture, err error)

GetRealtimeDepartures ...

type SuggestionRes

type SuggestionRes struct {
	Query       string   `json:"query"`
	Suggestions []string `json:"suggestions"`
}

SuggestionRes represents the result from the Suggestions endpoint (given by SuggestionsURL).

type Transport

type Transport struct {
	Type     TransportType `json:"type"`
	WalkText string        `json:"walk_text,omitempty"`
	LineNum  int           `json:"linenum"`
	Start    time.Time     `json:"start_time"`
}

Transport ...

type TransportType

type TransportType int

TransportType ...

const (
	// TransportBus ...
	TransportBus TransportType = iota
	// TransportWalking ...
	TransportWalking
)

Jump to

Keyboard shortcuts

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