Module: QC::API

Defined in:
lib/qc.rb

Defined Under Namespace

Classes: Request

Class Method Summary collapse

Class Method Details

.json2reqstr(json) ⇒ Object



265
266
267
# File 'lib/qc.rb', line 265

def API.json2reqstr json
  "GET\n/iaas/\n" + json2params(json)
end

.json2sign(key, json) ⇒ Object



269
270
271
# File 'lib/qc.rb', line 269

def API.json2sign key, json
  QC.hmac(key, json2reqstr(sort_json(json)))
end

.json2url(key, json) ⇒ Object



273
274
275
276
277
# File 'lib/qc.rb', line 273

def API.json2url key, json
  sign = json2sign(key, json)
  params = json2params(json)
  "https://api.qingcloud.com/iaas/?#{params}&signature=#{sign}"
end

.sort_json(json) ⇒ Object



261
262
263
# File 'lib/qc.rb', line 261

def API.sort_json json
  JSON.parse(json).to_a.sort.to_s
end