Documentation
¶
Index ¶
- Constants
- Variables
- func AlertTypeAll() []string
- func DayAll() []string
- func FeedNameAll() []string
- func FormFactorAll() []string
- func NewError(msg string, err error) error
- func NewFileServer(addr, rootDir string) (*http.Server, error)
- func NewFloat64(v float64) *float64
- func NewInt64(v int64) *int64
- func NewString(v string) *string
- func PropulsionTypeAll() []string
- func RentalMethodAll() []string
- func UserTypeAll() []string
- type Boolean
- type Cache
- type Client
- type ClientOptions
- type ClientSubscribeOptions
- type Coordinate
- type Feed
- type FeedCommon
- func (s *FeedCommon) Expired() bool
- func (s *FeedCommon) GetData() interface{}
- func (s *FeedCommon) GetLanguage() string
- func (s *FeedCommon) GetLastUpdated() Timestamp
- func (s *FeedCommon) GetTTL() int
- func (s *FeedCommon) GetVersion() string
- func (s *FeedCommon) Name() string
- func (s *FeedCommon) SetData(v interface{}) Feed
- func (s *FeedCommon) SetLanguage(v string) Feed
- func (s *FeedCommon) SetLastUpdated(v Timestamp) Feed
- func (s *FeedCommon) SetTTL(v int) Feed
- func (s *FeedCommon) SetVersion(v string) Feed
- type FeedFreeBikeStatus
- type FeedFreeBikeStatusBike
- type FeedFreeBikeStatusData
- type FeedGbfs
- type FeedGbfsFeed
- type FeedGbfsLanguage
- type FeedGbfsVersions
- type FeedGbfsVersionsData
- type FeedGbfsVersionsVersion
- type FeedGeofencingZones
- type FeedGeofencingZonesData
- type FeedGeofencingZonesGeoJSONFeature
- type FeedGeofencingZonesGeoJSONFeatureCollection
- type FeedGeofencingZonesGeoJSONFeatureProperties
- type FeedGeofencingZonesGeoJSONFeaturePropertiesRule
- type FeedHandler
- type FeedStationInformation
- type FeedStationInformationData
- type FeedStationInformationStation
- type FeedStationStatus
- type FeedStationStatusData
- type FeedStationStatusStation
- type FeedStationStatusVehicleDock
- type FeedStationStatusVehicleType
- type FeedSystemAlerts
- type FeedSystemAlertsAlert
- type FeedSystemAlertsAlertTime
- type FeedSystemAlertsData
- type FeedSystemCalendar
- type FeedSystemCalendarCalendar
- type FeedSystemCalendarData
- type FeedSystemHours
- type FeedSystemHoursData
- type FeedSystemHoursRentalHour
- type FeedSystemInformation
- type FeedSystemInformationData
- type FeedSystemPricingPlans
- type FeedSystemPricingPlansData
- type FeedSystemPricingPlansPricingPlan
- type FeedSystemRegions
- type FeedSystemRegionsData
- type FeedSystemRegionsRegion
- type FeedVehicleTypes
- type FeedVehicleTypesData
- type FeedVehicleTypesVehicleType
- type GeoJSONFeature
- type GeoJSONFeatureCollection
- type GeoJSONGeometry
- type ID
- type InMemoryCache
- type Price
- type RentalApp
- type RentalApps
- type RentalURIs
- type Server
- type ServerOptions
- type Timestamp
Constants ¶
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" )
const ( FormFactorBicycle = "bicycle" FormFactorCar = "car" FormFactorMoped = "moped" FormFactorOther = "other" FormFactorScooter = "scooter" )
const ( PropulsionTypeHuman = "human" PropulsionTypeElectricAssist = "electric_assist" PropulsionTypeElectric = "electric" PropulsionTypeCombustion = "combustion" )
const ( AlertTypeSystemClosure = "SYSTEM_CLOSURE" AlertTypeStationClosure = "STATION_CLOSURE" AlertTypeStationMove = "STATION_MOVE" AlertTypeOther = "OTHER" )
const ( RentalMethodKey = "KEY" RentalMethodCreditCard = "CREDITCARD" RentalMethodPayPass = "PAYPASS" RentalMethodApplePay = "APPLEPAY" RentalMethodAndroidPay = "ANDROIDPAY" RentalMethodTransitCard = "TRANSITCARD" RentalMethodAccountNumber = "ACCOUNTNUMBER" RentalMethodPhone = "PHONE" )
const ( UserTypeMember = "member" UserTypeNonMember = "nonmember" )
const ( DayMon = "mon" DayTue = "tue" DayWed = "wed" DayThu = "thu" DayFri = "fri" DaySat = "sat" DaySun = "sun" )
Variables ¶
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") )
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 NewFileServer ¶
NewFileServer ...
Types ¶
type Client ¶
type Client struct { Options *ClientOptions // contains filtered or unexported fields }
Client ...
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 ¶
Coordinate ...
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 ...
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) GetLastUpdated ¶
func (s *FeedCommon) GetLastUpdated() Timestamp
GetLastUpdated ...
func (*FeedCommon) SetLastUpdated ¶
func (s *FeedCommon) SetLastUpdated(v Timestamp) Feed
SetLastUpdated ...
type FeedFreeBikeStatus ¶
type FeedFreeBikeStatus struct { FeedCommon Data *FeedFreeBikeStatusData `json:"data"` }
FeedFreeBikeStatus ...
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 ...
type FeedGbfsFeed ¶
FeedGbfsFeed ...
type FeedGbfsLanguage ¶
type FeedGbfsLanguage struct {
Feeds []*FeedGbfsFeed `json:"feeds"`
}
FeedGbfsLanguage ...
type FeedGbfsVersions ¶
type FeedGbfsVersions struct { FeedCommon Data *FeedGbfsVersionsData `json:"data"` }
FeedGbfsVersions ...
type FeedGbfsVersionsData ¶
type FeedGbfsVersionsData struct {
Versions []*FeedGbfsVersionsVersion `json:"versions"`
}
FeedGbfsVersionsData ...
type FeedGbfsVersionsVersion ¶
FeedGbfsVersionsVersion ...
type FeedGeofencingZones ¶
type FeedGeofencingZones struct { FeedCommon Data *FeedGeofencingZonesData `json:"data"` }
FeedGeofencingZones ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
type FeedSystemRegionsData ¶
type FeedSystemRegionsData struct {
Regions []*FeedSystemRegionsRegion `json:"regions"`
}
FeedSystemRegionsData ...
type FeedSystemRegionsRegion ¶
FeedSystemRegionsRegion ...
type FeedVehicleTypes ¶
type FeedVehicleTypes struct { FeedCommon Data *FeedVehicleTypesData `json:"data"` }
FeedVehicleTypes (v2.1-RC)
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 InMemoryCache ¶
InMemoryCache ...
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 ...
Source Files
¶
- client.go
- feed.go
- feed_free_bike_status.go
- feed_gbfs.go
- feed_gbfs_versions.go
- feed_geofencing_zones.go
- feed_station_information.go
- feed_station_status.go
- feed_system_alerts.go
- feed_system_calendar.go
- feed_system_hours.go
- feed_system_information.go
- feed_system_pricing_plans.go
- feed_system_regions.go
- feed_vehicle_types.go
- server.go
- utils.go