module TingYun::TingYunService::Http

Public Instance Methods

decompress_response(response) click to toggle source

Decompresses the response from the server, if it is gzip encoded, otherwise returns it verbatim

# File lib/ting_yun/ting_yun_service/http.rb, line 37
def decompress_response(response)
  if response['content-encoding'] == 'gzip'
    Zlib::GzipReader.new(StringIO.new(response.body)).read
  else
    response.body
  end
end
remote_method_uri(method) click to toggle source
# File lib/ting_yun/ting_yun_service/http.rb, line 20
def remote_method_uri(method)
  params = {'version'=> @data_version}
  params[:license] = @license_key unless method == :trace
  raise ::TingYun::Support::Exception::AppSessionKeyError.new("@appSessionKey is asked when the upload-method happen") if method==:trace && @appSessionKey.nil?
  params[:sessionKey] = @appSessionKey
  params[:format] = "json"

  uri = "/" + method.to_s
  uri << '?' + params.map do |k,v|
    next unless v
    "#{k}=#{v}"
  end.compact.join('&')
  uri
end