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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d0655317d528786ceaf0f17b6c784cc8b5efeb1
4
- data.tar.gz: 619f36cf862d95e9ddde9e8d1f77e6bd9cbfb7e3
3
+ metadata.gz: 0c0929d5ecd1f5782f3d45430abda827eca543eb
4
+ data.tar.gz: 845d2acb693add6da8133eb91c6c08e9d1c7e081
5
5
  SHA512:
6
- metadata.gz: 09a3f33748d49d7bfcc248fb72a776c80bc4051fb3b894230d67c0f07e01c202729aef6fef5b89fbaa265ca0f81574bcbeaa20312915654b4ed3a3352e35fc1d
7
- data.tar.gz: 30275329df704750b1b8178bfedd01d022e949c8a382b29a2e21ae42ca7528f8a57c99f42513e8844b66f6219eeb9ecd85e3dd68c86bb83a80e58bba52d5da86
6
+ metadata.gz: ef1dce7aa4918838809507224e5b5de7de343360101a17de5e12b47760fc82a5288c5fc9f65e7636354c2f5aa886537456f08f5c58d9149f3c58bca6d0b2201c
7
+ data.tar.gz: f51087241477988a0482c136689d1b196cfd7aa4cd5eac2ac61248c02befe9e0ed89b3cb5c1a2179fe82db67fd5a1f0633b8012bf15a0532a8b70079dea0621e
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Fitbyte
2
2
 
3
- Fitbyte is a gem that allows interaction with [Fitbit's REST API](https://dev.fitbit.com/docs/basics/), using the OAuth 2.0 protocol for user authorization.
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:
@@ -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{A gem that allows interaction with Fitbit's REST API, using OAuth2 for user authorization.}
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
 
@@ -1,15 +1,15 @@
1
1
  module Fitbyte
2
2
  class Client
3
3
  def daily_activity_summary(date=Date.today)
4
- get("user/-/activities/date/#{format_date(date)}.json")
4
+ get("user/#{@user_id}/activities/date/#{format_date(date)}.json")
5
5
  end
6
6
 
7
7
  def frequent_activities
8
- get("user/-/activities/frequent.json")
8
+ get("user/#{@user_id}/activities/frequent.json")
9
9
  end
10
10
 
11
11
  def favorite_activities
12
- get("user/-/activities/favorite.json")
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/-/activities.json")
20
+ get("user/#{@user_id}/activities.json")
21
21
  end
22
22
 
23
23
  def daily_goals
24
- get("user/-/activities/goals/daily.json")
24
+ get("user/#{@user_id}/activities/goals/daily.json")
25
25
  end
26
26
 
27
27
  def weekly_goals
28
- get("user/-/activities/goals/weekly.json")
28
+ get("user/#{@user_id}/activities/goals/weekly.json")
29
29
  end
30
30
  end
31
31
  end
@@ -1,7 +1,7 @@
1
1
  module Fitbyte
2
2
  class Client
3
3
  def alarms(tracker_id)
4
- get("user/-/devices/tracker/#{tracker_id}/alarms.json")
4
+ get("user/#{@user_id}/devices/tracker/#{tracker_id}/alarms.json")
5
5
  end
6
6
  end
7
7
  end
@@ -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
@@ -1,7 +1,7 @@
1
1
  module Fitbyte
2
2
  class Client
3
3
  def devices
4
- get("user/-/devices.json")
4
+ get("user/#{@user_id}/devices.json")
5
5
  end
6
6
  end
7
7
  end
@@ -1,23 +1,23 @@
1
1
  module Fitbyte
2
2
  class Client
3
3
  def food_logs(date=Date.today)
4
- get("user/-/foods/log/date/#{format_date(date)}.json")
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/-/foods/recent.json")
8
+ get("user/#{@user_id}/foods/recent.json")
9
9
  end
10
10
 
11
11
  def frequent_foods
12
- get("user/-/foods/log/frequent.json")
12
+ get("user/#{@user_id}/foods/log/frequent.json")
13
13
  end
14
14
 
15
15
  def favorite_foods
16
- get("user/-/foods/log/favorite.json")
16
+ get("user/#{@user_id}/foods/log/favorite.json")
17
17
  end
18
18
 
19
19
  def food_goals
20
- get("user/-/foods/log/goal.json")
20
+ get("user/#{@user_id}/foods/log/goal.json")
21
21
  end
22
22
  end
23
23
  end
@@ -1,11 +1,11 @@
1
1
  module Fitbyte
2
2
  class Client
3
3
  def friends
4
- get("user/-/friends.json")
4
+ get("user/#{@user_id}/friends.json")
5
5
  end
6
6
 
7
7
  def friends_leaderboard
8
- get("user/-/friends/leaderboard.json")
8
+ get("user/#{@user_id}/friends/leaderboard.json")
9
9
  end
10
10
  end
11
11
  end
@@ -1,7 +1,7 @@
1
1
  module Fitbyte
2
2
  class Client
3
3
  def sleep_logs(date=Date.today)
4
- get("user/-/sleep/date/#{format_date(date)}.json")
4
+ get("user/#{@user_id}/sleep/date/#{format_date(date)}.json")
5
5
  end
6
6
  end
7
7
  end
@@ -1,11 +1,11 @@
1
1
  module Fitbyte
2
2
  class Client
3
3
  def profile
4
- get("user/-/profile.json")
4
+ get("user/#{@user_id}/profile.json")
5
5
  end
6
6
 
7
7
  def badges
8
- get("user/-/badges.json")
8
+ get("user/#{@user_id}/badges.json")
9
9
  end
10
10
  end
11
11
  end
@@ -1,4 +1,4 @@
1
1
  module Fitbyte
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  REPO_URL = "https://github.com/zokioki/fitbyte"
4
4
  end
@@ -1,7 +1,7 @@
1
1
  module Fitbyte
2
2
  class Client
3
3
  def water_logs(date=Date.today)
4
- get("user/-/foods/log/water/date/#{format_date(date)}.json")
4
+ get("user/#{@user_id}/foods/log/water/date/#{format_date(date)}.json")
5
5
  end
6
6
  end
7
7
  end
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.0
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 00:00:00.000000000 Z
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: A gem that allows interaction with Fitbit's REST API, using OAuth2 for user
122
+ summary: This gem allows interaction with Fitbit's REST API, using OAuth2 for user
123
123
  authorization.
124
124
  test_files: []