Sha256: 12dff024a5432f956d3b10ffa3cf79509c7b435f17800ff8cf5a4403cdf61f21
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 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 def get(path) @l.info "GET #{path}" response = @client.get do |req| req.url path req.headers['X-HockeyAppToken'] = @token end response end def get_object(path) response = get path JSON.parse(response.body) || {} end 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.1 | lib/hockeyhelper/networking.rb |