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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d2626f675ac8bb8f23b2019bdd9d02e8e78df1ee8a36d48ce6d28f89c6b6ab0
4
- data.tar.gz: 96afdb7e8c048c50bc93ff64629adea04f2b74bf6c362937e5b97d53363aee5d
3
+ metadata.gz: e32d57771b474557bc23dc628c8b7568fa485d891ab8fd89386dad799f69106a
4
+ data.tar.gz: dde2ef47e0ac604df0011dfce1c5ee33b2c6a4291cc5fa7ba2d489fa3f97b102
5
5
  SHA512:
6
- metadata.gz: a0e3d726e15468a788100246e265b8b2444e2e93cd62648e5572d28070dc310f8e1d247b6f20e0e2571546bccf57db7a6f3b320d812ca47a2238fadd4a0abc0d
7
- data.tar.gz: 42bafb71ee85ecbd73291ce301f167a0f65317f3a8673fd5b7da68e13e1cb1d7a2c9bddf0f1db2380fe4713cc2339d9915c3c1ab85b021a73494986f74c9f6e9
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
- begin
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 = MultiJson.load(response.body, symbolize_keys: symbolize_keys)
183
+ body = response.body
174
184
  parsed_response = Response.new(headers: headers, body: body)
175
- rescue MultiJson::ParseError
176
- error_params = { title: "UNPARSEABLE_RESPONSE", status_code: 500 }
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
@@ -1,3 +1,3 @@
1
1
  module Confrater
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confrater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Espen Antonsen