procore 0.6.9 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a122d8e74f07636c87c3db3bfedb0836f813e31c1e8a3b6df25f84da131f06a
4
- data.tar.gz: 58b335464bf7b9c1bc7284e1651fc05d08796d348da464d6d327d8c0b8243a2a
3
+ metadata.gz: ba26de8f801db077402e6119b3d45bc04c097a6ac5f25c2a686c2ece6f1660f2
4
+ data.tar.gz: 65020be1331a41550388c1ad39bee27b91d1a09bcc1ae346273d5b1a8f1034ca
5
5
  SHA512:
6
- metadata.gz: 825662dbe28de8510a825cfd7e512050b7bf09da321a952587d8c243e05d71ba7b61af0fbc668334696ea0a61ddf065174055b6df38875e51c2b7735ac498110
7
- data.tar.gz: f329ffd5f5cb34aa5571fc1f79b4a24b13a1c5ec25f981bef7d4be7e2e45fecf789792d971c00c287f534dea30cdcfadbe7d4689fe49d277752aa8a22b3bd692
6
+ metadata.gz: 17c3671f731c30b852a8daa6fe4fde8af9ccf19bdf52962485a06ac1182dc937d1a8737f23bb7254ab8244135efecc0432f9157311ff47b0d6d95a6da6252ca5
7
+ data.tar.gz: 62a695f1b3f1f53c40182eb637ca59839b1f8045c260ab937abc2cae4d6d431b1ddda685d349fb3091f804ef851b88a65f33e8aaa313562f3dc5ecef67763d6a
@@ -1,5 +1,12 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.7.0 (February 21, 2018)
4
+
5
+ * Add multipart request support
6
+ * Move to `RestClient` from `HTTParty`
7
+
8
+ *Matt Brinza*
9
+
3
10
  ## 0.6.9 (February 09, 2018)
4
11
 
5
12
  * Add HTTP PUT support
@@ -1,4 +1,4 @@
1
- require "httparty"
1
+ require "rest-client"
2
2
 
3
3
  module Procore
4
4
  # Module which defines HTTP verbs GET, POST, PUT, PATCH and DELETE. Is
@@ -26,10 +26,10 @@ module Procore
26
26
  )
27
27
 
28
28
  with_response_handling do
29
- HTTParty.get(
30
- "#{base_api_path}/#{path}",
31
- query: query,
32
- headers: headers,
29
+ RestClient::Request.execute(
30
+ method: :get,
31
+ url: "#{base_api_path}/#{path}",
32
+ headers: headers.merge(params: query),
33
33
  timeout: Procore.configuration.timeout,
34
34
  )
35
35
  end
@@ -54,9 +54,10 @@ module Procore
54
54
  )
55
55
 
56
56
  with_response_handling do
57
- HTTParty.post(
58
- "#{base_api_path}/#{path}",
59
- body: body.to_json,
57
+ RestClient::Request.execute(
58
+ method: :post,
59
+ url: "#{base_api_path}/#{path}",
60
+ payload: payload(body),
60
61
  headers: headers(options),
61
62
  timeout: Procore.configuration.timeout,
62
63
  )
@@ -81,9 +82,10 @@ module Procore
81
82
  )
82
83
 
83
84
  with_response_handling do
84
- HTTParty.put(
85
- "#{base_api_path}/#{path}",
86
- body: body.to_json,
85
+ RestClient::Request.execute(
86
+ method: :put,
87
+ url: "#{base_api_path}/#{path}",
88
+ payload: payload(body),
87
89
  headers: headers(options),
88
90
  timeout: Procore.configuration.timeout,
89
91
  )
@@ -109,9 +111,10 @@ module Procore
109
111
  )
110
112
 
111
113
  with_response_handling do
112
- HTTParty.patch(
113
- "#{base_api_path}/#{path}",
114
- body: body.to_json,
114
+ RestClient::Request.execute(
115
+ method: :patch,
116
+ url: "#{base_api_path}/#{path}",
117
+ payload: payload(body),
115
118
  headers: headers(options),
116
119
  timeout: Procore.configuration.timeout,
117
120
  )
@@ -134,10 +137,10 @@ module Procore
134
137
  )
135
138
 
136
139
  with_response_handling do
137
- HTTParty.delete(
138
- "#{base_api_path}/#{path}",
139
- query: query,
140
- headers: headers,
140
+ RestClient::Request.execute(
141
+ method: :delete,
142
+ url: "#{base_api_path}/#{path}",
143
+ headers: headers.merge(params: query),
141
144
  timeout: Procore.configuration.timeout,
142
145
  )
143
146
  end
@@ -151,7 +154,7 @@ module Procore
151
154
 
152
155
  begin
153
156
  result = yield
154
- rescue Timeout::Error, Errno::ECONNREFUSED => e
157
+ rescue RestClient::Exceptions::Timeout, Errno::ECONNREFUSED => e
155
158
  if retries <= Procore.configuration.max_retries
156
159
  retries += 1
157
160
  sleep 1.5**retries
@@ -164,6 +167,8 @@ module Procore
164
167
  "values.",
165
168
  ), e
166
169
  end
170
+ rescue RestClient::ExceptionWithResponse => e
171
+ result = e.response
167
172
  end
168
173
 
169
174
  response = Procore::Response.new(
@@ -177,7 +182,7 @@ module Procore
177
182
  when 200..299
178
183
  Util.log_info(
179
184
  "API Request Finished ",
180
- path: result.request.path,
185
+ path: result.request.url,
181
186
  status: result.code.to_s,
182
187
  duration: "#{((Time.now - request_start_time) * 1000).round(0)}ms",
183
188
  request_id: result.headers["x-request-id"],
@@ -185,7 +190,7 @@ module Procore
185
190
  else
186
191
  Util.log_error(
187
192
  "API Request Failed",
188
- path: result.request.path,
193
+ path: result.request.url,
189
194
  status: result.code.to_s,
190
195
  duration: "#{((Time.now - request_start_time) * 1000).round(0)}ms",
191
196
  request_id: result.headers["x-request-id"],
@@ -241,5 +246,13 @@ module Procore
241
246
  end
242
247
  end
243
248
  end
249
+
250
+ def payload(body)
251
+ multipart?(body) ? body : body.to_json
252
+ end
253
+
254
+ def multipart?(body)
255
+ RestClient::Payload::has_file?(body)
256
+ end
244
257
  end
245
258
  end
@@ -1,3 +1,3 @@
1
1
  module Procore
2
- VERSION = "0.6.9".freeze
2
+ VERSION = "0.7.0".freeze
3
3
  end
@@ -34,6 +34,6 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency "sqlite3"
35
35
  spec.add_development_dependency "webmock"
36
36
 
37
- spec.add_dependency "httparty", "~> 0.16"
38
37
  spec.add_dependency "oauth2", "~> 1.4"
38
+ spec.add_dependency "rest-client", "~> 2.0.0"
39
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Procore Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-16 00:00:00.000000000 Z
11
+ date: 2018-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -165,33 +165,33 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: httparty
168
+ name: oauth2
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '0.16'
173
+ version: '1.4'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '0.16'
180
+ version: '1.4'
181
181
  - !ruby/object:Gem::Dependency
182
- name: oauth2
182
+ name: rest-client
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '1.4'
187
+ version: 2.0.0
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '1.4'
194
+ version: 2.0.0
195
195
  description: Procore Ruby Gem
196
196
  email:
197
197
  - opensource@procore.comm
@@ -247,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
247
  version: '0'
248
248
  requirements: []
249
249
  rubyforge_project:
250
- rubygems_version: 2.7.5
250
+ rubygems_version: 2.7.6
251
251
  signing_key:
252
252
  specification_version: 4
253
253
  summary: Procore Ruby Gem