help_scout 0.5.0 → 0.6.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 +16 -11
- 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: 81382f7b709606575977992773cbf146b9063a6f
|
4
|
+
data.tar.gz: 9d50c47b51f8beff738cc166ff0f41b66aea5cee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c0d08c3dc4e5a25f98b022419c612b92e9008b8ba0fd0649f539dc153982a7b2a6a9a14336e6cade5215226ff34d35ac66dec7c62200c23b07b48da852555db
|
7
|
+
data.tar.gz: 4436eeb10dbb398874b2fa89dd34b7e01fdeeab4f4684e30582dddf4d8820d53925426758f4285316702382ee0c2e62060b4a6feae01342cda47bc6b28cb7256
|
data/lib/help_scout.rb
CHANGED
@@ -5,7 +5,11 @@ class HelpScout
|
|
5
5
|
class ValidationError < StandardError; end
|
6
6
|
class NotImplementedError < StandardError; end
|
7
7
|
|
8
|
+
# Status codes used by Help Scout, not all are implemented in this gem yet.
|
9
|
+
# http://developer.helpscout.net/help-desk-api/status-codes/
|
10
|
+
HTTP_OK = 200
|
8
11
|
HTTP_CREATED = 201
|
12
|
+
HTTP_NO_CONTENT = 204
|
9
13
|
HTTP_BAD_REQUEST = 400
|
10
14
|
|
11
15
|
attr_accessor :last_response
|
@@ -24,16 +28,9 @@ class HelpScout
|
|
24
28
|
def create_conversation(data)
|
25
29
|
post("conversations", { body: data })
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
return conversation_uri.match(/(\d+)\.json$/)[1]
|
31
|
-
elsif last_response.code == HTTP_BAD_REQUEST
|
32
|
-
# Validation failed so return the errors
|
33
|
-
raise ValidationError, last_response.parsed_response["message"]
|
34
|
-
else
|
35
|
-
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}"
|
36
|
-
end
|
31
|
+
# Extract ID of created conversation from the Location header
|
32
|
+
conversation_uri = last_response.headers["location"]
|
33
|
+
conversation_uri.match(/(\d+)\.json$/)[1]
|
37
34
|
end
|
38
35
|
|
39
36
|
# Public: Get conversation
|
@@ -195,6 +192,14 @@ class HelpScout
|
|
195
192
|
}.merge(options)
|
196
193
|
|
197
194
|
@last_response = HTTParty.send(method, uri, options)
|
198
|
-
|
195
|
+
|
196
|
+
case @last_response.code
|
197
|
+
when HTTP_OK, HTTP_CREATED, HTTP_NO_CONTENT
|
198
|
+
@last_response.parsed_response
|
199
|
+
when HTTP_BAD_REQUEST
|
200
|
+
raise ValidationError, last_response.parsed_response["message"]
|
201
|
+
else
|
202
|
+
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}"
|
203
|
+
end
|
199
204
|
end
|
200
205
|
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.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Paagman
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-08-
|
13
|
+
date: 2017-08-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|