Documentation ¶
Index ¶
- Constants
- type Address
- type ApiError
- type Base
- type CancellationReasonResult
- type Category
- type Client
- type Driver
- type DriverLocation
- type DriverResult
- type DriverService
- type Duration
- type DurationMin
- type DurationSec
- type Employee
- type EmployeeLastRidesResult
- type EmployeeResult
- type EmployeeService
- type EmployeeStatusResult
- type Estimate
- type Filter
- type HistoricalCategory
- type HistoricalDriver
- type HistoricalRideInfo
- type Icon
- type Location
- type Passenger
- type QRCodeResult
- type QuoteResult
- type QuoteService
- type ResponseError
- type Result
- type Ride
- type RideHistory
- type RideInfo
- type RideResult
- type RideService
- func (rs *RideService) Cancel(ctx context.Context, ride int, reason int) (*Result, error)
- func (rs *RideService) CancellationReason(ctx context.Context) (*CancellationReasonResult, error)
- func (rs *RideService) Create(ctx context.Context, r *Ride) (*RideResult, error)
- func (rs *RideService) QRCode(ctx context.Context, f Filter) (*QRCodeResult, error)
- func (rs *RideService) Rate(ctx context.Context, ride int, rating int) (*Result, error)
- func (rs *RideService) Read(ctx context.Context, f Filter) (*RideResult, error)
- type SubCategory
- type Time
- type TokenSource
- type TravelInfo
- type Vehicle
- type Webhook
- type WebhookResult
- type WebhookRide
- type WebhookService
- func (ws *WebhookService) Activate(ctx context.Context) (*Result, error)
- func (ws *WebhookService) Create(ctx context.Context, w *Webhook) (*Result, error)
- func (ws *WebhookService) Deactivate(ctx context.Context) (*Result, error)
- func (ws *WebhookService) Read(ctx context.Context) (*WebhookResult, error)
- func (ws *WebhookService) Update(ctx context.Context, w *Webhook) (*Result, error)
Constants ¶
const ( RideStatusSearchingForDriver = "searching-for-driver" RideStatusDriverNotFound = "driver-not-found" RideStatusCancelled = "ride-cancelled" RideStatusDriverFound = "driver-found" RideStatusWaitingForDriver = "waiting-for-driver" RideStatusInProgress = "on-ride" RideStatusPaid = "ride-paid" RideStatusCompleted = "ride-completed" )
Ride statuses.
const ( RideCancelledByUser = "1" RideCancelledByDriver = "2" RideCancelledBySystem = "3" )
Cancelled By
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiError ¶
type ApiError struct {
// contains filtered or unexported fields
}
ApiError implements the error interface and returns infos from the request.
type Base ¶
Base represents a generic type for describing a resource with an ID an Description attributes.
type CancellationReasonResult ¶
type CancellationReasonResult struct {
Reasons []Base `json:"reasons"`
}
CancellationReasonResult represents the response of listing the cancellation reason of rides.
type Category ¶
type Category struct { ID int `json:"id"` Description string `json:"description"` SubCategories []SubCategory `json:"subcategories"` }
The categories available for the region requested.
type Client ¶
type Client struct { // Services implemented Driver *DriverService Employee *EmployeeService Quote *QuoteService Ride *RideService Webhook *WebhookService // contains filtered or unexported fields }
Client is responsible for handling requests to the Wappa API.
func NewClient ¶ added in v2.0.1
NewClient returns a new Wappa API client with provided host URL and HTTP client.
type DriverLocation ¶
type DriverLocation struct { Location Bearing float64 `json:"bearing,omitempty"` Type int `json:"typeId,omitempty"` }
DriverLocation is the struct representing the driver location entity in the API.
type DriverResult ¶
type DriverResult struct { Result Drivers []*DriverLocation `json:"drivers"` }
DriverResult is the API response payload.
type DriverService ¶
type DriverService service
DriverService is responsible for handling the requests to the driver resource.
func (*DriverService) Nearby ¶
func (ds *DriverService) Nearby(ctx context.Context, f Filter) (*DriverResult, error)
Nearby returns the driver of a given type that are closest to the given coordinates.
type Duration ¶ added in v2.1.1
Duration is a time duration represented as hh:mm:ss.
func (*Duration) UnmarshalJSON ¶ added in v2.1.1
type DurationMin ¶ added in v2.1.0
DurationMin is a custom minutes duration type for unmashaling data from the API.
func (*DurationMin) UnmarshalJSON ¶ added in v2.1.0
func (d *DurationMin) UnmarshalJSON(b []byte) (err error)
type DurationSec ¶ added in v2.1.0
DurationSec is a custom seconds duration type for unmashaling data from the API.
func (*DurationSec) UnmarshalJSON ¶ added in v2.1.0
func (d *DurationSec) UnmarshalJSON(b []byte) (err error)
type Employee ¶
type Employee struct { ID int `json:"employeeId"` Email string `json:"email"` DDD string `json:"ddd"` Phone string `json:"phone"` Registration string `json:"registration"` }
Employe is the struct representing the employee entity in the API.
type EmployeeLastRidesResult ¶
type EmployeeLastRidesResult struct { Result History []*RideHistory `json:"history"` }
EmployeeLastRidesResult represents the up to 100 last employee last rides.
type EmployeeResult ¶
type EmployeeResult struct {
Employees []*Employee `json:"employees"`
}
WebhookResult is the API response payload.
type EmployeeService ¶
type EmployeeService service
EmployeeService is responsible for handling the requests to the webhook resource.
func (*EmployeeService) LastRides ¶
func (es *EmployeeService) LastRides(ctx context.Context, f Filter) (*EmployeeLastRidesResult, error)
LastRides returns up to 100 last rides of a given employee.
func (*EmployeeService) Read ¶
func (es *EmployeeService) Read(ctx context.Context, f Filter) (*EmployeeResult, error)
Read returns the list of employees associated with the credentials.
func (*EmployeeService) Status ¶
func (es *EmployeeService) Status(ctx context.Context, id int) (*EmployeeStatusResult, error)
Status returns the current status of employees in the API.
type EmployeeStatusResult ¶
type EmployeeStatusResult struct { // The ride id if the current ride. RideID int `json:"rideId"` // Employee ride status. // Possible values: Free, AwaitingPickup, OnRide, RideCompleted or OnAuction. Status string `json:"status"` }
EmployeeStatusResult represents the current status of the employee.
type Estimate ¶
type Estimate struct { Minimum float64 `json:"minimum"` Maximum float64 `json:"maximum"` Distance float64 `json:"distance"` // Measured in KM. Journey DurationMin `json:"journey"` TimeToPickup DurationSec `json:"timeToPickupValue"` }
type HistoricalCategory ¶
type HistoricalDriver ¶
type HistoricalDriver struct { Driver Category HistoricalCategory `json:"category"` Photo string `json:"photo"` }
type HistoricalRideInfo ¶
type HistoricalRideInfo struct { Status string `json:"status"` StartedAt *Time `json:"rideDate"` EndedAt *Time `json:"finishDate"` PaidAt *Time `json:"paymentDate"` MapURL string `json:"rideMapURL"` CancelledBy string `json:"cancelledBy"` CancelledReason string `json:"cancelledReason"` Value float64 `json:"rideValue"` OriginalValue float64 `json:"rideOriginalValue"` DIscount float64 `json:"rideDiscount"` ExternalID int `json:"externalId"` DurationInSeconds int `json:"durationInSeconds"` Distance int `json:"distance"` }
HistoricalRideInfo represents a historical information about a ride made by the employee
type QRCodeResult ¶
QRCode represents a result payload when generating a QR code.
type QuoteResult ¶
type QuoteResult struct { Categories []*Category `json:"categories"` EstimatedAt *time.Time `json:"date"` }
DriverResult is the API response payload.
type QuoteService ¶
type QuoteService service
QuoteService is responsible for handling the requests to the quote resource.
func (*QuoteService) Estimate ¶
func (qs *QuoteService) Estimate(ctx context.Context, f Filter) (*QuoteResult, error)
Estimate returns a quote for a ride with the given parameters.
type ResponseError ¶
ResponseError contains the default error porperties returnes by the API.
type Result ¶
type Result struct { Success bool Error ResponseError // Returned by the API when error occurs Message string }
Result contains the base porperties all requests to the Wappa API returns.
type Ride ¶
type Ride struct { EmployeeID int `json:"employeeId"` TaxiTypeID int `json:"taxiTypeId"` TaxiCategoryID int `json:"taxiCategoryId"` LatOrigin float64 `json:"latitudeOrigin"` LngOrigin float64 `json:"longitudeOrigin"` LatDestiny float64 `json:"latitudeDestiny"` LngDestiny float64 `json:"longitudeDestiny"` OriginRef string `json:"originReference,omitempty"` ExternalID string `json:"externalId,omitempty"` PassengerPhoneAreaCode string `json:"passengerPhoneAreaCode,omitempty"` PassengerPhoneNumber string `json:"passengerPhoneNumber,omitempty"` }
Ride is the struct representing the ride entity in the API.
type RideHistory ¶
type RideHistory struct { ID int `json:"rideId"` CompanyID int `json:"companyId"` Passenger Passenger `json:"passenger"` Origin Address `json:"origin"` Destiny Address `json:"destiny"` Driver HistoricalDriver `json:"driver"` Info HistoricalRideInfo `json:"rideInfo"` }
RideHistory represents the historical information of a ride.
type RideInfo ¶
type RideInfo struct { // Possible values of Status: // - searching-for-driver // - driver-not-found // - ride-cancelled // - driver-found // - waiting-for-driver // - on-ride // - ride-paid // - ride-completed Status string `json:"status"` DriverLocation Location `json:"driverLocation"` ToOrigin TravelInfo `json:"toOrigin"` ToDestiny TravelInfo `json:"toDestiny"` // The agent that canceled the ride. // Passenger = 1, Driver = 2, System = 3 CancelledBy string `json:"cancelledBy"` // The reason that the ride was canceled for. CancalledReason string `json:"cancelledReason"` // The ride value, if available. RideValue float64 `json:"rideValue"` // The external ID provided when the ride was requested. ExternalID string `json:"externalId"` }
type RideResult ¶
type RideResult struct { Result ID int `json:"rideID"` Passenger Passenger `json:"passenger"` Origin Address `json:"origin"` Destiny Address `json:"destiny"` Driver Driver `json:"driver"` Info RideInfo `json:"rideInfo"` }
DriverResult is the API response payload.
type RideService ¶
type RideService service
RideService is responsible for handling the requests to the ride resource.
func (*RideService) CancellationReason ¶
func (rs *RideService) CancellationReason(ctx context.Context) (*CancellationReasonResult, error)
CancellationReason returns the list of possible reasons a user can choose when cancelling a ride.
func (*RideService) Create ¶
func (rs *RideService) Create(ctx context.Context, r *Ride) (*RideResult, error)
Create creates a new ride in the API.
func (*RideService) QRCode ¶
func (rs *RideService) QRCode(ctx context.Context, f Filter) (*QRCodeResult, error)
QRCode returns a string that when displayed as a QR code can be used on the "Embarque Imediato" feature.
func (*RideService) Read ¶
func (rs *RideService) Read(ctx context.Context, f Filter) (*RideResult, error)
Read returns the info of a ride.
type SubCategory ¶
type SubCategory struct { ID int `json:"id"` TypeID int `json:"typeId"` Default bool `json:"default"` Description string `json:"description"` Discount float64 `json:"discount"` Estimate Estimate `json:"estimate"` Observation string `json:"observation"` Icon Icon `json:"icon"` }
The available subcategories for this category.
type Time ¶
Time is a custom time type for unmashaling data from the API.
func (Time) MarshalJSON ¶
func (*Time) UnmarshalJSON ¶
type TokenSource ¶
type TokenSource struct {
// contains filtered or unexported fields
}
TokenSource implements the oauth2.TokenSource interface, in order to reuse the Wappa token.
func NewTokenSource ¶
func NewTokenSource(ctx context.Context, host, username, password string) *TokenSource
NewTokenSource returns a oauth2.TokenSource for issuing a Wappa token.
The provided context optionally controls which HTTP client is used. See the oauth2.HTTPClient variable. host should be sufixed by '/'.
type TravelInfo ¶
type Webhook ¶
type Webhook struct { URL string `json:"url"` Endpoint string `json:"endpoint"` AuthKey string `json:"authKey"` Active bool `json:"active,omitempty"` }
Webhook is the struct representing the Webhook entity in the API.
type WebhookResult ¶
WebhookResult is the API response payload.
type WebhookRide ¶
type WebhookRide struct { Code int `json:"code"` RideID int `json:"rideId"` CompanyID int `json:"companyId"` EmployeeID int `json:"employeeId"` Status string `json:"status"` TaxiLocation Location `json:"taxiLocation"` OriginLocation Location `json:"originLocation"` DestinyLocation Location `json:"destinyLocation"` TimeToOriginSec int `json:"timeToOriginSec"` TimeToOrigin Duration `json:"timeToOrigin"` DistanceToOriginKM int `json:"destanceToOriginKm"` TimeToDestinySec int `json:"timeToDestinySec"` TimeToDestiny Duration `json:"timeToDestiny"` RideValue float64 `json:"rideValue"` ExternalID string `json:"externalId"` }
WebhookRide is the payload sent by the Webhook.
type WebhookService ¶
type WebhookService service
WebhookService is responsible for handling the requests to the webhook resource.
func (*WebhookService) Activate ¶
func (ws *WebhookService) Activate(ctx context.Context) (*Result, error)
Activate activates the current webhook if it has been deactivated in the API.
func (*WebhookService) Deactivate ¶
func (ws *WebhookService) Deactivate(ctx context.Context) (*Result, error)
Deactivate deactivates the current webhook in the API.
func (*WebhookService) Read ¶
func (ws *WebhookService) Read(ctx context.Context) (*WebhookResult, error)
Read returns the webhooks created in the API.