Module: Careerbuilder::Utils::Request
Instance Method Summary collapse
Instance Method Details
#get(params) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/careerbuilder/utils/request.rb', line 6 def get(params) # combine params into query string query = "token=#{Careerbuilder.configuration.api_token}&" params.each{|key,value| query << "#{key}=#{value}&"} # get call on REST API base_url = 'http://api.appcast.io/search?' response = HTTParty.get(base_url + query) # parse data begin data = JSON.parse(response.body, {symbolize_names: true}) rescue JSON::ParserError data = {error: "Careerbuilder Error"} end end |