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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62dae154ee84e9bd1b12554b7640ccd778c1d961
4
- data.tar.gz: 8f6e5fddb9c5fd010c36d8928913d1e48a1aeac3
3
+ metadata.gz: 99924000d7bfdc5ea399f4165de67eea51793c80
4
+ data.tar.gz: c527dc4718abb27f6b3fae265db14f84c8a96648
5
5
  SHA512:
6
- metadata.gz: f540a1cb8574caea5944bbb78f10d5adedec1f9292500dabfb684d463f0e16116cc48aed705774c5a48969209ffb45d1b6bdfa1580ab86ddfc98b4a4c855385e
7
- data.tar.gz: e584154ffb74e865febd99500c79228241d349537168b4980c722c20c2158a922d03ea3e303cc78e122005b93943b9c649e69857e4cf8715d6f34f0212077cc6
6
+ metadata.gz: b254a0e0cf9511812475d3525b3d8c7f1fea111116355a2cd1e032aeb49bf6df548f0d498241ed132e59caf40c3b8e775b71b4c9945b6ca800c8c328b7094b4c
7
+ data.tar.gz: ab520589df5123e715000d1629a65c7d612095a470ca7a0af54269622c8b4df9037d5341639ce6702c6629dd76f595e807858b4643d762b77b1fdee8897bcc9b
@@ -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
- @last_response.parsed_response
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
- raise InternalServerError
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
- error_message = "Rate limit of 200 RPM or 12 POST/PUT/DELETE requests per 5 seconds reached. Next request possible in #{retry_after} seconds."
247
- raise TooManyRequestsError, error_message
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: #{@last_response.code}: #{@last_response.parsed_response["message"] if @last_response.parsed_response}"
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
@@ -1,3 +1,3 @@
1
1
  class HelpScout
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
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.10.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-02-27 00:00:00.000000000 Z
14
+ date: 2018-03-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: httparty