postmates 0.1.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.
@@ -0,0 +1,39 @@
1
+ {
2
+ "status": "pending",
3
+ "dropoff": {
4
+ "phone_number": "415-555-1234",
5
+ "notes": "Optional note to ring the bell",
6
+ "location": {
7
+ "lat": 37.7930812,
8
+ "lng": -122.395944
9
+ },
10
+ "name": "Alice, Optional Dropoff Business Name, Inc.",
11
+ "address": "101 Market Street"
12
+ },
13
+ "updated": "2015-01-01T18:24:54Z",
14
+ "fee": 1350,
15
+ "quote_id": "dqt_K9LFfpSZCdAJsk",
16
+ "complete": false,
17
+ "courier": null,
18
+ "created": "2015-01-01T18:24:54Z",
19
+ "kind": "delivery",
20
+ "manifest": {
21
+ "description": "a box of kittens"
22
+ },
23
+ "currency": "usd",
24
+ "pickup": {
25
+ "phone_number": "555-555-5555",
26
+ "notes": "Optional note that this is Invoice #123",
27
+ "location": {
28
+ "lat": 37.7811372,
29
+ "lng": -122.4123037
30
+ },
31
+ "name": "The Warehouse, Optional Pickup Business Name, Inc.",
32
+ "address": "20 McAllister Street"
33
+ },
34
+ "dropoff_deadline": "2015-01-01T19:24:54Z",
35
+ "live_mode": false,
36
+ "pickup_eta": null,
37
+ "dropoff_eta": null,
38
+ "id": "del_K9LFxVVbl5sac-"
39
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "kind": "error",
3
+ "code": "forbidden",
4
+ "message": ""
5
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "kind": "error",
3
+ "code": "invalid_params",
4
+ "params": {
5
+ "dropoff_name": "This field is required.",
6
+ "pickup_phone_number": "This field is required.",
7
+ "dropoff_address": "This field is required.",
8
+ "pickup_name": "This field is required.",
9
+ "manifest": "This field is required.",
10
+ "pickup_address": "This field is required.",
11
+ "dropoff_phone_number": "This field is required."
12
+ },
13
+ "message": "The parameters of your request were invalid."
14
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "kind": "error",
3
+ "code": "not_found",
4
+ "message": "The requested endpoint could not be found."
5
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "kind": "delivery_quote",
3
+ "fee": 1350,
4
+ "created": "2015-01-01T18:23:43Z",
5
+ "expires": "2015-01-01T18:28:43Z",
6
+ "currency": "usd",
7
+ "duration": 60,
8
+ "dropoff_eta": "2015-01-01T19:28:43Z",
9
+ "id": "dqt_K9LFfpSZCdAJsk"
10
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "pickup_address": "20 McAllister St, San Francisco, CA",
3
+ "dropoff_address": "101 Market St, San Francisco, CA"
4
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "kind": "error",
3
+ "code": "server_error",
4
+ "message": "We had a problem processing the request."
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "kind": "error",
3
+ "code": "service_unavailable",
4
+ "message": "Try again later."
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "kind": "error",
3
+ "code": "unauthorized",
4
+ "message": "Authentication was incorrect."
5
+ }
@@ -0,0 +1,19 @@
1
+ describe Postmates do
2
+ describe '.new' do
3
+ it 'returns a Postmates::Client' do
4
+ expect(Postmates.new).to be_a Postmates::Client
5
+ end
6
+ end
7
+
8
+ describe '.configure' do
9
+ it 'sets the api_key and customer_id' do
10
+ Postmates.configure do |config|
11
+ config.api_key = '1234'
12
+ config.customer_id = 'abcd'
13
+ end
14
+
15
+ expect(Postmates.api_key).to eq '1234'
16
+ expect(Postmates.customer_id).to eq 'abcd'
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,57 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter]
6
+
7
+ SimpleCov.start
8
+
9
+ require 'json'
10
+ require 'rspec'
11
+ require 'webmock/rspec'
12
+ require 'postmates'
13
+
14
+ RSpec.configure do |config|
15
+ config.expect_with(:rspec) { |c| c.syntax = :expect }
16
+ end
17
+
18
+ WebMock.disable_net_connect!(allow: 'coveralls.io')
19
+
20
+ def postmates_test_client
21
+ Postmates.new.tap do |client|
22
+ client.configure do |config|
23
+ config.api_key = '1234'
24
+ config.customer_id = 'abcd'
25
+ end
26
+ end
27
+ end
28
+
29
+ HTTP_REQUEST_METHODS = [:get, :post]
30
+
31
+ HTTP_REQUEST_METHODS.each do |verb|
32
+ Object.send(:define_method, "stub_#{verb}") do |path, options = {}|
33
+ file = options.delete(:returns)
34
+ code = options.delete(:response_code) || 200
35
+ endpoint = 'https://1234:@api.postmates.com/v1/' + path
36
+ headers = Postmates::Configuration::DEFAULT_HEADERS
37
+ stub_request(verb, endpoint)
38
+ .with(headers: headers, body: options)
39
+ .to_return(body: fixture(file), status: code)
40
+ end
41
+ end
42
+
43
+ def fixture_path
44
+ File.expand_path('../fixtures', __FILE__)
45
+ end
46
+
47
+ def fixture(file)
48
+ File.new(fixture_path + '/' + file)
49
+ end
50
+
51
+ def payload(params_file)
52
+ JSON.parse(IO.read(fixture(params_file)))
53
+ end
54
+
55
+ def path_to(endpoint)
56
+ "customers/#{customer_id}/#{endpoint}"
57
+ end
metadata ADDED
@@ -0,0 +1,218 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: postmates
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rahul Horé
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "<"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.10'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: '0.7'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "<"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.10'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0.7'
33
+ - !ruby/object:Gem::Dependency
34
+ name: faraday_middleware
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "<"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.10'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0.8'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "<"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.10'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0.8'
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.7'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.7'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rake
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '10.0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '10.0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: rspec
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '3.0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '3.0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: webmock
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '1.0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '1.0'
109
+ - !ruby/object:Gem::Dependency
110
+ name: simplecov
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: 0.9.0
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: 0.9.0
123
+ - !ruby/object:Gem::Dependency
124
+ name: coveralls
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: 0.7.0
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: 0.7.0
137
+ description: Ruby client for the Postmates API
138
+ email:
139
+ - hore.rahul@gmail.com
140
+ executables: []
141
+ extensions: []
142
+ extra_rdoc_files: []
143
+ files:
144
+ - ".gitignore"
145
+ - ".rspec"
146
+ - ".travis.yml"
147
+ - Gemfile
148
+ - LICENSE.txt
149
+ - README.md
150
+ - Rakefile
151
+ - lib/faraday/raise_http_exception.rb
152
+ - lib/postmates.rb
153
+ - lib/postmates/client.rb
154
+ - lib/postmates/configuration.rb
155
+ - lib/postmates/connection.rb
156
+ - lib/postmates/delivery.rb
157
+ - lib/postmates/error.rb
158
+ - lib/postmates/quote.rb
159
+ - lib/postmates/request.rb
160
+ - lib/postmates/response.rb
161
+ - lib/postmates/utils.rb
162
+ - lib/postmates/version.rb
163
+ - postmates.gemspec
164
+ - spec/client_spec.rb
165
+ - spec/error_spec.rb
166
+ - spec/fixtures/create_params.json
167
+ - spec/fixtures/deliveries.json
168
+ - spec/fixtures/delivery.json
169
+ - spec/fixtures/forbidden.json
170
+ - spec/fixtures/invalid_params.json
171
+ - spec/fixtures/not_found.json
172
+ - spec/fixtures/quote.json
173
+ - spec/fixtures/quote_params.json
174
+ - spec/fixtures/server_error.json
175
+ - spec/fixtures/service_unavailable.json
176
+ - spec/fixtures/unauthorized.json
177
+ - spec/postmates_spec.rb
178
+ - spec/spec_helper.rb
179
+ homepage: https://github.com/O-I/postmates
180
+ licenses:
181
+ - MIT
182
+ metadata: {}
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: 1.9.3
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ requirements: []
198
+ rubyforge_project:
199
+ rubygems_version: 2.4.3
200
+ signing_key:
201
+ specification_version: 4
202
+ summary: Ruby wrapper for the Postmates API
203
+ test_files:
204
+ - spec/client_spec.rb
205
+ - spec/error_spec.rb
206
+ - spec/fixtures/create_params.json
207
+ - spec/fixtures/deliveries.json
208
+ - spec/fixtures/delivery.json
209
+ - spec/fixtures/forbidden.json
210
+ - spec/fixtures/invalid_params.json
211
+ - spec/fixtures/not_found.json
212
+ - spec/fixtures/quote.json
213
+ - spec/fixtures/quote_params.json
214
+ - spec/fixtures/server_error.json
215
+ - spec/fixtures/service_unavailable.json
216
+ - spec/fixtures/unauthorized.json
217
+ - spec/postmates_spec.rb
218
+ - spec/spec_helper.rb