lib/hockeyhelper/networking.rb in hockeyhelper-0.0.1 vs lib/hockeyhelper/networking.rb in hockeyhelper-0.0.2
- old
+ new
@@ -27,25 +27,34 @@
else
NullLogger.new
end
end
+ # The http wrapper for GET method to the HockayApp.
+ # you might give a block object if necessary.
def get(path)
@l.info "GET #{path}"
response = @client.get do |req|
req.url path
req.headers['X-HockeyAppToken'] = @token
+ yield req if block_given?
end
response
end
+ # The http wrapper for GET method to the HockayApp.
+ # you might give a block object if necessary.
+ # see the #get method
+ #
+ # Return the Hash object from response json.
def get_object(path)
- response = get path
+ response = get(path)
JSON.parse(response.body) || {}
end
+ # The http wrapper for POST method to the HockayApp.
def post(path, bodyhash)
@l.info "POST #{path}, #{bodyhash}"
response = @client.post do |req|
req.url path
\ No newline at end of file