source

package
v0.0.0-...-fa793e7 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultFetchSpacing = 100 * time.Millisecond
View Source
const DefaultMaxPages = 5
View Source
const DefaultPageSize = 10_000

Variables

View Source
var ErrTooManyPages = errors.New("fetching operations takes too many pages")

Functions

This section is empty.

Types

type AffectedTrain

type AffectedTrain struct {
	TrainID
	StationID int `json:"stid"`
	Sequence  int `json:"seq"`
}

type Disruption

type Disruption struct {
	ID             int              `json:"id"`
	Type           string           `json:"tc"`
	Title          string           `json:"tt"`
	Message        string           `json:"msg"`
	AffectedTrains []*AffectedTrain `json:"ar"`
}

type Disruptions

type Disruptions struct {
	Timestamp       time.Time         `json:"ts"`
	Disruptions     []*Disruption     `json:"ds"`
	DisruptionTypes map[string]string `json:"dt"`
}

func FetchDisruptions

func FetchDisruptions(ctx context.Context, apikey string, client http2.Doer, dateFrom, dateTo time2.Date) (d *Disruptions, err error)

type OperationTrain

type OperationTrain struct {
	TrainID
	Status string                `json:"s"`
	Stops  []*OperationTrainStop `json:"st"`
}

type OperationTrainStop

type OperationTrainStop struct {
	StopID          int             `json:"id"`
	PlannedSequence int             `json:"psn"`
	ActualSequence  int             `json:"asn"`
	LiveArrival     time2.LocalTime `json:"aa"`
	LiveDeparture   time2.LocalTime `json:"ad"`
	Confirmed       bool            `json:"cf"`
	Cancelled       bool            `json:"cn"`
}

type Operations

type Operations struct {
	Timestamp time.Time         `json:"ts"`
	Pages     Pagination        `json:"pg"`
	Trains    []*OperationTrain `json:"tr"`
}

func FetchOperations

func FetchOperations(ctx context.Context, apikey string, client http2.Doer, options PageFetchOptions) (*Operations, error)

func FetchOperationsPage

func FetchOperationsPage(ctx context.Context, apikey string, client http2.Doer, page, pageSize int, cacheBuster int64) (o *Operations, err error)

type PageFetchOptions

type PageFetchOptions struct {
	PageSize int
	MaxPages int
}

func NewPageFetchOptions

func NewPageFetchOptions() PageFetchOptions

type Pagination

type Pagination struct {
	Page         int  `json:"p"`
	PageSize     int  `json:"ps"`
	TotalPages   int  `json:"tp"`
	TotalEntries int  `json:"tc"`
	HasNext      bool `json:"hn"`
	HasPrevious  bool `json:"hp"`
}

type Period

type Period struct {
	From time2.Date `json:"f"`
	To   time2.Date `json:"t"`
}

type TrainID

type TrainID struct {
	ScheduleID    int        `json:"sid"`
	OrderID       int        `json:"oid"`
	TrainOrderID  int        `json:"toid"`
	OperatingDate time2.Date `json:"od"`
}

type TrimmedRoute

type TrimmedRoute struct {
	ScheduleID             int          `json:"sid"`
	OrderID                int          `json:"oid"`
	TrainOrderID           int          `json:"toid"`
	OperatingDates         []time2.Date `json:"od"`
	CarrierCode            string       `json:"cc"`
	Number                 string       `json:"nn"`
	InternationalDepNumber string       `json:"idn"`
	InternationalArrNumber string       `json:"ian"`
}

func (*TrimmedRoute) GetNumber

func (r *TrimmedRoute) GetNumber() string

func (*TrimmedRoute) TrainIDs

func (r *TrimmedRoute) TrainIDs() []TrainID

type TrimmedSchedules

type TrimmedSchedules struct {
	Timestamp time.Time       `json:"ts"`
	Trains    []*TrimmedRoute `json:"rt"`
}

func FetchTrimmedSchedules

func FetchTrimmedSchedules(ctx context.Context, apikey string, client http2.Doer, startDate, endDate time2.Date) (*TrimmedSchedules, error)

Jump to

Keyboard shortcuts

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