confrater 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/confrater/api_request.rb +14 -4
- data/lib/confrater/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e32d57771b474557bc23dc628c8b7568fa485d891ab8fd89386dad799f69106a
|
4
|
+
data.tar.gz: dde2ef47e0ac604df0011dfce1c5ee33b2c6a4291cc5fa7ba2d489fa3f97b102
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd91d74fc584773a592b18ffbb78f81181918f291638bd5256f979e7e6254168e5b2d25f998e56e79250635f73293dcfe58cfbbcc771759520208249fd038ba9
|
7
|
+
data.tar.gz: 3d6624237336b0eaa91a25f30e8ba132d60590ef2c4da26fa9a0d7f7223d4965cf8ba7139643a4d1c7dfe16e8e39cb50f8aba3ab0cf51dcf746997ea0d19f65d
|
@@ -168,12 +168,22 @@ module Confrater
|
|
168
168
|
parsed_response = nil
|
169
169
|
|
170
170
|
if response.body && !response.body.empty?
|
171
|
-
|
171
|
+
if /json/.match(response.headers['content-type'])
|
172
|
+
begin
|
173
|
+
headers = response.headers
|
174
|
+
body = MultiJson.load(response.body, symbolize_keys: symbolize_keys)
|
175
|
+
parsed_response = Response.new(headers: headers, body: body)
|
176
|
+
rescue MultiJson::ParseError
|
177
|
+
error_params = { title: "UNPARSEABLE_RESPONSE", status_code: 500 }
|
178
|
+
error = APIError.new("Unparseable response: #{response.body}", error_params)
|
179
|
+
raise error
|
180
|
+
end
|
181
|
+
elsif /text/.match(response.headers['content-type'])
|
172
182
|
headers = response.headers
|
173
|
-
body =
|
183
|
+
body = response.body
|
174
184
|
parsed_response = Response.new(headers: headers, body: body)
|
175
|
-
|
176
|
-
error_params = { title: "
|
185
|
+
else
|
186
|
+
error_params = { title: "UNPARSEABLE_RESPONSE_TYPE", status_code: 500 }
|
177
187
|
error = APIError.new("Unparseable response: #{response.body}", error_params)
|
178
188
|
raise error
|
179
189
|
end
|
data/lib/confrater/version.rb
CHANGED