Created
November 5, 2014 05:35
-
-
Save holman/55130df8c9ba9fbce085 to your computer and use it in GitHub Desktop.
A quick Hubot script to display Uber surge pricing from a particular point (LIKE AN OFFICE).
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
# Description | |
# Uber surge pricing magic checker. | |
# | |
# Commands: | |
# hubot uber me - Show the surge pricing information from the SF office. | |
Table = require 'cli-table' | |
module.exports = (robot) -> | |
robot.respond /uber me/i, (msg) -> | |
params = | |
'server_token': "#{process.env.HUBOT_UBER_TOKEN}" | |
'start_latitude': 37.782093 # this'll take you from the GitHub office, sooooo | |
'start_longitude': -122.391580 # your mileage (haha good one holman!) may vary | |
'end_latitude': 37.786959 | |
'end_longitude': -122.397803 | |
msg.http("https://api.uber.com/v1/estimates/price").query(params).get() (err, res, body) -> | |
table = new Table | |
head: ['phat ride', 'surge pricing'], | |
style: { head: false, border: [] } | |
json = JSON.parse(body) | |
for product in json["prices"] | |
table.push [product["display_name"], product["surge_multiplier"]] | |
msg.send "#{table}" |
I really liked this idea so I fleshed it out a bit
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
YMMV - I see what you did there