simplificator-withings 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+ *.gem
data/README.rdoc CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
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
4
 
5
+
6
+ == Installation ==
7
+
8
+ gem install simplificator-withings
9
+
10
+
5
11
  == How To ==
6
12
 
7
13
  See sample.rb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/withings/user.rb CHANGED
@@ -1,4 +1,13 @@
1
1
  class Withings::User
2
+
3
+ def self.authenticate(email_or_user_id, password_or_public_key)
4
+ if email_or_user_id.include?('@')
5
+ by_email(email_or_user_id, password_or_public_key)
6
+ else
7
+ by_user_id(email_or_user_id, password_or_public_key)
8
+ end
9
+ end
10
+
2
11
  # Authenticate by email and password
3
12
  def self.by_email(email, password)
4
13
  response = Connection.get_request('/account', :action => :getuserslist, :email => email, :hash => auth_hash(email, password))
data/sample.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  require 'rubygems'
2
- require 'lib/withings'
2
+ require 'withings'
3
3
 
4
4
  # All classes are name-spaced
5
5
  include Withings
6
6
 
7
7
  # A user can be authenticated with email address and password
8
- user = User.by_email('<YOUR EMAIL ADDRESS>', '<YOUR PASSWORD>')
8
+ user = User.authenticate('<YOUR EMAIL ADDRESS>', '<YOUR PASSWORD>')
9
9
 
10
10
  # Or you can fetch details if you have the user id and public key
11
- user = User.by_user_id('<YOUR USER ID>', '<YOUR PUBLIC KEY>')
11
+ user = User.authenticate('<YOUR USER ID>', '<YOUR PUBLIC KEY>')
12
12
 
13
13
  # or if you already have user id and public key, you can create ir yourself
14
14
  user = User.new(:user_id => '<YOUR USER ID>', :public_key => '<YOUR PUBLIC_KEY>')
@@ -26,4 +26,4 @@ user.describe_notification('http://foo.bar.com')
26
26
  user.revoke_notification('http://foo.bar.com')
27
27
 
28
28
  # list measurement groups
29
- puts user.measurement_groups(:per_page => 10, :page => 1, :end_at => Time.now).join("\n")
29
+ user.measurement_groups(:per_page => 10, :page => 1, :end_at => Time.now).join("\n")
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - pascalbetz