lib/ducksboard/widget.rb in ducksboard-0.1.0 vs lib/ducksboard/widget.rb in ducksboard-0.1.1
- old
+ new
@@ -1,11 +1,10 @@
require 'json'
module Ducksboard
class Widget
include ::HTTParty
base_uri "https://push.ducksboard.com/values"
- basic_auth Ducksboard.api_key, 'ducksboard-gem'
attr_accessor :id, :data, :type
def initialize(id, data={})
@id = id
@@ -28,10 +27,13 @@
@data[:timestamp] = time
end
def update(data=nil)
@data = data if data
- self.class.post('/' + id.to_s, :body => @data.to_json)
+ auth = {:username => ::Ducksboard.api_key, :password => "ducksboard-gem"}
+ self.class.post('/' + id.to_s,
+ :basic_auth => auth,
+ :body => @data.to_json)
end
def save
if valid?
update.code.to_i == 200