Documentation ¶
Overview ¶
Package gooctranspoapi provides a Go wrapper around the OC Transpo Live Next Bus Arrival Data Feed API.
Index ¶
- Constants
- func ColumnAndValue(column, value string) func(url.Values) error
- func Direction(direction string) func(url.Values) error
- func ID(id string) func(url.Values) error
- func Limit(limit int) func(url.Values) error
- func OrderBy(orderBy string) func(url.Values) error
- type Connection
- func (c Connection) GetGTFSAgency(ctx context.Context, options ...func(url.Values) error) (*GTFSAgency, error)
- func (c Connection) GetGTFSCalendar(ctx context.Context, options ...func(url.Values) error) (*GTFSCalendar, error)
- func (c Connection) GetGTFSCalendarDates(ctx context.Context, options ...func(url.Values) error) (*GTFSCalendarDates, error)
- func (c Connection) GetGTFSRoutes(ctx context.Context, options ...func(url.Values) error) (*GTFSRoutes, error)
- func (c Connection) GetGTFSStopTimes(ctx context.Context, options ...func(url.Values) error) (*GTFSStopTimes, error)
- func (c Connection) GetGTFSStops(ctx context.Context, options ...func(url.Values) error) (*GTFSStops, error)
- func (c Connection) GetGTFSTrips(ctx context.Context, options ...func(url.Values) error) (*GTFSTrips, error)
- func (c Connection) GetNextTripsForStop(ctx context.Context, routeNo, stopNo string) (*NextTripsForStop, error)
- func (c Connection) GetNextTripsForStopAllRoutes(ctx context.Context, stopNo string) (*NextTripsForStopAllRoutes, error)
- func (c Connection) GetRouteSummaryForStop(ctx context.Context, stopNo string) (*RouteSummaryForStop, error)
- type GPSSpeed
- type GTFSAgency
- type GTFSCalendar
- type GTFSCalendarDates
- type GTFSRoutes
- type GTFSStopTimes
- type GTFSStops
- type GTFSTrips
- type LastTripOfSchedule
- type Latitude
- type Longitude
- type NextTripsForStop
- type NextTripsForStopAllRoutes
- type Route
- type RouteDirection
- type RouteSummaryForStop
- type RouteWithTrips
- type Trip
Constants ¶
const APIURLPrefix = "https://api.octranspo1.com/v1.3/"
APIURLPrefix is the address at which the API is available.
Variables ¶
This section is empty.
Functions ¶
func ColumnAndValue ¶
ColumnAndValue will setup the request to return data from a specific column and value.
Types ¶
type Connection ¶
type Connection struct { ID string Key string Limiter *rate.Limiter HTTPClient *http.Client // contains filtered or unexported fields }
Connection holds the Application ID and API key needed to make requests. It also has a rate limiter, used by the Connection's methods to limit calls on the API. The HTTP Client is a public field, so that it can be swapped out with a custom HTTP Client if needed.
func NewConnection ¶
func NewConnection(id, key string) Connection
NewConnection returns a new connection without a rate limit.
func NewConnectionWithRateLimit ¶
func NewConnectionWithRateLimit(id, key string, perSec float64, burst int) Connection
NewConnectionWithRateLimit returns a new connection with a rate limit set. This is helpful for ensuring you don't go over the daily call limit, which is usually 10,000 requests per day. It you use the connection over 24 hours, a connection with a perSec rate of 0.11572 would make around 9998 requests.
func (Connection) GetGTFSAgency ¶
func (c Connection) GetGTFSAgency(ctx context.Context, options ...func(url.Values) error) (*GTFSAgency, error)
GetGTFSAgency returns the GTFS agency table.
func (Connection) GetGTFSCalendar ¶
func (c Connection) GetGTFSCalendar(ctx context.Context, options ...func(url.Values) error) (*GTFSCalendar, error)
GetGTFSCalendar returns the GTFS calendar table.
func (Connection) GetGTFSCalendarDates ¶
func (c Connection) GetGTFSCalendarDates(ctx context.Context, options ...func(url.Values) error) (*GTFSCalendarDates, error)
GetGTFSCalendarDates returns the GTFS calendar_dates table
func (Connection) GetGTFSRoutes ¶
func (c Connection) GetGTFSRoutes(ctx context.Context, options ...func(url.Values) error) (*GTFSRoutes, error)
GetGTFSRoutes returns the GTFS routes table.
func (Connection) GetGTFSStopTimes ¶
func (c Connection) GetGTFSStopTimes(ctx context.Context, options ...func(url.Values) error) (*GTFSStopTimes, error)
GetGTFSStopTimes returns the GTFS stop_times table. It requires a trip_id, stop_code or id value specified, using ColumnAndValue() or ID() options.
func (Connection) GetGTFSStops ¶
func (c Connection) GetGTFSStops(ctx context.Context, options ...func(url.Values) error) (*GTFSStops, error)
GetGTFSStops returns the GTFS stops table. It requires a stop_id, stop_code or id value specified, using ColumnAndValue() or ID() options.
func (Connection) GetGTFSTrips ¶
func (c Connection) GetGTFSTrips(ctx context.Context, options ...func(url.Values) error) (*GTFSTrips, error)
GetGTFSTrips returns the GTFS trips table. It requires a route_id or id value specified, using ColumnAndValue() or ID() options.
func (Connection) GetNextTripsForStop ¶
func (c Connection) GetNextTripsForStop(ctx context.Context, routeNo, stopNo string) (*NextTripsForStop, error)
GetNextTripsForStop returns the next three trips on the route for a given stop number.
func (Connection) GetNextTripsForStopAllRoutes ¶
func (c Connection) GetNextTripsForStopAllRoutes(ctx context.Context, stopNo string) (*NextTripsForStopAllRoutes, error)
GetNextTripsForStopAllRoutes returns the next three trips for all routes for a given stop number.
func (Connection) GetRouteSummaryForStop ¶
func (c Connection) GetRouteSummaryForStop(ctx context.Context, stopNo string) (*RouteSummaryForStop, error)
GetRouteSummaryForStop returns the routes for a given stop number.
type GTFSAgency ¶
type GTFSAgency struct { Query struct { Table string `json:"table"` Direction string `json:"direction"` Format string `json:"format"` } `json:"Query"` Gtfs []struct { ID string `json:"id"` AgencyName string `json:"agency_name"` AgencyURL string `json:"agency_url"` AgencyTimezone string `json:"agency_timezone"` AgencyLang string `json:"agency_lang"` AgencyPhone string `json:"agency_phone"` } `json:"Gtfs"` }
GTFSAgency is the GTFS agency table.
type GTFSCalendar ¶
type GTFSCalendar struct { Query struct { Table string `json:"table"` Direction string `json:"direction"` Format string `json:"format"` } `json:"Query"` Gtfs []struct { ID string `json:"id"` ServiceID string `json:"service_id"` Monday string `json:"monday"` Tuesday string `json:"tuesday"` Wednesday string `json:"wednesday"` Thursday string `json:"thursday"` Friday string `json:"friday"` Saturday string `json:"saturday"` Sunday string `json:"sunday"` StartDate string `json:"start_date"` EndDate string `json:"end_date"` } `json:"Gtfs"` }
GTFSCalendar is the GTFS calendar table.
type GTFSCalendarDates ¶
type GTFSCalendarDates struct { Query struct { Table string `json:"table"` Direction string `json:"direction"` Format string `json:"format"` } `json:"Query"` Gtfs []struct { ID string `json:"id"` ServiceID string `json:"service_id"` Date string `json:"date"` ExceptionType string `json:"exception_type"` } `json:"Gtfs"` }
GTFSCalendarDates is GTFS calendar_dates table.
type GTFSRoutes ¶
type GTFSRoutes struct { Query struct { Table string `json:"table"` Direction string `json:"direction"` Format string `json:"format"` } `json:"Query"` Gtfs []struct { ID string `json:"id"` RouteID string `json:"route_id"` RouteShortName string `json:"route_short_name"` RouteLongName string `json:"route_long_name"` RouteDesc string `json:"route_desc"` RouteType string `json:"route_type"` } `json:"Gtfs"` }
GTFSRoutes is the GTFS routes table.
type GTFSStopTimes ¶
type GTFSStopTimes struct { Query struct { Table string `json:"table"` Direction string `json:"direction"` Column string `json:"column"` Value string `json:"value"` Format string `json:"format"` } `json:"Query"` Gtfs []struct { ID string `json:"id"` TripID string `json:"trip_id"` ArrivalTime string `json:"arrival_time"` DepartureTime string `json:"departure_time"` StopID string `json:"stop_id"` StopSequence string `json:"stop_sequence"` PickupType string `json:"pickup_type"` DropOffType string `json:"drop_off_type"` } `json:"Gtfs"` }
GTFSStopTimes is the GTFS stop_times table.
type GTFSStops ¶
type GTFSStops struct { Query struct { Table string `json:"table"` Direction string `json:"direction"` Column string `json:"column"` Value string `json:"value"` Format string `json:"format"` } `json:"Query"` Gtfs []struct { ID string `json:"id"` StopID string `json:"stop_id"` StopCode string `json:"stop_code"` StopName string `json:"stop_name"` StopDesc string `json:"stop_desc"` StopLat string `json:"stop_lat"` StopLon string `json:"stop_lon"` ZoneID string `json:"zone_id"` StopURL string `json:"stop_url"` LocationType string `json:"location_type"` ParentStation string `json:"parent_station"` } `json:"Gtfs"` }
GTFSStops is the GTFS stops table.
type GTFSTrips ¶
type GTFSTrips struct { Query struct { Table string `json:"table"` Direction string `json:"direction"` Column string `json:"column"` Value string `json:"value"` Format string `json:"format"` } `json:"Query"` Gtfs []struct { ID string `json:"id"` RouteID string `json:"route_id"` ServiceID string `json:"service_id"` TripID string `json:"trip_id"` TripHeadsign string `json:"trip_headsign"` DirectionID string `json:"direction_id"` BlockID string `json:"block_id"` } `json:"Gtfs"` }
GTFSTrips is the GTFS trips table.
type LastTripOfSchedule ¶ added in v0.4.0
LastTripOfSchedule stores both the data and if the data was set by the API
type NextTripsForStop ¶
type NextTripsForStop struct { StopNo string StopLabel string Error string RouteDirections []RouteDirection }
NextTripsForStop is a simplified version of the data returned by a request to GetNextTripsForStop
type NextTripsForStopAllRoutes ¶
type NextTripsForStopAllRoutes struct { StopNo string StopDescription string Error string Routes []RouteWithTrips }
NextTripsForStopAllRoutes is a simplified version of the data returned by a request to GetNextTripsForStopAllRoutes
type RouteDirection ¶ added in v0.4.0
type RouteDirection struct { RouteNo string RouteLabel string Direction string Error string RequestProcessingTime time.Time Trips []Trip }
RouteDirection is used by NextTripsForStop to store route direction data.
type RouteSummaryForStop ¶
type RouteSummaryForStop struct { StopNo string StopDescription string Error string Routes []Route }
RouteSummaryForStop is a simplified version of the data returned by a request to GetRouteSummaryForStop.