def invoke_api_call(api_call)
      url = URI.parse(api_call[:url])
      http = Net::HTTP.new(url.host, url.port)
      http.use_ssl = true
			http.verify_mode = OpenSSL::SSL::VERIFY_NONE

      # Concatenate parameters to form data
      data = api_call[:params].to_a.map{|pair| pair.map{|x| URI.escape(x.to_s)}.join '='}.join('&')
      headers = {
        'Content-Type' => 'application/x-www-form-urlencoded'
      }

      RubyDesk.logger.info "URL: #{api_call[:url]}"
      RubyDesk.logger.info "method: #{api_call[:method]}"
      RubyDesk.logger.info "Params: #{data}"

      case api_call[:method]
        when :get, 'get' then
          resp, data = http.request(Net::HTTP::Get.new(url.path+"?"+data, headers))
        when :post, 'post' then
          resp, data = http.request(Net::HTTP::Post.new(url.path, headers), data)
        when :delete, 'delete' then
          resp, data = http.request(Net::HTTP::Delete.new(url.path, headers), data)
      end

      RubyDesk.logger.info "Response code: #{resp.code}"
      RubyDesk.logger.info "Returned data: #{data}"

      case resp.code
        when "200" then return data
        when "400" then raise RubyDesk::BadRequest, data
        when "401", "403" then raise RubyDesk::UnauthorizedError, data
        when "404" then raise RubyDesk::PageNotFound, data
        when "500" then raise RubyDesk::ServerError, data
        else raise RubyDesk::Error, data
      end

    end
def invoke_api_call(api_call)
      url = URI.parse(api_call[:url])
      http = Net::HTTP.new(url.host, url.port)
      http.use_ssl = true
			http.verify_mode = OpenSSL::SSL::VERIFY_NONE

      # Concatenate parameters to form data
      data = api_call[:params].to_a.map{|pair| pair.map{|x| URI.escape(x.to_s)}.join '='}.join('&')
      headers = {
        'Content-Type' => 'application/x-www-form-urlencoded'
      }

      RubyDesk.logger.info "URL: #{api_call[:url]}"
      RubyDesk.logger.info "method: #{api_call[:method]}"
      RubyDesk.logger.info "Params: #{data}"

      case api_call[:method]
        when :get, 'get' then
          resp, data = http.request(Net::HTTP::Get.new(url.path+"?"+data, headers))
        when :post, 'post' then
          resp, data = http.request(Net::HTTP::Post.new(url.path, headers), data)
        when :delete, 'delete' then
          resp, data = http.request(Net::HTTP::Delete.new(url.path, headers), data)
      end

      RubyDesk.logger.info "Response code: #{resp.code}"
      RubyDesk.logger.info "Returned data: #{data}"

      case resp.code
        when "200" then return data
        when "400" then raise RubyDesk::BadRequest, data
        when "401", "403" then raise RubyDesk::UnauthorizedError, data
        when "404" then raise RubyDesk::PageNotFound, data
        when "500" then raise RubyDesk::ServerError, data
        else raise RubyDesk::Error, data
      end

    end
def invoke_api_call ( api_call ) url = URI . parse ( api_call [ :url ] ) http = Net :: HTTP . new ( url . host , url . port ) http . use_ssl = true http . verify_mode = OpenSSL :: SSL :: VERIFY_NONE # Concatenate parameters to form data data = api_call [ :params ] . to_a . map { | pair | pair . map { | x | URI . escape ( x . to_s ) } . join '=' } . join ( '&' ) headers = { 'Content-Type' => 'application/x-www-form-urlencoded' } RubyDesk . logger . info "URL: #{api_call[:url]}" RubyDesk . logger . info "method: #{api_call[:method]}" RubyDesk . logger . info "Params: #{data}" case api_call [ :method ] when :get , 'get' then resp , data = http . request ( Net :: HTTP :: Get . new ( url . path + "?" + data , headers ) ) when :post , 'post' then resp , data = http . request ( Net :: HTTP :: Post . new ( url . path , headers ) , data ) when :delete , 'delete' then resp , data = http . request ( Net :: HTTP :: Delete . new ( url . path , headers ) , data ) end RubyDesk . logger . info "Response code: #{resp.code}" RubyDesk . logger . info "Returned data: #{data}" case resp . code when "200" then return data when "400" then raise RubyDesk :: BadRequest , data when "401" , "403" then raise RubyDesk :: UnauthorizedError , data when "404" then raise RubyDesk :: PageNotFound , data when "500" then raise RubyDesk :: ServerError , data else raise RubyDesk :: Error , data end end
invokes the given API call and returns body of the response as text
invokes the given API call and returns body of the response as text