diff --git a/Gemfile b/Gemfile index 96f9d3d..3b54c34 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,3 @@ # Gemfile for AlchemyAPI Ruby SDK source "https://rubygems.org" -gem "json" +gem "httparty" diff --git a/alchemyapi.rb b/alchemyapi.rb index 89974e9..873ed1a 100644 --- a/alchemyapi.rb +++ b/alchemyapi.rb @@ -15,11 +15,11 @@ require 'rubygems' -require 'net/http' require 'uri' -require 'json' +require 'httparty' class AlchemyAPI + include HTTParty #Setup the endpoints @@ENDPOINTS = {} @@ -520,10 +520,7 @@ def analyze(url, options) options['outputMode'] = 'json' #Fire off the HTTP request - res = Net::HTTP::post_form(URI.parse(url), options) - - #parse and return the response - return JSON.parse(res.body) + self.class.post(url, body: options).parsed_response end end