Class: PackageTracker::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/package_tracker/request.rb

Class Method Summary collapse

Class Method Details

.do_request(http_method, uri, path, body, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/package_tracker/request.rb', line 11

def self.do_request(http_method, uri, path, body, options={})      
  raw_request = http_method.new(path)
  raw_request.body = body
  
  http = Net::HTTP.new(uri, options[:port])
  http.use_ssl = true if options[:https]
  
  http.request(raw_request)
end

.get(uri, path, body, options = {}) ⇒ Object



3
4
5
# File 'lib/package_tracker/request.rb', line 3

def self.get(uri, path, body, options={})
  do_request(Net::HTTP::Get, uri, path, body, options)
end

.post(uri, path, body, options = {}) ⇒ Object



7
8
9
# File 'lib/package_tracker/request.rb', line 7

def self.post(uri, path, body, options={})
  do_request(Net::HTTP::Post, uri, path, body, options)
end