fitbyte 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/fitbyte.gemspec +1 -1
- data/lib/fitbyte/activities.rb +6 -6
- data/lib/fitbyte/alarms.rb +1 -1
- data/lib/fitbyte/client.rb +6 -4
- data/lib/fitbyte/devices.rb +1 -1
- data/lib/fitbyte/food.rb +5 -5
- data/lib/fitbyte/friends.rb +2 -2
- data/lib/fitbyte/sleep.rb +1 -1
- data/lib/fitbyte/user.rb +2 -2
- data/lib/fitbyte/version.rb +1 -1
- data/lib/fitbyte/water.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c0929d5ecd1f5782f3d45430abda827eca543eb
|
4
|
+
data.tar.gz: 845d2acb693add6da8133eb91c6c08e9d1c7e081
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef1dce7aa4918838809507224e5b5de7de343360101a17de5e12b47760fc82a5288c5fc9f65e7636354c2f5aa886537456f08f5c58d9149f3c58bca6d0b2201c
|
7
|
+
data.tar.gz: f51087241477988a0482c136689d1b196cfd7aa4cd5eac2ac61248c02befe9e0ed89b3cb5c1a2179fe82db67fd5a1f0633b8012bf15a0532a8b70079dea0621e
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Fitbyte
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/fitbyte.svg)](https://badge.fury.io/rb/fitbyte)
|
4
|
+
|
5
|
+
This gem allows interaction with [Fitbit's REST API](https://dev.fitbit.com/docs/basics/), using the OAuth 2.0 protocol for user authorization.
|
4
6
|
|
5
7
|
**Note:** Fitbit's API is currently in beta, and is in active/rapid development. Breaking changes to certain endpoints may be introduced during early development of this gem, until Fitbit's API solidifies.
|
6
8
|
|
@@ -18,14 +20,14 @@ gem "fitbyte"
|
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
To use the Fitbit API, you must register your application at [dev.fitbit.com](https://dev.fitbit.com/apps). After registering, you should have access to **CLIENT ID**, **CLIENT SECRET**, and **REDIRECT URI** values for use in instantiating a *Fitbyte::Client* object.
|
23
|
+
To use the Fitbit API, you must register your application at [dev.fitbit.com](https://dev.fitbit.com/apps). After registering, you should have access to **CLIENT ID**, **CLIENT SECRET**, and **REDIRECT URI (Callback URL)** values for use in instantiating a *Fitbyte::Client* object.
|
22
24
|
|
23
25
|
- Create a client instance:
|
24
26
|
|
25
27
|
```ruby
|
26
28
|
client = Fitbyte::Client.new(client_id: my_client_id,
|
27
29
|
client_secret: my_client_secret,
|
28
|
-
redirect_uri: "http://example.com")
|
30
|
+
redirect_uri: "http://example.com/handle/callback")
|
29
31
|
```
|
30
32
|
|
31
33
|
- Generate a link for the Fitbit authorization page:
|
data/fitbyte.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Zoran Pesic"]
|
10
10
|
spec.email = ["zoran1991@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
12
|
+
spec.summary = %q{This gem allows interaction with Fitbit's REST API, using OAuth2 for user authorization.}
|
13
13
|
spec.homepage = Fitbyte::REPO_URL
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/lib/fitbyte/activities.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
module Fitbyte
|
2
2
|
class Client
|
3
3
|
def daily_activity_summary(date=Date.today)
|
4
|
-
get("user
|
4
|
+
get("user/#{@user_id}/activities/date/#{format_date(date)}.json")
|
5
5
|
end
|
6
6
|
|
7
7
|
def frequent_activities
|
8
|
-
get("user
|
8
|
+
get("user/#{@user_id}/activities/frequent.json")
|
9
9
|
end
|
10
10
|
|
11
11
|
def favorite_activities
|
12
|
-
get("user
|
12
|
+
get("user/#{@user_id}/activities/favorite.json")
|
13
13
|
end
|
14
14
|
|
15
15
|
def all_activities
|
@@ -17,15 +17,15 @@ module Fitbyte
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def lifetime_stats
|
20
|
-
get("user
|
20
|
+
get("user/#{@user_id}/activities.json")
|
21
21
|
end
|
22
22
|
|
23
23
|
def daily_goals
|
24
|
-
get("user
|
24
|
+
get("user/#{@user_id}/activities/goals/daily.json")
|
25
25
|
end
|
26
26
|
|
27
27
|
def weekly_goals
|
28
|
-
get("user
|
28
|
+
get("user/#{@user_id}/activities/goals/weekly.json")
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/fitbyte/alarms.rb
CHANGED
data/lib/fitbyte/client.rb
CHANGED
@@ -41,6 +41,8 @@ module Fitbyte
|
|
41
41
|
|
42
42
|
def get_token(auth_code)
|
43
43
|
@token = @client.auth_code.get_token(auth_code, redirect_uri: @redirect_uri, headers: auth_header)
|
44
|
+
@user_id = @token.params["user_id"]
|
45
|
+
return @token
|
44
46
|
end
|
45
47
|
|
46
48
|
def token
|
@@ -63,6 +65,10 @@ module Fitbyte
|
|
63
65
|
}
|
64
66
|
end
|
65
67
|
|
68
|
+
def get(path)
|
69
|
+
JSON.parse(token.get(("#{@api_version}/" + path), headers: request_headers).response.body)
|
70
|
+
end
|
71
|
+
|
66
72
|
def defaults
|
67
73
|
{
|
68
74
|
site_url: "https://api.fitbit.com",
|
@@ -73,9 +79,5 @@ module Fitbyte
|
|
73
79
|
locale: "en_US"
|
74
80
|
}
|
75
81
|
end
|
76
|
-
|
77
|
-
def get(path)
|
78
|
-
JSON.parse(token.get(("#{@api_version}/" + path), headers: request_headers).response.body)
|
79
|
-
end
|
80
82
|
end
|
81
83
|
end
|
data/lib/fitbyte/devices.rb
CHANGED
data/lib/fitbyte/food.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
module Fitbyte
|
2
2
|
class Client
|
3
3
|
def food_logs(date=Date.today)
|
4
|
-
get("user
|
4
|
+
get("user/#{@user_id}/foods/log/date/#{format_date(date)}.json")
|
5
5
|
end
|
6
6
|
|
7
7
|
def recent_foods
|
8
|
-
get("user
|
8
|
+
get("user/#{@user_id}/foods/recent.json")
|
9
9
|
end
|
10
10
|
|
11
11
|
def frequent_foods
|
12
|
-
get("user
|
12
|
+
get("user/#{@user_id}/foods/log/frequent.json")
|
13
13
|
end
|
14
14
|
|
15
15
|
def favorite_foods
|
16
|
-
get("user
|
16
|
+
get("user/#{@user_id}/foods/log/favorite.json")
|
17
17
|
end
|
18
18
|
|
19
19
|
def food_goals
|
20
|
-
get("user
|
20
|
+
get("user/#{@user_id}/foods/log/goal.json")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/lib/fitbyte/friends.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Fitbyte
|
2
2
|
class Client
|
3
3
|
def friends
|
4
|
-
get("user
|
4
|
+
get("user/#{@user_id}/friends.json")
|
5
5
|
end
|
6
6
|
|
7
7
|
def friends_leaderboard
|
8
|
-
get("user
|
8
|
+
get("user/#{@user_id}/friends/leaderboard.json")
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/lib/fitbyte/sleep.rb
CHANGED
data/lib/fitbyte/user.rb
CHANGED
data/lib/fitbyte/version.rb
CHANGED
data/lib/fitbyte/water.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fitbyte
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zoran Pesic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|
@@ -119,6 +119,6 @@ rubyforge_project:
|
|
119
119
|
rubygems_version: 2.4.5
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
|
-
summary:
|
122
|
+
summary: This gem allows interaction with Fitbit's REST API, using OAuth2 for user
|
123
123
|
authorization.
|
124
124
|
test_files: []
|