Documentation
¶
Index ¶
- func CheckResponse(r *http.Response, teedBody io.Reader) error
- type Authorization
- type AuthorizeService
- type BasicAuthTransport
- type Client
- type ErrorResponse
- type History
- type HistoryItem
- type HistoryService
- type Parking
- type Parkings
- type ParkingsService
- type Position
- type Profile
- type ProfileService
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Authorization ¶
type Authorization struct {
SessionID *string `json:"SessionId,omitempty"`
}
Authorization describes the body of profile/authorize method response.
type AuthorizeService ¶
type AuthorizeService struct {
// contains filtered or unexported fields
}
AuthorizeService is necessary for the methods which need authorization. Velobike uses basic auth for the authorization and gives a 'SessionId' token.
func (*AuthorizeService) Authorize ¶
func (s *AuthorizeService) Authorize() (*Authorization, *Response, error)
Authorize method authorizes user and get receives token.
type BasicAuthTransport ¶
type BasicAuthTransport struct { Username string // velobike.ru user id Password string // velobike.ru password // Transport is the underlying HTTP transport to use when making requests. // It will default to http.DefaultTransport if nil. Transport http.RoundTripper }
BasicAuthTransport is an http.RoundTripper that authenticates all requests using HTTP Basic Authentication with the provided username and password.
func (*BasicAuthTransport) Client ¶
func (t *BasicAuthTransport) Client() *http.Client
Client returns an *http.Client that makes requests that are authenticated using HTTP Basic Authentication.
type Client ¶
type Client struct { // Base URL for API requests. BaseURL *url.URL // Services used for talking to different parts of the API. Parkings *ParkingsService Authorization *AuthorizeService Profile *ProfileService History *HistoryService // Session ID for authorized user SessionID *string // contains filtered or unexported fields }
A Client manages communication with the API.
func NewClient ¶
NewClient returns a new API client. If a nil httpClient is provided, http.DefaultClient will be used.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type ErrorResponse ¶
type ErrorResponse struct { Code string `json:"code"` ExtCode int `json:"extCode"` LocalizedMessage string `json:"localizedMessage"` Message string `json:"message"` Response *http.Response }
ErrorResponse indicates an error caused by an API request.
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
Error implements an error interface.
type History ¶
type History struct { Items []HistoryItem `json:"Items,omitempty"` TotalRidesTime *time.Time `json:"TotalRidesTime,omitempty"` }
History describes the body of ride/history method response.
type HistoryItem ¶
type HistoryItem struct { Type *string `json:"Type,omitempty"` // Possible types: "Ride", "Pay" // Fields common for both "Ride" and "Pay" types ID *string `json:"Id,omitempty"` Price *float64 `json:"Price,omitempty"` Rejected *bool `json:"Rejected,omitempty"` StartDate *time.Time `json:"StartDate,omitempty"` // layout: 2006-01-02T15:04:05 // Fields available only for "Ride" type BikeID *string `json:"BikeId,omitempty"` BikeType *string `json:"BikeType,omitempty"` EndDate *time.Time `json:"EndDate,omitempty"` StartBikeParkingNumber *string `json:"StartBikeParkingNumber,omitempty"` StartBikeParkingName *string `json:"StartBikeParkingName,omitempty"` StartBikeParkingAddress *string `json:"StartBikeParkingAddress,omitempty"` StartBikeSlotNumber *string `json:"StartBikeSlotNumber,omitempty"` EndBikeParkingNumber *string `json:"EndBikeParkingNumber,omitempty"` EndBikeParkingName *string `json:"EndBikeParkingName,omitempty"` EndBikeParkingAddress *string `json:"EndBikeParkingAddress,omitempty"` EndBikeSlotNumber *string `json:"EndBikeSlotNumber,omitempty"` Time *time.Time `json:"Time,omitempty"` // Duration is always 5-10 seconds less than Time. I suspect it represents Time minus time needed to lock/unlock the bike. Duration *time.Duration `json:"Duration"` Distance *int `json:"CoveredDistance,omitempty"` Text *string `json:"Text,omitempty"` // Fields available only for "Pay" type Contract *string `json:"Contract,omitempty"` Status *string `json:"Status,omitempty"` PanMask *string `json:"PanMask,omitempty"` }
HistoryItem describes part of body responsible for a single ride.
type HistoryService ¶
type HistoryService struct {
// contains filtered or unexported fields
}
HistoryService contains history of user's rides.
type Parking ¶
type Parking struct { Address *string `json:"Address,omitempty"` FreeElectricPlaces *int `json:"FreeElectricPlaces,omitempty"` FreeOrdinaryPlaces *int `json:"FreeOrdinaryPlaces,omitempty"` FreePlaces *int `json:"FreePlaces,omitempty"` HasTerminal *bool `json:"HasTerminal,omitempty"` ID *string `json:"Id,omitempty"` IsFavourite *bool `json:"IsFavourite,omitempty"` IsLocked *bool `json:"IsLocked,omitempty"` Name *string `json:"Name,omitempty"` Position *Position `json:"Position,omitempty"` StationTypes []string `json:"StationTypes,omitempty"` TotalElectricPlaces *int `json:"TotalElectricPlaces,omitempty"` TotalOrdinaryPlaces *int `json:"TotalOrdinaryPlaces,omitempty"` TotalPlaces *int `json:"TotalPlaces,omitempty"` }
Parking describes part of body responsible for a single parking.
type Parkings ¶
type Parkings struct {
Items []Parking `json:"Items,omitempty"`
}
Parkings describes ride/parkings method response.
type ParkingsService ¶
type ParkingsService struct {
// contains filtered or unexported fields
}
ParkingsService is a service to deal with parkings.
type Profile ¶
type Profile struct { UserID *string `json:"UserId,omitempty"` Email *string `json:"Email,omitempty"` PhoneNumber *string `json:"PhoneNumber,omitempty"` RegisterDate *string `json:"RegisterDate,omitempty"` FirstName *string `json:"FirstName,omitempty"` LastName *string `json:"LastName,omitempty"` AvatarURL *string `json:"AvatarUrl,omitempty"` TroikaCardNumber *string `json:"TroikaCardNumber,omitempty"` TroikaPrintCardNumber *string `json:"TroikaPrintCardNumber,omitempty"` Balance *float64 `json:"Balance,omitempty"` Holded *bool `json:"Holded,omitempty"` HoldedAmount *float64 `json:"HoldedAmount,omitempty"` TariffID *string `json:"TariffId,omitempty"` TariffStart *time.Time `json:"TariffStart,omitempty"` TariffEnd *time.Time `json:"TariffEnd,omitempty"` }
Profile describes profile method response body.
type ProfileService ¶
type ProfileService struct {
// contains filtered or unexported fields
}
ProfileService is a service to deal with user's profile.