Sha256: 039f2e04dd80c4bfe19d9c781e78ca5cb20626215bc5517a2744e948aec7b835
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
require 'uuid' class NirvanaHQ def post payload result = `curl -sX POST 'https://api.nirvanahq.com/?api=json&appid=gem&authtoken=#{@token}' -d '#{payload}'` end # final form tbd. For now, have it parse out the results of the request, and send that along as a hash obj def everything raw = JSON.parse(`curl -sX GET 'https://api.nirvanahq.com/?api=rest&appid=gem&authtoken=#{@token}&method=everything&since=0'`) raw['results'] end # task_details a hash with the task info def add task_details #prepare payload now = Time.now.to_i defaults = { "method" => "task.save", "id" => UUID.generate, "type" => 0, "_type" => now, "state" => 0, "_state" => now, } task = defaults.merge(task_details) self.post [task].to_json end def trash task_id task = { "method" => "task.save", "id" => task_id, "state" => 6, "_state" => Time.now.to_i } self.post [task].to_json end def delete task_id task = { "method" => "task.save", "id" => task_id, "deleted" => Time.now.to_i, "_deleted" => Time.now.to_i } self.post [task].to_json end def undelete task_id task = { "method" => "task.save", "id" => task_id, "deleted" => 0, "_deleted" => Time.now.to_i } self.post [task].to_json end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nirvanahq-0.1.4 | lib/nirvanahq/task.rb |