fitgem_oauth2 2.0.1 → 2.1.0
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 +22 -22
- data/lib/fitgem_oauth2.rb +6 -6
- data/lib/fitgem_oauth2/activity.rb +209 -209
- data/lib/fitgem_oauth2/body_measurements.rb +163 -163
- data/lib/fitgem_oauth2/client.rb +126 -126
- data/lib/fitgem_oauth2/devices.rb +45 -45
- data/lib/fitgem_oauth2/errors.rb +30 -30
- data/lib/fitgem_oauth2/food.rb +27 -27
- data/lib/fitgem_oauth2/food/collection.rb +51 -51
- data/lib/fitgem_oauth2/food/metadata.rb +63 -63
- data/lib/fitgem_oauth2/food/series.rb +55 -55
- data/lib/fitgem_oauth2/friends.rb +44 -44
- data/lib/fitgem_oauth2/heartrate.rb +85 -85
- data/lib/fitgem_oauth2/sleep.rb +86 -86
- data/lib/fitgem_oauth2/subscriptions.rb +32 -32
- data/lib/fitgem_oauth2/users.rb +7 -7
- data/lib/fitgem_oauth2/utils.rb +48 -48
- data/lib/fitgem_oauth2/version.rb +3 -3
- metadata +5 -5
data/lib/fitgem_oauth2/users.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
module FitgemOauth2
|
2
|
-
class Client
|
3
|
-
def user_info
|
4
|
-
get_call("user/#{user_id}/profile.json")
|
5
|
-
end
|
6
|
-
end
|
7
|
-
end
|
1
|
+
module FitgemOauth2
|
2
|
+
class Client
|
3
|
+
def user_info
|
4
|
+
get_call("user/#{user_id}/profile.json")
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
data/lib/fitgem_oauth2/utils.rb
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
module FitgemOauth2
|
2
|
-
class Client
|
3
|
-
def format_date(date)
|
4
|
-
|
5
|
-
return nil if date.nil?
|
6
|
-
|
7
|
-
valid_semantic_date = %w[today yesterday].include? date
|
8
|
-
valid_date_string = (date =~ /\d{4}\-\d{2}\-\d{2}/) == 0
|
9
|
-
if valid_date_string
|
10
|
-
date
|
11
|
-
elsif valid_semantic_date
|
12
|
-
date_from_semantic(date)
|
13
|
-
elsif date.is_a?(Date) || date.is_a?(Time) || date.is_a?(DateTime)
|
14
|
-
date.strftime('%Y-%m-%d')
|
15
|
-
else
|
16
|
-
raise FitgemOauth2::InvalidDateArgument, "Date used must be a date/time object or a string in the format YYYY-MM-DD; supplied argument is a #{date.class}"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def format_time(time)
|
21
|
-
if (time =~ /\d{2}:\d{2}/) == 0
|
22
|
-
time
|
23
|
-
elsif time.is_a?(DateTime) || time.is_a?(Time)
|
24
|
-
time.strftime('%H:%M')
|
25
|
-
else
|
26
|
-
raise FitgemOauth2::InvalidTimeArgument, "Time used must be a DateTime/Time object or a string in the format hh:mm; supplied argument is a #{time.class}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def validate_start_date(start_date)
|
31
|
-
raise FitgemOauth2::InvalidArgumentError, 'Please specify a valid start date.' unless start_date
|
32
|
-
end
|
33
|
-
|
34
|
-
def validate_end_date(end_date)
|
35
|
-
raise FitgemOauth2::InvalidArgumentError, 'Please specify a valid end date.' unless end_date
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def date_from_semantic(semantic)
|
41
|
-
if semantic === 'yesterday'
|
42
|
-
(Date.today - 1).strftime('%Y-%m-%d')
|
43
|
-
elsif semantic == 'today'
|
44
|
-
Date.today.strftime('%Y-%m-%d')
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
1
|
+
module FitgemOauth2
|
2
|
+
class Client
|
3
|
+
def format_date(date)
|
4
|
+
|
5
|
+
return nil if date.nil?
|
6
|
+
|
7
|
+
valid_semantic_date = %w[today yesterday].include? date
|
8
|
+
valid_date_string = (date =~ /\d{4}\-\d{2}\-\d{2}/) == 0
|
9
|
+
if valid_date_string
|
10
|
+
date
|
11
|
+
elsif valid_semantic_date
|
12
|
+
date_from_semantic(date)
|
13
|
+
elsif date.is_a?(Date) || date.is_a?(Time) || date.is_a?(DateTime)
|
14
|
+
date.strftime('%Y-%m-%d')
|
15
|
+
else
|
16
|
+
raise FitgemOauth2::InvalidDateArgument, "Date used must be a date/time object or a string in the format YYYY-MM-DD; supplied argument is a #{date.class}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def format_time(time)
|
21
|
+
if (time =~ /\d{2}:\d{2}/) == 0
|
22
|
+
time
|
23
|
+
elsif time.is_a?(DateTime) || time.is_a?(Time)
|
24
|
+
time.strftime('%H:%M')
|
25
|
+
else
|
26
|
+
raise FitgemOauth2::InvalidTimeArgument, "Time used must be a DateTime/Time object or a string in the format hh:mm; supplied argument is a #{time.class}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def validate_start_date(start_date)
|
31
|
+
raise FitgemOauth2::InvalidArgumentError, 'Please specify a valid start date.' unless start_date
|
32
|
+
end
|
33
|
+
|
34
|
+
def validate_end_date(end_date)
|
35
|
+
raise FitgemOauth2::InvalidArgumentError, 'Please specify a valid end date.' unless end_date
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def date_from_semantic(semantic)
|
41
|
+
if semantic === 'yesterday'
|
42
|
+
(Date.today - 1).strftime('%Y-%m-%d')
|
43
|
+
elsif semantic == 'today'
|
44
|
+
Date.today.strftime('%Y-%m-%d')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module FitgemOauth2
|
2
|
-
VERSION = '2.0
|
3
|
-
end
|
1
|
+
module FitgemOauth2
|
2
|
+
VERSION = '2.1.0'.freeze
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fitgem_oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ankit Gupta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 12.3.3
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 12.3.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
|
-
rubygems_version: 3.0.
|
112
|
+
rubygems_version: 3.0.3
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Fitbit API client library
|