fitbit_api 0.14.1 → 0.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/fitbit_api/client.rb +28 -0
- data/lib/fitbit_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 417f3489c6b33f4acc4d8eebf14048c5a50b4f86905679f04a436472aea67bd7
|
4
|
+
data.tar.gz: 01ebe9bcc0db08753267015b0ac50a4950c8394c1f7b8563298d2b7657544007
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66c83ce386d49728e5ec75f4e343c18a015f776c6cc8b8721ff1c4e2700098ece8f1c6b2c3788a7cc1521d3f1302319f25552ea7a1a70b0b9a93ffd0d8e47d52
|
7
|
+
data.tar.gz: 4e97184f094af8aed5a1fd8ea427a9be8c128ebbe439990a8c933a3463c7b8ddb0b31b64ce512d5998118a8f1988aa0ed56ad6009f6045e282d06fc131723bc3
|
data/CHANGELOG.md
CHANGED
data/lib/fitbit_api/client.rb
CHANGED
@@ -31,10 +31,16 @@ module FitbitAPI
|
|
31
31
|
establish_token(opts)
|
32
32
|
end
|
33
33
|
|
34
|
+
# Returns the authorize endpoint URL of the OAuth2 provider.
|
35
|
+
|
34
36
|
def auth_url
|
35
37
|
@client.auth_code.authorize_url(redirect_uri: @redirect_uri, scope: @scope)
|
36
38
|
end
|
37
39
|
|
40
|
+
# Returns an OAuth2::AccessToken instance obtained from the given authorization code.
|
41
|
+
#
|
42
|
+
# @param auth_code [String] An authorization code
|
43
|
+
|
38
44
|
def get_token(auth_code)
|
39
45
|
@token = @client.auth_code.get_token(
|
40
46
|
auth_code,
|
@@ -45,6 +51,8 @@ module FitbitAPI
|
|
45
51
|
@token
|
46
52
|
end
|
47
53
|
|
54
|
+
# Refreshes the current Access Token.
|
55
|
+
|
48
56
|
def refresh_token!
|
49
57
|
@token = @token.refresh!(headers: auth_headers)
|
50
58
|
@user_id ||= @token.params['user_id']
|
@@ -53,6 +61,8 @@ module FitbitAPI
|
|
53
61
|
@token
|
54
62
|
end
|
55
63
|
|
64
|
+
# Revokes the user's authorizations and all associated tokens.
|
65
|
+
|
56
66
|
def revoke_token!
|
57
67
|
body = { token: token.token }
|
58
68
|
headers = default_request_headers.merge(auth_headers)
|
@@ -61,14 +71,32 @@ module FitbitAPI
|
|
61
71
|
process_keys!(MultiJson.load(response.body))
|
62
72
|
end
|
63
73
|
|
74
|
+
# Performs an authorized GET request to the configured API namespace.
|
75
|
+
#
|
76
|
+
# @param path [String] The request path
|
77
|
+
# @param params [Hash] The query parameters
|
78
|
+
# @param opts [Hash] Additional request options (e.g. headers)
|
79
|
+
|
64
80
|
def get(path, params={}, opts={}, &block)
|
65
81
|
request(:get, path, opts.merge(params: params), &block)
|
66
82
|
end
|
67
83
|
|
84
|
+
# Performs an authorized POST request to the configured API namespace.
|
85
|
+
#
|
86
|
+
# @param path [String] The request path
|
87
|
+
# @param body [Hash] The request body
|
88
|
+
# @param opts [Hash] Additional request options (e.g. headers)
|
89
|
+
|
68
90
|
def post(path, body={}, opts={}, &block)
|
69
91
|
request(:post, path, opts.merge(body: body), &block)
|
70
92
|
end
|
71
93
|
|
94
|
+
# Performs an authorized DELETE request to the configured API namespace.
|
95
|
+
#
|
96
|
+
# @param path [String] The request path
|
97
|
+
# @param params [Hash] The query parameters
|
98
|
+
# @param opts [Hash] Additional request options (e.g. headers)
|
99
|
+
|
72
100
|
def delete(path, params={}, opts={}, &block)
|
73
101
|
request(:delete, path, opts.merge(params: params), &block)
|
74
102
|
end
|
data/lib/fitbit_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fitbit_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zoran
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|