New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

uber_ride_request

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

uber_ride_request

Request a ride to the Uber API

unpublished
latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

Uber Ride Request

Usage

Request an UberX ride by only setting the starting and ending GPS coordinates.

Example

Every method on the client returns a promise, so they can be chained together. You can order a ride as following:

const Client = require('uber_ride_request').Uber;

const access_token = "YOUR_ACCESS_TOKEN"; // Retrieve it by generating a token under the "authorization" tab in https://developer.uber.com/dashboard/
const isSandbox = true; // Set to 'false' if you wish to order a real UberX

const uber = new Client(access_token, isSandbox);

uber.start_lat = 48.870694;
uber.start_lng = 2.317030;
uber.end_lat = 48.871405;
uber.end_lng = 2.301235;
uber.seats = 2;

uber.getUberXEstimate().then(result => {
    if(result != null){
        let distance_estimate = (result.trip.distance_estimate * 1.60934).toFixed(2);
        console.log("Estimated distance: " + distance_estimate + " km");
        uber.getRequest().then(result => {
            console.log("Ordered Uber successfully!");
            // Notify user about the ride process after one minute
            setTimeout(function(){
                getCurrentRide();
            }, 60000);
        });
    } else {
        console.warn("No UberX arround you.");
    }
});

function getCurrentRide(){
    uber.getCurrent().then(result =>{
        let status = result.status;
        let eta = result.pickup.eta;
        console.log("Current status: " + status + ". Driver arrives in: " + eta + " minutes.");
    });
}

You can also cancel an Uber ride requested by using:

uber.cancelCurrent().then(result => {
    if(result == 204){
        console.log("Canceled order successfully!");
    } else {
        res.send("No ride to cancel.");
    }
});

License

MIT

Antoine de Chassey

Keywords

Uber

FAQs

Package last updated on 03 Aug 2017

Related posts