Documentation
¶
Index ¶
- Constants
- type DbStateRepository
- func (sr *DbStateRepository) FindAll() ([]State, error)
- func (sr *DbStateRepository) FindByTimeRange(from, to time.Time) ([]State, error)
- func (sr *DbStateRepository) GetLast() (State, error)
- func (sr *DbStateRepository) Save(state State) error
- func (sr *DbStateRepository) SaveAll(states []State) error
- type JsonStateRepository
- type Request
- type State
- type Station
- type VelobikeResponse
- type VelobikeResponseItem
Constants ¶
View Source
const VelobikeAPIEndpointURI = "https://velobike.ru/ajax/parkings/"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DbStateRepository ¶
func ProvideDbStateRepository ¶
func ProvideDbStateRepository(DB *gorm.DB) DbStateRepository
func (*DbStateRepository) FindAll ¶
func (sr *DbStateRepository) FindAll() ([]State, error)
func (*DbStateRepository) FindByTimeRange ¶
func (sr *DbStateRepository) FindByTimeRange(from, to time.Time) ([]State, error)
func (*DbStateRepository) GetLast ¶
func (sr *DbStateRepository) GetLast() (State, error)
func (*DbStateRepository) Save ¶
func (sr *DbStateRepository) Save(state State) error
func (*DbStateRepository) SaveAll ¶
func (sr *DbStateRepository) SaveAll(states []State) error
type JsonStateRepository ¶
type JsonStateRepository struct {
// contains filtered or unexported fields
}
func ProvideJsonStateRepository ¶
func ProvideJsonStateRepository(directory string) JsonStateRepository
type Request ¶
type Request struct {
RawResponse []byte
ParsedResponse *VelobikeResponse
}
func NewRequest ¶
func NewRequest() Request
type State ¶
type State struct {
ID uint64 `gorm:"primary_key;auto_increment" json:"-"`
Time time.Time `gorm:"index:time_idx"`
IsLocked bool
IsFavourite bool
FreeElectricPlaces uint8
FreeOrdinaryPlaces uint8
FreePlaces uint8
TotalElectricPlaces uint8
TotalOrdinaryPlaces uint8
TotalPlaces uint8
Station Station `gorm:"foreignkey:StationID"`
StationID string `gorm:"type:char(5)"`
}
State contains information about the station at a specific point in time
func ToStates ¶
func ToStates(response VelobikeResponse) []State
type Station ¶
type Station struct {
ID string `gorm:"primary_key;index:station_idx;type:char(5)"`
Name string
Address string
PositionLat float32
PositionLon float32
HasTerminal bool
}
Station contains information about Velobike station
type VelobikeResponse ¶
type VelobikeResponse struct {
Items []VelobikeResponseItem
Time time.Time `json:"-"`
}
VelobikeResponse structure is properly parsed JSON with request time added.
type VelobikeResponseItem ¶
type VelobikeResponseItem struct {
Address string
FreeElectricPlaces uint8
FreeOrdinaryPlaces uint8
FreePlaces uint8
HasTerminal bool
ID string
IsFavourite bool
IsLocked bool
Name string
Position struct {
Lat float32
Lon float32
}
StationTypes []string
TotalElectricPlaces uint8
TotalOrdinaryPlaces uint8
TotalPlaces uint8
}
VelobikeResponseItem structure is properly parsed JSON item.
Click to show internal directories.
Click to hide internal directories.