module AParserClient
Constants
- VERSION
Public Instance Methods
send_request(request)
click to toggle source
# File lib/a_parser_client/api.rb, line 214 def send_request(request) uri = URI @api_url req = Net::HTTP::Post.new uri req.body = (request) req.content_type = 'text/plain; charset=UTF-8' begin res = Net::HTTP.start(uri.hostname, uri.port) do |http| http.request(req) end rescue StandardError => e puts "Send request error: #{e}" end return unless res begin JSON.parse res.body rescue JSON::ParserError => e raise "Not a JSON type response from the server #{@api_url}. Probably not an API endpoint. Error: #{e}" end end