2
votes

I'm using the uber api to make requests to the sandbox. Specifically, I'm using the node-uber library from here:https://github.com/shernshiou/node-uber

When I try to set the surge multiplier, using the following code snippet:

 uber.products.setSurgeMultiplierByID('90475b1e-382e-437f-a50f-d9ac28c150c8', 2.2, function (err, res) {
  if (err) console.error("error" + err);
  else console.log("surge success" + res);
  });

And then I make a request:

uber.requests.create({
  "start_latitude": lat,
  "start_longitude": longitude,
  }, function (err, res) {
    if (err) console.error(err);
    else console.log(res);
  });

I see in the response that the surge multiplier is still 1.0

What am I doing wrong? And also, is the uber sandbox supposed to hold a state between my PUT request to the sandbox and my request to call an uber? How does it save that state specifically for me? Is it based on my auth token?

Thanks!

1
You also have to pass the product id for which you previously requested a surge to the requests.create method along with the start_latitude/start_longitude or start_place_id parameters which are mandatory for all ride requests. - Alex Bitek

1 Answers

1
votes

I don't think you're doing anything wrong! The Sandbox mode is supposed to keep track of the "state change" (request status, product status). The API keeps track of that by associating your specific state to either:

  • the server_token: surge multiplier and driver's availability changes trigger the /products endpoint. You can use OAuth or simply your server_token to access it.
  • an OAuth access_token: Request status changes trigger the /requests endpoint. This endpoint requires being accessed with a valid OAuth aacess_token after authentication.

As for the issue you're reporting: After some investigation, I created an issue report on GitHub. I'm contributing to the node-uber project and I'll submit a bugfix today. Will update this answer accordingly. Stay tuned!

UPDATE: I just pushed out an update for node-uber. With v0.9.6, your issue should be fixed. Let me know otherwise! With the code above, you'd need to expect an HTTP 409 error (because surge_multiplier > 2.0) coming back from the requests.create method.