uber-ruby 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2324fd9c73d2168231140fe965422216613fc11d
4
- data.tar.gz: a385f12ffa2b11f1be8f2af001bd1a1851e282d2
3
+ metadata.gz: 93d69c949e47b3a7bb3cb2a6fe8974c0c0cbed74
4
+ data.tar.gz: a08749d07d41d4088f3e43c60f59163050b7bc72
5
5
  SHA512:
6
- metadata.gz: cd50721c71e64aa9b3585a0eaa4e3e3b29b70ad963f94bae2b0003ddda39b7452b6ff455ea80df814a6f9bd520ebec368c7410a666729423f5b55f9e45f461d2
7
- data.tar.gz: 1ff97c56bcaa40777f5db89bc04350557bbe996cf81e405c1b59ff5df7ecbad76026bef798ce9e5ba9d7dd094ec8606ce960f484756605478ad51efc53608781
6
+ metadata.gz: 87eb821c0fd2a65a117b566974622a6a278ea770841979ccaf07ee18e477dcc0ebfb1e0c057d5b45666a9e3bba81974a369dd9a8fc30a0b278fc4a8a33c517ae
7
+ data.tar.gz: 0f2c191980473e7a33c07b2b5f3e4babe97b38a172c95558b5fa5875a56dddd296aea81c3347c8d55a2672f6b4030b86ecfb946cbf4611fa9652edd673599a77
data/README.md CHANGED
@@ -28,7 +28,58 @@ end
28
28
 
29
29
  ## Usage
30
30
 
31
- TODO: Write usage instructions here
31
+ ### Request Products
32
+
33
+ ```ruby
34
+ client = Uber::Client.new do |config|
35
+ config.server_token = "YOUR_SERVER_TOKEN"
36
+ end
37
+ client.products(latitude: lat, longitude: lon)
38
+ ```
39
+
40
+ ### Request price estimations
41
+
42
+ ```ruby
43
+ client = Uber::Client.new do |config|
44
+ config.server_token = "YOUR_SERVER_TOKEN"
45
+ end
46
+ client.price_estimations(start_latitude: slat, start_longitude: slon,
47
+ end_latitude: dlat, end_longitude: dlon)
48
+ ```
49
+
50
+ ### Request time estimations
51
+
52
+ ```ruby
53
+ client = Uber::Client.new do |config|
54
+ config.server_token = "YOUR_SERVER_TOKEN"
55
+ end
56
+ client.time_estimations(start_latitude: slat, start_longitude: slon)
57
+ ```
58
+
59
+ ### Retrieve user info
60
+
61
+ ```ruby
62
+ client = Uber::Client.new do |config|
63
+ config.server_token = "YOUR_SERVER_TOKEN"
64
+ config.client_id = "YOUR_CLIENT_ID"
65
+ config.client_secret = "YOUR_CLIENT_SECRET"
66
+ config.bearer_toekn = "USER_ACCESS_TOKEN"
67
+ end
68
+ client.me
69
+ ```
70
+
71
+ ### Retrieve user activities
72
+
73
+ ```ruby
74
+ client = Uber::Client.new do |config|
75
+ config.server_token = "YOUR_SERVER_TOKEN"
76
+ config.client_id = "YOUR_CLIENT_ID"
77
+ config.client_secret = "YOUR_CLIENT_SECRET"
78
+ config.bearer_toekn = "USER_ACCESS_TOKEN"
79
+ end
80
+ client.history
81
+ ```
82
+
32
83
 
33
84
  ## Contributing
34
85
 
@@ -7,7 +7,7 @@ module Uber
7
7
  module Activities
8
8
  def history(*args)
9
9
  arguments = Uber::Arguments.new(args)
10
- perform_with_object(:get, "/v1/history", arguments.options, Activity)
10
+ perform_with_object(:get, "/v1.1/history", arguments.options, Activity)
11
11
  end
12
12
  end
13
13
  end
data/lib/uber/activity.rb CHANGED
@@ -1,21 +1,25 @@
1
1
  module Uber
2
2
  class Activity < Base
3
- attr_accessor :offset, :limit, :count, :history
3
+ attr_accessor :offset, :limit, :count, :histories
4
4
 
5
- def history=(value)
6
- @history = History.new(value)
5
+ def history=(values)
6
+ @histories = values.map { |value| History.new(value) }
7
7
  end
8
8
  end
9
9
 
10
10
  class History < Base
11
- attr_accessor :uuid, :request_time, :product_id, :status, :distance, :start_time, :end_time, :start_location, :end_location
11
+ attr_accessor :uuid, :request_time, :product_id, :status, :distance, :start_time, :end_time
12
12
 
13
- def start_location=(value)
14
- @start_location = Location.new(value)
13
+ def request_time=(value)
14
+ @request_time = ::Time.at(value)
15
15
  end
16
16
 
17
- def end_location=(value)
18
- @end_location = Location.new(value)
17
+ def start_time=(value)
18
+ @start_time = ::Time.at(value)
19
+ end
20
+
21
+ def end_time=(value)
22
+ @end_time = ::Time.at(value)
19
23
  end
20
24
  end
21
25
 
data/lib/uber/client.rb CHANGED
@@ -22,6 +22,10 @@ module Uber
22
22
  validate_credential_type!
23
23
  end
24
24
 
25
+ def bearer_token=(token)
26
+ @bearer_token = Token.new(access_token: token, token_type: Token::BEARER_TYPE)
27
+ end
28
+
25
29
  def connection_options
26
30
  @connection_options ||= {
27
31
  :builder => middleware,
@@ -120,11 +124,10 @@ module Uber
120
124
  end
121
125
 
122
126
  def request_headers(method, path, params = {}, signature_params = params)
123
- bearer_token_request = params.delete(:bearer_token_request)
124
127
  headers = {}
125
128
  headers[:accept] = '*/*'
126
129
  headers[:content_type] = 'application/x-www-form-urlencoded; charset=UTF-8'
127
- if bearer_token_request
130
+ if bearer_token?
128
131
  headers[:authorization] = bearer_auth_header
129
132
  else
130
133
  headers[:authorization] = server_auth_header
data/lib/uber/token.rb CHANGED
@@ -2,14 +2,14 @@ require 'uber/base'
2
2
 
3
3
  module Uber
4
4
  class Token < Uber::Base
5
- attr_reader :access_token, :token_type
5
+ attr_accessor :access_token, :token_type
6
6
  alias_method :to_s, :access_token
7
7
 
8
8
  BEARER_TYPE = 'bearer'
9
9
 
10
10
  # @return [Boolean]
11
11
  def bearer?
12
- @attrs[:token_type] == BEARER_TYPE
12
+ token_type == BEARER_TYPE
13
13
  end
14
14
  end
15
15
  end
data/lib/uber/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Uber
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 1
5
- PATCH = 1
4
+ MINOR = 2
5
+ PATCH = 0
6
6
 
7
7
  class << self
8
8
  # @return [String]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uber-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dingding Ye
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-15 00:00:00.000000000 Z
11
+ date: 2015-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: 1.3.5
186
186
  requirements: []
187
187
  rubyforge_project:
188
- rubygems_version: 2.4.1
188
+ rubygems_version: 2.4.2
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: The Uber Ruby Gem.