lib/securitytrails/client.rb in securitytrails-0.1.5 vs lib/securitytrails/client.rb in securitytrails-0.2.0

- old
+ new

@@ -37,13 +37,15 @@ end def request(req) Net::HTTP.start(HOST, 443, https_options) do |http| response = http.request(req) - if response.code == '200' + raise(Error, "unsupported response code returned: #{response.code}") unless response.code == "200" + + if response["Content-Type"].to_s.include? "application/json" yield JSON.parse(response.body, object_class: Response) else - raise(Error, "unsupported response code returned: #{response.code}") + yield response.body end end end def get(path, params = {}, &block)