Project

ubercar

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Provides easy way to interact with the Uber API in any kind of application
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.3.5, ~> 2.3
~> 1.5
>= 3.3.1, ~> 3.3
>= 10.0.0, ~> 10.0
~> 2.6
 Project Readme

Gem for Uber API ( uber.com )

Gem Version Code Climate Gratipay

This is a Ruby Gem for the uber.com API. It should simplify the process of consuming data from the Uber API for developers using Ruby.

Installation

Add following to your application Gemfile

gem 'ubercar'

Then execute

$ bundle install

Or install it just like that

$ gem install ubercar

Usage

It's pretty straightforward. Sample script using UberCars API:

#!/usr/bin/env ruby
require 'ubercar'
require 'ap'

CFG_CLIENT_ID = '-banana'
CFG_SERVER_TOKEN = 'z1FXM8272irpotatO'
CFG_SECRET = 'B6fzcg4WminionsehnPUr075'


client = UberCar::Client.new({ app_user_key: CFG_CLIENT_ID, app_user_secret: CFG_SECRET, app_server_token: CFG_SERVER_TOKEN, api_host: 'https://api.uber.com/v1' })

result = client.show_products(:latitude => '51.512555', :longitude => '-0.127716')
ap result

result = client.estimate_price(:start_latitude => '51.5107835', :start_longitude => '-0.1167915', :end_latitude => '51.5024782', :end_longitude => '-0.1003484')
ap result

result = client.estimate_time(:start_latitude => '51.512555', :start_longitude => '-0.127716')
# estimate_time can be used with :customer_uuid and product_id for further customization
ap result

result = client.promotions(:start_latitude => '51.5107835', :start_longitude => '-0.1167915', :end_latitude => '51.5024782', :end_longitude => '-0.1003484')
ap result

# returns sign up URL. You can fill up all the fields ( check Uber API documentation )
result = client.sign_up()
ap result

And its output:

{
    "products" => [
        [0] {
                "capacity" => 4,
                   "image" => "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberx.png",
            "display_name" => "uberX",
              "product_id" => "3cb90303-3869-4701-a8fd-92efba468a94",
             "description" => "Cheap, fast & reliable"
        },
        [1] {
                "capacity" => 6,
                   "image" => "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-uberXL_london.png",
            "display_name" => "uberXL",
              "product_id" => "d9b19d17-f013-4b98-9b3f-cf5a9e91d2aa",
             "description" => "Spacious, Convenient Comfort"
        },
        [2] {
                "capacity" => 4,
                   "image" => "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-black.png",
            "display_name" => "UberEXEC",
              "product_id" => "34a6cad0-0629-4ca0-ae68-ed0cea7695ca",
             "description" => "Discreet executive quality"
        },
        [3] {
                "capacity" => 4,
                   "image" => "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-lux.png",
            "display_name" => "UberLUX",
              "product_id" => "ea52c793-1ad7-4c46-96b3-b1836b8cd0f9",
             "description" => "Ultimate luxury & style"
        },
        [4] {
                "capacity" => 5,
                   "image" => "http://d1a3f4spazzrp4.cloudfront.net/car-types/mono/mono-blacktaxi2.png",
            "display_name" => "UberTAXI",
              "product_id" => "6a6629df-3400-4e4b-8742-ebd79bf4ef99",
             "description" => "Iconic, Knowledgeable & Versatile"
        }
    ]
}
{
    "prices" => [
        [0] {
            "localized_display_name" => "uberX",
                          "duration" => 393,
                      "low_estimate" => "5",
                      "display_name" => "uberX",
                        "product_id" => "3cb90303-3869-4701-a8fd-92efba468a94",
                          "distance" => 1.44,
                  "surge_multiplier" => 1.0,
                          "estimate" => "£5-6",
                     "high_estimate" => "6",
                     "currency_code" => "GBP"
        },
        [1] {
            "localized_display_name" => "uberXL",
                          "duration" => 393,
                      "low_estimate" => "7",
                      "display_name" => "uberXL",
                        "product_id" => "d9b19d17-f013-4b98-9b3f-cf5a9e91d2aa",
                          "distance" => 1.44,
                  "surge_multiplier" => 1.0,
                          "estimate" => "£7-9",
                     "high_estimate" => "9",
                     "currency_code" => "GBP"
        },
        [2] {
            "localized_display_name" => "UberEXEC",
                          "duration" => 393,
                      "low_estimate" => "10",
                      "display_name" => "UberEXEC",
                        "product_id" => "34a6cad0-0629-4ca0-ae68-ed0cea7695ca",
                          "distance" => 1.44,
                  "surge_multiplier" => 1.0,
                          "estimate" => "£10",
                     "high_estimate" => "10",
                     "currency_code" => "GBP"
        },
        [3] {
            "localized_display_name" => "UberLUX",
                          "duration" => 393,
                      "low_estimate" => "14",
                      "display_name" => "UberLUX",
                        "product_id" => "ea52c793-1ad7-4c46-96b3-b1836b8cd0f9",
                          "distance" => 1.44,
                  "surge_multiplier" => 1.0,
                          "estimate" => "£14",
                     "high_estimate" => "14",
                     "currency_code" => "GBP"
        },
        [4] {
            "localized_display_name" => "UberTAXI",
                          "duration" => 393,
                      "low_estimate" => nil,
                      "display_name" => "UberTAXI",
                        "product_id" => "6a6629df-3400-4e4b-8742-ebd79bf4ef99",
                          "distance" => 1.44,
                  "surge_multiplier" => 1.0,
                          "estimate" => "Metered",
                     "high_estimate" => nil,
                     "currency_code" => nil
        }
    ]
}
{
    "times" => [
        [0] {
            "localized_display_name" => "uberX",
                          "estimate" => 508,
                      "display_name" => "uberX",
                        "product_id" => "3cb90303-3869-4701-a8fd-92efba468a94"
        },
        [1] {
            "localized_display_name" => "UberEXEC",
                          "estimate" => 381,
                      "display_name" => "UberEXEC",
                        "product_id" => "34a6cad0-0629-4ca0-ae68-ed0cea7695ca"
        },
        [2] {
            "localized_display_name" => "UberLUX",
                          "estimate" => 576,
                      "display_name" => "UberLUX",
                        "product_id" => "ea52c793-1ad7-4c46-96b3-b1836b8cd0f9"
        }
    ]
}
{
       "display_text" => "£10 account credit",
    "localized_value" => "£10",
               "type" => "account_credit"
}
"https://m.uber.com/sign-up?client_id=bananaPotatoKey&"