gbfs

package module
v0.0.0-...-7e096b4 Latest Latest
Warning

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

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

README

GBFS

Go implementation of client, server and validator for GBFS (General Bikeshare Feed Specification).

Usage

Client
import "github.com/petoc/gbfs"
c, err := gbfs.NewClient(gbfs.ClientOptions{
    AutoDiscoveryURL: "http://127.0.0.1:8080/v3/system_id/gbfs.json",
    DefaultLanguage:  "en",
})
if err != nil {
    log.Fatal(err)
}
Get single feed
f := &gbfs.FeedSystemInformation{}
err := c.Get(f)
if err != nil {
    log.Println(err)
}
if f.Data != nil {
    log.Printf("feed=%s system_id=%s", f.Name(), *f.Data.SystemID)
}
Subscribe

Client provides built-in function to handle feed updates.

err := c.Subscribe(gbfs.ClientSubscribeOptions{
    // Languages: []string{"en"},
    // FeedNames: []string{gbfs.FeedNameStationInformation, gbfs.FeedNameFreeBikeStatus},
    Handler: func(c *gbfs.Client, f gbfs.Feed, err error) {
        if err != nil {
            log.Println(err)
            return
        }
        j, _ := json.Marshal(f)
        log.Printf("feed=%s data=%s", f.Name(), j)
    },
})
if err != nil {
    log.Println(err)
}

Subscription options Languages and FeedNames restrict subscription only to selected languages and feeds.

Server
import "github.com/petoc/gbfs"
s, err := gbfs.NewServer(gbfs.ServerOptions{
    SystemID:     "system_id",
    RootDir:      "public",
    BaseURL:      "http://127.0.0.1:8080",
    BasePath:     "v3/system_id",
    Version:      gbfs.V30,
    DefaultTTL:   60,
    FeedHandlers: []*gbfs.FeedHandler{
        // see example for how to add feed handlers
    },
    UpdateHandler: func(s *gbfs.Server, feed gbfs.Feed, path string, err error) {
        if err != nil {
            log.Println(err)
            return
        }
        log.Printf("system=%s ttl=%d version=%s updated=%s", s.Options.SystemID, feed.GetTTL(), feed.GetVersion(), path)
    },
})
if err != nil {
    log.Fatal(err)
}
log.Fatal(s.Start())

Main autodiscovery feed gbfs.json will be constructed from all available feeds in FeedHandlers. After that, all FeedHandlers will be regularly executed after configured TTL. If TTL is not set for individual feeds, it will be inherited from FeedHandler. If TTL is not set even for FeedHandler, DefaultTTL from ServerOptions will be used for feed.

Serving feeds

Feeds can be served as static files with standard webservers (Nginx, Apache, ...) or with simple built-in static file server.

fs, err := gbfs.NewFileServer("127.0.0.1:8080", "public")
if err != nil {
    log.Fatal(err)
}
log.Fatal(fs.ListenAndServe())
Validator

Validator validates feeds for common issues, such as missing required fields, invalid values, mutually exclusive fields, and so on. Validation result contains parsed feed in Feed struct and slices of Infos, Warnings and Errors. Important validation issues will be in Errors. Warnings usually comply with specification, but should be considered in order to be consistent with most of providers. Infos contains just notes, such as usage of field officialy available from newer versions of specification.

Not all invalid type issues will be reported, only common ones like coordinates or prices as strings, instead of float. Other uncommon type issues will prevent feed from being parsed. In such cases, some reasonable error should be returned from client.

import "github.com/petoc/gbfs/validator"
f := &gbfs.FeedSystemInformation{}
err := c.Get(f)
if err != nil {
    log.Fatal(err)
}
v := validator.New()
r := v.Validate(f, gbfs.V10)
log.Printf("infos=%v", r.Infos)
log.Printf("warnings=%v", r.Warnings)
log.Printf("errors=%v", r.Errors)

License

Licensed under MIT license.

Documentation

Index

Constants

View Source
const (
	DateFormat = "2006-01-02"
	TimeFormat = "15:04:05"

	V10 string = "1.0"
	V11 string = "1.1"
	V20 string = "2.0"
	V21 string = "2.1"
	V30 string = "3.0"

	FeedNameGbfs               = "gbfs"
	FeedNameGbfsVersions       = "gbfs_versions"
	FeedNameSystemInformation  = "system_information"
	FeedNameVehicleTypes       = "vehicle_types"
	FeedNameStationInformation = "station_information"
	FeedNameStationStatus      = "station_status"
	FeedNameFreeBikeStatus     = "free_bike_status"
	FeedNameSystemHours        = "system_hours"
	FeedNameSystemCalendar     = "system_calendar"
	FeedNameSystemRegions      = "system_regions"
	FeedNameSystemPricingPlans = "system_pricing_plans"
	FeedNameSystemAlerts       = "system_alerts"
	FeedNameGeofencingZones    = "geofencing_zones"
)
View Source
const (
	FormFactorBicycle = "bicycle"
	FormFactorCar     = "car"
	FormFactorMoped   = "moped"
	FormFactorOther   = "other"
	FormFactorScooter = "scooter"
)
View Source
const (
	PropulsionTypeHuman          = "human"
	PropulsionTypeElectricAssist = "electric_assist"
	PropulsionTypeElectric       = "electric"
	PropulsionTypeCombustion     = "combustion"
)
View Source
const (
	AlertTypeSystemClosure  = "SYSTEM_CLOSURE"
	AlertTypeStationClosure = "STATION_CLOSURE"
	AlertTypeStationMove    = "STATION_MOVE"
	AlertTypeOther          = "OTHER"
)
View Source
const (
	RentalMethodKey           = "KEY"
	RentalMethodCreditCard    = "CREDITCARD"
	RentalMethodPayPass       = "PAYPASS"
	RentalMethodApplePay      = "APPLEPAY"
	RentalMethodAndroidPay    = "ANDROIDPAY"
	RentalMethodTransitCard   = "TRANSITCARD"
	RentalMethodAccountNumber = "ACCOUNTNUMBER"
	RentalMethodPhone         = "PHONE"
)
View Source
const (
	UserTypeMember    = "member"
	UserTypeNonMember = "nonmember"
)
View Source
const (
	DayMon = "mon"
	DayTue = "tue"
	DayWed = "wed"
	DayThu = "thu"
	DayFri = "fri"
	DaySat = "sat"
	DaySun = "sun"
)

Variables

View Source
var (
	ErrMissingAutodiscoveryURL = errors.New("missing auto discovery url")
	ErrFeedNotFound            = errors.New("feed not found")
	ErrFailedAutodiscoveryURL  = errors.New("failed to get auto discovery url")
	ErrInvalidLanguage         = errors.New("invalid language")
	ErrInvalidSubscribeHandler = errors.New("invalid subscribe handler")
)
View Source
var (
	ErrMissingSystemID      = errors.New("missing system id")
	ErrMissingRootDir       = errors.New("missing root directory")
	ErrMissingBaseURL       = errors.New("missing base url")
	ErrInvalidDefaultTTL    = errors.New("invalid default ttl")
	ErrMissingFeedHandlers  = errors.New("missing feed handlers")
	ErrMissingServerAddress = errors.New("missing server address")
)

Functions

func AlertTypeAll

func AlertTypeAll() []string

AlertTypeAll ...

func DayAll

func DayAll() []string

DayAll ...

func FeedNameAll

func FeedNameAll() []string

FeedNameAll ...

func FormFactorAll

func FormFactorAll() []string

FormFactorAll ...

func NewError

func NewError(msg string, err error) error

NewError Wrap error

func NewFileServer

func NewFileServer(addr, rootDir string) (*http.Server, error)

NewFileServer ...

func NewFloat64

func NewFloat64(v float64) *float64

NewFloat64 ...

func NewInt64

func NewInt64(v int64) *int64

NewInt64 ...

func NewString

func NewString(v string) *string

NewString ...

func PropulsionTypeAll

func PropulsionTypeAll() []string

PropulsionTypeAll ...

func RentalMethodAll

func RentalMethodAll() []string

RentalMethodAll ...

func UserTypeAll

func UserTypeAll() []string

UserTypeAll ...

Types

type Boolean

type Boolean bool

Boolean ...

func NewBoolean

func NewBoolean(v bool) *Boolean

NewBoolean ...

func (*Boolean) UnmarshalJSON

func (t *Boolean) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type Cache

type Cache interface {
	Get(k string) (v Feed, ok bool)
	Set(k string, v Feed)
}

Cache ...

type Client

type Client struct {
	Options *ClientOptions
	// contains filtered or unexported fields
}

Client ...

func NewClient

func NewClient(options ClientOptions) (*Client, error)

NewClient ...

func (*Client) Get

func (c *Client) Get(feed Feed) error

Get ...

func (*Client) GetURL

func (c *Client) GetURL(url string, feed Feed) error

GetURL ...

func (*Client) Subscribe

func (c *Client) Subscribe(options ClientSubscribeOptions) error

Subscribe ...

type ClientOptions

type ClientOptions struct {
	AutoDiscoveryURL string
	DefaultLanguage  string
	UserAgent        string
	HTTPClient       *http.Client
	Cache            Cache
}

ClientOptions ...

type ClientSubscribeOptions

type ClientSubscribeOptions struct {
	Languages []string
	FeedNames []string
	Handler   func(*Client, Feed, error)
}

ClientSubscribeOptions ...

type Coordinate

type Coordinate struct {
	Float64 float64
	OldType string
}

Coordinate ...

func NewCoordinate

func NewCoordinate(v float64) *Coordinate

NewCoordinate ...

func (*Coordinate) MarshalJSON

func (p *Coordinate) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*Coordinate) String

func (p *Coordinate) String() string

String ...

func (*Coordinate) UnmarshalJSON

func (p *Coordinate) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type Feed

type Feed interface {
	Name() string
	GetLanguage() string
	SetLanguage(string) Feed
	GetLastUpdated() Timestamp
	SetLastUpdated(Timestamp) Feed
	GetTTL() int
	SetTTL(int) Feed
	GetVersion() string
	SetVersion(string) Feed
	GetData() interface{}
	SetData(interface{}) Feed
	Expired() bool
}

Feed ...

func FeedStruct

func FeedStruct(name string) Feed

FeedStruct ...

type FeedCommon

type FeedCommon struct {
	sync.RWMutex
	Language    *string     `json:"-"` // Unofficial helper parameter
	LastUpdated *Timestamp  `json:"last_updated"`
	TTL         *int        `json:"ttl"`
	Version     *string     `json:"version,omitempty"` // (v1.1)
	Data        interface{} `json:"data"`
}

FeedCommon ...

func (*FeedCommon) Expired

func (s *FeedCommon) Expired() bool

Expired ...

func (*FeedCommon) GetData

func (s *FeedCommon) GetData() interface{}

GetData ...

func (*FeedCommon) GetLanguage

func (s *FeedCommon) GetLanguage() string

GetLanguage ...

func (*FeedCommon) GetLastUpdated

func (s *FeedCommon) GetLastUpdated() Timestamp

GetLastUpdated ...

func (*FeedCommon) GetTTL

func (s *FeedCommon) GetTTL() int

GetTTL ...

func (*FeedCommon) GetVersion

func (s *FeedCommon) GetVersion() string

GetVersion ...

func (*FeedCommon) Name

func (s *FeedCommon) Name() string

Name ...

func (*FeedCommon) SetData

func (s *FeedCommon) SetData(v interface{}) Feed

SetData ...

func (*FeedCommon) SetLanguage

func (s *FeedCommon) SetLanguage(v string) Feed

SetLanguage ...

func (*FeedCommon) SetLastUpdated

func (s *FeedCommon) SetLastUpdated(v Timestamp) Feed

SetLastUpdated ...

func (*FeedCommon) SetTTL

func (s *FeedCommon) SetTTL(v int) Feed

SetTTL ...

func (*FeedCommon) SetVersion

func (s *FeedCommon) SetVersion(v string) Feed

SetVersion ...

type FeedFreeBikeStatus

type FeedFreeBikeStatus struct {
	FeedCommon
	Data *FeedFreeBikeStatusData `json:"data"`
}

FeedFreeBikeStatus ...

func (*FeedFreeBikeStatus) Name

func (f *FeedFreeBikeStatus) Name() string

Name ...

type FeedFreeBikeStatusBike

type FeedFreeBikeStatusBike struct {
	BikeID             *ID         `json:"bike_id"`
	SystemID           *ID         `json:"system_id,omitempty"` // (v3.0-RC)
	Lat                *Coordinate `json:"lat"`
	Lon                *Coordinate `json:"lon"`
	IsReserved         *Boolean    `json:"is_reserved"`
	IsDisabled         *Boolean    `json:"is_disabled"`
	RentalURIs         *RentalURIs `json:"rental_uris,omitempty"`          // (v1.1)
	VehicleTypeID      *ID         `json:"vehicle_type_id,omitempty"`      // (v2.1-RC)
	LastReported       *Timestamp  `json:"last_reported,omitempty"`        // (v2.1-RC)
	CurrentRangeMeters *float64    `json:"current_range_meters,omitempty"` // (v2.1-RC)
}

FeedFreeBikeStatusBike ...

type FeedFreeBikeStatusData

type FeedFreeBikeStatusData struct {
	Bikes []*FeedFreeBikeStatusBike `json:"bikes"`
}

FeedFreeBikeStatusData ...

type FeedGbfs

type FeedGbfs struct {
	FeedCommon
	Data map[string]*FeedGbfsLanguage `json:"data"`
}

FeedGbfs ...

func (*FeedGbfs) Name

func (f *FeedGbfs) Name() string

Name ...

type FeedGbfsFeed

type FeedGbfsFeed struct {
	Name *string `json:"name"`
	URL  *string `json:"url"`
}

FeedGbfsFeed ...

type FeedGbfsLanguage

type FeedGbfsLanguage struct {
	Feeds []*FeedGbfsFeed `json:"feeds"`
}

FeedGbfsLanguage ...

type FeedGbfsVersions

type FeedGbfsVersions struct {
	FeedCommon
	Data *FeedGbfsVersionsData `json:"data"`
}

FeedGbfsVersions ...

func (*FeedGbfsVersions) Name

func (f *FeedGbfsVersions) Name() string

Name ...

type FeedGbfsVersionsData

type FeedGbfsVersionsData struct {
	Versions []*FeedGbfsVersionsVersion `json:"versions"`
}

FeedGbfsVersionsData ...

type FeedGbfsVersionsVersion

type FeedGbfsVersionsVersion struct {
	Version *string `json:"version"`
	URL     *string `json:"url"`
}

FeedGbfsVersionsVersion ...

type FeedGeofencingZones

type FeedGeofencingZones struct {
	FeedCommon
	Data *FeedGeofencingZonesData `json:"data"`
}

FeedGeofencingZones ...

func (*FeedGeofencingZones) Name

func (f *FeedGeofencingZones) Name() string

Name ...

type FeedGeofencingZonesData

type FeedGeofencingZonesData struct {
	GeofencingZones *FeedGeofencingZonesGeoJSONFeatureCollection `json:"geofencing_zones"`
}

FeedGeofencingZonesData ...

type FeedGeofencingZonesGeoJSONFeature

type FeedGeofencingZonesGeoJSONFeature struct {
	GeoJSONFeature
	Properties *FeedGeofencingZonesGeoJSONFeatureProperties `json:"properties"`
}

FeedGeofencingZonesGeoJSONFeature ...

func NewFeedGeofencingZonesGeoJSONFeature

func NewFeedGeofencingZonesGeoJSONFeature(geometry *GeoJSONGeometry, properties *FeedGeofencingZonesGeoJSONFeatureProperties) *FeedGeofencingZonesGeoJSONFeature

NewFeedGeofencingZonesGeoJSONFeature ...

type FeedGeofencingZonesGeoJSONFeatureCollection

type FeedGeofencingZonesGeoJSONFeatureCollection struct {
	GeoJSONFeatureCollection
	Features []*FeedGeofencingZonesGeoJSONFeature `json:"features"`
}

FeedGeofencingZonesGeoJSONFeatureCollection ...

func NewFeedGeofencingZonesGeoJSONFeatureCollection

func NewFeedGeofencingZonesGeoJSONFeatureCollection(features []*FeedGeofencingZonesGeoJSONFeature) *FeedGeofencingZonesGeoJSONFeatureCollection

NewFeedGeofencingZonesGeoJSONFeatureCollection ...

type FeedGeofencingZonesGeoJSONFeatureProperties

type FeedGeofencingZonesGeoJSONFeatureProperties struct {
	Name  *string                                            `json:"name,omitempty"`
	Start *Timestamp                                         `json:"start,omitempty"`
	End   *Timestamp                                         `json:"end,omitempty"`
	Rules []*FeedGeofencingZonesGeoJSONFeaturePropertiesRule `json:"rules,omitempty"`
}

FeedGeofencingZonesGeoJSONFeatureProperties ...

type FeedGeofencingZonesGeoJSONFeaturePropertiesRule

type FeedGeofencingZonesGeoJSONFeaturePropertiesRule struct {
	VehicleTypeIDs     []*ID    `json:"vehicle_type_ids,omitempty"`
	RideAllowed        *Boolean `json:"ride_allowed"`
	RideThroughAllowed *Boolean `json:"ride_through_allowed"`
	MaximumSpeedKph    *int64   `json:"maximum_speed_kph,omitempty"`
}

FeedGeofencingZonesGeoJSONFeaturePropertiesRule ...

type FeedHandler

type FeedHandler struct {
	Language string
	TTL      int
	Path     string
	Handler  func(*Server) ([]Feed, error)
}

FeedHandler ...

type FeedStationInformation

type FeedStationInformation struct {
	FeedCommon
	Data *FeedStationInformationData `json:"data"`
}

FeedStationInformation ...

func (*FeedStationInformation) Name

func (f *FeedStationInformation) Name() string

Name ...

type FeedStationInformationData

type FeedStationInformationData struct {
	Stations []*FeedStationInformationStation `json:"stations"`
}

FeedStationInformationData ...

type FeedStationInformationStation

type FeedStationInformationStation struct {
	StationID           *ID              `json:"station_id"`
	Name                *string          `json:"name"`
	ShortName           *string          `json:"short_name,omitempty"`
	Lat                 *Coordinate      `json:"lat"`
	Lon                 *Coordinate      `json:"lon"`
	Address             *string          `json:"address,omitempty"`
	CrossStreet         *string          `json:"cross_street,omitempty"`
	RegionID            *ID              `json:"region_id,omitempty"`
	PostCode            *string          `json:"post_code,omitempty"`
	RentalMethods       []string         `json:"rental_methods,omitempty"`
	IsVirtualStation    *Boolean         `json:"is_virtual_station,omitempty"` // (v2.1-RC)
	StationArea         *GeoJSONGeometry `json:"station_area,omitempty"`       // (v2.1-RC)
	Capacity            *int64           `json:"capacity,omitempty"`
	VehicleCapacity     map[ID]int64     `json:"vehicle_capacity,omitempty"`      // (v2.1-RC)
	VehicleTypeCapacity map[ID]int64     `json:"vehicle_type_capacity,omitempty"` // (v2.1-RC)
	IsValetStation      *Boolean         `json:"is_valet_station,omitempty"`      // (v2.1-RC)
	RentalURIs          *RentalURIs      `json:"rental_uris,omitempty"`           // (v1.1)
}

FeedStationInformationStation ...

type FeedStationStatus

type FeedStationStatus struct {
	FeedCommon
	Data *FeedStationStatusData `json:"data"`
}

FeedStationStatus ...

func (*FeedStationStatus) Name

func (f *FeedStationStatus) Name() string

Name ...

type FeedStationStatusData

type FeedStationStatusData struct {
	Stations []*FeedStationStatusStation `json:"stations"`
}

FeedStationStatusData ...

type FeedStationStatusStation

type FeedStationStatusStation struct {
	StationID             *ID                             `json:"station_id"`
	NumBikesAvailable     *int64                          `json:"num_bikes_available"`
	NumBikesDisabled      *int64                          `json:"num_bikes_disabled,omitempty"`
	NumDocksAvailable     *int64                          `json:"num_docks_available,omitempty"` // conditionally required (v2.0)
	NumDocksDisabled      *int64                          `json:"num_docks_disabled,omitempty"`
	IsInstalled           *Boolean                        `json:"is_installed"`
	IsRenting             *Boolean                        `json:"is_renting"`
	IsReturning           *Boolean                        `json:"is_returning"`
	LastReported          *Timestamp                      `json:"last_reported"`
	VehicleTypesAvailable []*FeedStationStatusVehicleType `json:"vehicle_types_available,omitempty"` // conditionally required (v2.1-RC)
	VehicleDocksAvailable []*FeedStationStatusVehicleDock `json:"vehicle_docks_available,omitempty"` // conditionally required (v2.1-RC)
}

FeedStationStatusStation ...

type FeedStationStatusVehicleDock

type FeedStationStatusVehicleDock struct {
	VehicleTypeIDs []*ID  `json:"vehicle_type_ids"` // (v2.1-RC)
	Count          *int64 `json:"count"`            // (v2.1-RC)
}

FeedStationStatusVehicleDock ...

type FeedStationStatusVehicleType

type FeedStationStatusVehicleType struct {
	VehicleTypeID *ID    `json:"vehicle_type_id"` // (v2.1-RC)
	Count         *int64 `json:"count"`           // (v2.1-RC)
}

FeedStationStatusVehicleType ...

type FeedSystemAlerts

type FeedSystemAlerts struct {
	FeedCommon
	Data *FeedSystemAlertsData `json:"data"`
}

FeedSystemAlerts ...

func (*FeedSystemAlerts) Name

func (f *FeedSystemAlerts) Name() string

Name ...

type FeedSystemAlertsAlert

type FeedSystemAlertsAlert struct {
	AlertID     *ID                          `json:"alert_id"`
	Type        *string                      `json:"type"`
	Times       []*FeedSystemAlertsAlertTime `json:"times,omitempty"`
	StationIDs  []*ID                        `json:"station_ids,omitempty"`
	RegionIDs   []*ID                        `json:"region_ids,omitempty"`
	URL         *string                      `json:"url,omitempty"`
	Summary     *string                      `json:"summary"`
	Description *string                      `json:"description,omitempty"`
	LastUpdated *Timestamp                   `json:"last_updated,omitempty"`
}

FeedSystemAlertsAlert ...

type FeedSystemAlertsAlertTime

type FeedSystemAlertsAlertTime struct {
	Start *Timestamp `json:"start"`
	End   *Timestamp `json:"end,omitempty"`
}

FeedSystemAlertsAlertTime ...

type FeedSystemAlertsData

type FeedSystemAlertsData struct {
	Alerts []*FeedSystemAlertsAlert `json:"alerts"`
}

FeedSystemAlertsData ...

type FeedSystemCalendar

type FeedSystemCalendar struct {
	FeedCommon
	Data *FeedSystemCalendarData `json:"data"`
}

FeedSystemCalendar ...

func (*FeedSystemCalendar) Name

func (f *FeedSystemCalendar) Name() string

Name ...

type FeedSystemCalendarCalendar

type FeedSystemCalendarCalendar struct {
	StartMonth *int64 `json:"start_month"`
	StartDay   *int64 `json:"start_day"`
	StartYear  *int64 `json:"start_year,omitempty"`
	EndMonth   *int64 `json:"end_month"`
	EndDay     *int64 `json:"end_day"`
	EndYear    *int64 `json:"end_year,omitempty"`
}

FeedSystemCalendarCalendar ...

type FeedSystemCalendarData

type FeedSystemCalendarData struct {
	Calendars []*FeedSystemCalendarCalendar `json:"calendars"`
}

FeedSystemCalendarData ...

type FeedSystemHours

type FeedSystemHours struct {
	FeedCommon
	Data *FeedSystemHoursData `json:"data"`
}

FeedSystemHours ...

func (*FeedSystemHours) Name

func (f *FeedSystemHours) Name() string

Name ...

type FeedSystemHoursData

type FeedSystemHoursData struct {
	RentalHours []*FeedSystemHoursRentalHour `json:"rental_hours"`
}

FeedSystemHoursData ...

type FeedSystemHoursRentalHour

type FeedSystemHoursRentalHour struct {
	UserTypes []string `json:"user_types"`
	Days      []string `json:"days"`
	StartTime *string  `json:"start_time"`
	EndTime   *string  `json:"end_time"`
}

FeedSystemHoursRentalHour ...

type FeedSystemInformation

type FeedSystemInformation struct {
	FeedCommon
	Data *FeedSystemInformationData `json:"data"`
}

FeedSystemInformation ...

func (*FeedSystemInformation) Name

func (f *FeedSystemInformation) Name() string

Name ...

type FeedSystemInformationData

type FeedSystemInformationData struct {
	SystemID                    *ID         `json:"system_id"`
	Language                    *string     `json:"language"`
	Name                        *string     `json:"name"`
	ShortName                   *string     `json:"short_name,omitempty"`
	Operator                    *string     `json:"operator,omitempty"`
	URL                         *string     `json:"url,omitempty"`
	PurchaseURL                 *string     `json:"purchase_url,omitempty"`
	StartDate                   *string     `json:"start_date,omitempty"`
	PhoneNumber                 *string     `json:"phone_number,omitempty"`
	Email                       *string     `json:"email,omitempty"`
	FeedContactEmail            *string     `json:"feed_contact_email,omitempty"` // (v1.1)
	Timezone                    *string     `json:"timezone"`
	LicenseID                   *string     `json:"license_id,omitempty"`                    // (v3.0-RC)
	LicenseURL                  *string     `json:"license_url,omitempty"`                   // (v3.0-RC)
	AttributionOrganizationName *string     `json:"attribution_organization_name,omitempty"` // (v3.0-RC)
	AttributionURL              *string     `json:"attribution_url,omitempty"`               // (v3.0-RC)
	RentalApps                  *RentalApps `json:"rental_apps,omitempty"`                   // (v1.1)
}

FeedSystemInformationData ...

type FeedSystemPricingPlans

type FeedSystemPricingPlans struct {
	FeedCommon
	Data *FeedSystemPricingPlansData `json:"data"`
}

FeedSystemPricingPlans ...

func (*FeedSystemPricingPlans) Name

func (f *FeedSystemPricingPlans) Name() string

Name ...

type FeedSystemPricingPlansData

type FeedSystemPricingPlansData struct {
	Plans []*FeedSystemPricingPlansPricingPlan `json:"plans"`
}

FeedSystemPricingPlansData ...

type FeedSystemPricingPlansPricingPlan

type FeedSystemPricingPlansPricingPlan struct {
	PlanID      *ID      `json:"plan_id"`
	URL         *string  `json:"url,omitempty"`
	Name        *string  `json:"name"`
	Currency    *string  `json:"currency"`
	Price       *Price   `json:"price"`
	IsTaxable   *Boolean `json:"is_taxable"`
	Description *string  `json:"description"`
}

FeedSystemPricingPlansPricingPlan ...

type FeedSystemRegions

type FeedSystemRegions struct {
	FeedCommon
	Data *FeedSystemRegionsData `json:"data"`
}

FeedSystemRegions ...

func (*FeedSystemRegions) Name

func (f *FeedSystemRegions) Name() string

Name ...

type FeedSystemRegionsData

type FeedSystemRegionsData struct {
	Regions []*FeedSystemRegionsRegion `json:"regions"`
}

FeedSystemRegionsData ...

type FeedSystemRegionsRegion

type FeedSystemRegionsRegion struct {
	RegionID *ID     `json:"region_id"`
	Name     *string `json:"name"`
}

FeedSystemRegionsRegion ...

type FeedVehicleTypes

type FeedVehicleTypes struct {
	FeedCommon
	Data *FeedVehicleTypesData `json:"data"`
}

FeedVehicleTypes (v2.1-RC)

func (*FeedVehicleTypes) Name

func (f *FeedVehicleTypes) Name() string

Name ...

type FeedVehicleTypesData

type FeedVehicleTypesData struct {
	VehicleTypes []*FeedVehicleTypesVehicleType `json:"vehicle_types"`
}

FeedVehicleTypesData ...

type FeedVehicleTypesVehicleType

type FeedVehicleTypesVehicleType struct {
	VehicleTypeID  *ID      `json:"vehicle_type_id"`
	FormFactor     *string  `json:"form_factor"`
	PropulsionType *string  `json:"propulsion_type"`
	MaxRangeMeters *float64 `json:"max_range_meters,omitempty"`
	Name           *string  `json:"name,omitempty"`
}

FeedVehicleTypesVehicleType ...

type GeoJSONFeature

type GeoJSONFeature struct {
	Type       string           `json:"type"`
	Geometry   *GeoJSONGeometry `json:"geometry"`
	Properties interface{}      `json:"properties,omitempty"`
}

GeoJSONFeature ...

func NewGeoJSONFeature

func NewGeoJSONFeature(geometry *GeoJSONGeometry, properties interface{}) *GeoJSONFeature

NewGeoJSONFeature ...

type GeoJSONFeatureCollection

type GeoJSONFeatureCollection struct {
	Type     string            `json:"type"`
	Features []*GeoJSONFeature `json:"features"`
}

GeoJSONFeatureCollection ...

func NewGeoJSONFeatureCollection

func NewGeoJSONFeatureCollection(features []*GeoJSONFeature) *GeoJSONFeatureCollection

NewGeoJSONFeatureCollection ...

type GeoJSONGeometry

type GeoJSONGeometry struct {
	Type        string      `json:"type"`
	Coordinates interface{} `json:"coordinates"`
	Properties  interface{} `json:"properties,omitempty"`
}

GeoJSONGeometry ...

func NewGeoJSONGeometryMultiPolygon

func NewGeoJSONGeometryMultiPolygon(coordinates interface{}, properties interface{}) *GeoJSONGeometry

NewGeoJSONGeometryMultiPolygon ...

type ID

type ID string

ID ...

func NewID

func NewID(v string) *ID

NewID ...

func (*ID) UnmarshalJSON

func (t *ID) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type InMemoryCache

type InMemoryCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

InMemoryCache ...

func NewInMemoryCache

func NewInMemoryCache() *InMemoryCache

NewInMemoryCache ...

func (*InMemoryCache) Get

func (c *InMemoryCache) Get(k string) (v Feed, ok bool)

Get ...

func (*InMemoryCache) Set

func (c *InMemoryCache) Set(k string, v Feed)

Set ...

type Price

type Price struct {
	Float64 float64
	OldType string
}

Price ...

func NewPrice

func NewPrice(v float64) *Price

NewPrice ...

func (*Price) MarshalJSON

func (p *Price) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*Price) String

func (p *Price) String() string

String ...

func (*Price) UnmarshalJSON

func (p *Price) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type RentalApp

type RentalApp struct {
	StoreURI     *string `json:"store_uri,omitempty"`     // (v1.1)
	DiscoveryURI *string `json:"discovery_uri,omitempty"` // (v1.1)
}

RentalApp ...

type RentalApps

type RentalApps struct {
	Android *RentalApp `json:"android,omitempty"`
	IOS     *RentalApp `json:"ios,omitempty"`
}

RentalApps ...

type RentalURIs

type RentalURIs struct {
	Android *string `json:"android,omitempty"`
	IOS     *string `json:"ios,omitempty"`
	Web     *string `json:"web,omitempty"`
}

RentalURIs ...

type Server

type Server struct {
	Options *ServerOptions
}

Server ...

func NewServer

func NewServer(options ServerOptions) (*Server, error)

NewServer ...

func (*Server) Start

func (s *Server) Start() error

Start ...

type ServerOptions

type ServerOptions struct {
	SystemID      string
	RootDir       string
	BaseURL       string
	BasePath      string
	Version       string
	DefaultTTL    int
	FeedHandlers  []*FeedHandler
	UpdateHandler func(server *Server, feed Feed, path string, err error)
}

ServerOptions ...

type Timestamp

type Timestamp int64

Timestamp ...

func NewTimestamp

func NewTimestamp(v int64) *Timestamp

NewTimestamp ...

func (Timestamp) Time

func (t Timestamp) Time() time.Time

Time ...

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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