simplificator-withings 0.6.10 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de76ef3c93a7d3cd7d94630fb978d2e677e2c7e9
4
- data.tar.gz: 30bc4cbd6703ec373bcc8817f18dabb476a940af
3
+ metadata.gz: 93725a1f1eaa8d6b32a039d4d5fa36131fbfaa8d
4
+ data.tar.gz: d3dbf54ac59121fb3b11282fbcbb54f0edaab04c
5
5
  SHA512:
6
- metadata.gz: b6ef5b20617a5b76dd20ef5002e4ecd10d2e30581d3b7ab56feda28aa2bbb2493514a567932d8263c4d63fae73ffa39f29b10a38b6806ba72916f4eb2d9feee9
7
- data.tar.gz: c5d0fa9058955da7f29819b178c5579fbea84171825568fcc92741214e391909ca94de533160ffc7f6b336608f1704112b80c197285ba928d921101232eb7a4c
6
+ metadata.gz: ada238f3bb8506df0af1bffec2a7f7ca7806a4b2027c6a3636b096d78280239f24ab716c5646db50b01169936fac4dace7f62940c520e48c26790bcf6d446910
7
+ data.tar.gz: 213d827e296db6820e6125bd4c7a995becf365813667d533625def10b9ff98647aa6f3ef81438dffa146c2d5eef08448790a8fde057adf9dacccc1f398ac9f64
@@ -0,0 +1,24 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ Gemfile.lock
21
+
22
+ ## PROJECT::SPECIFIC
23
+ *.gem
24
+ demo.rb
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in liftapp-client.gemspec
4
+ gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 pascalbetz
1
+ Copyright (c) 2009 Simplificator AG
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,179 +1,186 @@
1
- = simplificator-withings
2
-
3
- This is a ruby implementation for the Withings API. Description of the API can be found here: http://www.withings.com/en/api
4
-
5
- == Versions ==
6
-
7
- === 0.6.10 ===
8
-
9
- * Do not raise an exception on unknown types of measurement groups.
10
-
11
- === 0.6.9 ===
12
-
13
- * Added support for activities (thanks to invernizzi)
14
-
15
- === 0.6.8 ===
16
-
17
- * updated README (thanks to jmaddi)
18
-
19
- === 0.6.7 ===
20
-
21
- * Swap ruby-hmac for openssl
22
- * Allow string userid in User.authenticate
23
-
24
- === 0.6.6 ===
25
-
26
- Added list_notifications method to user.
27
-
28
- === 0.6.3 ===
29
-
30
- Fixed escaping for parameters.
31
-
32
- === 0.6.2 ===
33
-
34
- Updated Readme and Gemspec
35
-
36
- === 0.6.0 ===
37
-
38
- OAuth implemented. This version is not compatible to previous releases.
39
- Authentication via userid/publickey is not supported anymore.
40
-
41
- === 0.4.5 ===
42
- E-Mail Address is downcased before hashing it (authentication)
43
-
44
- === 0.4.4 ===
45
- Various fixes for the support of Blood Pressure Monitor
46
-
47
- === 0.4.0 ===
48
- Note that this release breaks the API of previous releases:
49
-
50
- === User.authenticate ===
51
-
52
- User.authenticate() has been replaced by User.userlist
53
-
54
- There is no description available and no guarantee on the order that users are returned by the API (and yes, there can be many users for a single Account)
55
- so it seems best to leave the decision to the users of the API.
56
-
57
- The old method is still there but please update your code. It will be removed in the next release.
58
-
59
- === MeasurementGroup ===
60
-
61
- MeasurementGroup#createt_at has been replaced by MeasurementGroup#taken_on
62
-
63
- Created at is usually the timestamp at which a record was created. But MeasurementGroup#created_at was the timestamp when you actually took the measurement. You can also take measurements (via the Web UI on withings.com) which are for a past date. The record is created today, but the measurement
64
- was taken on 2 weeks ago.
65
-
66
- The old method is still there but please update your code. It will be removed in the next release.
67
-
68
- == Installation
69
-
70
- gem install simplificator-withings
71
- gem install ruby-hmac
72
-
73
- == Authentication
74
-
75
- The WBS API now uses OAuth. See the API documentation for details.
76
-
77
- == TODO
78
-
79
- * Integration Test? But i don't want to share my credentials... Perhaps with a test account on withings? Solution from Withings support:
80
- Hi,
81
-
82
- The easiest is that you just create a regular account
83
- (http://start.withings.com), associate it with one scale, then create a user
84
- (like any regular customer).
85
-
86
- Once this is done, the account is activated. You may then go to My
87
- account/My scale and dissociate the scale, the account will stay opened.
88
- That account may be used by who ever you think it should for test purposes
89
- and will not be associated to a specific scale.
90
-
91
- Thanks for your enquiry !
92
-
93
- fred
94
-
95
- == Remarks
96
-
97
- * The gem is still under development and the API might change a bit.
98
- * Authentication by user_id/public_key is only supported when the user has activated sharing.
99
- He can do this either in the sharing overlay on my.withings.com or
100
- through the api (user.share <LIST OF DEVICES>) after authentication by email/password
101
- * As soon as the user sets sharing to false (user.share = false) the public_key is reset
102
- and upon next activation of sharing a new public_key is assigned.
103
- * All the methods making remote calls can throw Withing::ApiError if something goes wrong
104
- (wrong public_key, missing parameters, ...).
105
- You can find more details on the error by looking at the status code in the error.
106
-
107
- == How To
108
-
109
- Require the API implementation
110
- require 'rubygems'
111
- require 'withings'
112
-
113
- All classes are name-spaced, if your other code allows you can include Withings
114
- include Withings
115
-
116
- Setup
117
- Withings.consumer_secret = '1234'
118
- Withings.consumer_key = 'abcd'
119
-
120
-
121
- A user can be authenticated using user id and oauth token/secret
122
- user = User.authenticate('<YOUR USER ID>', '<YOUR OAUTH TOKEN>', '<YOUR OAUTH TOKEN SECRET>')
123
-
124
-
125
- You can handle subscriptions through the API (all devices currently known => Scale + Blood Pressure Monitor)
126
- user.subscribe_notification('http://foo.bar.com', 'test subscription')
127
- Specify what devices you are interested
128
- user.subscribe_notification('http://foo.bar.com', 'test subscription', Withings::SCALE, Withings::BLOOD_PRESSURE_MONITOR)
129
-
130
- user.describe_notification('http://foo.bar.com')
131
- user.revoke_notification('http://foo.bar.com')
132
-
133
- List notifications is now possible
134
- user.list_notifications
135
-
136
- And finally you can get measurements, after all this is what it's for
137
- user.measurement_groups(:per_page => 10, :page => 1, :end_at => Time.now)
138
- user.measurement_groups(:category => MeasurementGroup::CATEGORY_TARGET)
139
- user.measurement_groups(:last_updated_at => Time.at(12345))
140
- user.measurement_groups(:start_at => Time.at(12345), :end_at => Time.at(67890))
141
- user.measurement_groups(:measurement_type => MeasurementGroup::TYPE_FAT)
142
- user.measurement_groups(:device => Withings::SCALE)
143
-
144
- Since 0.6.9 you can also get activities
145
- user.get_activities
146
-
147
-
148
- == Note on keys in hashes
149
-
150
- Keys to constructors (User, MeasurementGroup and NotificationDescription) and methods (User.measurement_groups)
151
- can be either String or Symbol
152
-
153
- == Note on naming convention
154
-
155
- The WBS API has parameter with shortened names (e.g. 'grpid') or names not following a consistent naming pattern. While this
156
- API implementation tries to stick as close to the API as possible it also tries to unify and simplify the parameter names.
157
- The constructors for User, MeasurementGroup and NotificationDescription accept the names provided by the API but convert the names then
158
- to a more "ruby" way.
159
- An exception to this are the "id" and "publickey" parameters for User.new, they are accepted as "user_id" and "public_key" as well.
160
-
161
- == Note on Patches/Pull Requests
162
-
163
- * Fork the project.
164
- * Make your feature addition or bug fix.
165
- * Add tests for it. This is important so I don't break it in a
166
- future version unintentionally.
167
- * Commit, do not mess with rakefile, version, or history.
168
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
169
- * Send me a pull request. Bonus points for topic branches.
170
-
171
- == Dependencies
172
-
173
- HTTParty is used for making the HTTP requests and Shoulda and Mocha are used for testing.
174
- Thanks for these Gems.
175
-
176
-
177
- == Copyright
178
-
179
- Copyright (c) 2012 simplificator. See LICENSE for details.
1
+ = simplificator-withings
2
+
3
+ This is a ruby implementation for the Withings API. Description of the API can be found here: http://www.withings.com/en/api
4
+
5
+ == Versions
6
+
7
+ === 0.7.0
8
+
9
+ * Removed shoulda
10
+ * Fixed failing tests
11
+ * Refactored Gemspec
12
+ * Closed PR from github
13
+
14
+ === 0.6.10
15
+
16
+ * Do not raise an exception on unknown types of measurement groups.
17
+
18
+ === 0.6.9
19
+
20
+ * Added support for activities (thanks to invernizzi)
21
+
22
+ === 0.6.8
23
+
24
+ * updated README (thanks to jmaddi)
25
+
26
+ === 0.6.7
27
+
28
+ * Swap ruby-hmac for openssl
29
+ * Allow string userid in User.authenticate
30
+
31
+ === 0.6.6
32
+
33
+ Added list_notifications method to user.
34
+
35
+ === 0.6.3
36
+
37
+ Fixed escaping for parameters.
38
+
39
+ === 0.6.2
40
+
41
+ Updated Readme and Gemspec
42
+
43
+ === 0.6.0
44
+
45
+ OAuth implemented. This version is not compatible to previous releases.
46
+ Authentication via userid/publickey is not supported anymore.
47
+
48
+ === 0.4.5
49
+ E-Mail Address is downcased before hashing it (authentication)
50
+
51
+ === 0.4.4
52
+ Various fixes for the support of Blood Pressure Monitor
53
+
54
+ === 0.4.0
55
+ Note that this release breaks the API of previous releases:
56
+
57
+ === User.authenticate
58
+
59
+ User.authenticate() has been replaced by User.userlist
60
+
61
+ There is no description available and no guarantee on the order that users are returned by the API (and yes, there can be many users for a single Account)
62
+ so it seems best to leave the decision to the users of the API.
63
+
64
+ The old method is still there but please update your code. It will be removed in the next release.
65
+
66
+ === MeasurementGroup
67
+
68
+ MeasurementGroup#created_at has been replaced by MeasurementGroup#taken_at
69
+
70
+ Created at is usually the timestamp at which a record was created. But MeasurementGroup#created_at was the timestamp when you actually took the measurement. You can also take measurements (via the Web UI on withings.com) which are for a past date. The record is created today, but the measurement
71
+ was taken on 2 weeks ago.
72
+
73
+ The old method is still there but please update your code. It will be removed in the next release.
74
+
75
+ == Installation
76
+
77
+ gem install simplificator-withings
78
+ gem install ruby-hmac
79
+
80
+ == Authentication
81
+
82
+ The WBS API now uses OAuth. See the API documentation for details.
83
+
84
+ == TODO
85
+
86
+ * Integration Test? But i don't want to share my credentials... Perhaps with a test account on withings? Solution from Withings support:
87
+ Hi,
88
+
89
+ The easiest is that you just create a regular account
90
+ (http://start.withings.com), associate it with one scale, then create a user
91
+ (like any regular customer).
92
+
93
+ Once this is done, the account is activated. You may then go to My
94
+ account/My scale and dissociate the scale, the account will stay opened.
95
+ That account may be used by who ever you think it should for test purposes
96
+ and will not be associated to a specific scale.
97
+
98
+ Thanks for your enquiry !
99
+
100
+ fred
101
+
102
+ == Remarks
103
+
104
+ * The gem is still under development and the API might change a bit.
105
+ * Authentication by user_id/public_key is only supported when the user has activated sharing.
106
+ He can do this either in the sharing overlay on my.withings.com or
107
+ through the api (user.share <LIST OF DEVICES>) after authentication by email/password
108
+ * As soon as the user sets sharing to false (user.share = false) the public_key is reset
109
+ and upon next activation of sharing a new public_key is assigned.
110
+ * All the methods making remote calls can throw Withing::ApiError if something goes wrong
111
+ (wrong public_key, missing parameters, ...).
112
+ You can find more details on the error by looking at the status code in the error.
113
+
114
+ == How To
115
+
116
+ Require the API implementation
117
+ require 'rubygems'
118
+ require 'withings'
119
+
120
+ All classes are name-spaced, if your other code allows you can include Withings
121
+ include Withings
122
+
123
+ Setup
124
+ Withings.consumer_secret = '1234'
125
+ Withings.consumer_key = 'abcd'
126
+
127
+
128
+ A user can be authenticated using user id and oauth token/secret
129
+ user = User.authenticate('<YOUR USER ID>', '<YOUR OAUTH TOKEN>', '<YOUR OAUTH TOKEN SECRET>')
130
+
131
+
132
+ You can handle subscriptions through the API (all devices currently known => Scale + Blood Pressure Monitor)
133
+ user.subscribe_notification('http://foo.bar.com', 'test subscription')
134
+ Specify what devices you are interested
135
+ user.subscribe_notification('http://foo.bar.com', 'test subscription', Withings::SCALE, Withings::BLOOD_PRESSURE_MONITOR)
136
+
137
+ user.describe_notification('http://foo.bar.com')
138
+ user.revoke_notification('http://foo.bar.com')
139
+
140
+ List notifications is now possible
141
+ user.list_notifications
142
+
143
+ And finally you can get measurements, after all this is what it's for
144
+ user.measurement_groups(:per_page => 10, :page => 1, :end_at => Time.now)
145
+ user.measurement_groups(:category => MeasurementGroup::CATEGORY_TARGET)
146
+ user.measurement_groups(:last_updated_at => Time.at(12345))
147
+ user.measurement_groups(:start_at => Time.at(12345), :end_at => Time.at(67890))
148
+ user.measurement_groups(:measurement_type => MeasurementGroup::TYPE_FAT)
149
+ user.measurement_groups(:device => Withings::SCALE)
150
+
151
+ Since 0.6.9 you can also get activities
152
+ user.get_activities
153
+
154
+
155
+ == Note on keys in hashes
156
+
157
+ Keys to constructors (User, MeasurementGroup and NotificationDescription) and methods (User.measurement_groups)
158
+ can be either String or Symbol
159
+
160
+ == Note on naming convention
161
+
162
+ The WBS API has parameter with shortened names (e.g. 'grpid') or names not following a consistent naming pattern. While this
163
+ API implementation tries to stick as close to the API as possible it also tries to unify and simplify the parameter names.
164
+ The constructors for User, MeasurementGroup and NotificationDescription accept the names provided by the API but convert the names then
165
+ to a more "ruby" way.
166
+ An exception to this are the "id" and "publickey" parameters for User.new, they are accepted as "user_id" and "public_key" as well.
167
+
168
+ == Note on Patches/Pull Requests
169
+
170
+ * Fork the project.
171
+ * Make your feature addition or bug fix.
172
+ * Add tests for it. This is important so I don't break it in a
173
+ future version unintentionally.
174
+ * Commit, do not mess with rakefile, version, or history.
175
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
176
+ * Send me a pull request. Bonus points for topic branches.
177
+
178
+ == Dependencies
179
+
180
+ HTTParty is used for making the HTTP requests and Shoulda and Mocha are used for testing.
181
+ Thanks for these Gems.
182
+
183
+
184
+ == Copyright
185
+
186
+ Copyright (c) 2012 simplificator. See LICENSE for details.
@@ -1,34 +1,36 @@
1
- module Withings
2
- SCALE = 1
3
- BLOOD_PRESSURE_MONITOR = 4
4
-
5
- def self.consumer_secret=(value)
6
- @consumer_secret = value
7
- end
8
-
9
- def self.consumer_secret
10
- raise 'Please specify consumer_secret' unless @consumer_secret
11
- @consumer_secret
12
- end
13
-
14
- def self.consumer_key=(value)
15
- @consumer_key = value
16
- end
17
-
18
- def self.consumer_key
19
- raise 'Please specify consumer_key' unless @consumer_key
20
- @consumer_key
21
- end
22
- end
23
-
24
- # Copied over from ActiveSupport
25
- unless Hash.new.respond_to?(:stringify_keys)
26
- class Hash
27
- def stringify_keys
28
- inject({}) do |options, (key, value)|
29
- options[key.to_s] = value
30
- options
31
- end
32
- end
33
- end
34
- end
1
+ module Withings
2
+ SCALE = 1
3
+ BLOOD_PRESSURE_MONITOR = 4
4
+ PULSE = 16
5
+ SLEEP_MONITOR = 32
6
+
7
+ def self.consumer_secret=(value)
8
+ @consumer_secret = value
9
+ end
10
+
11
+ def self.consumer_secret
12
+ raise 'Please specify consumer_secret' unless @consumer_secret
13
+ @consumer_secret
14
+ end
15
+
16
+ def self.consumer_key=(value)
17
+ @consumer_key = value
18
+ end
19
+
20
+ def self.consumer_key
21
+ raise 'Please specify consumer_key' unless @consumer_key
22
+ @consumer_key
23
+ end
24
+ end
25
+
26
+ # Copied over from ActiveSupport
27
+ unless Hash.new.respond_to?(:stringify_keys)
28
+ class Hash
29
+ def stringify_keys
30
+ inject({}) do |options, (key, value)|
31
+ options[key.to_s] = value
32
+ options
33
+ end
34
+ end
35
+ end
36
+ end