Class: Convore::API

Inherits:
Object
  • Object
show all
Defined in:
lib/convore/api.rb

Class Method Summary collapse

Class Method Details

.cacheObject



6
7
8
# File 'lib/convore/api.rb', line 6

def cache
	@@cache ||= {}
end

.get(api_uri, username = nil, password = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/convore/api.rb', line 10

def get(api_uri, username=nil, password=nil)
	response = cache[api_uri] ? cache[api_uri] : 
	Net::HTTP.start('convore.com', 443, nil, nil, nil, nil, {:use_ssl => true}) {|http|
		req = Net::HTTP::Get.new(api_uri)
		req.basic_auth(username, password) if username && password
		req.set_content_type('application/json')
		http.request(req)
	}
	cache[api_uri] = response
end