fitgem 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5aaeb0e1f4c0baea6b4d4b4e3a49625b8263d18f
4
+ data.tar.gz: e89fd2e5c2fb3694bfca85a311ef13dff614f7f2
5
+ SHA512:
6
+ metadata.gz: 5b7334843303227af479383f16a012a8445ca6ccf584ace5c54cf34f9dc23bb883e586e48dbd02657922c03d27e984f0600fb925a6d64c614364ff2c26039655
7
+ data.tar.gz: 8611b499e6fd9108d4d5fefca76226a296ff88d7695015423b8315fb937916af0cebc6bedf3173e345dc0bcef2c822e791641d468cc074e892ce386a3aff449a
data/.gitignore CHANGED
@@ -6,4 +6,5 @@ pkg/*
6
6
  test*.rb
7
7
  *.dmp
8
8
  .fitgem.yml
9
- .idea
9
+ .idea
10
+ .rvmrc
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm ruby-1.9.3-p327@fitgem --create
1
+ rvm use 2.0.0@fitgem --create
data/.travis.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  rvm:
2
- - 1.9.2
3
2
  - 1.9.3
3
+ - 2.0.0
data/README.md CHANGED
@@ -1,50 +1,31 @@
1
1
  # Fitgem [![Build Status](https://secure.travis-ci.org/whazzmaster/fitgem.png)](http://travis-ci.org/whazzmaster/fitgem)
2
2
 
3
- Provides access to fitbit.com data through their OAuth/REST API. Fitgem can pull data with or without user
4
- authentication. Without user authentication, any data that the a fitbit.com user has denoted as 'public' can be
5
- gathered. If a user logs in via OAuth then all exposed data can be gathered.
3
+ Provides access to [fitbit.com](http://www.fitbit.com) data through [their API](http://dev.fitbit.com). Fitgem can pull data with or without usernauthentication. Without user authentication, any data that the a fitbit.com user has denoted as 'public' can be gathered. If a user logs in via OAuth then all exposed data can be gathered.
6
4
 
7
- The [Fitbit API](https://wiki.fitbit.com/display/API/Fitbit+API) is currently in BETA and is under
8
- development to extend its reach. Since it is early in the lifecycle of the API I expect this gem to go through a number
9
- of revisions as we attempt to match the functionality of their platform.
5
+ The [Fitbit API](https://wiki.fitbit.com/display/API/Fitbit+API) is currently in BETA and is under development to extend its reach. Since it is early in the lifecycle of the API I expect this gem to go through a number of revisions as we attempt to match the functionality of their platform.
10
6
 
11
7
  # Usage
12
8
 
13
9
  Install fitgem:
14
- ```
10
+
11
+ ```bash
15
12
  $ gem install fitgem
16
13
  ```
17
-
18
14
  Comprehensive method documentation is [available online](http://www.rubydoc.info/github/whazzmaster/fitgem/frames).
19
15
 
20
- [The wiki has information](https://github.com/whazzmaster/fitgem/wiki/The-OAuth-Process) on how to use fitgem in the
21
- OAuth handshake with [fitbit.com](http://www.fitbit.com). You may also be interested in using
22
- [omniauth-fitbit](https://github.com/tkgospodinov/omniauth-fitbit) to integrate Fitbit accounts into your web
23
- application.
16
+ The best way to connect your users to the Fitbit API is to use
17
+ **[omniauth-fitbit](https://github.com/tkgospodinov/omniauth-fitbit)** to integrate Fitbit accounts into your web
18
+ application. Once you have a Fitbit API OAuth `access_token` for a user it's simple to create a client object through fitgem to send and receive fitness data.
24
19
 
25
- ## Usage in a Rails Application
26
-
27
- We've started to develop an example app using the fitgem client.
28
- See [https://github.com/whazzmaster/fitgem-client](https://github.com/whazzmaster/fitgem-client) for more information or
29
- check out [the hosted version](http://www.fitbitclient.com). The fitgem-client project is evolving more slowly than the
30
- library itself, but work continues.
20
+ **Go to [http://fitbitclient.com](http://fitbitclient.com) to view online documentation on how to use fitgem**. The reference app includes information on how to use some bench test tools to get acquainted with the library, and the application code itself (Rails 3.2 + Backbone.js) is also [available online](https://github.com/whazzmaster/fitgem-client) to illustrate how the live data from Fitbit is manipulated by the application.
31
21
 
32
22
  # Subscriptions
33
23
 
34
- The Fitbit API allows for you to set up notification subscription so that when values change (via automatic syncs with
35
- the fitbit device) your applications can be notified automatically. You can set up a default subscription callback URL
36
- via the [Fitbit dev site](https://dev.fitbit.com/ 'Fitbit Developer Site') and then use the Subscriptions API to add or
37
- remove subscriptions for individual users.
38
-
39
- __Currently, notification management is experimental in this gem__. There is currently code to add, remove, and list
40
- subscriptions (foods, activities, sleep, body, and all collections).
24
+ The Fitbit API allows for you to set up notification subscription so that when values change (via automatic syncs with the fitbit device) your applications can be notified automatically. You can set up a default subscription callback URL via the [Fitbit dev site](https://dev.fitbit.com/ 'Fitbit Developer Site') and then use the Subscriptions API to add or remove subscriptions for individual users.
41
25
 
42
- # Contributing to fitgem #
26
+ # Help Improve Fitgem!
43
27
 
44
- 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
45
- 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
46
- if you absolutely need functionality that isn't included here, feel free to fork and implement it, then send me a pull
47
- request.
28
+ 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**.
48
29
 
49
30
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
50
31
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
@@ -57,13 +38,9 @@ necessary, that is fine, but please isolate to its own commit so I can cherry-pi
57
38
 
58
39
  ## Contributors
59
40
 
60
- Many thanks to everyone that has contributed to improve fitgem!
61
-
62
- [https://github.com/whazzmaster/fitgem/graphs/contributors](https://github.com/whazzmaster/fitgem/graphs/contributors)
41
+ **Many, many thanks** to [everyone that has contributed to improve fitgem](https://github.com/whazzmaster/fitgem/graphs/contributors)!
63
42
 
64
43
  # Copyright & Disclaimer
65
44
 
66
- Copyright (c) 2011-2012 Zachery Moneypenny. See LICENSE for further details. __I am not employed by fitbit.com__. I
67
- created this library to assist other ruby developers in creating interesting applications on top of fitbit.com's
68
- data store and device data stream.
45
+ Copyright © 2011-2013 Zachery Moneypenny. See LICENSE for further details. __I am not employed by fitbit.com__. I created this library to assist other ruby developers in creating interesting applications on top of fitbit.com's data store and device data stream.
69
46
 
@@ -89,7 +89,7 @@ module Fitgem
89
89
  # @option opts [String, Integer] :durationMillis Activity duration in milliseconds.
90
90
  # Must be a numeric value in Integer or String format. This value is REQUIRED for all calls.
91
91
  # @option opts [String] :startTime Activity start time, in the format "HH:mm" using hours
92
- # and seconds. Thie value is REQUIRED for all calls.
92
+ # and seconds. This value is REQUIRED for all calls.
93
93
  # @option opts [String] :date Activity date, in "yyyy-MM-dd" format. This value is REQUIRED for all calls.
94
94
  #
95
95
  # @option opts [String] :distance Distance traveled, a string in the format "X.XX". This value is
@@ -139,5 +139,52 @@ module Fitgem
139
139
  def remove_favorite_activity(activity_id)
140
140
  delete("/user/#{@user_id}/activities/log/favorite/#{activity_id}.json")
141
141
  end
142
+
143
+ # ==========================================
144
+ # Intraday Activity Data Methods
145
+ # ==========================================
146
+
147
+ # Get intraday time series data for the specified resource
148
+ #
149
+ # @option opts [Symbol] :resource The sub-resource you want to retrieve time series data for; must
150
+ # be one of :calories, :steps, :floors, or :elevation. This value is REQUIRED for all calls.
151
+ # @option opts [String, Datetime, Date] :date The date to retrieve a time series on. This value is
152
+ # REQUIRED for all calls.
153
+ # @option opts [String] :detailLevel The resolution of the time series data; must be one of "1min"
154
+ # or "15min".
155
+ #
156
+ # @options opts [DateTime, Time, String] :startTime The start of the time period to request data for.
157
+ # @options opts [DateTime, Time, String] :endTime The end of the time period to request data for.
158
+ #
159
+ # @return [Hash] A hash containing time series data
160
+ def intraday_time_series(opts)
161
+ unless opts[:resource] && [:calories, :steps, :floors, :elevation].include?(opts[:resource])
162
+ raise Fitgem::InvalidArgumentError, 'Must specify resource to fetch intraday time series data for. One of (:calories, :steps, :floors, or :elevation) is required.'
163
+ end
164
+
165
+ unless opts[:date]
166
+ raise Fitgem::InvalidArgumentError, 'Must specify the date to fetch intraday time series data for.'
167
+ end
168
+
169
+ unless opts[:detailLevel] && %w(1min 15min).include?(opts[:detailLevel])
170
+ raise Fitgem::InvalidArgumentError, 'Must specify the data resolution to fetch intraday time series data for. One of (\"1d\" or \"15min\") is required.'
171
+ end
172
+
173
+ resource = opts.delete(:resource)
174
+ date = format_date(opts.delete(:date))
175
+ detail_level = opts.delete(:detailLevel)
176
+ time_window_specified = opts[:startTime] || opts[:endTime]
177
+ resource_path = "/user/#{@user_id}/activities/"
178
+
179
+ if time_window_specified
180
+ start_time = format_time(opts.delete(:startTime))
181
+ end_time = format_time(opts.delete(:endTime))
182
+ resource_path += "#{resource}/date/#{date}/1d/#{detail_level}/time/#{start_time}/#{end_time}.json"
183
+ else
184
+ resource_path += "#{resource}/date/#{date}/1d/#{detail_level}.json"
185
+ end
186
+
187
+ get(resource_path, opts)
188
+ end
142
189
  end
143
190
  end
data/lib/fitgem/client.rb CHANGED
@@ -39,7 +39,7 @@ module Fitgem
39
39
  # :consumer_key => my_key,
40
40
  # :consumer_secret => my_secret,
41
41
  # :token => fitbit_oauth_token,
42
- # :secret => :fitbit_oauth_secret,
42
+ # :secret => fitbit_oauth_secret,
43
43
  # :unit_system => Fitgem::ApiUnitSystem.METRIC
44
44
  # }
45
45
  attr_accessor :api_unit_system
@@ -1,3 +1,3 @@
1
1
  module Fitgem
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7.0"
3
3
  end
data/spec/fitgem_spec.rb CHANGED
@@ -8,7 +8,7 @@ describe Fitgem do
8
8
  })
9
9
  end
10
10
 
11
- describe "global settings" do
11
+ describe 'global settings' do
12
12
  it 'should expose the api_version' do
13
13
  @client.api_version.should == "1"
14
14
  end
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fitgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
5
- prerelease:
4
+ version: 0.7.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Zachery Moneypenny
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-28 00:00:00.000000000 Z
11
+ date: 2013-05-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: oauth
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: yard
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rdiscount
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: A client library to send and retrieve workout, weight, and diet data
@@ -137,33 +126,26 @@ files:
137
126
  - spec/fitgem_constructor_spec.rb
138
127
  homepage: http://github.com/whazzmaster/fitgem
139
128
  licenses: []
129
+ metadata: {}
140
130
  post_install_message:
141
131
  rdoc_options: []
142
132
  require_paths:
143
133
  - lib
144
134
  required_ruby_version: !ruby/object:Gem::Requirement
145
- none: false
146
135
  requirements:
147
- - - ! '>='
136
+ - - '>='
148
137
  - !ruby/object:Gem::Version
149
138
  version: '0'
150
- segments:
151
- - 0
152
- hash: 3756517255535395412
153
139
  required_rubygems_version: !ruby/object:Gem::Requirement
154
- none: false
155
140
  requirements:
156
- - - ! '>='
141
+ - - '>='
157
142
  - !ruby/object:Gem::Version
158
143
  version: '0'
159
- segments:
160
- - 0
161
- hash: 3756517255535395412
162
144
  requirements: []
163
145
  rubyforge_project: fitgem
164
- rubygems_version: 1.8.24
146
+ rubygems_version: 2.0.3
165
147
  signing_key:
166
- specification_version: 3
148
+ specification_version: 4
167
149
  summary: OAuth client library to the data on fitbit.com
168
150
  test_files:
169
151
  - spec/fitgem_spec.rb