hafas

package
v0.0.0-...-70a2b83 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionalInfo

type AdditionalInfo struct {
	AttrHU    bool   `json:"attr_HU"`
	AttrHUVal string `json:"attr_HU_val"`
	AttrMU    bool   `json:"attr_MU"`
}

type Attrs

type Attrs struct {
	Code          string `json:"code"`
	HightPriority bool   `json:"hightPriority"`
	Priority      string `json:"priority"`
	Text          string `json:"text"`
}

type Client

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

Client is an API client for a HAFAS REST API endpoint.

func NewClient

func NewClient(baseURL, timeZone string) (*Client, error)

NewClient creates a new client. Parameters:

baseURL: e.g. https://zvv.hafas.cloud/bin
timeZone: e.g. Europe/Zurich

func (*Client) FindStop

func (c *Client) FindStop(ctx context.Context, query string) (*Stop, error)

func (*Client) GetStops

func (c *Client) GetStops(ctx context.Context, query string, nResults int) ([]Stop, error)

func (*Client) StBoard

func (c *Client) StBoard(ctx context.Context, stopName, stopID string, ts time.Time, nResults int) ([]Conn, error)

type Color

type Color struct {
	Bg string `json:"bg"`
	Fg string `json:"fg"`
}

type Conn

type Conn struct {
	Attributes          []Attrs       `json:"attributes"`
	AttributesBfr       []Attrs       `json:"attributes_bfr"`
	Cancelled           bool          `json:"cancelled"`
	Date                string        `json:"date"`
	HasGlobalHIMMessage bool          `json:"hasGlobalHIMMessage"`
	HasHIMMessage       bool          `json:"hasHIMMessage"`
	HimMessages         []interface{} `json:"himMessages"`
	Locations           []Location    `json:"locations"`
	MainLocation        Location      `json:"mainLocation"`
	Name                string        `json:"name"`
	Product             Product       `json:"product"`
	TrainInfo           string        `json:"trainInfo"`
}

type Location

type Location struct {
	Countdown string        `json:"countdown"`
	Date      string        `json:"date"`
	Location  LocationPoint `json:"location"`
	Platform  string        `json:"platform"`
	RealTime  RealTime      `json:"realTime"`
	Time      string        `json:"time"`
}

func (Location) BestCountdown

func (l Location) BestCountdown() time.Duration

func (Location) DateTime

func (l Location) DateTime() string

type LocationPoint

type LocationPoint struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	TupelID string `json:"tupelId"`
	Type    string `json:"type"`
	X       int64  `json:"x"`
	Y       int64  `json:"y"`
}

type Product

type Product struct {
	Color         Color  `json:"color"`
	Direction     string `json:"direction"`
	DirectionType string `json:"directionType"`
	Icon          string `json:"icon"`
	Line          string `json:"line"`
	LongName      string `json:"longName"`
	Name          string `json:"name"`
	Type          string `json:"type"`
}

func (Product) Emoji

func (p Product) Emoji() string

func (Product) String

func (p Product) String() string

type RealTime

type RealTime struct {
	Countdown         string `json:"countdown"`
	Date              string `json:"date"`
	Delay             string `json:"delay"`
	HasRealTime       bool   `json:"hasRealTime"`
	IsDelayed         bool   `json:"isDelayed"`
	IsPlatformChanged bool   `json:"isPlatformChanged"`
	Platform          string `json:"platform"`
	Time              string `json:"time"`
}

type Station

type Station struct {
	AdditionalInformation AdditionalInfo `json:"additionalInformation"`
	Name                  string         `json:"name"`
}

type Stop

type Stop struct {
	ExtID     string `json:"extId"`
	ID        string `json:"id"`
	ProdClass string `json:"prodClass"`
	State     string `json:"state"`
	Type      string `json:"type"`
	TypeStr   string `json:"typeStr"`
	Name      string `json:"value"`
	Weight    string `json:"weight"`
	Xcoord    string `json:"xcoord"`
	Ycoord    string `json:"ycoord"`
}

Jump to

Keyboard shortcuts

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