rjawbone 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +121 -0
- data/app/helpers/jawbone/rails/jawbone_helper.rb +11 -0
- data/lib/rjawbone/api/moves.rb +1 -1
- data/lib/rjawbone/api/sleeps.rb +16 -1
- data/lib/rjawbone/rails.rb +6 -0
- data/lib/rjawbone/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfc7014b01b14972ce975bdbae8d42b48fa540d6
|
4
|
+
data.tar.gz: d25108a6faba246f304309765b29fdcec79a1c1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1874eef6085d99dd154f5b10a81b7c0d3b5936d158206c3012b551da3f25e8b30c53e6015de697204099e84bbc94dabea93f2d203c3e35d3d0fc8b49b6ab64e
|
7
|
+
data.tar.gz: 8b6b146bc4b92976c25dcd6bca235d65bfad5cc7117242976faeede0fe05d2d4ba312362e2c34bd764fe3cd4c1386b52e274075f532c2298a8cd44415eb24346
|
data/README.md
CHANGED
@@ -1,7 +1,128 @@
|
|
1
1
|
# Rjawbone
|
2
2
|
|
3
|
+
<dl>
|
4
|
+
<dt>Homepage</dt><dd><a href="#">homepage</a></dd>
|
5
|
+
<dt>Author</dt><dd><a href="">Taylor Daugherty</a></dd>
|
6
|
+
<dt>Documentation</dt><dd><a href="#">Ruby Gems</a></dd>
|
7
|
+
</dl>
|
8
|
+
|
9
|
+
[](https://badge.fury.io/rb/rjawbone)
|
3
10
|
[](https://travis-ci.org/tylrd/rjawbone)
|
4
11
|
[](https://codeclimate.com/github/tylrd/rjawbone)
|
5
12
|
[](https://codeclimate.com/github/tylrd/rjawbone/coverage)
|
6
13
|
[](http://inch-ci.org/github/tylrd/rjawbone)
|
7
14
|
[](https://gemnasium.com/tylrd/rjawbone)
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem install rjawbone
|
20
|
+
```
|
21
|
+
|
22
|
+
|
23
|
+
## Configuration
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Rjawbone.configure do |config|
|
27
|
+
config.client_id = ENV['JAWBONE_CLIENT']
|
28
|
+
config.client_secret = ENV['JAWBONE_SECRET']
|
29
|
+
config.redirect_uri = redirect_uri
|
30
|
+
config.scope = %w(basic_read sleep_read move_read) # any scope you need here
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
For a rails project, you can put this in `config/initializers/rjawbone.rb`.
|
35
|
+
|
36
|
+
|
37
|
+
## Authentication
|
38
|
+
|
39
|
+
This gem provides two helper methods for following the OAuth 2.0 flow.
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
# Returns a url for your configured jawbone application
|
43
|
+
Rjawbone::Oauth.authorization_url
|
44
|
+
|
45
|
+
# Exchanges the authorization code for an access token
|
46
|
+
Rjawbone::Oauth.exchange_code(code)
|
47
|
+
```
|
48
|
+
|
49
|
+
After obtaining an access token, you will need to persist it.
|
50
|
+
|
51
|
+
[Here](https://jawbone.com/up/developer/authentication) you can read about the authorization flow.
|
52
|
+
|
53
|
+
## Client
|
54
|
+
|
55
|
+
The API calls are made by initializing a Rjawbone client object.
|
56
|
+
|
57
|
+
The ACCESS_TOKEN is retrieved from the Authentication step.
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
Rjawbone::Client.new(access_token: ACCESS_TOKEN, refresh_token: REFRESH)
|
61
|
+
|
62
|
+
# OR
|
63
|
+
|
64
|
+
Rjawbone::Client.new do |config|
|
65
|
+
config.access_token = TOKEN
|
66
|
+
config.refresh_token = REFRESH
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
After initializing the client object, you can retrieve any object allowed by your configured scope.
|
71
|
+
|
72
|
+
|
73
|
+
## Resources
|
74
|
+
|
75
|
+
#### Lists
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
# Returns a Rjawbone::Model::List object
|
79
|
+
list = client.moves
|
80
|
+
|
81
|
+
# The list has a collection attribute, composed of Rjawbone::Model::Item objects
|
82
|
+
# The list object has methods that assist in retrieving information
|
83
|
+
|
84
|
+
# Pagination
|
85
|
+
list.next_page
|
86
|
+
|
87
|
+
# Enumerability
|
88
|
+
list.map {|move| move.xid }
|
89
|
+
list.select {|move| move.details.distance >= 5000}
|
90
|
+
```
|
91
|
+
|
92
|
+
#### Items
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
# The item object has all the fields from the raw API response
|
96
|
+
# When a "sleep" or "move" type, the Rjawbone::Model::Item can implement the #ticks method
|
97
|
+
|
98
|
+
list = client.moves
|
99
|
+
move = list.first
|
100
|
+
|
101
|
+
# Returns a Rjawbone::Model::List of objects of "ticks"
|
102
|
+
# The ticks associated with that move resource
|
103
|
+
ticks = move.ticks
|
104
|
+
|
105
|
+
# These ticks are a list, so include enumerablity and pagination methods
|
106
|
+
ticks.reject {|tick| tick.steps <= 50}
|
107
|
+
ticks = client.moves.map {|item| item.ticks}
|
108
|
+
```
|
109
|
+
|
110
|
+
#### Resources
|
111
|
+
|
112
|
+
Implemented endpoints:
|
113
|
+
- moves
|
114
|
+
- sleeps
|
115
|
+
- heartrates
|
116
|
+
|
117
|
+
## TODO
|
118
|
+
|
119
|
+
- band_events
|
120
|
+
- body_events
|
121
|
+
- goals
|
122
|
+
- meals
|
123
|
+
- mood
|
124
|
+
- settings
|
125
|
+
- timezone
|
126
|
+
- trends
|
127
|
+
- friends
|
128
|
+
|
data/lib/rjawbone/api/moves.rb
CHANGED
data/lib/rjawbone/api/sleeps.rb
CHANGED
@@ -2,10 +2,25 @@ module Rjawbone
|
|
2
2
|
module API
|
3
3
|
module Sleeps
|
4
4
|
|
5
|
-
def
|
5
|
+
def sleeps
|
6
6
|
get_object(Rjawbone::SLEEPS_USER, Rjawbone::Model::List)
|
7
7
|
end
|
8
8
|
|
9
|
+
def sleep_details(xid, params = {})
|
10
|
+
url = "#{Rjawbone::SLEEPS_ENDPOINT}/#{xid}"
|
11
|
+
get_object(build_endpoint(url, params), Rjawbone::Model::Details)
|
12
|
+
end
|
13
|
+
|
14
|
+
def sleeps_graph(xid, params = {})
|
15
|
+
endpoint = "#{Rjawbone::MOVES_ENDPOINT}/#{xid}/image"
|
16
|
+
# TODO
|
17
|
+
end
|
18
|
+
|
19
|
+
def sleep_ticks(xid, params = {})
|
20
|
+
url = "#{Rjawbone::MOVES_ENDPOINT}/#{xid}/ticks"
|
21
|
+
get_object(build_endpoint(url, params), Rjawbone::Model::List)
|
22
|
+
end
|
23
|
+
|
9
24
|
end
|
10
25
|
end
|
11
26
|
end
|
data/lib/rjawbone/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjawbone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Daugherty
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- LICENSE.txt
|
167
167
|
- README.md
|
168
168
|
- Rakefile
|
169
|
+
- app/helpers/jawbone/rails/jawbone_helper.rb
|
169
170
|
- bin/console
|
170
171
|
- bin/setup
|
171
172
|
- exe/jawbone
|
@@ -183,6 +184,7 @@ files:
|
|
183
184
|
- lib/rjawbone/models/list.rb
|
184
185
|
- lib/rjawbone/models/sleeps.rb
|
185
186
|
- lib/rjawbone/oauth.rb
|
187
|
+
- lib/rjawbone/rails.rb
|
186
188
|
- lib/rjawbone/utils.rb
|
187
189
|
- lib/rjawbone/version.rb
|
188
190
|
- rjawbone.gemspec
|