uber_api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +2 -0
- data/lib/uber_api/client.rb +48 -0
- data/lib/uber_api/version.rb +3 -0
- data/lib/uber_api.rb +8 -0
- data/uber_api.gemspec +23 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 066aeb2e9f0760d4698f3347c70d14edbb97532a
|
4
|
+
data.tar.gz: af4cdb2580f030ece34d66642d69ea6cf1de9733
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f9ba16416ff2a7bf3aadfbd90acd8eaac17d139627ad308ec9cae83bb5ac52693b3dacbd4c31916da2bdc0f9515cc9e67ea324a7fd2a889147169c0f5b348c73
|
7
|
+
data.tar.gz: 3cde26220cbd313b0e7fdfa23435edc95ed92a30034bd408610879da7bd0d0e0677f102aacf4cabaf2255e14d9fad34617fc42bcc2d2ecd16d87c7de247acda0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 abhijeetkalyan
|
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,32 @@
|
|
1
|
+
# UberApi
|
2
|
+
Not completely functional yet! Still integrating OAuth for user endpoints along with modularization + documentation of code to follow
|
3
|
+
tomorrow.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'uber_api'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install uber_api
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
TODO: Write usage instructions here
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it ( https://github.com/[my-github-username]/uber_api/fork )
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require "faraday_middleware"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Uber
|
6
|
+
class Client
|
7
|
+
API_LOCATION = 'https://api.uber.com'
|
8
|
+
API_VERSION = '/v1'
|
9
|
+
attr_accessor :client_id , :server_token , :secret , :bearer_token
|
10
|
+
|
11
|
+
def initialize(params={})
|
12
|
+
params.each { |k,v| instance_variable_set("@#{k}", v) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(endpoint, params)
|
16
|
+
conn = Faraday.new API_LOCATION do |conn|
|
17
|
+
conn.request :json
|
18
|
+
conn.response :json, :content_type => /\bjson$/
|
19
|
+
conn.authorization :Token, @server_token
|
20
|
+
conn.adapter Faraday.default_adapter
|
21
|
+
end
|
22
|
+
response = conn.get API_VERSION.concat(endpoint) , params
|
23
|
+
response_hash = JSON.parse(response.body.to_json)
|
24
|
+
end
|
25
|
+
|
26
|
+
def products(latitude, longitude)
|
27
|
+
params = {:latitude => latitude.to_s, :longitude => longitude.to_s}
|
28
|
+
response = get("/products", params)
|
29
|
+
response["products"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def prices(start_latitude, start_longitude, end_latitude, end_longitude)
|
33
|
+
params = {:start_latitude => start_latitude.to_s, :start_longitude => start_longitude.to_s,
|
34
|
+
:end_latitude => end_latitude.to_s, :end_longitude => end_longitude.to_s}
|
35
|
+
response = get("/estimates/price", params)
|
36
|
+
response["prices"]
|
37
|
+
end
|
38
|
+
|
39
|
+
def times(start_latitude, start_longitude, customer_uuid, product_id)
|
40
|
+
params = {
|
41
|
+
:start_longitude => start_longitude.to_s, :start_longitude => start_longitude.to_s,
|
42
|
+
:customer_uuid => customer_uuid.to_s, :product_id => product_id.to_s
|
43
|
+
}
|
44
|
+
response = get("/estimates/time", params)
|
45
|
+
response["times"]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/uber_api.rb
ADDED
data/uber_api.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'uber_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "uber_api"
|
8
|
+
spec.version = UberApi::VERSION
|
9
|
+
spec.authors = ["Abhijeet Kalyan"]
|
10
|
+
spec.email = ["abhijeetkalyan@gmail.com"]
|
11
|
+
spec.summary = %q{Ruby client for the Uber API.}
|
12
|
+
spec.description = %q{Currently doesn't support OAuth. Should be added within the next day or two}
|
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_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uber_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Abhijeet Kalyan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Currently doesn't support OAuth. Should be added within the next day
|
42
|
+
or two
|
43
|
+
email:
|
44
|
+
- abhijeetkalyan@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/uber_api.rb
|
55
|
+
- lib/uber_api/client.rb
|
56
|
+
- lib/uber_api/version.rb
|
57
|
+
- uber_api.gemspec
|
58
|
+
homepage: ''
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.0.14
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Ruby client for the Uber API.
|
82
|
+
test_files: []
|