uber_api 0.0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 066aeb2e9f0760d4698f3347c70d14edbb97532a
4
- data.tar.gz: af4cdb2580f030ece34d66642d69ea6cf1de9733
3
+ metadata.gz: f7637e27b2bb492fe35a9755020c7b9bd5739c78
4
+ data.tar.gz: bca73afa0f5e9cb3da91bd48fd138304ebf74675
5
5
  SHA512:
6
- metadata.gz: f9ba16416ff2a7bf3aadfbd90acd8eaac17d139627ad308ec9cae83bb5ac52693b3dacbd4c31916da2bdc0f9515cc9e67ea324a7fd2a889147169c0f5b348c73
7
- data.tar.gz: 3cde26220cbd313b0e7fdfa23435edc95ed92a30034bd408610879da7bd0d0e0677f102aacf4cabaf2255e14d9fad34617fc42bcc2d2ecd16d87c7de247acda0
6
+ metadata.gz: 461ebb7714cdddca8ea58874674daa4ff7c17d53adc5c412e9a82ea4fa37d34aa497733f25a930bc1159f5d12e00e0431067211507165a85eb44a2633ceee42d
7
+ data.tar.gz: a588c111f94f810d1c4d694d9834a703da536ebe500491a26e677e3c1f126d25182ac3208dba66239eba8ba6db4f649a462eaace171781b566f0d59d077a9ca3
@@ -1,3 +1,9 @@
1
+ =begin
2
+ Wrapper for the Uber API. API endpoints have been written as methods
3
+ within the Client class. Currently supports all API endpoints in v1,
4
+ please read the oauth/oauth_example.rb for how to generate bearer tokens
5
+ for OAuth endpoints(profile and history)
6
+ =end
1
7
  require "faraday"
2
8
  require "faraday_middleware"
3
9
  require "json"
@@ -6,20 +12,24 @@ module Uber
6
12
  class Client
7
13
  API_LOCATION = 'https://api.uber.com'
8
14
  API_VERSION = '/v1'
9
- attr_accessor :client_id , :server_token , :secret , :bearer_token
15
+ attr_accessor :server_token ,:bearer_token
10
16
 
11
17
  def initialize(params={})
12
18
  params.each { |k,v| instance_variable_set("@#{k}", v) }
13
19
  end
14
20
 
15
- def get(endpoint, params)
16
- conn = Faraday.new API_LOCATION do |conn|
21
+ def conn
22
+ @conn = Faraday.new API_LOCATION do |conn|
17
23
  conn.request :json
18
24
  conn.response :json, :content_type => /\bjson$/
19
- conn.authorization :Token, @server_token
25
+ if !@bearer_token then conn.authorization :Token, @server_token else conn.authorization :Bearer , @bearer_token end
20
26
  conn.adapter Faraday.default_adapter
21
27
  end
22
- response = conn.get API_VERSION.concat(endpoint) , params
28
+ end
29
+
30
+ def get(endpoint, params)
31
+ query_string = API_VERSION + endpoint
32
+ response = conn.get query_string, params
23
33
  response_hash = JSON.parse(response.body.to_json)
24
34
  end
25
35
 
@@ -37,12 +47,20 @@ module Uber
37
47
  end
38
48
 
39
49
  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
- }
50
+ params = {:start_latitude => start_latitude.to_s, :start_longitude => start_longitude.to_s,
51
+ :customer_uuid => customer_uuid.to_s, :product_id => product_id.to_s}
44
52
  response = get("/estimates/time", params)
45
53
  response["times"]
54
+ end
55
+
56
+ def history(offset, limit)
57
+ params = {:offset => offset.to_s, :limit => limit.to_s}
58
+ response = get("/history", params)
59
+ end
60
+
61
+ def profile
62
+ params = {}
63
+ response = get("/me", params)
46
64
  end
47
65
  end
48
66
  end
@@ -1,3 +1,3 @@
1
1
  module UberApi
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.1"
3
3
  end
data/uber_api.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Abhijeet Kalyan"]
10
10
  spec.email = ["abhijeetkalyan@gmail.com"]
11
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}
12
+ spec.description = %q{Ruby client for the Uber API. Supports all endpoints, but please read the oauth_example on Github for how to generate bearer tokens}
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uber_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhijeet Kalyan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-26 00:00:00.000000000 Z
11
+ date: 2014-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,8 +38,8 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
- description: Currently doesn't support OAuth. Should be added within the next day
42
- or two
41
+ description: Ruby client for the Uber API. Supports all endpoints, but please read
42
+ the oauth_example on Github for how to generate bearer tokens
43
43
  email:
44
44
  - abhijeetkalyan@gmail.com
45
45
  executables: []