simplificator-withings 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/withings/user.rb CHANGED
@@ -48,17 +48,15 @@ class Withings::User
48
48
 
49
49
 
50
50
  def subscribe_notification(callback_url, description, *devices)
51
- devices = [Withings::SCALE, Withings::BLOOD_PRESSURE_MONITOR] if Array(devices).empty?
52
- devices = devices.inject('|'.to_sym)
53
- connection.get_request('/notify', :action => :subscribe, :callbackurl => callback_url, :comment => description, :appli => devices)
51
+ connection.get_request('/notify', :action => :subscribe, :callbackurl => callback_url, :comment => description, :appli => devices_bitmask(*devices))
54
52
  end
55
53
 
56
- def revoke_notification(callback_url)
57
- connection.get_request('/notify', :action => :revoke, :callbackurl => callback_url)
54
+ def revoke_notification(callback_url, *devices)
55
+ connection.get_request('/notify', :action => :revoke, :callbackurl => callback_url, :appli => devices_bitmask(*devices))
58
56
  end
59
57
 
60
- def describe_notification(callback_url)
61
- response = connection.get_request('/notify', :action => :get, :callbackurl => callback_url)
58
+ def describe_notification(callback_url, *devices)
59
+ response = connection.get_request('/notify', :action => :get, :callbackurl => callback_url, :appli => devices_bitmask(*devices))
62
60
  Withings::NotificationDescription.new(response.merge(:callbackurl => callback_url))
63
61
  end
64
62
 
@@ -92,8 +90,7 @@ class Withings::User
92
90
  end
93
91
 
94
92
  def share(*devices)
95
- devices = [Withings::SCALE, Withings::BLOOD_PRESSURE_MONITOR] if Array(devices).empty?
96
- @share = devices.inject('|'.to_sym)
93
+ @share = devices_bitmask(devices)
97
94
  connection.get_request('/user', :action => :update, :ispublic => @share)
98
95
  end
99
96
 
@@ -108,6 +105,11 @@ class Withings::User
108
105
 
109
106
 
110
107
  protected
108
+
109
+ def devices_bitmask(*devices)
110
+ devices = [Withings::SCALE, Withings::BLOOD_PRESSURE_MONITOR] if Array(devices).empty?
111
+ devices.inject('|'.to_sym)
112
+ end
111
113
 
112
114
  def connection
113
115
  @connection ||= Withings::Connection.new(self)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{simplificator-withings}
5
- s.version = "0.4.2"
5
+ s.version = "0.4.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["pascalbetz"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplificator-withings
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 2
10
- version: 0.4.2
9
+ - 3
10
+ version: 0.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - pascalbetz