fitgem_oauth2 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fitgem_oauth2.gemspec +1 -1
- data/lib/fitgem_oauth2/activity.rb +34 -1
- data/lib/fitgem_oauth2/client.rb +4 -3
- data/lib/fitgem_oauth2/errors.rb +4 -1
- data/lib/fitgem_oauth2/users.rb +7 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0efccedfb12ab6108ad90cba0ccc374135d0625a
|
4
|
+
data.tar.gz: a4fa19ece3dea0919916967fcc5ac351d01cf02f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8138725e9b7a274f2a55043240664173030e26fd0bd5c5c9a84a26c3b328721715276f28f6d4f2269748df935d13cdc07f7f79288a3f3e58e99f006feb8b87a6
|
7
|
+
data.tar.gz: 84c1594d94978aec4b40a61a17cfca9bb5abe281e51af6eca0d2f7fa969f3d329bfd36f8b6ed26a568e08f27b396e86cf3e3e4831f5d474778c37c2eee31d43e
|
data/fitgem_oauth2.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'fitgem_oauth2'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.5'
|
4
4
|
s.date = '2016-01-18'
|
5
5
|
s.summary = "This gem allows requesting data from Fitbit API using OAuth2"
|
6
6
|
s.description = "This gem allows requesting data from Fitbit API using OAuth2"
|
@@ -4,6 +4,39 @@ module FitgemOauth2
|
|
4
4
|
def activities_on_date(date)
|
5
5
|
get_call("1/user/#{user_id}/activities/date/#{format_date(date)}.json")
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
|
+
def calories_on_date(date)
|
9
|
+
get_call("1/user/#{user_id}/activities/calories/date/#{format_date(date)}/1d.json")
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def intraday_time_series(opts)
|
14
|
+
unless opts[:resource] && [:calories, :steps, :distance, :floors, :elevation].include?(opts[:resource])
|
15
|
+
raise FitgemOauth2::InvalidArgumentError, 'Must specify resource to fetch intraday time series data for. One of (:calories, :steps, :distance, :floors, or :elevation) is required.'
|
16
|
+
end
|
17
|
+
|
18
|
+
unless opts[:date]
|
19
|
+
raise FitgemOauth2::InvalidArgumentError, 'Must specify the date to fetch intraday time series data for.'
|
20
|
+
end
|
21
|
+
|
22
|
+
unless opts[:detailLevel] && %w(1min 15min).include?(opts[:detailLevel])
|
23
|
+
raise FitgemOauth2::InvalidArgumentError, 'Must specify the data resolution to fetch intraday time series data for. One of (\"1d\" or \"15min\") is required.'
|
24
|
+
end
|
25
|
+
|
26
|
+
resource = opts.delete(:resource)
|
27
|
+
date = format_date(opts.delete(:date))
|
28
|
+
detail_level = opts.delete(:detailLevel)
|
29
|
+
time_window_specified = opts[:startTime] || opts[:endTime]
|
30
|
+
resource_path = "1/user/#{@user_id}/activities/"
|
31
|
+
|
32
|
+
if time_window_specified
|
33
|
+
start_time = format_time(opts.delete(:startTime))
|
34
|
+
end_time = format_time(opts.delete(:endTime))
|
35
|
+
resource_path += "#{resource}/date/#{date}/1d/#{detail_level}/time/#{start_time}/#{end_time}.json"
|
36
|
+
else
|
37
|
+
resource_path += "#{resource}/date/#{date}/1d/#{detail_level}.json"
|
38
|
+
end
|
39
|
+
get_call(resource_path)
|
40
|
+
end
|
8
41
|
end
|
9
42
|
end
|
data/lib/fitgem_oauth2/client.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'fitgem_oauth2/activity.rb'
|
2
|
+
require 'fitgem_oauth2/errors.rb'
|
2
3
|
require 'fitgem_oauth2/sleep.rb'
|
3
4
|
require 'fitgem_oauth2/steps.rb'
|
4
|
-
|
5
|
+
require 'fitgem_oauth2/users.rb'
|
5
6
|
require 'fitgem_oauth2/utils.rb'
|
6
7
|
|
7
|
-
|
8
|
+
|
8
9
|
|
9
10
|
require 'base64'
|
10
11
|
require 'faraday'
|
@@ -71,7 +72,7 @@ module FitgemOauth2
|
|
71
72
|
request.params['grant_type'] = "refresh_token"
|
72
73
|
request.params['refresh_token'] = refresh_token
|
73
74
|
end
|
74
|
-
response.body
|
75
|
+
return JSON.parse(response.body)
|
75
76
|
end
|
76
77
|
|
77
78
|
private
|
data/lib/fitgem_oauth2/errors.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fitgem_oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ankit Gupta
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- lib/fitgem_oauth2/errors.rb
|
38
38
|
- lib/fitgem_oauth2/sleep.rb
|
39
39
|
- lib/fitgem_oauth2/steps.rb
|
40
|
+
- lib/fitgem_oauth2/users.rb
|
40
41
|
- lib/fitgem_oauth2/utils.rb
|
41
42
|
homepage: http://rubygems.org/gems/fitgem_oauth2
|
42
43
|
licenses:
|