help_scout 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/help_scout.rb +12 -7
- data/lib/help_scout/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99924000d7bfdc5ea399f4165de67eea51793c80
|
4
|
+
data.tar.gz: c527dc4718abb27f6b3fae265db14f84c8a96648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b254a0e0cf9511812475d3525b3d8c7f1fea111116355a2cd1e032aeb49bf6df548f0d498241ed132e59caf40c3b8e775b71b4c9945b6ca800c8c328b7094b4c
|
7
|
+
data.tar.gz: ab520589df5123e715000d1629a65c7d612095a470ca7a0af54269622c8b4df9037d5341639ce6702c6629dd76f595e807858b4643d762b77b1fdee8897bcc9b
|
data/lib/help_scout.rb
CHANGED
@@ -8,6 +8,7 @@ class HelpScout
|
|
8
8
|
class TooManyRequestsError < StandardError; end
|
9
9
|
class InternalServerError < StandardError; end
|
10
10
|
class ForbiddenError < StandardError; end
|
11
|
+
class ServiceUnavailable < StandardError; end
|
11
12
|
|
12
13
|
# Status codes used by Help Scout, not all are implemented in this gem yet.
|
13
14
|
# http://developer.helpscout.net/help-desk-api/status-codes/
|
@@ -19,6 +20,7 @@ class HelpScout
|
|
19
20
|
HTTP_NOT_FOUND = 404
|
20
21
|
HTTP_TOO_MANY_REQUESTS = 429
|
21
22
|
HTTP_INTERNAL_SERVER_ERROR = 500
|
23
|
+
HTTP_SERVICE_UNAVAILABLE = 503
|
22
24
|
|
23
25
|
attr_accessor :last_response
|
24
26
|
|
@@ -229,10 +231,9 @@ class HelpScout
|
|
229
231
|
}.merge(options)
|
230
232
|
|
231
233
|
@last_response = HTTParty.send(method, uri, options)
|
232
|
-
|
233
|
-
case @last_response.code
|
234
|
+
case last_response.code
|
234
235
|
when HTTP_OK, HTTP_CREATED, HTTP_NO_CONTENT
|
235
|
-
|
236
|
+
last_response.parsed_response
|
236
237
|
when HTTP_BAD_REQUEST
|
237
238
|
raise ValidationError, last_response.parsed_response["validationErrors"]
|
238
239
|
when HTTP_FORBIDDEN
|
@@ -240,13 +241,17 @@ class HelpScout
|
|
240
241
|
when HTTP_NOT_FOUND
|
241
242
|
raise NotFoundError
|
242
243
|
when HTTP_INTERNAL_SERVER_ERROR
|
243
|
-
|
244
|
+
error_message = JSON.parse(last_response.body)["error"]
|
245
|
+
raise InternalServerError, error_message
|
246
|
+
when HTTP_SERVICE_UNAVAILABLE
|
247
|
+
raise ServiceUnavailable
|
244
248
|
when HTTP_TOO_MANY_REQUESTS
|
245
249
|
retry_after = last_response.headers["Retry-After"]
|
246
|
-
|
247
|
-
|
250
|
+
message = "Rate limit of 200 RPM or 12 POST/PUT/DELETE requests per 5 " +
|
251
|
+
"seconds reached. Next request possible in #{retry_after} seconds."
|
252
|
+
raise TooManyRequestsError, message
|
248
253
|
else
|
249
|
-
raise NotImplementedError, "Help Scout returned something that is not implemented by the help_scout gem yet: #{
|
254
|
+
raise NotImplementedError, "Help Scout returned something that is not implemented by the help_scout gem yet: #{last_response.code}: #{last_response.parsed_response["message"] if last_response.parsed_response}"
|
250
255
|
end
|
251
256
|
end
|
252
257
|
end
|
data/lib/help_scout/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: help_scout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Paagman
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-
|
14
|
+
date: 2018-03-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: httparty
|