api

package
v0.0.0-...-fa1da9e Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConnections

func GetConnections(stationFrom string, stationTo string) ([]byte, error)

GetConnections fetches the connection data from the API and returns the response body as a byte slice.

func GetDurationInMinutes

func GetDurationInMinutes(c Connection) string

func GetSNCBStationTimeTable

func GetSNCBStationTimeTable(stationName string) ([]byte, error)

GetSNCBStationTimeTable fetches the timetable for a specific station

func GetSNCBStationsJSON

func GetSNCBStationsJSON() ([]byte, error)

GetSNCBStationsJSON fetches the list of SNCB stations

Types

type Connection

type Connection struct {
	ID        string              `json:"id"`
	Departure ConnectionDeparture `json:"departure"`
	Arrival   ConnectionArrival   `json:"arrival"`
	Duration  string              `json:"duration"`
	Number    string              `json:"number"`
	Vias      Vias                `json:"vias,omitempty"` // waarom de * ?
}

func ParseConnections

func ParseConnections(body []byte) ([]Connection, error)

ParseConnections takes the response body as a byte slice and returns an array of Connection structs.

func (Connection) GetDelayInSeconds

func (c Connection) GetDelayInSeconds() int

func (Connection) GetUnixDepartureTime

func (c Connection) GetUnixDepartureTime() int

type ConnectionArrival

type ConnectionArrival struct {
	Station      string       `json:"station"`
	StationInfo  StationInfo  `json:"stationinfo"`
	Time         string       `json:"time"`  // Unix
	Delay        string       `json:"delay"` // seconds
	Canceled     string       `json:"canceled"`
	Left         string       `json:"left"`
	Platform     string       `json:"platform"`
	PlatformInfo PlatformInfo `json:"platforminfo"`
}

type ConnectionDeparture

type ConnectionDeparture struct {
	Station  string `json:"station"`
	Time     string `json:"time"`  // Unix
	Delay    string `json:"delay"` // seconds
	Canceled string `json:"canceled"`
	Left     string `json:"left"`
	IsExtra  string `json:"isExtra"`
	Vehicle  string `json:"vehicle"`
	Platform string `json:"platform"`
	//Stops    []Stop `json:"stops"`
	VehicleInfo VehicleInfo `json:"vehicleinfo"`
}

TODO:

type ConnectionResult

type ConnectionResult struct {
	Connection []Connection `json:"connection"`
}

type Departures

type Departures struct {
	Number    string               `json:"number"`
	Departure []TimetableDeparture `json:"departure"`
}

type Occupancy

type Occupancy struct {
	ID   string `json:"@id"`
	Name string `json:"name"`
}

type PlatformInfo

type PlatformInfo struct {
	Name   string `json:"name"`
	Normal string `json:"normal"`
}

type Station

type Station struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	StandardName string `json:"standardname"`
}

func ParseStations

func ParseStations(jsonData []byte) ([]Station, error)

ParseStations parses the JSON data of stations

type StationInfo

type StationInfo struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	LocationX    string `json:"locationX"`
	LocationY    string `json:"locationY"`
	StandardName string `json:"standardname"`
}

type StationTimetableResponse

type StationTimetableResponse struct {
	Version     string      `json:"version"`
	Timestamp   string      `json:"timestamp"`
	Station     string      `json:"station"`
	StationInfo StationInfo `json:"stationinfo"`
	Departures  Departures  `json:"departures"`
}

type Stop

type Stop struct {
	Station string `json:"station"`
	Time    string `json:"time"`  // Unix
	Delay   string `json:"delay"` // seconds
}

type TimetableDeparture

type TimetableDeparture struct {
	ID                  string       `json:"id"`
	Station             string       `json:"station"`
	StationInfo         StationInfo  `json:"stationinfo"`
	Time                string       `json:"time"`
	Delay               string       `json:"delay"` // seconds
	Canceled            string       `json:"canceled"`
	Left                string       `json:"left"`
	IsExtra             string       `json:"isExtra"`
	Vehicle             string       `json:"vehicle"`
	VehicleInfo         VehicleInfo  `json:"vehicleinfo"`
	Platform            string       `json:"platform"`
	PlatformInfo        PlatformInfo `json:"platforminfo"`
	Occupancy           Occupancy    `json:"occupancy"`
	DepartureConnection string       `json:"departureConnection"`
}

func ParseiRailDepartures

func ParseiRailDepartures(jsonData []byte) ([]TimetableDeparture, error)

ParseiRailDepartures handles fetching of timetable departures

func (TimetableDeparture) GetDelayInSeconds

func (d TimetableDeparture) GetDelayInSeconds() int

func (TimetableDeparture) GetUnixDepartureTime

func (d TimetableDeparture) GetUnixDepartureTime() int

type VehicleInfo

type VehicleInfo struct {
	Name      string `json:"name"`
	ShortName string `json:"shortname"`
	Number    string `json:"number"`
	Type      string `json:"type"`
	LocationX string `json:"locationX"`
	LocationY string `json:"locationY"`
	ID        string `json:"@id"`
}

type ViaInfo

type ViaInfo struct {
	ID        string              `json:"id"`
	Arrival   ConnectionArrival   `json:"arrival"`
	Departure ConnectionDeparture `json:"departure"`
	// Station     string              `json:"station"`
	TimeBetween string `json:"timeBetween"`
}

type Vias

type Vias struct {
	Number string    `json:"number"`
	Via    []ViaInfo `json:"via"`
}

Jump to

Keyboard shortcuts

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