Documentation
¶
Index ¶
- Variables
- func SubscribeActiveTrips(ctx context.Context, ts oauth2.TokenSource) (<-chan TripUpdate, error)
- func SubscribeServerDate(ctx context.Context, ts oauth2.TokenSource) (<-chan time.Time, error)
- type AssetStatus
- type Bike
- type BikeCode
- type BikeSerial
- type BikeType
- type Client
- func (c *Client) CancelBikeReserve(ctx context.Context) (bool, error)
- func (c *Client) GetActiveTrip(ctx context.Context) (Trip, error)
- func (c *Client) GetClientInfo(ctx context.Context) (ClientInfo, error)
- func (c *Client) GetStationCached(ctx context.Context, serial StationSerial) (Station, error)
- func (c *Client) GetStationDocks(ctx context.Context, id StationSerial) (Docks, error)
- func (c *Client) GetStations(ctx context.Context) ([]Station, error)
- func (c *Client) GetTrip(ctx context.Context, code TripCode) (Trip, error)
- func (c *Client) GetTripHistory(ctx context.Context, page, pageSize int) ([]Trip, error)
- func (c *Client) GetUnratedTrips(ctx context.Context, page, pageSize int) ([]Trip, error)
- func (c *Client) PayTripWithMoney(ctx context.Context, id TripCode) (int, error)
- func (c *Client) PayTripWithPoints(ctx context.Context, id TripCode) (int, error)
- func (c *Client) RateTrip(ctx context.Context, code TripCode, rating TripRating) (bool, error)
- func (c *Client) ReserveBike(ctx context.Context, id BikeSerial) (bool, error)
- func (c *Client) StartTrip(ctx context.Context) (bool, error)
- type ClientInfo
- type ClientSubscription
- type Code
- type Dock
- type DockCode
- type DockSerial
- type Docks
- type Serial
- type Station
- type StationCode
- type StationContent
- type StationSerial
- type SubscriptionCode
- type Trip
- type TripCode
- type TripRating
- type TripUpdate
- type UserCode
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoActiveTrip = fmt.Errorf("gira: no active trip") ErrAlreadyHasActiveTrip = fmt.Errorf("gira: already has active trip") ErrBikeAlreadyReserved = fmt.Errorf("gira: bike already reserved") ErrNotEnoughBalance = fmt.Errorf("gira: not enough balance") ErrTripIntervalLimit = fmt.Errorf("gira: trip interval limit") ErrHasNoActiveSubscriptions = fmt.Errorf("gira: has no active subscriptions") ErrNoServiceStatusFound = fmt.Errorf("gira: no service status found") ErrBikeAlreadyInTrip = fmt.Errorf("gira: bike already in trip") ErrTMLCommunication = fmt.Errorf("gira: TML communication error") ErrForbidden = fmt.Errorf("gira: forbidden") )
View Source
var ( AssetStatusActive AssetStatus = "active" BikeTypeElectric BikeType = "electric" BikeTypeConventional BikeType = "conventional" )
Functions ¶
func SubscribeActiveTrips ¶
func SubscribeActiveTrips(ctx context.Context, ts oauth2.TokenSource) (<-chan TripUpdate, error)
func SubscribeServerDate ¶
Types ¶
type AssetStatus ¶
type AssetStatus string
type Bike ¶
type Bike struct { Code BikeCode Serial BikeSerial Status AssetStatus Parent DockCode Name string Type BikeType Battery string // set only if returned from GetStationDocks DockNumber int }
func BikeFromCallbackData ¶
BikeFromCallbackData parses the callback data and returns the bike.
func (Bike) CallbackData ¶
CallbackData returns the callback data for the bike. It contains enough data to show info about bike.
func (Bike) PrettyBattery ¶
func (Bike) PrettyString ¶
func (Bike) TextBattery ¶
func (Bike) TextString ¶
type BikeSerial ¶
type BikeSerial Serial
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CancelBikeReserve ¶
func (*Client) GetClientInfo ¶
func (c *Client) GetClientInfo(ctx context.Context) (ClientInfo, error)
func (*Client) GetStationCached ¶
GetStationCached returns a station from the cache if it exists, otherwise it calls GetStation. This is useful to avoid calling GetStations multiple times if up-to-date data like free dock count is not required.
func (*Client) GetStationDocks ¶
func (*Client) GetTripHistory ¶
func (*Client) GetUnratedTrips ¶
func (*Client) PayTripWithMoney ¶
func (*Client) PayTripWithPoints ¶
func (*Client) ReserveBike ¶
type ClientInfo ¶
type ClientInfo struct { Code UserCode Name string Balance float64 Bonus int ActiveSubscriptions []ClientSubscription }
type ClientSubscription ¶
type Dock ¶
type Dock struct { Code DockCode Serial DockSerial Status AssetStatus Parent StationCode Number int LedStatus string LockStatus string Bike *Bike }
func (Dock) ButtonString ¶
type DockSerial ¶
type DockSerial Serial
type Docks ¶
type Docks []Dock
func (Docks) ConventionalBikesAvailable ¶
func (Docks) ElectricBikesAvailable ¶
type Station ¶
type Station struct { Code StationCode Serial StationSerial Status AssetStatus Type string Name string Description string Latitude float64 Longitude float64 Docks int Bikes int }
type StationCode ¶
type StationCode Code
type StationContent ¶
type StationContent struct {
Docks []Dock
}
type StationSerial ¶
type StationSerial Serial
type SubscriptionCode ¶
type SubscriptionCode Code
type Trip ¶
type Trip struct { Code TripCode TripStatus string User UserCode Client UserCode BikeCode BikeCode BikeName string StartLocation StationCode EndLocation StationCode StartLocationName string EndLocationName string StartDate time.Time EndDate time.Time StartOccupation float64 EndOccupation float64 EndTripDock DockCode Distance float64 Cost float64 TotalBonus int CostBonus int Rating int Photo string Comment string }
type TripRating ¶
type TripUpdate ¶
type TripUpdate struct { Code TripCode Bike string StartDate time.Time EndDate time.Time Cost float64 Finished bool Canceled bool CanPayWithMoney bool CanUsePoints bool ClientPoints int TripPoints int Period string PeriodTime string Error int }
func (TripUpdate) PrettyDuration ¶
func (t TripUpdate) PrettyDuration() string
PrettyDuration returns the duration of the trip in a human-readable format. If the trip is still ongoing, the current time is used as the end time.
Click to show internal directories.
Click to hide internal directories.