Class: Abrio::Request
- Inherits:
-
Object
- Object
- Abrio::Request
- Defined in:
- lib/abrio/request.rb
Overview
Wrapper responsible for all requests.
Class Method Summary collapse
-
.get(uri, parameters) ⇒ Object
Call get at uri with parameters.
Class Method Details
.get(uri, parameters) ⇒ Object
Call get at uri with parameters.
- uri
-
Complete url. Example: abr.io/api/links/shorten
- parameters
-
Hash of parameters. Example: => âxmlâ, :version => â1.0â
Returns response body, a String.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/abrio/request.rb', line 12 def self.get(uri, parameters) params = build_parameters(parameters) begin url = URI.parse(uri) req = Net::HTTP::Get.new("#{url}?#{params}") res = Net::HTTP.start(url.host, url.port) do |http| http.request(req) end res.body rescue StandardError => e raise Abrio::Error.new(e) end end |