rail

package module
v0.0.0-...-77b3b61 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2018 License: MIT Imports: 12 Imported by: 0

README

rail

GoDoc Build Status Coverage Status Report card

rail is a Go client library for accessing the railwayapi.com API.

RailwayAPI.com provides API for Indian Railways data of Trains and Stations, along with features like Train Live status, PNR status, Arrivals on Station, Trains Between Stations etc

Installation

Requires Go version 1.7 or above.

$ go get -u github.com/go-india/rail
Usage

Construct a new rail client, then use the various methods on the client to access different parts of the RailwayAPI.

For demonstration:

package main

import (
  "context"
  "github.com/go-india/rail"
)

var ctx = context.Background()

func main() {
  client := rail.NewClient(API_KEY)

  // Gets PNR status details.
  resp, err := client.PNRStatus(ctx, 2124289856)

  // Gets Live running status of Train.
  resp, err := client.LiveTrainStatus(ctx, 14311, time.Now())

  // Gets fares of train.
  resp, err := client.TrainFare(ctx, 14311, "BE", "ADI", 24, "SL", "GN", time.Now())
}

Notes

  • Using the context package for passing context.
  • Make sure you have a valid API Key. If not, you can get a new one by registering at railwayapi.com registration page.

For complete usage of rail, see the full package docs.

Authentication

If you are using concrete Client, then you need to assign client.Auth field to make the client methods use authenticator for requests.

client := rail.Client{
  Auth: rail.NewAuth(API_KEY),
}

This will add API Key to each request made by client methods.

Integration Tests

You can run integration tests from the directory.

$ go test -v

Note: Use -update flag to update the testdata. When using update flag, you will need to define RAILWAYAPI_TEST_API_KEY in your environment for tests to use the API Key for testing.

Contributing

We welcome pull requests, bug fixes and issue reports. Before proposing a change, please discuss your change by raising an issue.

License

This library is distributed under the MIT license found in the LICENSE file.

Author

Yash Raj Singh

Documentation

Overview

Package rail provides a client for using RailwayAPI.com's API.

You can read the API server documentation at https://railwayapi.com/api

Usage

Construct a new rail client, then use the various methods on the client to access different parts of the RailwayAPI.

For demonstration:

package main

import (
  "context"
  "github.com/go-india/rail"
)

var ctx = context.Background()

func main() {
  client := rail.NewClient(API_KEY)

  // Gets PNR status details.
  pnr, err := client.PNRStatus(ctx, 2124289856)

  // Gets Live running status of Train.
  live, err := client.LiveTrainStatus(ctx, 14311, time.Now())

  // Gets fares of train.
  fare, err := client.TrainFare(ctx, 14311, "BE", "ADI", 24, "SL", "GN", time.Now())
}

Notes:

* Using the https://godoc.org/context package for passing context.

* Look at tests(*_test.go) files for more sample usage.

Authentication

If you are using concrete Client, then you need to assign client.Auth field to make the client methods use authenticator for requests.

client := rail.Client{
  Auth: rail.NewAuth(API_KEY),
}

This will add API Key to each request made by client methods.

Index

Constants

View Source
const (
	// DefaultBaseURL is the default base server URL of the API.
	DefaultBaseURL = "https://api.railwayapi.com"
	// DefaultUserAgent is the default user agent used by client.
	DefaultUserAgent = "go-india/rail"
)
View Source
const (
	// WindowHour2 refers to window hour 2 of indian railway.
	WindowHour2 = 1 + iota
	// WindowHour4 refers to window hour 4 of indian railway.
	WindowHour4
)

Variables

View Source
var (
	// ErrNoAuth is returned when auth is not defined for a client.
	ErrNoAuth = errors.New("rail: no authenticator in client")
)

Functions

func NewAuth

func NewAuth(APIKey string) func(Requester) Requester

NewAuth returns a new authenticator function.

Assign to client.Auth field to make client methods use it for requests.

Types

type Available

type Available struct {
	Status string    `json:"status"`
	Date   time.Time `json:"date"`
}

Available holds an available item

func (*Available) UnmarshalJSON

func (a *Available) UnmarshalJSON(data []byte) error

UnmarshalJSON convert JSON data to struct

type CancelledTrainsReq

type CancelledTrainsReq struct {
	// Specifies the date for which result is required.
	Date time.Time `validate:"required"`
}

CancelledTrainsReq parameters

func (CancelledTrainsReq) Request

func (r CancelledTrainsReq) Request() (*http.Request, error)

Request encodes CancelledTrainsReq parameters returning a new http.Request

type CancelledTrainsResp

type CancelledTrainsResp struct {
	Trains []TrainSemi `json:"trains,omitempty"`
	Total  *int        `json:"total,omitempty"`

	*Response
}

CancelledTrainsResp holds cancelled trains details

type CheckSeatReq

type CheckSeatReq struct {
	// Specifies the train number.
	TrainNumber uint32 `validate:"required"`
	// Specifies the source station code.
	FromStationCode string `validate:"required"`
	// Specifies the destination station code.
	ToStationCode string `validate:"required"`
	// Specifies the date for which result is required.
	Date time.Time `validate:"required"`
	// Specifies the class code. Ex: SL/AC/2S
	Class string `validate:"required"`
	// Specifies the quota code. Ex: GN etc
	Quota string `validate:"required"`
}

CheckSeatReq parameters

func (CheckSeatReq) Request

func (r CheckSeatReq) Request() (*http.Request, error)

Request encodes CheckSeat parameters returning a new http.Request

type CheckSeatResp

type CheckSeatResp struct {
	Train        *Train      `json:"train,omitempty"`
	FromStation  *Station    `json:"from_station,omitempty"`
	ToStation    *Station    `json:"to_station,omitempty"`
	Quota        *Quota      `json:"quota,omitempty"`
	JourneyClass *Class      `json:"journey_class,omitempty"`
	Availability []Available `json:"availability,omitempty"`

	*Response
}

CheckSeatResp holds seat availability response

type Class

type Class struct {
	Available *bool  // `json:"available,omitempty"`
	Name      string `json:"name,omitempty"`
	Code      string `json:"code,omitempty"`
}

Class holds class details

func (*Class) UnmarshalJSON

func (c *Class) UnmarshalJSON(data []byte) error

UnmarshalJSON convert JSON data to struct

type Client

type Client struct {
	// BaseURL is the base URL of the API server.
	BaseURL *url.URL
	// User agent used when communicating with the API.
	UserAgent string
	// HTTPClient is a reusable http client instance.
	HTTPClient *http.Client

	// Auth holds authenticator function used to authenticate requests.
	//
	// Client methods uses Auth to add APIKey to requests.
	// Use NewAuth(apikey) to generate a new authenticator.
	Auth func(Requester) Requester
}

Client is an railwayapi's HTTP REST API client instance.

Its zero value is usable client that uses http.DefaultTransport. Client is safe for use by multiple go routines.

func NewClient

func NewClient(APIKey string) Client

NewClient returns a new RailwayAPI.com authenticated API client.

Use returned client's methods to access various API functions.

func (Client) CancelledTrains

func (c Client) CancelledTrains(ctx context.Context, Date time.Time) (CancelledTrainsResp, error)

CancelledTrains gets list of all cancelled trains on a particular day.

func (Client) CheckSeat

func (c Client) CheckSeat(ctx context.Context,
	TrainNumber uint32,
	FromStationCode string,
	ToStationCode string,
	Class string,
	Quota string,
	Date time.Time,
) (CheckSeatResp, error)

CheckSeat gets train seat availability.

func (Client) Do

func (c Client) Do(r Requester, intoPtr interface{}) error

Do sends the http.Request and unmarshalls the JSON response into 'intoPtr'.

func (Client) LiveTrainStatus

func (c Client) LiveTrainStatus(ctx context.Context,
	TrainNumber uint32,
	Date time.Time,
) (LiveTrainStatusResp, error)

LiveTrainStatus gets live running status of a Train.

func (Client) PNRStatus

func (c Client) PNRStatus(ctx context.Context, PNRNumber uint64) (PNRStatusResp, error)

PNRStatus gets PNR status details.

func (Client) RescheduledTrains

func (c Client) RescheduledTrains(ctx context.Context, Date time.Time) (RescheduledTrainsResp, error)

RescheduledTrains gets list of all rescheduled trains on a particular date.

func (Client) StationCodeToName

func (c Client) StationCodeToName(ctx context.Context, StationCode string) (Stations, error)

StationCodeToName gets station details of the given station and its nearby stations using partial station name. Station’s name is autocompleted.

func (Client) StationNameToCode

func (c Client) StationNameToCode(ctx context.Context, StationName string) (Stations, error)

StationNameToCode gets station details of the given station and its nearby stations using partial station name. Station’s name is autocompleted.

func (Client) SuggestStation

func (c Client) SuggestStation(ctx context.Context, StationName string) (Stations, error)

SuggestStation suggests full station names given a partial station name.

func (Client) SuggestTrainByCode

func (c Client) SuggestTrainByCode(ctx context.Context, TrainCode uint32) (Trains, error)

SuggestTrainByCode suggests full train names or numbers given a partial train code.

func (Client) SuggestTrainByName

func (c Client) SuggestTrainByName(ctx context.Context, TrainName string) (Trains, error)

SuggestTrainByName suggests full train names or numbers given a partial train name.

func (Client) TrainArrivals

func (c Client) TrainArrivals(ctx context.Context,
	StationCode string,
	Hours WindowHour,
) (TrainArrivalsResp, error)

TrainArrivals get list of trains arriving at a station within a window period along with their live status.

Window time in hours to search, valid values are 2 or 4.

func (Client) TrainBetweenStations

func (c Client) TrainBetweenStations(ctx context.Context,
	FromStationCode string,
	ToStationCode string,
	Date time.Time,
) (TrainBetweenStationsResp, error)

TrainBetweenStations gets trains running between stations.

func (Client) TrainByName

func (c Client) TrainByName(ctx context.Context, TrainName string) (TrainResp, error)

TrainByName gets train details by its number.

func (Client) TrainByNumber

func (c Client) TrainByNumber(ctx context.Context, TrainNumber uint32) (TrainResp, error)

TrainByNumber gets train details by its number.

func (Client) TrainFare

func (c Client) TrainFare(ctx context.Context,
	TrainNumber uint32,
	FromStationCode string,
	ToStationCode string,
	Age uint8,
	Class string,
	Quota string,
	Date time.Time,
) (TrainFareResp, error)

TrainFare gets fares of a train.

func (Client) TrainRoute

func (c Client) TrainRoute(ctx context.Context, TrainNumber uint32) (TrainRouteResp, error)

TrainRoute gets details about all the stations in the train’s route.

type Day

type Day struct {
	Runs bool   // `json:"runs,omitempty"`
	Code string `json:"code,omitempty"`
}

Day holds day details

func (*Day) UnmarshalJSON

func (d *Day) UnmarshalJSON(data []byte) error

UnmarshalJSON convert JSON data to struct

type ErrAPI

type ErrAPI struct {
	// Response from the request which returned error.
	Response *http.Response
}

ErrAPI is returned by API calls when the response status code isn't 200.

func (ErrAPI) Error

func (err ErrAPI) Error() (errStr string)

Error implements the error interface.

type ExtendedTrain

type ExtendedTrain struct {
	*Train

	ToStation              *Station       `json:"to_station,omitempty"`
	FromStation            *Station       `json:"from_station,omitempty"`
	SourceDepartureTime    *time.Time     // `json:"src_departure_time,omitempty"`
	DestinationArrivalTime *time.Time     // `json:"dest_arrival_time,omitempty"`
	TravelDuration         *time.Duration // `json:"travel_time,omitempty"`
}

ExtendedTrain holds extended train details

func (*ExtendedTrain) UnmarshalJSON

func (et *ExtendedTrain) UnmarshalJSON(data []byte) error

UnmarshalJSON convert JSON data to struct

type LiveTrainStatusReq

type LiveTrainStatusReq struct {
	// Specifies the train number.
	TrainNumber uint32 `validate:"required"`
	// Specifies the date for which result is required.
	Date time.Time `validate:"required"`
}

LiveTrainStatusReq parameters

func (LiveTrainStatusReq) Request

func (r LiveTrainStatusReq) Request() (*http.Request, error)

Request encodes LiveTrainStatusReq parameters returning a new http.Request

type LiveTrainStatusResp

type LiveTrainStatusResp struct {
	Train          *Train     `json:"train,omitempty"`
	CurrentStation *Station   `json:"current_station,omitempty"`
	Route          []Route    `json:"route,omitempty"`
	StartDate      *time.Time // `json:"start_date,omitempty"`
	PositionRemark *string    `json:"position,omitempty"`

	*Response
}

LiveTrainStatusResp of the request

func (*LiveTrainStatusResp) UnmarshalJSON

func (s *LiveTrainStatusResp) UnmarshalJSON(data []byte) error

UnmarshalJSON convert JSON data to struct

type PNRStatusReq

type PNRStatusReq struct {
	PNRNumber uint64 `validate:"required"` // Specifies the pnr number.
}

PNRStatusReq parameters

func (PNRStatusReq) Request

func (r PNRStatusReq) Request() (*http.Request, error)

Request encodes PNRStatusReq parameters returning a new http.Request

type PNRStatusResp

type PNRStatusResp struct {
	ChartPrepared   *bool       `json:"chart_prepared,omitempty"`
	DateOfJourney   *time.Time  // `json:"doj,omitempty"`
	BoardingPoint   *Station    `json:"boarding_point,omitempty"`
	FromStation     *Station    `json:"from_station,omitempty"`
	ToStation       *Station    `json:"to_station,omitempty"`
	TotalPassengers *int        `json:"total_passengers,omitempty"`
	JourneyClass    *Class      `json:"journey_class,omitempty"`
	Train           *Train      `json:"train,omitempty"`
	Passengers      []Passenger `json:"passengers,omitempty"`
	PNR             *uint64     `json:"pnr,string,omitempty"`
	ReservationUpto *Station    `json:"reservation_upto,omitempty"`

	*Response
}

PNRStatusResp is the response for a PNRReq

func (*PNRStatusResp) UnmarshalJSON

func (p *PNRStatusResp) UnmarshalJSON(data []byte) error

UnmarshalJSON convert JSON data to struct

type Passenger

type Passenger struct {
	Number        *uint16 `json:"no,omitempty"`
	CurrentStatus *string `json:"current_status,omitempty"`
	BookingStatus *string `json:"booking_status,omitempty"`
}

Passenger holds passenger details

type Quota

type Quota struct {
	Name string `json:"name"`
	Code string `json:"code"`
}

Quota holds quota details

type Requester

type Requester interface {
	// Request should generate an HTTP request from parameters.
	Request() (*http.Request, error)
}

Requester is implemented by any value that has a Request method.

func WithCtx

func WithCtx(ctx context.Context, r Requester) Requester

WithCtx applies 'ctx' to the the http.Request and returns a new Requester

type RequesterFunc

type RequesterFunc func() (*http.Request, error)

RequesterFunc implements Requester

func (RequesterFunc) Request

func (f RequesterFunc) Request() (*http.Request, error)

Request invokes 'f'

type RescheduledTrain

type RescheduledTrain struct {
	FromStation *Station `json:"from_station,omitempty"`
	ToStation   *Station `json:"to_station,omitempty"`

	TimeDifference  *time.Duration // `json:"time_diff,omitempty"`
	RescheduledDate *time.Time     // `json:"rescheduled_date,omitempty"`
	RescheduledTime *time.Time     // `json:"rescheduled_time,omitempty"`

	*Train
}

RescheduledTrain holds rescheduled train detail

func (*RescheduledTrain) UnmarshalJSON

func (s *RescheduledTrain) UnmarshalJSON(data []byte) error

UnmarshalJSON convert JSON data to struct

type RescheduledTrainsReq

type RescheduledTrainsReq struct {
	// Specifies the date for which result is required.
	Date time.Time `validate:"required"`
}

RescheduledTrainsReq parameters

func (RescheduledTrainsReq) Request

func (r RescheduledTrainsReq) Request() (*http.Request, error)

Request encodes RescheduledTrainsReq parameters returning a new http.Request

type RescheduledTrainsResp

type RescheduledTrainsResp struct {
	Trains []RescheduledTrain `json:"trains,omitempty"`
	*Response
}

RescheduledTrainsResp holds rescheduled trains

type Response

type Response struct {
	// The debit key is included in each API response and it contains
	// the value by which the user’s credit was debited. Whether the user will
	// be debited or not depends upon the ResponseCode.
	Debit int `json:"debit"`

	// ResponseCode key included in each response contains the status
	// of the result returned.
	ResponseCode int `json:"response_code"`
}

Response is the standard response field that comes with every response from API.

Refer to following URL for more details. https://railwayapi.com/api/

type Route

type Route struct {
	ActualArrivalDate    *time.Time //`json:"actarr_date,omitempty"`
	ScheduledArrivalDate *time.Time //`json:"scharr_date,omitempty"`

	ScheduledArrivalTime   *time.Time //`json:"scharr,omitempty"`
	ScheduledDepartureTime *time.Time //`json:"schdep,omitempty"`
	ActualDepartureTime    *time.Time //`json:"actdep,omitempty"`
	ActualArrivalTime      *time.Time //`json:"actarr,omitempty"`

	HasArrived  *bool `json:"has_arrived,omitempty"`
	HasDeparted *bool `json:"has_departed,omitempty"`

	Station       *Station `json:"station,omitempty"`
	Status        *string  `json:"status,omitempty"`
	LateByMinutes *int     `json:"latemin,omitempty"`
	Distance      *float64 `json:"distance,omitempty"`
	Day           *int     `json:"day,omitempty"`
	Number        *int     `json:"no,omitempty"`
	Halt          *int     `json:"halt,omitempty"`
}

Route holds route details

func (*Route) UnmarshalJSON

func (r *Route) UnmarshalJSON(data []byte) error

UnmarshalJSON convert JSON data to struct

type Station

type Station struct {
	Latitude  float64 `json:"lat"`
	Longitude float64 `json:"lng"`
	Name      string  `json:"name"`
	Code      string  `json:"code"`
}

Station holds station details

type StationCodeToNameReq

type StationCodeToNameReq struct {
	// Specifies the source station code.
	StationCode string `validate:"required"`
}

StationCodeToNameReq parameters

func (StationCodeToNameReq) Request

func (r StationCodeToNameReq) Request() (*http.Request, error)

Request encodes StationCodeToNameReq parameters returning a new http.Request

type StationNameToCodeReq

type StationNameToCodeReq struct {
	// Specifies the source station name.
	StationName string `validate:"required"`
}

StationNameToCodeReq parameters

func (StationNameToCodeReq) Request

func (r StationNameToCodeReq) Request() (*http.Request, error)

Request encodes StationNameToCodeReq parameters returning a new http.Request

type Stations

type Stations struct {
	Stations []Station `json:"stations"`
	*Response
}

Stations holds stations

type SuggestStationReq

type SuggestStationReq struct {
	// Specifies the source station name.
	StationName string `validate:"required"`
}

SuggestStationReq parameters

func (SuggestStationReq) Request

func (r SuggestStationReq) Request() (*http.Request, error)

Request encodes SuggestStationReq parameters returning a new http.Request

type SuggestTrainByCodeReq

type SuggestTrainByCodeReq struct {
	// Specifies the Train code.
	TrainCode uint32 `validate:"required"`
}

SuggestTrainByCodeReq parameters

func (SuggestTrainByCodeReq) Request

func (r SuggestTrainByCodeReq) Request() (*http.Request, error)

Request encodes SuggestTrainByCodeReq parameters returning a new http.Request

type SuggestTrainByNameReq

type SuggestTrainByNameReq struct {
	// Specifies the Train name.
	TrainName string `validate:"required"`
}

SuggestTrainByNameReq parameters

func (SuggestTrainByNameReq) Request

func (r SuggestTrainByNameReq) Request() (*http.Request, error)

Request encodes SuggestTrainByNameReq parameters returning a new http.Request

type Train

type Train struct {
	Name    string  `json:"name"`
	Number  uint32  `json:"number,string"`
	Classes []Class `json:"classes,omitempty"`
	Days    []Day   `json:"days,omitempty"`
}

Train holds train details

type TrainArrivalsReq

type TrainArrivalsReq struct {
	// Specifies the source station code.
	StationCode string `validate:"required"`

	// Specifies the windows hours to search.
	//
	// Window time in hours to search, valid values are 2 or 4.
	Hours WindowHour `validate:"required"`
}

TrainArrivalsReq parameters

func (TrainArrivalsReq) Request

func (r TrainArrivalsReq) Request() (*http.Request, error)

Request encodes TrainArrivalsReq parameters returning a new http.Request

type TrainArrivalsResp

type TrainArrivalsResp struct {
	Trains []TrainWithTimings `json:"trains,omitempty"`
	Total  *int               `json:"total,omitempty"`

	*Response
}

TrainArrivalsResp holds train arrivals details

type TrainBetweenStationsReq

type TrainBetweenStationsReq struct {
	// Specifies the source station code.
	FromStationCode string `validate:"required"`
	// Specifies the destination station code.
	ToStationCode string `validate:"required"`
	// Specifies the date for which result is required.
	Date time.Time `validate:"required"`
}

TrainBetweenStationsReq parameters

func (TrainBetweenStationsReq) Request

func (r TrainBetweenStationsReq) Request() (*http.Request, error)

Request encodes TrainBetweenStationsReq parameters returning a new http.Request

type TrainBetweenStationsResp

type TrainBetweenStationsResp struct {
	Trains []ExtendedTrain `json:"trains,omitempty"`
	Total  *int            `json:"total,omitempty"`

	*Response
}

TrainBetweenStationsResp holds trains between stations

type TrainByNameReq

type TrainByNameReq struct {
	TrainName string `validate:"required"` // Specifies the train name.
}

TrainByNameReq parameters

func (TrainByNameReq) Request

func (r TrainByNameReq) Request() (*http.Request, error)

Request encodes TrainByNameReq parameters returning a new http.Request

type TrainByNumberReq

type TrainByNumberReq struct {
	TrainNumber uint32 `validate:"required"` // Specifies the train number.
}

TrainByNumberReq parameters

func (TrainByNumberReq) Request

func (r TrainByNumberReq) Request() (*http.Request, error)

Request encodes TrainByNumberReq parameters returning a new http.Request

type TrainFareReq

type TrainFareReq struct {
	// Specifies the train number.
	TrainNumber uint32 `validate:"required"`
	// Specifies the source station code.
	FromStationCode string `validate:"required"`
	// Specifies the destination station code.
	ToStationCode string `validate:"required"`
	// Specifies the age code of passenger
	Age uint8 `url:"age" validate:"required"`
	// Specifies the date for which result is required.
	Date time.Time `validate:"required"`
	// Specifies the class code. Ex: SL/AC/2S
	Class string `validate:"required"`
	// Specifies the quota code. Ex: GN etc
	Quota string `validate:"required"`
}

TrainFareReq parameters

func (TrainFareReq) Request

func (r TrainFareReq) Request() (*http.Request, error)

Request encodes TrainFareReq parameters returning a new http.Request

type TrainFareResp

type TrainFareResp struct {
	FromStation  *Station    `json:"from_station,omitempty"`
	ToStation    *Station    `json:"to_station,omitempty"`
	Quota        *Quota      `json:"quota,omitempty"`
	Train        *Train      `json:"train,omitempty"`
	Fare         *float64    `json:"fare,omitempty"`
	JourneyClass *Class      `json:"journey_class,omitempty"`
	Availability []Available `json:"availability,omitempty"`

	*Response
}

TrainFareResp holds fare details for a train journey

type TrainResp

type TrainResp struct {
	Train *Train `json:"train,omitempty"`
	*Response
}

TrainResp holds train details

type TrainRouteReq

type TrainRouteReq struct {
	TrainNumber uint32 `validate:"required"` // Specifies the train number.
}

TrainRouteReq parameters

func (TrainRouteReq) Request

func (r TrainRouteReq) Request() (*http.Request, error)

Request encodes TrainRouteReq parameters returning a new http.Request

type TrainRouteResp

type TrainRouteResp struct {
	Train *Train  `json:"train,omitempty"`
	Route []Route `json:"route,omitempty"`

	*Response
}

TrainRouteResp holds route information of a train

type TrainSemi

type TrainSemi struct {
	Source      *Station   `json:"source,omitempty"`
	Destination *Station   `json:"dest,omitempty"`
	Type        *string    `json:"type,omitempty"`
	StartDate   *time.Time //`json:"start_time,omitempty"`

	*Train
}

TrainSemi holds semi train information

func (*TrainSemi) UnmarshalJSON

func (s *TrainSemi) UnmarshalJSON(data []byte) error

UnmarshalJSON convert JSON data to struct

type TrainWithTimings

type TrainWithTimings struct {
	*Train

	DelayArrivalTime       *time.Time //`json:"delayarr,omitempty"`
	DelayDepartureTime     *time.Time //`json:"delaydep,omitempty"`
	ScheduledArrivalTime   *time.Time //`json:"scharr,omitempty"`
	ScheduledDepartureTime *time.Time //`json:"schdep,omitempty"`
	ActualDepartureTime    *time.Time //`json:"actdep,omitempty"`
	ActualArrivalTime      *time.Time //`json:"actarr,omitempty"`
}

TrainWithTimings holds train timings

func (*TrainWithTimings) UnmarshalJSON

func (r *TrainWithTimings) UnmarshalJSON(data []byte) error

UnmarshalJSON convert JSON data to struct

type Trains

type Trains struct {
	Trains []Train `json:"trains,omitempty"`
	*Response
}

Trains holds trains details

type WindowHour

type WindowHour uint8

WindowHour defines window time in hours to search.

Jump to

Keyboard shortcuts

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