marudor

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2020 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 APIClient

type APIClient struct {
	EndpointURL *url.URL
	UserAgent   string

	HafasService *HafasService
	// contains filtered or unexported fields
}

APIClient for api requests

func NewAPIClient

func NewAPIClient(endpoint string, httpClient *http.Client, log *logrus.Entry) (*APIClient, error)

NewAPIClient return a client with all services

type HafasArrival

type HafasArrival struct {
	Platform      string `json:"platform"`
	ScheduledTime int64  `json:"scheduledTime"`
	Time          int64  `json:"time"`
	Reihung       bool   `json:"reihung"`
}

HafasArrival ressource

type HafasCoordinates

type HafasCoordinates struct {
	Lng float64 `json:"lng"`
	Lat float64 `json:"lat"`
}

HafasCoordinates ressource

type HafasDeparture

type HafasDeparture struct {
	Platform      string `json:"platform"`
	ScheduledTime int64  `json:"scheduledTime"`
	Time          int64  `json:"time"`
	Reihung       bool   `json:"reihung"`
}

HafasDeparture ressource

type HafasMock

type HafasMock struct {
	TrainExists bool
}

HafasMock to testing

func (*HafasMock) GetTrainByStation

func (h *HafasMock) GetTrainByStation(ctx context.Context, trainName string, stationEVA int, stationDate int64) (*HafasTrain, error)

GetTrainByStation by name, station id and date

type HafasService

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

HafasService serve the marudor hafas api

func (*HafasService) FindTrain

func (h *HafasService) FindTrain(ctx context.Context, trainName string, date time.Time) (*[]HafasTrainResult, error)

FindTrain by name and date

func (*HafasService) GetTrainByStation

func (h *HafasService) GetTrainByStation(ctx context.Context, trainName string, stationEVA int, stationDate int64) (*HafasTrain, error)

GetTrainByStation by name, station id and date

type HafasStation

type HafasStation struct {
	ID          string           `json:"id"`
	Title       string           `json:"title"`
	Coordinates HafasCoordinates `json:"coordinates"`
}

HafasStation ressource

type HafasStop

type HafasStop struct {
	Station   *HafasStation   `json:"station"`
	Departure *HafasDeparture `json:"departure"`
	Arrival   *HafasArrival   `json:"arrival"`
	TrainLoad *HafasTrainLoad `json:"auslastung"`
}

HafasStop ressource

type HafasTrain

type HafasTrain struct {
	JID       string          `json:"jid"`
	Train     HafasTrainInfo  `json:"train"`
	Departure *HafasDeparture `json:"departure"`
	Arrival   *HafasArrival   `json:"arrival"`
	TrainLoad *HafasTrainLoad `json:"auslastung"`
	Type      string          `json:"type"`
	// duration
	// train
	// segmentStart
	// segmentDestination
	CurrentStop      *HafasStop  `json:"currentStop"`
	Stops            []HafasStop `json:"stops"`
	FinalDestination string      `json:"finalDestination"`
}

HafasTrain ressource

type HafasTrainInfo

type HafasTrainInfo struct {
	Name     string             `json:"name"`
	Line     string             `json:"line"`
	Admin    string             `json:"admin"`
	Number   string             `json:"number"`
	Type     string             `json:"type"`
	Operator HafasTrainOperator `json:"operator"`
}

HafasTrainInfo ressource

type HafasTrainLoad

type HafasTrainLoad struct {
	FirstClass  int `json:"first"`
	SecondClass int `json:"second"`
}

HafasTrainLoad ressource

type HafasTrainOperator

type HafasTrainOperator struct {
	Name string `json:"name"`
	IcoX int64  `json:"icoX"`
}

HafasTrainOperator resource

type HafasTrainResult

type HafasTrainResult struct {
	Train     HafasTrainInfo `json:"train"`
	JID       string         `json:"jid"`
	FirstStop *HafasStop     `json:"firstStop"`
	LastStop  *HafasStop     `json:"lastStop"`
	Stops     []HafasStop    `json:"stops"`
}

HafasTrainResult from find train search

Jump to

Keyboard shortcuts

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