uber-sdk 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTI3NzU5MWE1ZWI0YWI5OWQxZDAzZDk4MTAzNjczOWViZTU5YmMzMQ==
5
+ data.tar.gz: !binary |-
6
+ ZGEyNzFhNDk1Y2U2NjUzNDBjNWU4YmQ3Yzc5OGQ3MDhmYzk3NjQ3ZA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZGE3OWNjZGYwNDZmNGIzODNkNmFjMTFlZDIzZWEyNDBkNDc1N2ZlYjBlY2Nh
10
+ YjI4MDJjZDMzOWRiYTE0NGRlZjYxNWMyNTAxZDY1NWJkMTlhMzA1ODZkYzA3
11
+ OTEwMzMwMzk1Yjk3NDdkMzExOWY0ZTE3Y2NlZjFmNzkyZWRjOTQ=
12
+ data.tar.gz: !binary |-
13
+ ZmVlMzQ0NWEzZWUxN2E5MzljZWRmOTE5YzI4OThiOGUzMDMyODNiYTJiOWMy
14
+ YTEwYTE3OTMzZjgwMzYzOTkxYzA2ODcyMWM1ZmI5NjNkNmMwNTVjNTE1ZTNl
15
+ MWY1Y2I2Zjk4YzY3MjMzMTkxYWFkYzFkOTg4ZjMwYmVhZmZmNTU=
@@ -0,0 +1,23 @@
1
+ The MIT license
2
+
3
+ Copyright: (c) 2016, Christopher EnyTC
4
+ (c) 2014, Dingding Ye
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,189 @@
1
+ # Uber SDK for Ruby
2
+
3
+ > A Ruby SDK for the Uber API
4
+
5
+ ## Status
6
+
7
+ # [![Build Status](https://img.shields.io/travis/chrisenytc/uber-sdk/master.svg?maxAge=2592000g)](http://travis-ci.org/chrisenytc/uber-sdk) [![Maintenance](https://img.shields.io/maintenance/yes/2016.svg?maxAge=2592000)]() [![Gem](https://img.shields.io/gem/dt/uber-sdk.svg?maxAge=2592000)](http://rubygems.org/gems/uber-sdk) [![Code Climate](https://codeclimate.com/github/chrisenytc/uber-sdk/badges/gpa.svg)](https://codeclimate.com/github/chrisenytc/uber-sdk) [![Code Climate](https://img.shields.io/codeclimate/coverage/github/chrisenytc/uber-sdk.svg?maxAge=2592000)](https://codeclimate.com/github/chrisenytc/uber-sdk) [![Gem](https://img.shields.io/gem/v/uber-sdk.svg?maxAge=2592000)]() [![License](https://img.shields.io/github/license/chrisenytc/uber-sdk.svg?maxAge=2592000)](https://github.com/chrisenytc/uber-sdk/blob/master/LICENSE.txt) [![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social&maxAge=2592000)](https://twitter.com/intent/tweet?text=Awesome%20https://github.com/chrisenytc/uber-sdk%20via%20@chrisenytc)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem "uber-sdk", require: "uber"
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ Or install it yourself as:
24
+
25
+ ```bash
26
+ $ gem install uber-sdk
27
+ ```
28
+
29
+ ## Configuration
30
+
31
+ ```ruby
32
+ client = Uber::Client.new do |config|
33
+ config.server_token = "YOUR_SERVER_TOKEN"
34
+ config.client_id = "YOUR_CLIENT_ID"
35
+ config.client_secret = "YOUR_CLIENT_SECRET"
36
+ end
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ### Request Products
42
+
43
+ ```ruby
44
+ client = Uber::Client.new do |config|
45
+ config.server_token = "YOUR_SERVER_TOKEN"
46
+ end
47
+ client.products(latitude: lat, longitude: lon)
48
+ ```
49
+
50
+ ### Request price estimations
51
+
52
+ ```ruby
53
+ client = Uber::Client.new do |config|
54
+ config.server_token = "YOUR_SERVER_TOKEN"
55
+ end
56
+ client.price_estimations(start_latitude: slat, start_longitude: slon,
57
+ end_latitude: dlat, end_longitude: dlon)
58
+ ```
59
+
60
+ ### Request time estimations
61
+
62
+ ```ruby
63
+ client = Uber::Client.new do |config|
64
+ config.server_token = "YOUR_SERVER_TOKEN"
65
+ end
66
+ client.time_estimations(start_latitude: slat, start_longitude: slon)
67
+ ```
68
+
69
+ ### Retrieve user info
70
+
71
+ ```ruby
72
+ client = Uber::Client.new do |config|
73
+ config.server_token = "YOUR_SERVER_TOKEN"
74
+ config.client_id = "YOUR_CLIENT_ID"
75
+ config.client_secret = "YOUR_CLIENT_SECRET"
76
+ config.bearer_token = "USER_ACCESS_TOKEN"
77
+ end
78
+ client.me
79
+ ```
80
+
81
+ ### Retrieve user activities
82
+
83
+ ```ruby
84
+ client = Uber::Client.new do |config|
85
+ config.server_token = "YOUR_SERVER_TOKEN"
86
+ config.client_id = "YOUR_CLIENT_ID"
87
+ config.client_secret = "YOUR_CLIENT_SECRET"
88
+ config.bearer_token = "USER_ACCESS_TOKEN"
89
+ end
90
+ client.history
91
+ ```
92
+
93
+ ### Request a ride
94
+
95
+ ```ruby
96
+ client = Uber::Client.new do |config|
97
+ config.client_id = "YOUR_CLIENT_ID"
98
+ config.client_secret = "YOUR_CLIENT_SECRET"
99
+ config.bearer_token = "USER_ACCESS_TOKEN"
100
+ end
101
+
102
+ client.trip_request(product_id: product_id, start_latitude: start_lat, start_longitude: start_lng, end_latitude: end_lat, end_longitude: end_lng)
103
+ ```
104
+
105
+ ### Simulate a ride request with surge
106
+
107
+ ```ruby
108
+ client = Uber::Client.new do |config|
109
+ config.client_id = "YOUR_CLIENT_ID"
110
+ config.client_secret = "YOUR_CLIENT_SECRET"
111
+ config.bearer_token = "USER_ACCESS_TOKEN"
112
+ end
113
+
114
+ # Only available in sandbox environment
115
+ # Use this to simulate a surge
116
+ # More info here https://developer.uber.com/docs/sandbox#section-product-types
117
+ client.apply_surge 'product_id', 2.0
118
+
119
+ client.trip_request(product_id: product_id, start_latitude: start_lat, start_longitude: start_lng, end_latitude: end_lat, end_longitude: end_lng, surge_confirmation_id: surge_id)
120
+ ```
121
+
122
+ ### Simulate a ride request with no drivers available
123
+
124
+ ```ruby
125
+ client = Uber::Client.new do |config|
126
+ config.client_id = "YOUR_CLIENT_ID"
127
+ config.client_secret = "YOUR_CLIENT_SECRET"
128
+ config.bearer_token = "USER_ACCESS_TOKEN"
129
+ end
130
+
131
+ # Only available in sandbox environment
132
+ # Use this to simulate a request with no drivers available
133
+ # More info here https://developer.uber.com/docs/sandbox#section-product-types
134
+ client.apply_availability 'product_id', false
135
+
136
+ client.trip_request(product_id: product_id, start_latitude: start_lat, start_longitude: start_lng, end_latitude: end_lat, end_longitude: end_lng)
137
+ ```
138
+
139
+ ### Update the status of a ride request
140
+
141
+ ```ruby
142
+ client = Uber::Client.new do |config|
143
+ config.client_id = "YOUR_CLIENT_ID"
144
+ config.client_secret = "YOUR_CLIENT_SECRET"
145
+ config.bearer_token = "USER_ACCESS_TOKEN"
146
+ end
147
+
148
+ # Only available in sandbox environment
149
+ # Use this to simulate the status change of a ride request
150
+ # More info here https://developer.uber.com/docs/sandbox#section-request
151
+
152
+ client.trip_update('request_id', 'accepted')
153
+ ```
154
+
155
+ ### Retrieve a ride request details
156
+
157
+ ```ruby
158
+ client = Uber::Client.new do |config|
159
+ config.client_id = "YOUR_CLIENT_ID"
160
+ config.client_secret = "YOUR_CLIENT_SECRET"
161
+ config.bearer_token = "USER_ACCESS_TOKEN"
162
+ end
163
+
164
+ client.trip_details 'request_id'
165
+ ```
166
+
167
+ ### Cancel a ride request
168
+
169
+ ```ruby
170
+ client = Uber::Client.new do |config|
171
+ config.client_id = "YOUR_CLIENT_ID"
172
+ config.client_secret = "YOUR_CLIENT_SECRET"
173
+ config.bearer_token = "USER_ACCESS_TOKEN"
174
+ end
175
+
176
+ client.trip_cancel 'request_id'
177
+ ```
178
+
179
+ ## Contributing
180
+
181
+ 1. Fork it ( http://github.com/chrisenytc/uber-sdk/fork )
182
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
183
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
184
+ 4. Push to the branch (`git push origin my-new-feature`)
185
+ 5. Create new Pull Request
186
+
187
+ ## License
188
+
189
+ Check [here](LICENSE.txt)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: "spec"
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ require "uber/base"
3
+ require "uber/utils"
4
+ require "uber/api"
5
+ require "uber/arguments"
6
+ require "uber/error"
7
+ require "uber/token"
8
+ require "uber/client"
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ require "uber/api/products"
3
+ require "uber/api/price_estimates"
4
+ require "uber/api/time_estimates"
5
+ require "uber/api/activities"
6
+ require "uber/api/me"
7
+ require "uber/api/promotions"
8
+ require "uber/api/requests"
9
+
10
+ module Uber
11
+ module API
12
+ include Uber::Utils
13
+ include Uber::API::Products
14
+ include Uber::API::PriceEstimates
15
+ include Uber::API::TimeEstimates
16
+ include Uber::API::Activities
17
+ include Uber::API::Me
18
+ include Uber::API::Promotions
19
+ include Uber::API::Requests
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ require "uber/arguments"
3
+ require "uber/api_request"
4
+ require "uber/models/activity"
5
+
6
+ module Uber
7
+ module API
8
+ module Activities
9
+ def history(*args)
10
+ arguments = Uber::Arguments.new(args)
11
+ perform_with_object(:get, "/v1.2/history", arguments.options, Activity)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ require "uber/arguments"
3
+ require "uber/api_request"
4
+ require "uber/models/user"
5
+
6
+ module Uber
7
+ module API
8
+ module Me
9
+ def me(*args)
10
+ arguments = Uber::Arguments.new(args)
11
+ perform_with_object(:get, "/v1/me", arguments.options, User)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ require "uber/arguments"
3
+ require "uber/api_request"
4
+ require "uber/models/price"
5
+
6
+ module Uber
7
+ module API
8
+ module PriceEstimates
9
+ def price_estimations(*args)
10
+ arguments = Uber::Arguments.new(args)
11
+ perform_with_objects(
12
+ :get,
13
+ "/v1/estimates/price",
14
+ arguments.options,
15
+ Price
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ require "uber/arguments"
3
+ require "uber/api_request"
4
+ require "uber/models/product"
5
+
6
+ module Uber
7
+ module API
8
+ module Products
9
+ def products(*args)
10
+ arguments = Uber::Arguments.new(args)
11
+ perform_with_objects(:get, "/v1/products", arguments.options, Product)
12
+ end
13
+
14
+ def apply_surge(product_id, surge_multiplier)
15
+ perform_with_object(
16
+ :put,
17
+ "/v1/sandbox/products/#{product_id}",
18
+ { surge_multiplier: surge_multiplier },
19
+ Product
20
+ )
21
+ end
22
+
23
+ def apply_availability(product_id, value)
24
+ perform_with_object(
25
+ :put,
26
+ "/v1/sandbox/products/#{product_id}",
27
+ { drivers_available: value },
28
+ Product
29
+ )
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ require "uber/arguments"
3
+ require "uber/api_request"
4
+ require "uber/models/promotion"
5
+
6
+ module Uber
7
+ module API
8
+ module Promotions
9
+ def promotion(*args)
10
+ arguments = Uber::Arguments.new(args)
11
+ perform_with_object(
12
+ :get,
13
+ "/v1/promotions",
14
+ arguments.options,
15
+ Promotion
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+ require "uber/arguments"
3
+ require "uber/api_request"
4
+ require "uber/models/request"
5
+ require "uber/models/estimate"
6
+ require "uber/models/map"
7
+
8
+ module Uber
9
+ module API
10
+ module Requests
11
+ def trip_estimate(*args)
12
+ arguments = Uber::Arguments.new(args)
13
+ perform_with_object(
14
+ :post,
15
+ "v1/requests/estimate",
16
+ arguments.options,
17
+ Estimate
18
+ )
19
+ end
20
+
21
+ def trip_request(*args)
22
+ arguments = Uber::Arguments.new(args)
23
+ perform_with_object(:post, "v1/requests", arguments.options, Request)
24
+ end
25
+
26
+ def trip_current
27
+ perform_with_object(:get, "v1/requests/current", {}, Request)
28
+ end
29
+
30
+ def trip_details(request_id)
31
+ perform_with_object(:get, "v1/requests/#{request_id}", {}, Request)
32
+ end
33
+
34
+ def trip_map(request_id)
35
+ perform_with_object(:get, "v1/requests/#{request_id}/map", {}, Map)
36
+ end
37
+
38
+ def trip_update(request_id, status)
39
+ perform_with_object(
40
+ :put,
41
+ "v1/sandbox/requests/#{request_id}",
42
+ { status: status },
43
+ Request
44
+ )
45
+ end
46
+
47
+ def trip_cancel(request_id)
48
+ perform_with_object(:delete, "v1/requests/#{request_id}", {}, Request)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ require "uber/arguments"
3
+ require "uber/api_request"
4
+ require "uber/models/time"
5
+
6
+ module Uber
7
+ module API
8
+ module TimeEstimates
9
+ def time_estimations(*args)
10
+ arguments = Uber::Arguments.new(args)
11
+ perform_with_objects(
12
+ :get,
13
+ "/v1/estimates/time",
14
+ arguments.options,
15
+ Time
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end