uber-ruby 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YmFhZmY0OGRmMDc0MDNiYTJjYTY0NjA0MjNhNDJhMWM4MjlmMmQzNg==
5
- data.tar.gz: !binary |-
6
- YzU0ZjU2YmQzNjEzNjYxZTJhYTM5NzQ5YjVhNGIzNTBiNWI4MTIxMA==
2
+ SHA1:
3
+ metadata.gz: afcf13093d0201d8e6aa5184b284a855f26444f2
4
+ data.tar.gz: 579ce6c5fa4105bf687252d246183717757379aa
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YzhiYzEzZmYzZDc1M2FlNDliZjg1MjVhNWZiZjYwYmI2OGQ2MTc2YjJhYmEz
10
- ZDQxNjhjMmVmNGI1ZTYwMmQxNGI3MDAzMDdlM2ZhNWUzZGFlMGI3ZjZiMDEx
11
- NzQ1MTUyNWNlODRiY2QxOWIyNmQ3YzY3NDQ5ODBiZTk3OWRiNjI=
12
- data.tar.gz: !binary |-
13
- MGI0Yjg2ZDlhYjkzZTgyOGU2ZjcxMDJhNTZmNTdlNTU5NDJhNzU5ZDYwMDg5
14
- ZGVhMDUyYzE0OTg5ZWZjYTJhMTU4NTM1YjE5ZGNhYWU0YjAyY2I1MTRkYmYz
15
- ZmM2NWI0YzdkYzcxYzM5MTEyNTgxZmY5MTAzZDVhNjNiMDg4ZTk=
6
+ metadata.gz: d952ae18bf90371fa49e9810859bc44fea3d0421de5372c1bf80f455f543fbb3665eb0ae5941065df33c095d52926e85e1d40a33bbea03cd41029239e0639fb3
7
+ data.tar.gz: b1b9d1ec5e85eee3f5ac9ea666cacb130449c1127e7157a9277e66ff3ee050837da574996647787b6fa171e21ef1797023227ea5caaee34a106526a81d90d8ed
data/README.md CHANGED
@@ -327,7 +327,128 @@ trip.duration #=> 0
327
327
  ```
328
328
  More details can be found [here](https://developer.uber.com/docs/drivers/references/api/v1/partners-trips-get).
329
329
 
330
+ ## Deliveries API
331
+ [Deliveries API]() lets you and your customer track the exact location of your delivery from any device.
332
+ > OAuth 2.0 bearer token with the delivery scope
330
333
 
334
+ We provide this under namespace of `client.deliveries`. Besides OAuth, you can get bearer token with `delivery` scope via __client_credentials__ workflow, follow this [guide](https://developer.uber.com/docs/deliveries/guides/authentication#client-credentials-flow).
335
+
336
+ ```ruby
337
+ client = Uber::Client.new do |config|
338
+ config.server_token = "YOUR_SERVER_TOKEN"
339
+ config.client_id = "YOUR_CLIENT_ID"
340
+ config.client_secret = "YOUR_CLIENT_SECRET"
341
+ config.bearer_token = "USER_ACCESS_TOKEN"
342
+ end
343
+ ```
344
+
345
+
346
+ ### List deliveries
347
+ It retrieves a list of all deliveries
348
+
349
+
350
+ ```ruby
351
+ deliveries = client.deliveries.list #=> Array of Uber::Delivery::Delivery
352
+ ```
353
+ More details can be found [here](https://developer.uber.com/docs/deliveries/references/api/v1/deliveries-get)
354
+
355
+ ### Create a delivery
356
+ It allows a delivery to be requested given the delivery information and quote ID
357
+
358
+ ```ruby
359
+ delivery = client.deliveries.add_delivery({quote_id: 'KEBjNGUxNjhlZmNmMD...', .. })
360
+ delivery.quote_id #=> 'KEBjNGUxNjhlZmNmMD...'
361
+ ```
362
+ More details and parameters can be found [here](https://developer.uber.com/docs/deliveries/references/api/v1/deliveries-post)
363
+
364
+ ### Create delivery quote
365
+ Generate a delivery quote, given a pickup and dropoff location. On-demand and scheduled delivery quotes will be returned.
366
+
367
+ ```ruby
368
+ quotes = client.deliveries.add_quote({ "pickup" => { "location" => { ... } },
369
+ "dropoff" => { "location" => { ... } } )
370
+ # returns array of Uber::Delivery::Quote containing all On-demand and scheduled delivery quotes
371
+ quotes.size #=> 4
372
+ quotes[0].fee #=> 5.42
373
+ ```
374
+ More details can be found [here](https://developer.uber.com/docs/deliveries/references/api/v1/deliveries-quote-post)
375
+
376
+ ### Retrieve a delivery information
377
+ Get the status of an ongoing delivery
378
+
379
+ ```ruby
380
+ delivery = client.deliveries.retrieve('8b58bc58-7352-4278-b569-b5d24d8e3f76') #=> Uber::Delivery::Delivery
381
+ delivery.currency_code #=> "USD"
382
+ delivery.delivery_id #=> '8b58bc58-7352-4278-b569-b5d24d8e3f76'
383
+ delivery.fee #=> 5.0
384
+ ```
385
+ More details can be found [here](https://developer.uber.com/docs/deliveries/references/api/v1/deliveries-delivery_id-get)
386
+
387
+ ### Retrieve receipt for a delivery
388
+ ```ruby
389
+ receipt = client.deliveries.receipt('8b58bc58-7352-4278-b569-b5d24d8e3f76') #=> Uber::Delivery::Receipt
390
+ receipt.delivery_id #=> '8b58bc58-7352-4278-b569-b5d24d8e3f76'
391
+ receipt.total_fee #=> 6.17
392
+ receipt.charges #=> hash of charges
393
+ ```
394
+ More details can be found [here](https://developer.uber.com/docs/deliveries/references/api/v1/deliveries-delivery_id-receipt-get)
395
+
396
+ ### Get delivery ratings
397
+ Retrieve the available ratings for a delivery.
398
+
399
+ ```ruby
400
+ ratings = client.deliveries.ratings('8b58bc58-7352-4278-b569-b5d24d8e3f76')
401
+ # Array of Uber::Delivery::Rating
402
+ ratings.size #=> 2
403
+ ratings[0].waypoint #=> 'pickup'
404
+ ```
405
+ More details can be found [here](https://developer.uber.com/docs/deliveries/references/api/v1/deliveries-delivery_id-ratings-get)
406
+
407
+ ### Submit a rating
408
+ Submit a rating for a delivery.
409
+
410
+ ```ruby
411
+ status = client.deliveries.add_rating('8b58bc58-7352-4278-b569-b5d24d8e3f76',
412
+ {"waypoint"=>"dropoff",
413
+ "rating_type"=>"binary",
414
+ "rating_value"=>0,
415
+ "tags"=>["courier_not_on_time", "delivery_in_good_condition"],
416
+ "comments"=>"Courier was not professionally dressed."})
417
+ # Returns the status code, with no content
418
+ status #=> 204
419
+ ```
420
+ More details can be found [here](https://developer.uber.com/docs/deliveries/references/api/v1/deliveries-delivery_id-ratings-post)
421
+
422
+ ### Get rating tags
423
+ Retrieve the available rating tags for a delivery
424
+
425
+ ```ruby
426
+ tags = client.deliveries.rating_tags('8b58bc58-7352-4278-b569-b5d24d8e3f76')
427
+ # Array of Uber::Deliery::RatingTag
428
+ tags.size #=> 2
429
+ tags[0].waypoint #=> 'pickup'
430
+ tags.tags #=> Array of rating tags for delivery
431
+ ```
432
+ More details can be found [here](https://developer.uber.com/docs/deliveries/references/api/v1/deliveries-delivery_id-rating_tags-get)
433
+
434
+ ### Cancel a delivery
435
+ Cancel an existing delivery.
436
+
437
+ ```ruby
438
+ status = client.deliveries.cancel('8b58bc58-7352-4278-b569-b5d24d8e3f76')
439
+ status #=> 204
440
+ ```
441
+ More details can be found [here](https://developer.uber.com/docs/deliveries/references/api/v1/deliveries-delivery_id-cancel-post)
442
+
443
+ ### Get service regions
444
+ Returns all regions where UberRUSH is available.
445
+
446
+ ```ruby
447
+ regions = client.deliveries.regions
448
+ # Array of Uber::Delivery::Region
449
+ regions[0].city #=> 'San Francisco'
450
+ ```
451
+ More details can be found [here](https://developer.uber.com/docs/deliveries/references/api/v1/deliveries-regions-get)
331
452
 
332
453
  ## Contributors
333
454
 
@@ -8,6 +8,7 @@ require 'uber/api/reminders.rb'
8
8
  require 'uber/api/requests'
9
9
  require 'uber/api/places'
10
10
  require 'uber/api/partners'
11
+ require 'uber/api/deliveries'
11
12
 
12
13
  module Uber
13
14
  module API
@@ -0,0 +1,60 @@
1
+ require 'uber/arguments'
2
+ require 'uber/api_request'
3
+ require 'uber/models/delivery'
4
+
5
+ module Uber
6
+ module API
7
+ module Deliveries
8
+ include Uber::Utils
9
+
10
+ def list(*args)
11
+ arguments = Uber::Arguments.new(args)
12
+ perform_with_objects(:get, "/v1/deliveries", arguments.options, Delivery::Delivery, self.client)
13
+ end
14
+
15
+ def add_delivery(*args)
16
+ arguments = Uber::Arguments.new(args)
17
+ perform_with_object(:post, "/v1/deliveries", arguments.options, Delivery::Delivery, self.client)
18
+ end
19
+
20
+ def add_quote(*args)
21
+ arguments = Uber::Arguments.new(args)
22
+ perform_with_objects(:post, "/v1/deliveries/quote", arguments.options, Delivery::Quote, self.client)
23
+ end
24
+
25
+ def retrieve(delivery_id)
26
+ perform_with_object(:get, "/v1/deliveries/#{delivery_id}", {}, Delivery::Delivery, self.client)
27
+ end
28
+
29
+ def receipt(delivery_id)
30
+ delivery_id = delivery_id.is_a?(Delivery::Delivery) ? delivery_id.delivery_id : delivery_id
31
+ perform_with_object(:get, "/v1/deliveries/#{delivery_id}/receipt", {}, Delivery::Receipt, self.client)
32
+ end
33
+
34
+ def ratings(delivery_id)
35
+ delivery_id = delivery_id.is_a?(Delivery::Delivery) ? delivery_id.delivery_id : delivery_id
36
+ perform_with_objects(:get, "/v1/deliveries/#{delivery_id}/ratings", {}, Delivery::Rating, self.client)
37
+ end
38
+
39
+ def add_rating(delivery_id, *args)
40
+ delivery_id = delivery_id.is_a?(Delivery::Delivery) ? delivery_id.delivery_id : delivery_id
41
+ arguments = Uber::Arguments.new(args)
42
+ perform_without_object(:post, "/v1/deliveries/#{delivery_id}/rating", arguments.options, self.client)
43
+ end
44
+
45
+ def rating_tags(delivery_id)
46
+ delivery_id = delivery_id.is_a?(Delivery::Delivery) ? delivery_id.delivery_id : delivery_id
47
+ perform_with_objects(:get, "/v1/deliveries/#{delivery_id}/rating_tags", {}, Delivery::RatingTag, self.client)
48
+ end
49
+
50
+ def cancel(delivery_id)
51
+ delivery_id = delivery_id.is_a?(Delivery::Delivery) ? delivery_id.delivery_id : delivery_id
52
+ perform_without_object(:post, "/v1/deliveries/#{delivery_id}/cancel", {}, self.client)
53
+ end
54
+
55
+ def regions
56
+ perform_with_objects(:get, "/v1/deliveries/regions", {}, Delivery::Region, self.client)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -30,9 +30,14 @@ module Uber
30
30
  # @param klass [Class]
31
31
  # @return [Array]
32
32
  def perform_with_objects(klass)
33
- perform.values.flatten.collect do |element|
33
+ ((perform.values.find { |v| v.is_a?(Array) }) || []).collect do |element|
34
34
  klass.new(element)
35
35
  end
36
36
  end
37
+
38
+ # @return status_code [Integer]
39
+ def perform_without_object
40
+ @client.send(@request_method, @path, @options).status
41
+ end
37
42
  end
38
43
  end
@@ -120,6 +120,10 @@ module Uber
120
120
  def partners
121
121
  @partners ||= Uber::Partner::Client.new self
122
122
  end
123
+
124
+ def deliveries
125
+ @deliveries ||= Uber::Delivery::Client.new self
126
+ end
123
127
  private
124
128
 
125
129
  # Ensures that all credentials set during configuration are
@@ -180,5 +184,14 @@ module Uber
180
184
  end
181
185
  end
182
186
  end
187
+ module Delivery
188
+ class Client
189
+ include Uber::API::Deliveries
190
+ attr_reader :client
191
+ def initialize(client)
192
+ @client = client
193
+ end
194
+ end
195
+ end
183
196
 
184
197
  end
@@ -0,0 +1,6 @@
1
+ require 'uber/models/delivery/delivery'
2
+ require 'uber/models/delivery/quote'
3
+ require 'uber/models/delivery/rating'
4
+ require 'uber/models/delivery/rating_tag'
5
+ require 'uber/models/delivery/receipt'
6
+ require 'uber/models/delivery/region'
@@ -0,0 +1,13 @@
1
+ module Uber
2
+ module Delivery
3
+ class Delivery < Base
4
+ attr_accessor :courier, :created_at, :currency_code, :delivery_id,
5
+ :dropoff, :fee, :items, :order_reference_id, :pickup, :quote_id,
6
+ :status, :tracking_url, :batch
7
+
8
+ def created_at
9
+ @created_at && ::Time.at(@created_at)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ module Uber
2
+ module Delivery
3
+ class Quote < Base
4
+ attr_accessor :quote_id, :estimated_at, :expires_at, :fee, :currency_code,
5
+ :pickup_eta, :dropoff_eta
6
+
7
+ def estimated_at
8
+ @estimated_at && ::Time.at(@estimated_at)
9
+ end
10
+
11
+ def expires_at
12
+ @expires_at && ::Time.at(@expires_at)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ module Uber
2
+ module Delivery
3
+ class Rating < Base
4
+ attr_accessor :waypoint, :rating_type, :rating_value, :tags, :comments
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Uber
2
+ module Delivery
3
+ class RatingTag < Base
4
+ attr_accessor :waypoint, :tags
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Uber
2
+ module Delivery
3
+ class Receipt < Base
4
+ attr_accessor :charges, :charge_adjustments, :delivery_id, :currency_code, :total_fee
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Uber
2
+ module Delivery
3
+ class Region < Base
4
+ attr_accessor :city, :country, :type, :features
5
+ end
6
+ end
7
+ end
@@ -20,5 +20,13 @@ module Uber
20
20
  request = Uber::ApiRequest.new(client, request_method, path, options)
21
21
  request.perform_with_objects(klass)
22
22
  end
23
+
24
+ # @param request_method [Symbol]
25
+ # @param path [String]
26
+ # @param options [Hash]
27
+ def perform_without_object(request_method, path, options, client=self)
28
+ request = Uber::ApiRequest.new(client, request_method, path, options)
29
+ request.perform_without_object
30
+ end
23
31
  end
24
32
  end
@@ -1,7 +1,7 @@
1
1
  module Uber
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 9
4
+ MINOR = 10
5
5
  PATCH = 0
6
6
 
7
7
  class << self
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rspec", "~> 3.3.0"
28
28
 
29
29
  spec.add_dependency 'faraday', '~> 0.9.0'
30
- spec.add_dependency 'json', '~> 1.8'
30
+ spec.add_dependency 'json'
31
31
  end
metadata CHANGED
@@ -1,99 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uber-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.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: 2017-04-23 00:00:00.000000000 Z
11
+ date: 2017-11-03 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
- version: '1.8'
89
+ version: '0'
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
- version: '1.8'
96
+ version: '0'
97
97
  description: A Ruby interface to the Uber API.
98
98
  email:
99
99
  - yedingding@gmail.com
@@ -107,6 +107,7 @@ files:
107
107
  - lib/uber.rb
108
108
  - lib/uber/api.rb
109
109
  - lib/uber/api/activities.rb
110
+ - lib/uber/api/deliveries.rb
110
111
  - lib/uber/api/me.rb
111
112
  - lib/uber/api/partners.rb
112
113
  - lib/uber/api/places.rb
@@ -122,6 +123,13 @@ files:
122
123
  - lib/uber/client.rb
123
124
  - lib/uber/error.rb
124
125
  - lib/uber/models/activity.rb
126
+ - lib/uber/models/delivery.rb
127
+ - lib/uber/models/delivery/delivery.rb
128
+ - lib/uber/models/delivery/quote.rb
129
+ - lib/uber/models/delivery/rating.rb
130
+ - lib/uber/models/delivery/rating_tag.rb
131
+ - lib/uber/models/delivery/receipt.rb
132
+ - lib/uber/models/delivery/region.rb
125
133
  - lib/uber/models/estimate.rb
126
134
  - lib/uber/models/map.rb
127
135
  - lib/uber/models/partner.rb
@@ -153,17 +161,17 @@ require_paths:
153
161
  - lib
154
162
  required_ruby_version: !ruby/object:Gem::Requirement
155
163
  requirements:
156
- - - ! '>='
164
+ - - ">="
157
165
  - !ruby/object:Gem::Version
158
166
  version: '0'
159
167
  required_rubygems_version: !ruby/object:Gem::Requirement
160
168
  requirements:
161
- - - ! '>='
169
+ - - ">="
162
170
  - !ruby/object:Gem::Version
163
171
  version: 1.3.5
164
172
  requirements: []
165
173
  rubyforge_project:
166
- rubygems_version: 2.4.8
174
+ rubygems_version: 2.6.13
167
175
  signing_key:
168
176
  specification_version: 4
169
177
  summary: The Uber Ruby Gem.