fitgem 0.10.0 → 0.11.0

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: 95d4e7ae922736d2f4d8093c43988e563c2a2fae
4
- data.tar.gz: 1c018275740218d4adc237efd254740cf9656153
3
+ metadata.gz: 83ba31846e167d458f59cebdd7402d1e504b3fec
4
+ data.tar.gz: 74bacff3769f0a5e390582a347f5b9f8200be40f
5
5
  SHA512:
6
- metadata.gz: ff191fe963d6291b1ed8cf97be3b606e0dc5a27fab0696d2927d012d7774760b61cbe7064c207194b2fcd43e7248cb9c9a8f767661e0e6d2974648d02d187f06
7
- data.tar.gz: fee32faa7cfa3137dd711f71a1461d04fa1a30cc7951e03674d1da8b81adedac05be14c92f68ea45f6eba546878ee4e1362df08d4d78cc668fd584e50dca4a4d
6
+ metadata.gz: 31af46def4469ddaf15e8d0e97ac15d137079f9c0ad06df4a5098ef8fca038083224755759bc7f9f69e8432cd1cf9e0dfc304125ef1291220e325a8447f98697
7
+ data.tar.gz: 46206bae93b252713dea225cc1bb2286d773f750d23f06d269c4453a16ae14bc0e526c4cd47217c6ba95999ed035d07d64c7e4ac37f94206a62218ea64dd0a86
data/README.md CHANGED
@@ -19,29 +19,38 @@ gem 'fitgem'
19
19
  ```
20
20
 
21
21
  ## API Reference
22
-
23
- Comprehensive method documentation is [available online](http://www.rubydoc.info/github/whazzmaster/fitgem/frames).
22
+ Comprehensive method documentation is [available online](http://www.rubydoc.info/gems/fitbit/0.2.0/frames).
24
23
 
25
24
  The best way to connect your users to the Fitbit API is to use
26
- [omniauth-fitbit](https://github.com/tkgospodinov/omniauth-fitbit) to integrate Fitbit accounts into your web 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.
25
+ [omniauth-fitbit](https://github.com/tkgospodinov/omniauth-fitbit) to integrate
26
+ Fitbit accounts into your web application. Once you have a Fitbit API OAuth
27
+ `access_token` for a user it's simple to create a client object through fitgem
28
+ to send and receive fitness data.
27
29
 
28
30
  ## Subscriptions
29
-
30
- The Fitbit API allows for you to set up notification subscriptions. When user data changes (through syncing 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.
31
+ The Fitbit API allows for you to set up notification subscriptions. When user
32
+ data changes (through syncing with the fitbit device) your applications can be
33
+ notified automatically. You can set up a default subscription callback URL via
34
+ the [Fitbit dev site](https://dev.fitbit.com/ 'Fitbit Developer Site') and then
35
+ use the Subscriptions API to add or remove subscriptions for individual users.
31
36
 
32
37
  ## Reference Application
38
+ To learn more about how to use fitgem in a Rails application, go to
39
+ [http://fitbitclient.com](http://fitbitclient.com) or see the code at
40
+ [https://github.com/whazzmaster/fitgem-client](https://github.com/whazzmaster/fitgem-client).
33
41
 
34
- To learn more about how to use fitgem in a Rails application, go to [http://fitbitclient.com](http://fitbitclient.com) or see the code at [https://github.com/whazzmaster/fitgem-client](https://github.com/whazzmaster/fitgem-client).
35
-
36
- The reference app is written using Rails 3.2 and [Backbone.js](http://backbonejs.org) and includes examples on how to:
42
+ The reference app is written using Rails 3.2 and
43
+ [Backbone.js](http://backbonejs.org) and includes examples on how to:
37
44
 
38
45
  * Integrate OAuth logins [omniauth-fitbit](https://github.com/tkgospodinov/omniauth-fitbit)
39
46
  * Store and use OAuth access tokens
40
47
  * Create and use instances of `Fitgem::Client` using the stored OAuth access token
41
48
 
42
49
  ## Contributing to Fitgem
43
-
44
- The Fitbit REST API is in BETA right now, and so it will quite likely change over time. 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**.
50
+ The Fitbit REST API is in BETA right now, and so it will quite likely change
51
+ over time. I aim to keep as up-to-date as I can but if you absolutely need
52
+ functionality that isn't included here, **feel free to fork and implement it,
53
+ then send me a pull request**.
45
54
 
46
55
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
47
56
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
@@ -58,4 +67,5 @@ necessary, that is fine, but please isolate to its own commit so I can cherry-pi
58
67
 
59
68
  ## Copyright & Disclaimer
60
69
 
61
- Copyright © 2011-2013 Zachery Moneypenny. See LICENSE for further details. __I am not employed by [Fitbit](http://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.
70
+ Copyright © 2011-2015 Zachery Moneypenny. See LICENSE for further details.
71
+ __I am not employed by [Fitbit](http://fitbit.com)__.
@@ -146,6 +146,7 @@ module Fitgem
146
146
  # needed to make API calls, since it is stored internally. It is
147
147
  # returned so that you may make general OAuth calls if need be.
148
148
  def reconnect(token, secret)
149
+ @access_token = nil
149
150
  @token = token
150
151
  @secret = secret
151
152
  access_token
@@ -181,6 +182,7 @@ module Fitgem
181
182
  def consumer
182
183
  @consumer ||= OAuth::Consumer.new(@consumer_key, @consumer_secret, {
183
184
  :site => 'https://api.fitbit.com',
185
+ :authorize_url => 'https://www.fitbit.com/oauth/authorize',
184
186
  :proxy => @proxy
185
187
  })
186
188
  end
@@ -219,8 +221,12 @@ module Fitgem
219
221
  access_token.delete(uri, headers)
220
222
  end
221
223
 
222
- def extract_response_body(resp)
223
- resp.nil? || resp.body.nil? ? {} : JSON.parse(resp.body)
224
+ def extract_response_body(response)
225
+ return {} if response.nil?
226
+
227
+ raise ServiceUnavailableError if response.code == '503'
228
+
229
+ response.body.nil? ? {} : JSON.parse(response.body)
224
230
  end
225
231
  end
226
232
  end
@@ -25,4 +25,7 @@ module Fitgem
25
25
 
26
26
  class DeprecatedApiError < Exception
27
27
  end
28
+
29
+ class ServiceUnavailableError < Exception
30
+ end
28
31
  end
@@ -1,3 +1,3 @@
1
1
  module Fitgem
2
- VERSION = '0.10.0'
2
+ VERSION = '0.11.0'
3
3
  end
@@ -56,7 +56,7 @@ describe Fitgem::Client do
56
56
 
57
57
  it "returns the code and the JSON body in an array" do
58
58
  opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320", :use_subscription_id => true }
59
- expect(@resp).to receive(:code)
59
+ expect(@resp).to receive(:code).twice
60
60
  expect(@client.create_subscription(opts)).to be_a(Array)
61
61
  end
62
62
  end
@@ -87,7 +87,7 @@ describe Fitgem::Client do
87
87
 
88
88
  it "returns the code and the JSON body in an array" do
89
89
  opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320", :use_subscription_id => true }
90
- expect(@resp).to receive(:code)
90
+ expect(@resp).to receive(:code).twice
91
91
  expect(@client.remove_subscription(opts)).to be_a(Array)
92
92
  end
93
93
  end
@@ -33,4 +33,16 @@ describe Fitgem do
33
33
  expect(@client.user_id).to eq '-'
34
34
  end
35
35
  end
36
+
37
+ describe '#reconnect' do
38
+ it 'resets the access token' do
39
+ access_token = @client.reconnect('abc', '123')
40
+ expect(access_token.token).to eq('abc')
41
+ expect(access_token.secret).to eq('123')
42
+
43
+ access_token = @client.reconnect('def', '456')
44
+ expect(access_token.token).to eq('def')
45
+ expect(access_token.secret).to eq('456')
46
+ end
47
+ end
36
48
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fitgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachery Moneypenny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-08 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
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
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 3.0.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 3.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdiscount
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: A client library to send and retrieve workout, weight, and diet data
@@ -88,9 +88,9 @@ executables: []
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
- - .gitignore
92
- - .travis.yml
93
- - .yardopts
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - ".yardopts"
94
94
  - Gemfile
95
95
  - Guardfile
96
96
  - LICENSE
@@ -134,17 +134,17 @@ require_paths:
134
134
  - lib
135
135
  required_ruby_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - '>='
137
+ - - ">="
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  requirements:
142
- - - '>='
142
+ - - ">="
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
146
  rubyforge_project: fitgem
147
- rubygems_version: 2.2.2
147
+ rubygems_version: 2.4.5
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: OAuth client library to the data on fitbit.com