uber-ruby 0.1.1 → 0.2.0
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 +4 -4
- data/README.md +52 -1
- data/lib/uber/activities.rb +1 -1
- data/lib/uber/activity.rb +12 -8
- data/lib/uber/client.rb +5 -2
- data/lib/uber/token.rb +2 -2
- data/lib/uber/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93d69c949e47b3a7bb3cb2a6fe8974c0c0cbed74
|
4
|
+
data.tar.gz: a08749d07d41d4088f3e43c60f59163050b7bc72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
|
data/lib/uber/activities.rb
CHANGED
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, :
|
3
|
+
attr_accessor :offset, :limit, :count, :histories
|
4
4
|
|
5
|
-
def history=(
|
6
|
-
@
|
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
|
11
|
+
attr_accessor :uuid, :request_time, :product_id, :status, :distance, :start_time, :end_time
|
12
12
|
|
13
|
-
def
|
14
|
-
@
|
13
|
+
def request_time=(value)
|
14
|
+
@request_time = ::Time.at(value)
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
@
|
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
|
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
|
-
|
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
|
-
|
12
|
+
token_type == BEARER_TYPE
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/uber/version.rb
CHANGED
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.
|
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:
|
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.
|
188
|
+
rubygems_version: 2.4.2
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: The Uber Ruby Gem.
|