class Hockey::Networking

Networking Core Lib

Attributes

l[R]

Public Class Methods

new(token, debug: false) click to toggle source
# File lib/hockeyhelper/networking.rb, line 22
def initialize(token, debug: false)
  raise(ArgumentError, 'token must be an instance of String') unless token.kind_of?(String)

  @client = Faraday.new(:url => 'https://rink.hockeyapp.net')
  @token = token
  @l = if debug
         Logger.new(STDOUT)
       else
         NullLogger.new
       end
end

Public Instance Methods

delete(path) click to toggle source
# File lib/hockeyhelper/networking.rb, line 76
def delete(path)
  @l.info "DELETE #{path}"

  response = @client.delete do |req|
    req.url path
    req.headers['X-HockeyAppToken'] = @token
  end

  response
end
get(path) { |req| ... } click to toggle source

The http wrapper for GET method to the HockayApp. you might give a block object if necessary.

# File lib/hockeyhelper/networking.rb, line 36
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
get_object(path) click to toggle source

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.

# File lib/hockeyhelper/networking.rb, line 53
def get_object(path)
  response = get(path)
  JSON.parse(response.body) || {}
end
post(path, bodyhash) click to toggle source

The http wrapper for POST method to the HockayApp.

# File lib/hockeyhelper/networking.rb, line 59
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
post_object(path, bodyhash) click to toggle source
# File lib/hockeyhelper/networking.rb, line 71
def post_object(path, bodyhash)
  response = post path, bodyhash
  JSON.parse(response.body) || {}
end