-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
payments: ListPaymentMethods implemented #1
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Start of the API client, by implementing ListPaymentMethods. Example code below on how to retrieve payments methods: ```go package main import ( "fmt" "log" "github.com/orijtech/uber" ) func main() { client, err := uber.NewClient() if err != nil { log.Fatal(err) } listings, err := client.ListPaymentMethods() if err != nil { log.Fatal(err) } fmt.Printf("LastUsedD: %v\n", listings.LastUsedID) for i, method := range listings.Methods { fmt.Printf("#%d: ID: %q PaymentMethod: %q Description: %q\n", i, method.ID, method.PaymentMethod, method.Description) } } ```
odeke-em
added a commit
that referenced
this pull request
May 6, 2017
Implemented a method for time estimation. Sample usage: ```go func estimateTime() { client, err := uber.NewClient() if err != nil { log.Fatal(err) } estimatesPageChan, cancelChan, err := client.EstimateTime(&uber.EstimateRequest{ StartLatitude: 37.7752315, EndLatitude: 37.7752415, StartLongitude: -122.418075, EndLongitude: -122.518075, // Comment out to search only for estimates for: uberXL // ProductID: "821415d8-3bd5-4e27-9604-194e4359a449", }) if err != nil { log.Fatal(err) } itemCount := uint64(0) for page := range estimatesPageChan { if page.Err != nil { fmt.Printf("PageNumber: #%d err: %v", page.PageNumber, page.Err) continue } for i, estimate := range page.Estimates { itemCount += 1 fmt.Printf("Estimate: #%d ==> %#v\n", i, estimate) } if itemCount >= 23 { cancelChan <- true } } } ``` which gives ```shell Estimate: #0 ==> &uber.TimeEstimate{ETASeconds:120, ProductID:"57c0ff4e-1493-4ef9-a4df-6b961525cf92", Name:"SELECT", LocalizedName:"SELECT", LimitPerPage:0} Estimate: #1 ==> &uber.TimeEstimate{ETASeconds:240, ProductID:"821415d8-3bd5-4e27-9604-194e4359a449", Name:"uberXL", LocalizedName:"uberXL", LimitPerPage:0} Estimate: #2 ==> &uber.TimeEstimate{ETASeconds:240, ProductID:"d4abaae7-f4d6-4152-91cc-77523e8165a4", Name:"BLACK", LocalizedName:"BLACK", LimitPerPage:0} Estimate: #3 ==> &uber.TimeEstimate{ETASeconds:240, ProductID:"8920cb5e-51a4-4fa4-acdf-dd86c5e18ae0", Name:"SUV", LocalizedName:"SUV", LimitPerPage:0} Estimate: #4 ==> &uber.TimeEstimate{ETASeconds:120, ProductID:"ff5ed8fe-6585-4803-be13-3ca541235de3", Name:"ASSIST", LocalizedName:"ASSIST", LimitPerPage:0} Estimate: #5 ==> &uber.TimeEstimate{ETASeconds:900, ProductID:"2832a1f5-cfc0-48bb-ab76-7ea7a62060e7", Name:"WAV", LocalizedName:"WAV", LimitPerPage:0} Estimate: #6 ==> &uber.TimeEstimate{ETASeconds:120, ProductID:"93cf5da3-fa47-4e45-804e-ca7749b2d190", Name:"EXPRESS POOL", LocalizedName:"EXPRESS POOL", LimitPerPage:0} Estimate: #7 ==> &uber.TimeEstimate{ETASeconds:120, ProductID:"26546650-e557-4a7b-86e7-6a3942445247", Name:"POOL", LocalizedName:"POOL", LimitPerPage:0} Estimate: #8 ==> &uber.TimeEstimate{ETASeconds:120, ProductID:"a1111c8c-c720-46c3-8534-2fcdd730040d", Name:"uberX", LocalizedName:"uberX", LimitPerPage:0} ```
odeke-em
added a commit
that referenced
this pull request
May 6, 2017
Fixes #7. Implemented a method for time estimation. Sample usage: ```go func estimateTime() { client, err := uber.NewClient() if err != nil { log.Fatal(err) } estimatesPageChan, cancelChan, err := client.EstimateTime(&uber.EstimateRequest{ StartLatitude: 37.7752315, EndLatitude: 37.7752415, StartLongitude: -122.418075, EndLongitude: -122.518075, // Comment out to search only for estimates for: uberXL // ProductID: "821415d8-3bd5-4e27-9604-194e4359a449", }) if err != nil { log.Fatal(err) } itemCount := uint64(0) for page := range estimatesPageChan { if page.Err != nil { fmt.Printf("PageNumber: #%d err: %v", page.PageNumber, page.Err) continue } for i, estimate := range page.Estimates { itemCount += 1 fmt.Printf("Estimate: #%d ==> %#v\n", i, estimate) } if itemCount >= 23 { cancelChan <- true } } } ``` which gives ```shell Estimate: #0 ==> &uber.TimeEstimate{ETASeconds:120, ProductID:"57c0ff4e-1493-4ef9-a4df-6b961525cf92", Name:"SELECT", LocalizedName:"SELECT", LimitPerPage:0} Estimate: #1 ==> &uber.TimeEstimate{ETASeconds:240, ProductID:"821415d8-3bd5-4e27-9604-194e4359a449", Name:"uberXL", LocalizedName:"uberXL", LimitPerPage:0} Estimate: #2 ==> &uber.TimeEstimate{ETASeconds:240, ProductID:"d4abaae7-f4d6-4152-91cc-77523e8165a4", Name:"BLACK", LocalizedName:"BLACK", LimitPerPage:0} Estimate: #3 ==> &uber.TimeEstimate{ETASeconds:240, ProductID:"8920cb5e-51a4-4fa4-acdf-dd86c5e18ae0", Name:"SUV", LocalizedName:"SUV", LimitPerPage:0} Estimate: #4 ==> &uber.TimeEstimate{ETASeconds:120, ProductID:"ff5ed8fe-6585-4803-be13-3ca541235de3", Name:"ASSIST", LocalizedName:"ASSIST", LimitPerPage:0} Estimate: #5 ==> &uber.TimeEstimate{ETASeconds:900, ProductID:"2832a1f5-cfc0-48bb-ab76-7ea7a62060e7", Name:"WAV", LocalizedName:"WAV", LimitPerPage:0} Estimate: #6 ==> &uber.TimeEstimate{ETASeconds:120, ProductID:"93cf5da3-fa47-4e45-804e-ca7749b2d190", Name:"EXPRESS POOL", LocalizedName:"EXPRESS POOL", LimitPerPage:0} Estimate: #7 ==> &uber.TimeEstimate{ETASeconds:120, ProductID:"26546650-e557-4a7b-86e7-6a3942445247", Name:"POOL", LocalizedName:"POOL", LimitPerPage:0} Estimate: #8 ==> &uber.TimeEstimate{ETASeconds:120, ProductID:"a1111c8c-c720-46c3-8534-2fcdd730040d", Name:"uberX", LocalizedName:"uberX", LimitPerPage:0} ```
odeke-em
added a commit
that referenced
this pull request
Jul 19, 2017
Fixes #44 Implements CLI with multiple commands: * history * init * order Firstly to install the CLI: ```shell $ go get -u -v github.com/orijtech/uber/cmd/uber ``` Exhibits: * history: List your last 3 trips ```shell $ uber history --limit-per-page 3 --max-page 1 Page: #1 +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | TRIP # | CITY | DATE | DURATION | MILES | REQUESTID | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | 1 | Denver | 2017/07/15 21:47:44 MDT | 7m31s | 3.211 | 8e7f479c-63e2-4ccc-babd-8671771485c3 | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | 2 | San Francisco | 2017/07/13 18:11:06 MDT | 14m16s | 3.694 | d521aed9-e9bc-4673-9109-25d9ce5c434c | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | 3 | London | 2017/06/25 16:17:43 MDT | 13m35s | 3.318 | 1ce3cccb-2e09-4920-ad80-d00a4645f9ce | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ ``` * init init initializes the context and authorization for your Uber app in the current working directory ```shell $ go get -u -v github.com/orijtech/uber/cmd/uber $ uber init Please visit this URL for the auth dialog: https://login.uber.com/oauth/v2/authorize?access_type=offline&client_id=a_client_id&redirect_uri=https%3A%2F%2Fexample.org/uber&response_type=code&scope=profile+request+history+places+request_receipt+delivery&state=15004223370.604660 ``` which after successful authorization will give you a notice in your browser, to return to your terminal and will save the token to a file on disk, for example: ```shell Successfully saved your OAuth2.0 token to "/Users/orijtech/uber-account/.uber/credentials.json" ``` * order ```shell $ uber order Start Point: Redwood City Cinemark +--------+--------------------------------+-----------+-----------+-------------+ | CHOICE | NAME | RELEVANCE | LATITUDE | LONGITUDE | +--------+--------------------------------+-----------+-----------+-------------+ | 0 | Cinemark 20 Redwood City, | 98.70% | 37.485912 | -122.228752 | | | 825 Middlefield Rd, Redwood | | | | | | City, California 94063, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 1 | Redwood City, California, | 49.00% | 37.485199 | -122.236397 | | | United States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 2 | Redwood City Station, 805 | 39.00% | 37.485439 | -122.231796 | | | Veterans Blvd, Redwood City, | | | | | | California 94063, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 3 | Cinemark Ave, Markham, Ontario | 39.00% | 43.887989 | -79.225441 | | | L6B 1E3, Canada | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 4 | Cinemark Ct, Mulberry, Florida | 39.00% | 27.934687 | -81.996933 | | | 33860, United States | | | | +--------+--------------------------------+-----------+-----------+-------------+ Please enter your choice by numeric key or (n) to search again: 0 End Point: Palo Alto +--------+--------------------------------+-----------+-----------+-------------+ | CHOICE | NAME | RELEVANCE | LATITUDE | LONGITUDE | +--------+--------------------------------+-----------+-----------+-------------+ | 0 | Palo Alto, California, United | 99.00% | 37.442200 | -122.163399 | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 1 | Palo Alto Battlefield National | 99.00% | 26.021400 | -97.480598 | | | Historical Park, 7200 PAREDES | | | | | | LINE Rd, Los Fresnos, Texas | | | | | | 78566, United States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 2 | Palo Alto Baylands Nature | 99.00% | 37.459599 | -122.106003 | | | Preserve, 2500 Embarcadero | | | | | | Way, East Palo Alto, | | | | | | California 94303, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 3 | Palo Alto University, 1791 | 99.00% | 37.382301 | -122.188004 | | | Arastradero Rd, Palo Alto, | | | | | | California 94304, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 4 | Palo Alto High School, 50 | 99.00% | 37.437000 | -122.156998 | | | Embarcadero Rd, Palo Alto, | | | | | | California 94306, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ Please enter your choice by numeric key or (n) to search again: 0 Seat count: 1 or 2 (default 2) 1 +--------+--------+----------+----------+----------------------+--------------------+ | CHOICE | NAME | ESTIMATE | CURRENCY | PICKUP ETA (MINUTES) | DURATION (MINUTES) | +--------+--------+----------+----------+----------------------+--------------------+ | 0 | SELECT | $31-39 | USD | 3.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 1 | ASSIST | $15-19 | USD | 10.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 2 | uberXL | $19-24 | USD | 12.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 3 | BLACK | $40-50 | USD | 5.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 4 | SUV | $53-65 | USD | 5.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 5 | WAV | $13-16 | USD | 0.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 6 | POOL | $6-8 | USD | 9.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 7 | uberX | $15-19 | USD | 8.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ Please enter the choice of your item or n to cancel ```
odeke-em
added a commit
that referenced
this pull request
Jul 19, 2017
Fixes #44 Implements CLI with multiple commands: * history * init * order Firstly to install the CLI: ```shell $ go get -u -v github.com/orijtech/uber/cmd/uber ``` Exhibits: * history: List your last 3 trips ```shell $ uber history --limit-per-page 3 --max-page 1 Page: #1 +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | TRIP # | CITY | DATE | DURATION | MILES | REQUESTID | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | 1 | Denver | 2017/07/15 21:47:44 MDT | 7m31s | 3.211 | 8e7f479c-63e2-4ccc-babd-8671771485c3 | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | 2 | San Francisco | 2017/07/13 18:11:06 MDT | 14m16s | 3.694 | d521aed9-e9bc-4673-9109-25d9ce5c434c | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | 3 | London | 2017/06/25 16:17:43 MDT | 13m35s | 3.318 | 1ce3cccb-2e09-4920-ad80-d00a4645f9ce | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ ``` * init init initializes the context and authorization for your Uber app in the current working directory ```shell $ go get -u -v github.com/orijtech/uber/cmd/uber $ uber init Please visit this URL for the auth dialog: https://login.uber.com/oauth/v2/authorize?access_type=offline&client_id=a_client_id&redirect_uri=https%3A%2F%2Fexample.org/uber&response_type=code&scope=profile+request+history+places+request_receipt+delivery&state=15004223370.604660 ``` which after successful authorization will give you a notice in your browser, to return to your terminal and will save the token to a file on disk, for example: ```shell Successfully saved your OAuth2.0 token to "/Users/orijtech/uber-account/.uber/credentials.json" ``` * order ```shell $ uber order Start Point: Redwood City Cinemark +--------+--------------------------------+-----------+-----------+-------------+ | CHOICE | NAME | RELEVANCE | LATITUDE | LONGITUDE | +--------+--------------------------------+-----------+-----------+-------------+ | 0 | Cinemark 20 Redwood City, | 98.70% | 37.485912 | -122.228752 | | | 825 Middlefield Rd, Redwood | | | | | | City, California 94063, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 1 | Redwood City, California, | 49.00% | 37.485199 | -122.236397 | | | United States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 2 | Redwood City Station, 805 | 39.00% | 37.485439 | -122.231796 | | | Veterans Blvd, Redwood City, | | | | | | California 94063, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 3 | Cinemark Ave, Markham, Ontario | 39.00% | 43.887989 | -79.225441 | | | L6B 1E3, Canada | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 4 | Cinemark Ct, Mulberry, Florida | 39.00% | 27.934687 | -81.996933 | | | 33860, United States | | | | +--------+--------------------------------+-----------+-----------+-------------+ Please enter your choice by numeric key or (n) to search again: 0 End Point: Palo Alto +--------+--------------------------------+-----------+-----------+-------------+ | CHOICE | NAME | RELEVANCE | LATITUDE | LONGITUDE | +--------+--------------------------------+-----------+-----------+-------------+ | 0 | Palo Alto, California, United | 99.00% | 37.442200 | -122.163399 | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 1 | Palo Alto Battlefield National | 99.00% | 26.021400 | -97.480598 | | | Historical Park, 7200 PAREDES | | | | | | LINE Rd, Los Fresnos, Texas | | | | | | 78566, United States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 2 | Palo Alto Baylands Nature | 99.00% | 37.459599 | -122.106003 | | | Preserve, 2500 Embarcadero | | | | | | Way, East Palo Alto, | | | | | | California 94303, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 3 | Palo Alto University, 1791 | 99.00% | 37.382301 | -122.188004 | | | Arastradero Rd, Palo Alto, | | | | | | California 94304, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 4 | Palo Alto High School, 50 | 99.00% | 37.437000 | -122.156998 | | | Embarcadero Rd, Palo Alto, | | | | | | California 94306, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ Please enter your choice by numeric key or (n) to search again: 0 Seat count: 1 or 2 (default 2) 1 +--------+--------+----------+----------+----------------------+--------------------+ | CHOICE | NAME | ESTIMATE | CURRENCY | PICKUP ETA (MINUTES) | DURATION (MINUTES) | +--------+--------+----------+----------+----------------------+--------------------+ | 0 | SELECT | $31-39 | USD | 3.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 1 | ASSIST | $15-19 | USD | 10.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 2 | uberXL | $19-24 | USD | 12.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 3 | BLACK | $40-50 | USD | 5.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 4 | SUV | $53-65 | USD | 5.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 5 | WAV | $13-16 | USD | 0.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 6 | POOL | $6-8 | USD | 9.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 7 | uberX | $15-19 | USD | 8.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ Please enter the choice of your item or n to cancel ```
odeke-em
added a commit
that referenced
this pull request
Jul 19, 2017
Fixes #44 Implements CLI with multiple commands: * history * init * order Firstly to install the CLI: ```shell $ go get -u -v github.com/orijtech/uber/cmd/uber ``` Exhibits: * history: List your last 3 trips ```shell $ uber history --limit-per-page 3 --max-page 1 Page: #1 +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | TRIP # | CITY | DATE | DURATION | MILES | REQUESTID | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | 1 | Denver | 2017/07/15 21:47:44 MDT | 7m31s | 3.211 | 8e7f479c-63e2-4ccc-babd-8671771485c3 | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | 2 | San Francisco | 2017/07/13 18:11:06 MDT | 14m16s | 3.694 | d521aed9-e9bc-4673-9109-25d9ce5c434c | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | 3 | London | 2017/06/25 16:17:43 MDT | 13m35s | 3.318 | 1ce3cccb-2e09-4920-ad80-d00a4645f9ce | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ ``` * init init initializes the context and authorization for your Uber app in the current working directory ```shell $ go get -u -v github.com/orijtech/uber/cmd/uber $ uber init Please visit this URL for the auth dialog: https://login.uber.com/oauth/v2/authorize?access_type=offline&client_id=a_client_id&redirect_uri=https%3A%2F%2Fexample.org/uber&response_type=code&scope=profile+request+history+places+request_receipt+delivery&state=15004223370.604660 ``` which after successful authorization will give you a notice in your browser, to return to your terminal and will save the token to a file on disk, for example: ```shell Successfully saved your OAuth2.0 token to "/Users/orijtech/uber-account/.uber/credentials.json" ``` * order ```shell $ uber order Start Point: Redwood City Cinemark +--------+--------------------------------+-----------+-----------+-------------+ | CHOICE | NAME | RELEVANCE | LATITUDE | LONGITUDE | +--------+--------------------------------+-----------+-----------+-------------+ | 0 | Cinemark 20 Redwood City, | 98.70% | 37.485912 | -122.228752 | | | 825 Middlefield Rd, Redwood | | | | | | City, California 94063, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 1 | Redwood City, California, | 49.00% | 37.485199 | -122.236397 | | | United States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 2 | Redwood City Station, 805 | 39.00% | 37.485439 | -122.231796 | | | Veterans Blvd, Redwood City, | | | | | | California 94063, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 3 | Cinemark Ave, Markham, Ontario | 39.00% | 43.887989 | -79.225441 | | | L6B 1E3, Canada | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 4 | Cinemark Ct, Mulberry, Florida | 39.00% | 27.934687 | -81.996933 | | | 33860, United States | | | | +--------+--------------------------------+-----------+-----------+-------------+ Please enter your choice by numeric key or (n) to search again: 0 End Point: Palo Alto +--------+--------------------------------+-----------+-----------+-------------+ | CHOICE | NAME | RELEVANCE | LATITUDE | LONGITUDE | +--------+--------------------------------+-----------+-----------+-------------+ | 0 | Palo Alto, California, United | 99.00% | 37.442200 | -122.163399 | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 1 | Palo Alto Battlefield National | 99.00% | 26.021400 | -97.480598 | | | Historical Park, 7200 PAREDES | | | | | | LINE Rd, Los Fresnos, Texas | | | | | | 78566, United States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 2 | Palo Alto Baylands Nature | 99.00% | 37.459599 | -122.106003 | | | Preserve, 2500 Embarcadero | | | | | | Way, East Palo Alto, | | | | | | California 94303, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 3 | Palo Alto University, 1791 | 99.00% | 37.382301 | -122.188004 | | | Arastradero Rd, Palo Alto, | | | | | | California 94304, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 4 | Palo Alto High School, 50 | 99.00% | 37.437000 | -122.156998 | | | Embarcadero Rd, Palo Alto, | | | | | | California 94306, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ Please enter your choice by numeric key or (n) to search again: 0 Seat count: 1 or 2 (default 2) 1 +--------+--------+----------+----------+----------------------+--------------------+ | CHOICE | NAME | ESTIMATE | CURRENCY | PICKUP ETA (MINUTES) | DURATION (MINUTES) | +--------+--------+----------+----------+----------------------+--------------------+ | 0 | SELECT | $31-39 | USD | 3.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 1 | ASSIST | $15-19 | USD | 10.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 2 | uberXL | $19-24 | USD | 12.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 3 | BLACK | $40-50 | USD | 5.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 4 | SUV | $53-65 | USD | 5.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 5 | WAV | $13-16 | USD | 0.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 6 | POOL | $6-8 | USD | 9.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 7 | uberX | $15-19 | USD | 8.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ Please enter the choice of your item or n to cancel ```
odeke-em
added a commit
that referenced
this pull request
Jul 19, 2017
Fixes #44 Implements CLI with multiple commands: * history * init * order Firstly to install the CLI: ```shell $ go get -u -v github.com/orijtech/uber/cmd/uber ``` Exhibits: * history: List your last 3 trips ```shell $ uber history --limit-per-page 3 --max-page 1 Page: #1 +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | TRIP # | CITY | DATE | DURATION | MILES | REQUESTID | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | 1 | Denver | 2017/07/15 21:47:44 MDT | 7m31s | 3.211 | 8e7f479c-63e2-4ccc-babd-8671771485c3 | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | 2 | San Francisco | 2017/07/13 18:11:06 MDT | 14m16s | 3.694 | d521aed9-e9bc-4673-9109-25d9ce5c434c | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ | 3 | London | 2017/06/25 16:17:43 MDT | 13m35s | 3.318 | 1ce3cccb-2e09-4920-ad80-d00a4645f9ce | +--------+---------------+-------------------------+----------+-------+--------------------------------------+ ``` * init init initializes the context and authorization for your Uber app in the current working directory ```shell $ go get -u -v github.com/orijtech/uber/cmd/uber $ uber init Please visit this URL for the auth dialog: https://login.uber.com/oauth/v2/authorize?access_type=offline&client_id=a_client_id&redirect_uri=https%3A%2F%2Fexample.org/uber&response_type=code&scope=profile+request+history+places+request_receipt+delivery&state=15004223370.604660 ``` which after successful authorization will give you a notice in your browser, to return to your terminal and will save the token to a file on disk, for example: ```shell Successfully saved your OAuth2.0 token to "/Users/orijtech/uber-account/.uber/credentials.json" ``` * order ```shell $ uber order Start Point: Redwood City Cinemark +--------+--------------------------------+-----------+-----------+-------------+ | CHOICE | NAME | RELEVANCE | LATITUDE | LONGITUDE | +--------+--------------------------------+-----------+-----------+-------------+ | 0 | Cinemark 20 Redwood City, | 98.70% | 37.485912 | -122.228752 | | | 825 Middlefield Rd, Redwood | | | | | | City, California 94063, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 1 | Redwood City, California, | 49.00% | 37.485199 | -122.236397 | | | United States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 2 | Redwood City Station, 805 | 39.00% | 37.485439 | -122.231796 | | | Veterans Blvd, Redwood City, | | | | | | California 94063, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 3 | Cinemark Ave, Markham, Ontario | 39.00% | 43.887989 | -79.225441 | | | L6B 1E3, Canada | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 4 | Cinemark Ct, Mulberry, Florida | 39.00% | 27.934687 | -81.996933 | | | 33860, United States | | | | +--------+--------------------------------+-----------+-----------+-------------+ Please enter your choice by numeric key or (n) to search again: 0 End Point: Palo Alto +--------+--------------------------------+-----------+-----------+-------------+ | CHOICE | NAME | RELEVANCE | LATITUDE | LONGITUDE | +--------+--------------------------------+-----------+-----------+-------------+ | 0 | Palo Alto, California, United | 99.00% | 37.442200 | -122.163399 | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 1 | Palo Alto Battlefield National | 99.00% | 26.021400 | -97.480598 | | | Historical Park, 7200 PAREDES | | | | | | LINE Rd, Los Fresnos, Texas | | | | | | 78566, United States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 2 | Palo Alto Baylands Nature | 99.00% | 37.459599 | -122.106003 | | | Preserve, 2500 Embarcadero | | | | | | Way, East Palo Alto, | | | | | | California 94303, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 3 | Palo Alto University, 1791 | 99.00% | 37.382301 | -122.188004 | | | Arastradero Rd, Palo Alto, | | | | | | California 94304, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ | 4 | Palo Alto High School, 50 | 99.00% | 37.437000 | -122.156998 | | | Embarcadero Rd, Palo Alto, | | | | | | California 94306, United | | | | | | States | | | | +--------+--------------------------------+-----------+-----------+-------------+ Please enter your choice by numeric key or (n) to search again: 0 Seat count: 1 or 2 (default 2) 1 +--------+--------+----------+----------+----------------------+--------------------+ | CHOICE | NAME | ESTIMATE | CURRENCY | PICKUP ETA (MINUTES) | DURATION (MINUTES) | +--------+--------+----------+----------+----------------------+--------------------+ | 0 | SELECT | $31-39 | USD | 3.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 1 | ASSIST | $15-19 | USD | 10.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 2 | uberXL | $19-24 | USD | 12.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 3 | BLACK | $40-50 | USD | 5.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 4 | SUV | $53-65 | USD | 5.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 5 | WAV | $13-16 | USD | 0.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 6 | POOL | $6-8 | USD | 9.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ | 7 | uberX | $15-19 | USD | 8.0 | 22.0 | +--------+--------+----------+----------+----------------------+--------------------+ Please enter the choice of your item or n to cancel ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Start of the API client, by implementing ListPaymentMethods.
Example code below on how to retrieve payments methods: