ruby_uber 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e230b1b462a751a14b8c7239db64cb161c2da04c
4
+ data.tar.gz: c1ba55744502191d98dd10716e549dbf1d22fa1e
5
+ SHA512:
6
+ metadata.gz: c4e2cd5ed724bce408da8ec2c83c742bbe91553b43d426da3784c18a86dc87f4e5f22bee82fca5e367f254fc9397545c9e510d648092cf0026979f5a73ff1aca
7
+ data.tar.gz: 20e0e56ede226df1443ef0e6a70b8b477de71608d74b0cb7811074b0972cc62cf3e86c37cb839a10a27d92691088e3a81848a596ddb32d31d9ece47b6f4f3861
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ credentials.yml
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruber.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Daniel Luxemburg
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # RubyUber
2
+
3
+ A Ruby wrapper for the Uber [API](https://developer.uber.com/). Brought to you by the team at [Bandwagon](http://bandwagon.io/).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ruby_uber'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ruby_uber
18
+
19
+ ## Usage
20
+
21
+ First, create a client:
22
+
23
+ ``` rb
24
+ client = RubyUber::Client.new(
25
+ server_token: 'my_great_token',
26
+ client_id: 'my_client_id',
27
+ secret: 'shhh'
28
+ )
29
+ ```
30
+
31
+ Client instances must be created with either a `server_token` (for the non-user endpoints) or with a `client_id` and `secret` (for the user endpoints requiring OAuth). You should probably have both though.
32
+
33
+ Access a resource like this:
34
+
35
+ ``` rb
36
+ client.products.get(latitude: 40.69, longitude: -73.98)
37
+ # => [{display_name: "UberBLACK", capacity: 4 ... }, { ... }]
38
+ ```
39
+
40
+ `products`, `price_estimates`, and `time_estimates` are all implemented this way. See documentation for query parameters and response payloads [here](https://developer.uber.com/v1/endpoints/).
41
+
42
+ `user_activity` and `user_profile` have classes and pending specs. They'll be enabled (along with user authentication) soon.
43
+
44
+ ## Testing
45
+
46
+ To run all tests locally:
47
+
48
+ $ rspec spec
49
+
50
+ To point endpoint tests at the live server:
51
+
52
+ $ LIVE=1 rspec spec
53
+
54
+ Running the live tests requires API credentials. They're not in the repository. Create a `credentials.yml` in the root of the project that looks like this:
55
+
56
+ ``` yml
57
+ server_token: my_great_token
58
+ client_id: my_client_id
59
+ secret: shhh
60
+ ```
61
+
62
+ The tests will pull credentials from this file. It's gitignored so you can just leave it there.
63
+
64
+
65
+ ## Contributing
66
+
67
+ 1. Fork it ( https://github.com/WeeelsInc/ruby_uber/fork )
68
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
69
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
70
+ 4. Push to the branch (`git push origin my-new-feature`)
71
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/lib/ruby_uber.rb ADDED
@@ -0,0 +1,14 @@
1
+ require "ruby_uber/version"
2
+ require "ruby_uber/client"
3
+ require "ruby_uber/utility"
4
+ require "ruby_uber/v1/price_estimates"
5
+ require "ruby_uber/v1/products"
6
+ require "ruby_uber/v1/time_estimates"
7
+ require "ruby_uber/v1/user_activity"
8
+ require "ruby_uber/v1/user_profile"
9
+
10
+ module RubyUber
11
+
12
+ class AuthenticationError < RuntimeError; end;
13
+
14
+ end
@@ -0,0 +1,69 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+
4
+ module RubyUber
5
+ class Client
6
+
7
+ attr_accessor :server_token, :client_id, :secret
8
+
9
+ def initialize(options)
10
+ @server_token = options[:server_token]
11
+ @client_id = options[:client_id]
12
+ @secret = options[:secret]
13
+
14
+ if !server_token && !oauthable?
15
+ raise AuthenticationError,
16
+ "Must provide either :server_token or :client_id and :secret to initialize Ruber::Client"
17
+ end
18
+ end
19
+
20
+ def host
21
+ 'api.uber.com'
22
+ end
23
+
24
+ def base_url
25
+ "https://#{host}/v1"
26
+ end
27
+
28
+ def connection
29
+ @connection ||= Faraday.new(url: base_url) do |conn|
30
+ conn.request :json
31
+ conn.response :json
32
+ conn.adapter Faraday.default_adapter
33
+ end
34
+ end
35
+
36
+ def get(url, params)
37
+ connection.get(url, params) do |req|
38
+ req.headers['Authorization'] = "Token #{server_token}"
39
+ end
40
+ end
41
+
42
+ def price_estimates
43
+ V1::PriceEstimates.new(client: self)
44
+ end
45
+
46
+ def products
47
+ V1::Products.new(client: self)
48
+ end
49
+
50
+ def time_estimates
51
+ V1::TimeEstimates.new(client: self)
52
+ end
53
+
54
+ def user_activity
55
+ V1::UserActivity.new(client: self)
56
+ end
57
+
58
+ def user_profile
59
+ V1::UserProfile.new(client: self)
60
+ end
61
+
62
+ private
63
+
64
+ def oauthable?
65
+ client_id && secret
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,17 @@
1
+ module RubyUber
2
+ module Utility
3
+
4
+ def self.symbolize_keys(obj)
5
+ if obj.is_a?(Array)
6
+ return obj.map { |i| symbolize_keys(i) }
7
+ elsif obj.respond_to?(:reduce)
8
+ obj.reduce({}) {|memo,(k,v)|
9
+ memo[k.to_sym] = symbolize_keys(v); memo
10
+ }
11
+ else
12
+ obj
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ module RubyUber
2
+ module V1
3
+ class Base
4
+
5
+ attr_accessor :client
6
+
7
+ def initialize(options)
8
+ @client = options[:client]
9
+ end
10
+
11
+ def get(query = {})
12
+ body = Utility.symbolize_keys(client.get(path, query).body)
13
+ root_key ? body.fetch(root_key) { body } : body
14
+ end
15
+
16
+ def path
17
+ ""
18
+ end
19
+
20
+ def root_key
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,17 @@
1
+ require 'ruby_uber/v1/base'
2
+
3
+ module RubyUber
4
+ module V1
5
+ class PriceEstimates < Base
6
+
7
+ def path
8
+ "estimates/price"
9
+ end
10
+
11
+ def root_key
12
+ :prices
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'ruby_uber/v1/base'
2
+
3
+ module RubyUber
4
+ module V1
5
+ class Products < Base
6
+
7
+ def path
8
+ "products"
9
+ end
10
+
11
+ def root_key
12
+ :products
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'ruby_uber/v1/base'
2
+
3
+ module RubyUber
4
+ module V1
5
+ class TimeEstimates < Base
6
+
7
+ def path
8
+ "estimates/time"
9
+ end
10
+
11
+ def root_key
12
+ :times
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ require 'ruby_uber/v1/base'
2
+
3
+ module RubyUber
4
+ module V1
5
+ class UserActivity < Base
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'ruby_uber/v1/base'
2
+
3
+ module RubyUber
4
+ module V1
5
+ class UserProfile < Base
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module RubyUber
2
+ VERSION = "0.0.1"
3
+ end
data/ruby_uber.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruby_uber/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruby_uber"
8
+ spec.version = RubyUber::VERSION
9
+ spec.authors = ["Bandwagon", "Daniel Luxemburg"]
10
+ spec.email = ["dev_accounts@bandwagon.io", "daniel.luxemburg@bandwagon.io"]
11
+ spec.summary = "Ruby wrapper for the Uber API"
12
+ spec.description = "Ruby wrapper for the Uber API"
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "faraday", "~> 0.9.0"
22
+ spec.add_dependency "faraday_middleware", "~> 0.9.0"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "webmock"
27
+ spec.add_development_dependency "rake"
28
+ end
@@ -0,0 +1,98 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyUber::Client do
4
+
5
+ let(:client) {
6
+ RubyUber::Client.new({
7
+ server_token: 'my_great_token',
8
+ client_id: 'my_client_id',
9
+ secret: 'shhh'
10
+ })
11
+ }
12
+
13
+ describe ".new" do
14
+
15
+ it "can be created with a :server_token" do
16
+ expect {
17
+ RubyUber::Client.new({server_token: 'my_great_token'})
18
+ }.to_not raise_error
19
+ end
20
+
21
+ it "can be created with a :client_id and :secret" do
22
+ expect {
23
+ RubyUber::Client.new({
24
+ client_id: 'my_client_id',
25
+ secret: 'shhh'
26
+ })
27
+ }.to_not raise_error
28
+ end
29
+
30
+ it "must be created with either a :server_token or a :client_id and :secret" do
31
+ expect {
32
+ RubyUber::Client.new({})
33
+ }.to raise_error(RubyUber::AuthenticationError)
34
+ end
35
+
36
+ it "saves credential information" do
37
+ creds = {
38
+ server_token: 'my_great_token',
39
+ client_id: 'my_client_id',
40
+ secret: 'shhh'
41
+ }
42
+
43
+ r = RubyUber::Client.new(creds)
44
+
45
+ expect(r.server_token).to eq(creds[:server_token])
46
+ expect(r.client_id).to eq(creds[:client_id])
47
+ expect(r.secret).to eq(creds[:secret])
48
+ end
49
+
50
+ end
51
+
52
+ describe "#host" do
53
+
54
+ it "knows the API host" do
55
+ expect(client.host).to eq('api.uber.com')
56
+ end
57
+
58
+ end
59
+
60
+ describe "#connection" do
61
+
62
+ it "has an HTTP connection" do
63
+ expect(client.connection).to be_a(Faraday::Connection)
64
+ expect(client.connection.url_prefix.to_s).to eq("https://api.uber.com/v1")
65
+ end
66
+
67
+ end
68
+
69
+ context "v1 endpoints" do
70
+
71
+ it "has access to price estimates" do
72
+ expect(client.price_estimates).to be_a(RubyUber::V1::PriceEstimates)
73
+ expect(client.price_estimates.client).to eq(client)
74
+ end
75
+
76
+ it "has access to products" do
77
+ expect(client.products).to be_a(RubyUber::V1::Products)
78
+ expect(client.products.client).to eq(client)
79
+ end
80
+
81
+ it "has access to time estimates" do
82
+ expect(client.time_estimates).to be_a(RubyUber::V1::TimeEstimates)
83
+ expect(client.time_estimates.client).to eq(client)
84
+ end
85
+
86
+ it "has access to user activity" do
87
+ expect(client.user_activity).to be_a(RubyUber::V1::UserActivity)
88
+ expect(client.user_activity.client).to eq(client)
89
+ end
90
+
91
+ it "has access to user profile" do
92
+ expect(client.user_profile).to be_a(RubyUber::V1::UserProfile)
93
+ expect(client.user_profile.client).to eq(client)
94
+ end
95
+
96
+ end
97
+
98
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyUber::Utility do
4
+
5
+ describe ".symbolize_keys" do
6
+
7
+ it "symbolizes keys of a hash" do
8
+ strs = {"this" => "is", "a" => "stringy", "sort" => "of hash"}
9
+ syms = RubyUber::Utility.symbolize_keys(strs)
10
+ expect(syms[:this]).to eq(strs['this'])
11
+ expect(syms.keys.map(&:class).uniq).to eq([Symbol])
12
+ end
13
+
14
+ it "symbolizes keys of a nested hash" do
15
+ strs = {"this" => { "is" => "nested"} }
16
+ syms = RubyUber::Utility.symbolize_keys(strs)
17
+ expect(syms[:this][:is]).to eq(strs['this']['is'])
18
+ end
19
+
20
+ it "symbolizes keys of hashes in an array" do
21
+ strs = [{"one" => "two"},{"one" => "twentythree"}]
22
+ syms = RubyUber::Utility.symbolize_keys(strs)
23
+ expect(syms).to be_a(Array)
24
+ expect(syms.first[:one]).to eq(strs.first['one'])
25
+ key_klasses = syms.map { |s| s.keys }.flatten.map(&:class).uniq
26
+ expect(key_klasses).to eq([Symbol])
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyUber::V1::Base do
4
+
5
+ describe ".new" do
6
+
7
+ it "initializes with a client instance" do
8
+ client = double()
9
+
10
+ b = RubyUber::V1::Base.new(client: client)
11
+ expect(b.client).to eq(client)
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyUber::V1::PriceEstimates do
4
+
5
+ let(:client) {
6
+ RubyUber::Client.new({
7
+ server_token: 'my_great_token',
8
+ client_id: 'my_client_id',
9
+ secret: 'shhh'
10
+ })
11
+ }
12
+
13
+ let(:query) {
14
+ {
15
+ start_latitude: URBAN_FUTURE_LAB_COORDINATES[:latitude],
16
+ start_longitude: URBAN_FUTURE_LAB_COORDINATES[:longitude],
17
+ end_latitude: LAGUARDIA_COORDINATES[:latitude],
18
+ end_longitude: LAGUARDIA_COORDINATES[:longitude],
19
+ }
20
+ }
21
+
22
+ it "queries the /estimates/price endpoint" do
23
+ stub_request(:get, /api.uber.com\/v1\/estimates\/price/).
24
+ to_return(body: PRICE_ESTIMATES_RESPONSE)
25
+
26
+ result = RubyUber::V1::PriceEstimates.new(client: client).get(query)
27
+
28
+ expect(WebMock).to have_requested(:get, "https://api.uber.com/v1/estimates/price").
29
+ with(query: query, headers: {'Authorization' => 'Token my_great_token'})
30
+ end
31
+
32
+ it "gets price information for available products" do
33
+ stub_request(:get, /api.uber.com\/v1\/estimates\/price/).
34
+ to_return(body: PRICE_ESTIMATES_RESPONSE) unless live?
35
+
36
+ result = RubyUber::V1::PriceEstimates.new(client: live_client { client }).get(query)
37
+
38
+ expect(result).to be_a(Array)
39
+ expect(result.first[:product_id]).to be_a(String)
40
+ expect(result.first[:surge_multiplier]).to be_a(Float)
41
+ end
42
+
43
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyUber::V1::Products do
4
+
5
+ let(:client) {
6
+ RubyUber::Client.new({
7
+ server_token: 'my_great_token',
8
+ client_id: 'my_client_id',
9
+ secret: 'shhh'
10
+ })
11
+ }
12
+
13
+ let(:query) {
14
+ {
15
+ latitude: URBAN_FUTURE_LAB_COORDINATES[:latitude],
16
+ longitude: URBAN_FUTURE_LAB_COORDINATES[:longitude]
17
+ }
18
+ }
19
+
20
+ it "queries the /products endpoint" do
21
+
22
+ stub_request(:get, /api.uber.com\/v1\/products/).
23
+ to_return(body: PRODUCTS_RESPONSE)
24
+
25
+ result = RubyUber::V1::Products.new(client: client).get(query)
26
+
27
+ expect(WebMock).to have_requested(:get, "https://api.uber.com/v1/products").
28
+ with(query: query, :headers => {'Authorization' => 'Token my_great_token'})
29
+
30
+ end
31
+
32
+ it "gets details available products" do
33
+ stub_request(:get, /api.uber.com\/v1\/products/).
34
+ to_return(body: PRODUCTS_RESPONSE) unless live?
35
+
36
+ result = RubyUber::V1::Products.new(client: live_client { client }).get(query)
37
+
38
+ expect(result).to be_a(Array)
39
+ expect(result.first[:product_id]).to be_a(String)
40
+ expect(result.first[:display_name]).to be_a(String)
41
+ expect(result.first[:image]).to match(/^http/)
42
+ end
43
+
44
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyUber::V1::TimeEstimates do
4
+
5
+ let(:client) {
6
+ RubyUber::Client.new({
7
+ server_token: 'my_great_token',
8
+ client_id: 'my_client_id',
9
+ secret: 'shhh'
10
+ })
11
+ }
12
+
13
+ let(:query) {
14
+ {
15
+ start_latitude: URBAN_FUTURE_LAB_COORDINATES[:latitude],
16
+ start_longitude: URBAN_FUTURE_LAB_COORDINATES[:longitude]
17
+ }
18
+ }
19
+
20
+ it "queries the /estimates/time endpoint" do
21
+ stub_request(:get, /api.uber.com\/v1\/estimates\/time/).
22
+ to_return(body: TIME_ESTIMATES_RESPONSE)
23
+
24
+ result = RubyUber::V1::TimeEstimates.new(client: client).get(query)
25
+
26
+ expect(WebMock).to have_requested(:get, "https://api.uber.com/v1/estimates/time").
27
+ with(query: query, headers: {'Authorization'=>'Token my_great_token'})
28
+ end
29
+
30
+ it "gets time information for available products" do
31
+ stub_request(:get, /api.uber.com\/v1\/estimates\/time/).
32
+ to_return(body: TIME_ESTIMATES_RESPONSE) unless live?
33
+
34
+ result = RubyUber::V1::TimeEstimates.new(client: live_client { client }).get(query)
35
+
36
+ expect(result).to be_a(Array)
37
+ expect(result.first[:product_id]).to be_a(String)
38
+ expect(result.first[:estimate]).to be_a(Fixnum)
39
+ end
40
+
41
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyUber::V1::UserActivity do
4
+
5
+ pending "get the user activity for the authenticated user"
6
+
7
+ pending "paginates over the list of history items"
8
+
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyUber::V1::UserProfile do
4
+
5
+ pending "gets a user profile for the authenticated user"
6
+
7
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyUber do
4
+ end
@@ -0,0 +1,12 @@
1
+ require "bundler"
2
+ require 'webmock/rspec'
3
+
4
+ Bundler.require(:default,:development)
5
+
6
+ Dir[File.expand_path('../support/*.rb', __FILE__)].each {|f| require f}
7
+
8
+ RSpec.configure do |config|
9
+ config.include(LiveSpecs)
10
+ end
11
+
12
+ WebMock.allow_net_connect! if ENV['LIVE']
@@ -0,0 +1,9 @@
1
+ LAGUARDIA_COORDINATES = {
2
+ latitude: 40.7721,
3
+ longitude: -73.8737
4
+ }
5
+
6
+ URBAN_FUTURE_LAB_COORDINATES = {
7
+ latitude: 40.6939,
8
+ longitude: -73.9845
9
+ }
@@ -0,0 +1,24 @@
1
+ module LiveSpecs
2
+
3
+ def live?
4
+ !!ENV['LIVE']
5
+ end
6
+
7
+ def live_client &block
8
+ if live?
9
+ RubyUber::Client.new(live_client_credentials)
10
+ else
11
+ block.call
12
+ end
13
+ end
14
+
15
+ def live_client_credentials
16
+ @live_client_credentials ||= get_live_client_credentials
17
+ end
18
+
19
+ def get_live_client_credentials
20
+ credentials = YAML.load(File.new("credentials.yml").read)
21
+ RubyUber::Utility.symbolize_keys(credentials)
22
+ end
23
+
24
+ end
@@ -0,0 +1,133 @@
1
+ PRICE_ESTIMATES_RESPONSE = %q({
2
+ "prices": [
3
+ {
4
+ "product_id": "08f17084-23fd-4103-aa3e-9b660223934b",
5
+ "currency_code": "USD",
6
+ "display_name": "UberBLACK",
7
+ "estimate": "$23-29",
8
+ "low_estimate": 23,
9
+ "high_estimate": 29,
10
+ "surge_multiplier": 1.0
11
+ },
12
+ {
13
+ "product_id": "9af0174c-8939-4ef6-8e91-1a43a0e7c6f6",
14
+ "currency_code": "USD",
15
+ "display_name": "UberSUV",
16
+ "estimate": "$36-44",
17
+ "low_estimate": 36,
18
+ "high_estimate": 44,
19
+ "surge_multiplier": 1.25
20
+ },
21
+ {
22
+ "product_id": "aca52cea-9701-4903-9f34-9a2395253acb",
23
+ "currency_code": null,
24
+ "display_name": "uberTAXI",
25
+ "estimate": "Metered",
26
+ "low_estimate": null,
27
+ "high_estimate": null,
28
+ "surge_multiplier": 1.0
29
+ },
30
+ {
31
+ "product_id": "a27a867a-35f4-4253-8d04-61ae80a40df5",
32
+ "currency_code": "USD",
33
+ "display_name": "uberX",
34
+ "estimate": "$15",
35
+ "low_estimate": 15,
36
+ "high_estimate": 15,
37
+ "surge_multiplier": 1.0
38
+ }
39
+ ]
40
+ })
41
+
42
+ PRODUCTS_RESPONSE = %q({
43
+ "products": [
44
+ {
45
+ "product_id": "327f7914-cd12-4f77-9e0c-b27bac580d03",
46
+ "description": "The original Uber",
47
+ "display_name": "UberBLACK",
48
+ "capacity": 4,
49
+ "image": "http://..."
50
+ },
51
+ {
52
+ "product_id": "955b92da-2b90-4f32-9586-f766cee43b99",
53
+ "description": "Room for everyone",
54
+ "display_name": "UberSUV",
55
+ "capacity": 6,
56
+ "image": "http://..."
57
+ },
58
+ {
59
+ "product_id": "622237e-c1e4-4523-b6e7-e1ac53f625ed",
60
+ "description": "Taxi without the hassle",
61
+ "display_name": "uberTAXI",
62
+ "capacity": 4,
63
+ "image": "http://..."
64
+ },
65
+ {
66
+ "product_id": "b5e74e96-5d27-4caf-83e9-54c030cd6ac5",
67
+ "description": "The low-cost Uber",
68
+ "display_name": "uberX",
69
+ "capacity": 4,
70
+ "image": "http://..."
71
+ }
72
+ ]
73
+ })
74
+
75
+ TIME_ESTIMATES_RESPONSE = %q({
76
+ "times": [
77
+ {
78
+ "product_id": "5f41547d-805d-4207-a297-51c571cf2a8c",
79
+ "display_name": "UberBLACK",
80
+ "estimate": 410
81
+ },
82
+ {
83
+ "product_id": "694558c9-b34b-4836-855d-821d68a4b944",
84
+ "display_name": "UberSUV",
85
+ "estimate": 535
86
+ },
87
+ {
88
+ "product_id": "65af3521-a04f-4f80-8ce2-6d88fb6648bc",
89
+ "display_name": "uberTAXI",
90
+ "estimate": 294
91
+ },
92
+ {
93
+ "product_id": "17b011d3-65be-421d-adf6-a5480a366453",
94
+ "display_name": "uberX",
95
+ "estimate": 288
96
+ }
97
+ ]
98
+ })
99
+
100
+ USER_ACTIVITY_RESPONSE = %q({
101
+ "offset": 0,
102
+ "limit": 1,
103
+ "count": 5,
104
+ "history": [
105
+ {
106
+ "uuid": "7354db54-cc9b-4961-81f2-0094b8e2d215",
107
+ "request_time": 1401884467,
108
+ "product_id": "edf5e5eb-6ae6-44af-bec6-5bdcf1e3ed2c",
109
+ "status": "completed",
110
+ "distance": 0.0279562,
111
+ "start_time": 1401884646,
112
+ "start_location": {
113
+ "address": "706 Mission St, San Francisco, CA",
114
+ "latitude": 37.7860099,
115
+ "longitude": -122.4025387
116
+ },
117
+ "end_time": 1401884732,
118
+ "end_location": {
119
+ "address": "1455 Market Street, San Francisco, CA",
120
+ "latitude": 37.7758179,
121
+ "longitude": -122.4180285
122
+ }
123
+ }
124
+ ]
125
+ })
126
+
127
+ USER_PROFILE_RESPONSE = %q({
128
+ "first_name": "Uber",
129
+ "last_name": "Developer",
130
+ "email": "developer@uber.com",
131
+ "picture": "https://...",
132
+ "promo_code": "teypo"
133
+ })
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_uber
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Bandwagon
8
+ - Daniel Luxemburg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-08-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 0.9.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 0.9.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: faraday_middleware
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.9.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.9.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.6'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.6'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: webmock
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rake
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ description: Ruby wrapper for the Uber API
99
+ email:
100
+ - dev_accounts@bandwagon.io
101
+ - daniel.luxemburg@bandwagon.io
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - lib/ruby_uber.rb
112
+ - lib/ruby_uber/client.rb
113
+ - lib/ruby_uber/utility.rb
114
+ - lib/ruby_uber/v1/base.rb
115
+ - lib/ruby_uber/v1/price_estimates.rb
116
+ - lib/ruby_uber/v1/products.rb
117
+ - lib/ruby_uber/v1/time_estimates.rb
118
+ - lib/ruby_uber/v1/user_activity.rb
119
+ - lib/ruby_uber/v1/user_profile.rb
120
+ - lib/ruby_uber/version.rb
121
+ - ruby_uber.gemspec
122
+ - spec/ruby_uber/client_spec.rb
123
+ - spec/ruby_uber/utility_spec.rb
124
+ - spec/ruby_uber/v1/base_spec.rb
125
+ - spec/ruby_uber/v1/price_estimates_spec.rb
126
+ - spec/ruby_uber/v1/products_spec.rb
127
+ - spec/ruby_uber/v1/time_estimates_spec.rb
128
+ - spec/ruby_uber/v1/user_activity_spec.rb
129
+ - spec/ruby_uber/v1/user_profile_spec.rb
130
+ - spec/ruby_uber_spec.rb
131
+ - spec/spec_helper.rb
132
+ - spec/support/coordinates.rb
133
+ - spec/support/live_specs.rb
134
+ - spec/support/responses.rb
135
+ homepage: ''
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.2.2
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Ruby wrapper for the Uber API
159
+ test_files:
160
+ - spec/ruby_uber/client_spec.rb
161
+ - spec/ruby_uber/utility_spec.rb
162
+ - spec/ruby_uber/v1/base_spec.rb
163
+ - spec/ruby_uber/v1/price_estimates_spec.rb
164
+ - spec/ruby_uber/v1/products_spec.rb
165
+ - spec/ruby_uber/v1/time_estimates_spec.rb
166
+ - spec/ruby_uber/v1/user_activity_spec.rb
167
+ - spec/ruby_uber/v1/user_profile_spec.rb
168
+ - spec/ruby_uber_spec.rb
169
+ - spec/spec_helper.rb
170
+ - spec/support/coordinates.rb
171
+ - spec/support/live_specs.rb
172
+ - spec/support/responses.rb