Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 27 additions & 23 deletions cmd/uber/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

"github.com/olekukonko/tablewriter"

"github.com/odeke-em/cli-spinner"
spinner "github.com/odeke-em/cli-spinner"
"github.com/odeke-em/command"
"github.com/odeke-em/go-utils/fread"
"github.com/odeke-em/semalim"
Expand Down Expand Up @@ -79,7 +79,7 @@ func (p *paymentsCmd) Run(args []string, defaults map[string]*flag.Flag) {
lastUsedTok = "✔️"
}
table.Append([]string{
fmt.Sprintf("%s", method.PaymentMethod),
method.PaymentMethod.String(),
method.ID,
method.Description,
lastUsedTok,
Expand Down Expand Up @@ -139,7 +139,9 @@ func (a *initCmd) Run(args []string, defaults map[string]*flag.Flag) {
log.Fatal(err)
}

f.Write(blob)
if _, err := f.Write(blob); err != nil {
log.Fatal(err)
}
log.Printf("Successfully saved your OAuth2.0 token to %q", credsPath)
}

Expand Down Expand Up @@ -217,11 +219,11 @@ func (h *historyCmd) Run(args []string, defaults map[string]*flag.Flag) {
endDate := time.Unix(trip.EndTimeUnix, 0)
table.Append([]string{
fmt.Sprintf("%d", i+1),
fmt.Sprintf("%s", startCity.Name),
fmt.Sprintf("%s", startDate.Format("2006/01/02 15:04:05 MST")),
fmt.Sprintf("%s", endDate.Sub(startDate)),
startCity.Name,
startDate.Format("2006/01/02 15:04:05 MST"),
endDate.Sub(startDate).String(),
fmt.Sprintf("%.3f", trip.DistanceMiles),
fmt.Sprintf("%s", trip.RequestID),
trip.RequestID,
})
}
table.Render()
Expand Down Expand Up @@ -373,9 +375,9 @@ func (o *orderCmd) Run(args []string, defaults map[string]*flag.Flag) {
ufare := est.UpfrontFare
table.Append([]string{
fmt.Sprintf("%d", i),
fmt.Sprintf("%s", et.LocalizedName),
fmt.Sprintf("%s", et.Estimate),
fmt.Sprintf("%s", et.CurrencyCode),
et.LocalizedName,
string(et.Estimate),
string(et.CurrencyCode),
fmt.Sprintf("%.1f", ufare.PickupEstimateMinutes),
fmt.Sprintf("%.1f", et.DurationSeconds/60.0),
})
Expand Down Expand Up @@ -416,7 +418,9 @@ func (o *orderCmd) Run(args []string, defaults map[string]*flag.Flag) {
FareID: string(estimateChoice.UpfrontFare.Fare.ID),
ProductID: estimateChoice.Estimate.ProductID,
}
spinr.Start()
if err := spinr.Start(); err != nil {
log.Fatalf("spinrStart err: %v", err)
}
rres, err := uberClient.RequestRide(rreq)
spinr.Stop()
if err != nil {
Expand All @@ -437,11 +441,11 @@ func (o *orderCmd) Run(args []string, defaults map[string]*flag.Flag) {
}

dtable.Append([]string{
fmt.Sprintf("%s", rres.Status),
string(rres.Status),
rres.RequestID,
rres.Driver.Name,
fmt.Sprintf("%d", rres.Driver.Rating),
fmt.Sprintf("%s", rres.Driver.PhoneNumber),
rres.Driver.PhoneNumber,
fmt.Sprintf("%v", rres.Shared),
fmt.Sprintf("%.1f", locationDeref(rres.Pickup).ETAMinutes),
fmt.Sprintf("%.1f", locationDeref(rres.Destination).ETAMinutes),
Expand Down Expand Up @@ -483,7 +487,9 @@ func main() {
}

func doUberEstimates(uberC *uber.Client, esReq *uber.EstimateRequest, spinr *spinner.Spinner) ([]*estimateAndUpfrontFarePair, error) {
spinr.Start()
if err := spinr.Start(); err != nil {
return nil, err
}
estimatesPageChan, cancelPaging, err := uberC.EstimatePrice(esReq)
spinr.Stop()
if err != nil {
Expand All @@ -500,7 +506,9 @@ func doUberEstimates(uberC *uber.Client, esReq *uber.EstimateRequest, spinr *spi
}
}

spinr.Start()
if err := spinr.Start(); err != nil {
return nil, err
}
defer spinr.Stop()

jobsBench := make(chan semalim.Job)
Expand Down Expand Up @@ -550,7 +558,9 @@ func doSearch(prompt string, linesChan <-chan string, repeatSentinel string, spi
if query == "" {
return nil, query, errRepeat
}
spinr.Start()
if err := spinr.Start(); err != nil {
return nil, query, err
}
matches, err := mapboxClient.LookupPlace(context.Background(), query)
spinr.Stop()
if err != nil {
Expand All @@ -569,7 +579,7 @@ func doSearch(prompt string, linesChan <-chan string, repeatSentinel string, spi
coord := centerToCoord(feat.Center)
table.Append([]string{
fmt.Sprintf("%d", i),
fmt.Sprintf("%s", feat.PlaceName),
feat.PlaceName,
fmt.Sprintf("%.2f%%", feat.Relevance*100),
fmt.Sprintf("%f", coord.Lat),
fmt.Sprintf("%f", coord.Lng),
Expand All @@ -593,12 +603,6 @@ func doSearch(prompt string, linesChan <-chan string, repeatSentinel string, spi
return matches.Features[choice], query, nil
}

func input() string {
var str string
fmt.Scanln(os.Stdin, &str)
return str
}

type coord struct {
Lat, Lng float64
}
Expand Down
1 change: 0 additions & 1 deletion uberhook/uberhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type Webhook struct {
var _ authmid.Authenticator = (*Webhook)(nil)

var (
errBlankClientID = errors.New("expecting a non-blank clientID")
errBlankClientSecret = errors.New("expecting a non-blank clientSecret")
)

Expand Down
7 changes: 0 additions & 7 deletions v1/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,6 @@ func (c *Client) bearerToken() string {
return fmt.Sprintf("Bearer %s", c.token)
}

func (c *Client) tokenToken() string {
c.RLock()
defer c.RUnlock()

return fmt.Sprintf("Token %s", c.token)
}

func (c *Client) doAuthAndHTTPReq(req *http.Request) ([]byte, http.Header, error) {
req.Header.Set("Authorization", c.bearerToken())
return c.doHTTPReq(req)
Expand Down
3 changes: 1 addition & 2 deletions v1/deliveries.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ type Batch struct {
}

var (
errNilPickup = errors.New("a non-nil pickup is required")
errNilDropoff = errors.New("a non-nil pickup is required")
errNilPickup = errors.New("a non-nil pickup is required")

errNilEndpointLocation = errors.New("a non-nil endpoint.location is required")
errNilEndpointContact = errors.New("a non-nil endpoint.contact is required")
Expand Down
4 changes: 0 additions & 4 deletions v1/times.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ type TimeEstimatesPage struct {
PageNumber uint64
}

var timeExcludedValues = map[string]bool{
"seat_count": true,
}

func (c *Client) EstimateTime(treq *EstimateRequest) (pagesChan chan *TimeEstimatesPage, cancelPaging func(), err error) {
if treq == nil {
return nil, nil, errNilTimeEstimateRequest
Expand Down