fitgem 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -64,29 +64,33 @@ The docs are very fuzzy on subscription support at the moment; we definitely pla
64
64
 
65
65
  There is a good looking gem called [ruby-fitbit](https://github.com/danmayer/ruby-fitbit "ruby-fitbit") that
66
66
  also aims to collect data from the site. It was created before they released their REST API and uses screen-scraping to gather the data rather than through their API. I looked into forking it and refactoring
67
- to use the new API but after looking through the code I felt it would be more of a total rewrite and so decided
67
+ to use the new API but after looking through the code I felt it would be more of a total rewrite and so decided
68
68
  to create a new gem that I could design from scratch.
69
69
 
70
70
  ## Why the Name Change? ##
71
71
 
72
72
  It turns out that Fitbit.com does not want people to create libraries or applications that incorporate the name 'fitbit'. So, on May 12th I changed the name of the project/gem from 'fitbit' to 'fitgem'.
73
73
 
74
-
75
74
  # Changelog #
76
75
 
76
+ * 12 July, 2011:
77
+ * Added friends support (get friends, friend leaderboard, create invites, accept/reject invites)
78
+ * Added water support (get water data per date)
79
+ * Added sleep support (get sleep data per date)
80
+ * Added ability to update user profile information
77
81
  * 12 May, 2011:
78
82
  * Changed name and all references of this project from 'fitbit' to 'fitgem'
79
83
  * 11 April, 2011:
80
84
  * Fixed an issue where blank user id's are used and an error is thrown.
81
85
  * Added support for creating/removing subscriptions (this support is experimental for now, more tests coming)
82
- * 24 March, 2011:
86
+ * 24 March, 2011:
83
87
  * Added logging of activities and foods
84
88
  * Added ability to add favorite activities and foods
85
89
  * Added ability to delete logged activities and foods, and remove favorite activities and foods
86
90
  * Refactored data_by_time_range for more testability
87
91
  * Added ability to query devices
88
- * 19 March, 2011:
89
- * Updated auth client to support first-time auth and reconnections (if you have previously been authorized and received token/secret).
92
+ * 19 March, 2011:
93
+ * Updated auth client to support first-time auth and reconnections (if you have previously been authorized and received token/secret).
90
94
  * Added 'named' retrieval of activities and foods (recent_, favorite_, frequent_)
91
95
  * Added ability to log weight back to the site using the API
92
96
  * 18 March, 2001: First revision. Supports the auth process via oauth, and retrieval of user info and activities.
@@ -98,7 +102,7 @@ To be clear: __I am not employed by fitbit.com__. I created this library to ass
98
102
  # Contributing to fitgem #
99
103
 
100
104
  The Fitbit REST API is in BETA right now, and so it will quite likely change over time (though I can't be sure whether it will be additive change or change of the non-backwards-compatible variety). I aim to keep as up-to-date as I can but if you absolutely need functionality that isn't included here, feel free to fork and implement it, then send me a pull request.
101
-
105
+
102
106
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
103
107
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
104
108
  * Fork the project
data/lib/fitgem.rb CHANGED
@@ -4,5 +4,5 @@ require 'oauth'
4
4
  require 'fitgem/client'
5
5
 
6
6
  module Fitgem
7
- VERSION = "0.2.2"
7
+ VERSION = "0.3.0"
8
8
  end
data/lib/fitgem/client.rb CHANGED
@@ -2,8 +2,11 @@ require 'fitgem/helpers'
2
2
  require 'fitgem/errors'
3
3
  require 'fitgem/users'
4
4
  require 'fitgem/activities'
5
+ require 'fitgem/sleep'
6
+ require 'fitgem/water'
5
7
  require 'fitgem/units'
6
8
  require 'fitgem/foods'
9
+ require 'fitgem/friends'
7
10
  require 'fitgem/body_measurements'
8
11
  require 'fitgem/time_range'
9
12
  require 'fitgem/devices'
@@ -0,0 +1,51 @@
1
+ module Fitgem
2
+ class Client
3
+
4
+ # ==========================================
5
+ # Friend Retrieval Methods
6
+ # ==========================================
7
+ def friends
8
+ get("/user/#{@user_id}/friends.json")
9
+ end
10
+
11
+ def weekly_leaderboard
12
+ leaderboard('7d')
13
+ end
14
+
15
+ def monthly_leaderboard
16
+ leaderboard('30d')
17
+ end
18
+
19
+ # ==========================================
20
+ # Invitation Management Methods
21
+ # ==========================================
22
+ def invite_friend(options)
23
+ unless options[:email] || options[:user_id]
24
+ raise InvalidArgumentError.new "add_friend hash argument must include :email or :user_id"
25
+ end
26
+ translated_options = {}
27
+ translated_options[:invitedUserEmail] = options[:email] if options[:email]
28
+ translated_options[:invitedUserId] = options[:user_id] if options[:user_id]
29
+ post("/user/#{@user_id}/friends/invitations.json", translated_options)
30
+ end
31
+
32
+ def accept_invite(requestor_id)
33
+ respond_to_invite(requestor_id, true)
34
+ end
35
+
36
+ def decline_invite(requestor_id)
37
+ respond_to_invite(requestor_id, false)
38
+ end
39
+
40
+ private
41
+
42
+ def leaderboard(range)
43
+ get("/user/#{@user_id}/friends/leaderboard/#{range}.json")
44
+ end
45
+
46
+ def respond_to_invite(requestor_id, does_accept)
47
+ options = { :accept => does_accept.to_s }
48
+ post("/user/#{@user_id}/friends/invitations/#{requestor_id}.json", options)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,12 @@
1
+ module Fitgem
2
+ class Client
3
+
4
+ # ==========================================
5
+ # Sleep Retrieval Methods
6
+ # ==========================================
7
+ def sleep_on_date(date)
8
+ get("/user/#{@user_id}/sleep/date/#{format_date(date)}.json")
9
+ end
10
+
11
+ end
12
+ end
data/lib/fitgem/users.rb CHANGED
@@ -1,9 +1,19 @@
1
1
  module Fitgem
2
2
  class Client
3
-
4
- def user_info(options = {})
3
+
4
+ def user_info(options = {})
5
5
  get("/user/#{@user_id}/profile.json")
6
6
  end
7
-
7
+
8
+ # options[:gender] optional Gender; (MALE/FEMALE/NA)
9
+ # options[:birthday] optional Date of Birth; in the format yyyy-MM-dd
10
+ # options[:height] optional Height
11
+ # options[:nickname] optional Nickname
12
+ # options[:fullName] optional Full name
13
+ # options[:timezone] optional Timezone; in the format "America/Los_Angeles"
14
+ def update_user_info(options)
15
+ post("/user/#{@user_id}/profile.json", options)
16
+ end
17
+
8
18
  end
9
19
  end
@@ -0,0 +1,12 @@
1
+ module Fitgem
2
+ class Client
3
+
4
+ # ==========================================
5
+ # Water Retrieval Methods
6
+ # ==========================================
7
+ def water_on_date(date)
8
+ get("/user/#{@user_id}/foods/log/water/date/#{format_date(date)}.json")
9
+ end
10
+
11
+ end
12
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: fitgem
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.2
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Zachery Moneypenny
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-01 00:00:00 -05:00
13
+ date: 2011-07-12 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -104,11 +104,14 @@ files:
104
104
  - lib/fitgem/devices.rb
105
105
  - lib/fitgem/errors.rb
106
106
  - lib/fitgem/foods.rb
107
+ - lib/fitgem/friends.rb
107
108
  - lib/fitgem/helpers.rb
108
109
  - lib/fitgem/notifications.rb
110
+ - lib/fitgem/sleep.rb
109
111
  - lib/fitgem/time_range.rb
110
112
  - lib/fitgem/units.rb
111
113
  - lib/fitgem/users.rb
114
+ - lib/fitgem/water.rb
112
115
  - spec/fitgem_spec.rb
113
116
  - spec/spec_helper.rb
114
117
  has_rdoc: true