Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

lukaszraczylo/uber-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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&"

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages