uber-ruby 0.7.0 → 0.8.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: c4c9bf4cb4b8f0ced763b3702bb943a90ae36327
4
- data.tar.gz: 2e123aa2989f454b0f0e3e88a908e11e38aa7c95
3
+ metadata.gz: 8060589837d67de3722ccf0abed7a4d7746b71f6
4
+ data.tar.gz: 1c687e372cfcf81e0c672c170433b89911489286
5
5
  SHA512:
6
- metadata.gz: c9ec68f21a3ebb754e11df5d7559d222dfcb41552578697583110299dfa1c1130c45bf66afc23ca40bb8d6780fbd5babcc04f543414d0267d8a1a814dadd7d82
7
- data.tar.gz: d3c849532fe23d3f62ac85493fb4f92f1c6747c7aee8c88afe89f8162f316419960ffd376b643d7c089c659ca103e832e3d2b24002c2a0cc4001384c52dae9c0
6
+ metadata.gz: 4fe8b29d05132829972d2a6264e070467ef6dd3a6af3bd864e4aa9af6057ee36eaf941c991d013a3a8fed2bb1a969de4c1071bcf2bcfd2be0e03cf99de546a4f
7
+ data.tar.gz: 85da92e48dcb0fa4b60de2b1d4b3b6ed2307dc6d2b81a2422646733266f4678433b15f85cb29c674ae9ff2567477c38ee48ca4074f24be4181228f0dd8f44a54
data/README.md CHANGED
@@ -258,6 +258,60 @@ reminder.delete_reminder 'rem1'
258
258
  #=> Uber::Reminder
259
259
  ```
260
260
 
261
+ ## Drivers API
262
+ [Drivers API](https://developer.uber.com/docs/drivers/introduction) lets you build services and solutions that make the driver experience more productive and rewarding. With the driver's permission, you can use trip data, earnings, ratings and more to shape the future of the on-demand economy.
263
+
264
+ We provide this under namespace of `client.partners`
265
+
266
+ ### Driver details
267
+ It returns the profile of the authenticated driver.
268
+ > OAuth 2.0 bearer token with a partner.accounts scope.
269
+
270
+ ```ruby
271
+ driver = client.partners.me
272
+ driver.first_name #=> 'John'
273
+ driver.last_name #=> 'Driver'
274
+ driver.promo_code #=> 'join_john_on_uber'
275
+ ```
276
+ More details can be found [here](https://developer.uber.com/docs/drivers/references/api/v1/partners-me-get).
277
+
278
+ ### Earnings details
279
+ It returns an array of payments for the given driver. Payments are available at this endpoint in near real-time.
280
+ > OAuth 2.0 bearer token with scope partner.payments
281
+
282
+ ```ruby
283
+ earnings = client.partners.payments
284
+ # client.partners.earnings is also supported
285
+ earnings.count #=> 5
286
+ earnings.payments #=> Array of Uber::Partner::Payment
287
+ payment = earnings.payments.first
288
+ payment.category #=> 'fare'
289
+ payment.cash_collected #=> 7.63
290
+ payment.currency_code #=> 'USD'
291
+ payment.event_time #=> 2016-11-12 10:29:28 UTC
292
+
293
+ # Using params:
294
+ earnings = client.partners.payments(:offset => 1, :limit => 2)
295
+ ```
296
+ More details can be found [here](https://developer.uber.com/docs/drivers/references/api/v1/partners-payments-get).
297
+
298
+ ### Trips details
299
+ It returns an array of trips for the authenticated driver.
300
+ > OAuth 2.0 bearer token with the partner.trips.
301
+
302
+ ```ruby
303
+ trips = client.partners.trips
304
+ trips.count #=> 1
305
+ trips.offset #=> 0
306
+ trips.trips #=> Array of Uber::Partner::Trip
307
+ trip = trips.trips.first
308
+ trip.distance #=> 0
309
+ trip.status #=> 'driver_canceled'
310
+ trip.duration #=> 0
311
+ ```
312
+ More details can be found [here](https://developer.uber.com/docs/drivers/references/api/v1/partners-trips-get).
313
+
314
+
261
315
 
262
316
  ## Contributors
263
317
 
@@ -266,7 +320,7 @@ reminder.delete_reminder 'rem1'
266
320
 
267
321
  ## Contributing
268
322
 
269
- 1. Fork it ( http://github.com/<my-github-username>/uber-ruby/fork )
323
+ 1. Fork it ( http://github.com/sishen/uber-ruby/fork )
270
324
  2. Create your feature branch (`git checkout -b my-new-feature`)
271
325
  3. Commit your changes (`git commit -am 'Add some feature'`)
272
326
  4. Push to the branch (`git push origin my-new-feature`)
@@ -7,6 +7,7 @@ require 'uber/api/promotions'
7
7
  require 'uber/api/reminders.rb'
8
8
  require 'uber/api/requests'
9
9
  require 'uber/api/places'
10
+ require 'uber/api/partners'
10
11
 
11
12
  module Uber
12
13
  module API
@@ -0,0 +1,26 @@
1
+ require 'uber/arguments'
2
+ require 'uber/api_request'
3
+ require 'uber/models/partner'
4
+
5
+ module Uber
6
+ module API
7
+ module Partners
8
+ include Uber::Utils
9
+ def me
10
+ perform_with_object(:get, "v1/partners/me", {}, Uber::Partner::Partner, self.client)
11
+ end
12
+
13
+ def payments(*args)
14
+ arguments = Uber::Arguments.new(args)
15
+ perform_with_object(:get, "/v1/partners/payments", arguments.options, Uber::Partner::PaymentActivity, self.client)
16
+ end
17
+
18
+ def trips(*args)
19
+ arguments = Uber::Arguments.new(args)
20
+ perform_with_object(:get, "/v1/partners/trips", arguments.options, Uber::Partner::TripActivity, self.client)
21
+ end
22
+
23
+ alias_method :earnings, :payments
24
+ end
25
+ end
26
+ end
@@ -117,6 +117,9 @@ module Uber
117
117
  credentials.values.all?
118
118
  end
119
119
 
120
+ def partners
121
+ @partners ||= Uber::Partner::Client.new self
122
+ end
120
123
  private
121
124
 
122
125
  # Ensures that all credentials set during configuration are
@@ -167,4 +170,15 @@ module Uber
167
170
  "Token #{@server_token}"
168
171
  end
169
172
  end
173
+
174
+ module Partner
175
+ class Client
176
+ include Uber::API::Partners
177
+ attr_reader :client
178
+ def initialize(client)
179
+ @client = client
180
+ end
181
+ end
182
+ end
183
+
170
184
  end
@@ -0,0 +1,3 @@
1
+ require 'uber/models/partner/partner'
2
+ require 'uber/models/partner/payment'
3
+ require 'uber/models/partner/trip'
@@ -0,0 +1,8 @@
1
+ module Uber
2
+ module Partner
3
+ class Partner < Base
4
+ attr_accessor :driver_id, :first_name, :last_name, :phone_number, :email, :picture,
5
+ :rating, :promo_code, :activation_status
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ module Uber
2
+ module Partner
3
+
4
+ class PaymentActivity < Base
5
+ attr_accessor :offset, :limit, :count, :payments
6
+
7
+ def payments=(values)
8
+ @payments = values.map { |value| Uber::Partner::Payment.new value }
9
+ end
10
+ end
11
+
12
+ class Payment < Base
13
+ attr_accessor :category, :breakdown, :rider_fees, :event_time, :trip_id, :cash_collected,
14
+ :amount, :driver_id, :partner_id, :currency_code
15
+
16
+ def event_time
17
+ ::Time.at @event_time
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,29 @@
1
+ module Uber
2
+ module Partner
3
+
4
+ class TripActivity < Base
5
+ attr_accessor :count, :limit, :offset, :trips
6
+
7
+ def trips=(values)
8
+ @trips = values.map { |value| Uber::Partner::Trip.new value }
9
+ end
10
+ end
11
+
12
+ class Trip < Base
13
+ attr_accessor :dropoff, :vehicle_id, :distance, :start_city, :status_changes, :pickup,
14
+ :driver_id, :status, :duration, :trip_id
15
+
16
+ def status_changes=(values)
17
+ @status_changes = values.map { |value| Uber::Partner::StatusChange.new value }
18
+ end
19
+ end
20
+
21
+ class StatusChange < Base
22
+ attr_accessor :status, :timestamp
23
+
24
+ def time
25
+ ::Time.at @timestamp if @timestamp
26
+ end
27
+ end
28
+ end
29
+ end
@@ -7,8 +7,8 @@ module Uber
7
7
  # @param path [String]
8
8
  # @param options [Hash]
9
9
  # @param klass [Class]
10
- def perform_with_object(request_method, path, options, klass)
11
- request = Uber::ApiRequest.new(self, request_method, path, options)
10
+ def perform_with_object(request_method, path, options, klass, client=self)
11
+ request = Uber::ApiRequest.new(client, request_method, path, options)
12
12
  request.perform_with_object(klass)
13
13
  end
14
14
 
@@ -16,8 +16,8 @@ module Uber
16
16
  # @param path [String]
17
17
  # @param options [Hash]
18
18
  # @param klass [Class]
19
- def perform_with_objects(request_method, path, options, klass)
20
- request = Uber::ApiRequest.new(self, request_method, path, options)
19
+ def perform_with_objects(request_method, path, options, klass, client=self)
20
+ request = Uber::ApiRequest.new(client, request_method, path, options)
21
21
  request.perform_with_objects(klass)
22
22
  end
23
23
  end
@@ -1,7 +1,7 @@
1
1
  module Uber
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 7
4
+ MINOR = 8
5
5
  PATCH = 0
6
6
 
7
7
  class << self
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uber-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.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: 2016-09-13 00:00:00.000000000 Z
11
+ date: 2017-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: webmock
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.21.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.21.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 3.3.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 3.3.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: faraday
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.9.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.9.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: json
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.8'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.8'
97
97
  description: A Ruby interface to the Uber API.
@@ -108,6 +108,7 @@ files:
108
108
  - lib/uber/api.rb
109
109
  - lib/uber/api/activities.rb
110
110
  - lib/uber/api/me.rb
111
+ - lib/uber/api/partners.rb
111
112
  - lib/uber/api/places.rb
112
113
  - lib/uber/api/price_estimates.rb
113
114
  - lib/uber/api/products.rb
@@ -123,6 +124,10 @@ files:
123
124
  - lib/uber/models/activity.rb
124
125
  - lib/uber/models/estimate.rb
125
126
  - lib/uber/models/map.rb
127
+ - lib/uber/models/partner.rb
128
+ - lib/uber/models/partner/partner.rb
129
+ - lib/uber/models/partner/payment.rb
130
+ - lib/uber/models/partner/trip.rb
126
131
  - lib/uber/models/place.rb
127
132
  - lib/uber/models/price.rb
128
133
  - lib/uber/models/product.rb
@@ -147,17 +152,17 @@ require_paths:
147
152
  - lib
148
153
  required_ruby_version: !ruby/object:Gem::Requirement
149
154
  requirements:
150
- - - '>='
155
+ - - ">="
151
156
  - !ruby/object:Gem::Version
152
157
  version: '0'
153
158
  required_rubygems_version: !ruby/object:Gem::Requirement
154
159
  requirements:
155
- - - '>='
160
+ - - ">="
156
161
  - !ruby/object:Gem::Version
157
162
  version: 1.3.5
158
163
  requirements: []
159
164
  rubyforge_project:
160
- rubygems_version: 2.4.2
165
+ rubygems_version: 2.4.5.2
161
166
  signing_key:
162
167
  specification_version: 4
163
168
  summary: The Uber Ruby Gem.