shernshiou / node-uber

Uber API nodejs wrapper
MIT License
188 stars 66 forks source link

Request Endpoint #7

Closed shernshiou closed 9 years ago

shernshiou commented 9 years ago

Documentation

objectiveSee commented 9 years ago

Agree!

objectiveSee commented 9 years ago

I started this module, Request.js with this code:

function Products(uber) {
  this._uber = uber;
  this.path = 'requests';
}

module.exports = Products;

Products.prototype.requestRide = function (query, callback) {

    console.log('Making request. Query='+JSON.stringify(query));

  if (!query.start_latitude || !query.start_longitude || !query.product_id ) {
    return callback(new Error('Invalid parameters [REQUESTS]'));
  }

  var accessToken = this._uber.access_token;

  return this._uber.get({ 
    url: this.path, 
    params: query,
    access_token: accessToken,
  }, callback);

  return this._uber.get({ url: this.path, params: query }, callback);
};

The issue now is w/ auth permissions. I keep getting { message: 'Missing scope: request', code: 'unauthorized' }. I used https://github.com/uber/Python-Sample-Application/ to get my token and included request in it's list of scopes. (fixed. due to a bug in Ubers example python oAuth server)

objectiveSee commented 9 years ago

@shernshiou I have finished this story. I did not add any tests however because I don't know how to write them! Would love you to review the PR. Thank you!

https://github.com/shernshiou/node-uber/pull/11