Sha256: 4ab97708476a8eeba9cb1508fc89dad114bcb1fdea04d9557b708a3bf9c602ed
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
require 'faraday' require 'json' require 'logger' module Hockey class NullLogger < Logger def initialize *args end def debug; end def info; end def warn; end def error; end def fatal; end end # Networking Core Lib class Networking attr :l def initialize(token, debug:false) @client = Faraday.new(:url => 'https://rink.hockeyapp.net') @token = token @l = if debug Logger.new(STDOUT) 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) 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 req.headers['X-HockeyAppToken'] = @token req.body = bodyhash end response end def post_object(path, bodyhash) response = post path, bodyhash JSON.parse(response.body) || {} end def delete(path) @l.info "DELETE #{path}" response = @client.delete do |req| req.url path req.headers['X-HockeyAppToken'] = @token end response end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hockeyhelper-0.0.2 | lib/hockeyhelper/networking.rb |