lib/client/client.rb in factor-0.1.06 vs lib/client/client.rb in factor-0.1.07

- old
+ new

@@ -7,12 +7,13 @@ module Factor module Client class Client attr_accessor :host + FACTOR_HOST = ENV["FACTOR_HOST"] || "factor.io" - def initialize(host="http://factor.io") + def initialize(host=FACTOR_HOST) @host=host end def register(email,password) end @@ -106,11 +107,11 @@ # workflows def add_workflow(key,definition) - rest_post("workflows",{:name=>key,:definition=>definition}) + rest_post("workflows",{:workflow=>{:name=>key,:definition=>definition}}) end def get_workflows() rest_get("workflows") end @@ -122,11 +123,11 @@ # channels def add_channel(path,definition_file) file=zip(File.expand_path(path)) definition = File.read(definition_file) - rest_post("channels",{:zip=>file,:definition=>definition}) + rest_post("channels",{:zip=>file,:channel=>{:definition=>definition}}) end def get_channels() rest_get("channels") end @@ -189,30 +190,30 @@ def rest_get(path,params={}) params["auth_token"]=@token param_string=params.map{|key,value| "#{key}=#{value}"}.join("&") - JSON.parse(RestClient.get("#{@host}/#{path}.json?#{param_string}")) + JSON.parse(RestClient.get("http://#{@host}/#{path}.json?#{param_string}")) end def rest_put(path,params={}) params["auth_token"]=@token - JSON.parse(RestClient.put("#{@host}/#{path}.json",params)) + JSON.parse(RestClient.put("http://#{@host}/#{path}.json",params)) end def rest_post(path,params={}) #params["auth_token"]=@token - JSON.parse(RestClient.post("#{@host}/#{path}.json?auth_token=#{@token}",params)) + JSON.parse(RestClient.post("http://#{@host}/#{path}.json?auth_token=#{@token}",params)) end def rest_delete(path,params={}) params["auth_token"]=@token param_string=params.map{|key,value| "#{key}=#{value}"}.join("&") - JSON.parse(RestClient.delete("#{@host}/#{path}.json?#{param_string}")) + JSON.parse(RestClient.delete("http://#{@host}/#{path}.json?#{param_string}")) end end end end \ No newline at end of file