Skip to content
This repository was archived by the owner on Jun 13, 2020. It is now read-only.

Commit 07543a1

Browse files
committed
Merge pull request #9 from ryanseys/v.1.1
Update to API v.1.1
2 parents b090587 + 67c86c2 commit 07543a1

30 files changed

+244
-9173
lines changed

.gitignore

Whitespace-only changes.

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Contributing
2+
3+
I love contributions! :smile:
4+
5+
## I found an issue / I want a feature!
6+
7+
That's great! Let me know by filing an issue [on Github](https://github.com/ryanseys/node-jawbone-up/issues)
8+
9+
## I want to fix a bug!
10+
11+
Fork [the repo](https://github.com/ryanseys/node-jawbone-up), make your changes (preferably in a new branch), push them back to GitHub and send a pull request!
12+
13+
Check out how to [create a pull request](https://help.github.com/articles/creating-a-pull-request) for additional help.
14+
15+
## Additional Resources
16+
17+
[Jawbone Up Official API Documentation](https://jawbone.com/up/developer/)

README.md

Lines changed: 86 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
Jawbone UP API Node.js Library
44

5-
<b>
6-
NOTE: The UP API was recently updated to version 1.1, although they will continue to support version 1.0. This library is currently operational under API version 1.0 however I plan to update it to 1.1 once exams at school pass. =)
7-
</b>
5+
API Version: v.1.1
86

97
If you would like to contribute to this project in any way, including to update it to support API v1.1, please send me a pull request!
108

@@ -25,10 +23,13 @@ See below for an example of how this could be done. This library does not
2523
assist in getting an `access_token` through OAuth, but once you get the token,
2624
it will apparently last for a **year**.
2725

26+
A `client_secret` attribute is required if you would like to use `up.refreshToken.get()` to get new refresh tokens. It is not required otherwise.
27+
2828
```javascript
2929
var options = {
3030
// ** REQUIRED **
31-
access_token: 'xyz' // Access token for specific user
31+
access_token: 'xyz' // Access token for specific user,
32+
client_secret: 'abc' // Client Secret (required for up.refreshToken.get())
3233
}
3334

3435
var up = require('jawbone-up')(options);
@@ -38,25 +39,6 @@ var up = require('jawbone-up')(options);
3839

3940
Official UP API can be found at [jawbone.com/up/developer](https://jawbone.com/up/developer/)
4041

41-
Generated documentation for this library is hosted at [ryanseys.github.io/node-jawbone-up/docs](http://ryanseys.github.io/node-jawbone-up/docs/)
42-
43-
You can also generate the docs yourself:
44-
45-
```
46-
npm install
47-
node_modules/.bin/jsdoc . -d docs
48-
```
49-
50-
Or see below for an overview...
51-
52-
The callback function will follow the format as specified below:
53-
54-
```javascript
55-
function callback(err, body) {
56-
// do stuff
57-
}
58-
```
59-
6042
Example callback:
6143

6244
```javascript
@@ -77,178 +59,199 @@ function callback(err, body) {
7759

7860
```javascript
7961
// get user info
80-
up.me.get({}, callback) // GET /nudge/api/v.1.0/users/@me
62+
up.me.get({}, callback) // GET /nudge/api/v.1.1/users/@me/
8163

8264
// get friends of user
83-
up.friends.get({}, callback) // GET /nudge/api/v.1.0/users/@me/friends
65+
up.friends.get({}, callback) // GET /nudge/api/v.1.1/users/@me/friends
8466

8567
// get mood of user
86-
up.mood.get({}, callback) // GET /nudge/api/v.1.0/users/@me/mood
68+
up.mood.get({}, callback) // GET /nudge/api/v.1.1/users/@me/mood
8769

8870
// get trends of user
89-
up.trends.get({}, callback) // GET /nudge/api/v.1.0/users/@me/trends
71+
up.trends.get({}, callback) // GET /nudge/api/v.1.1/users/@me/trends
9072

9173
// get goals of user
92-
up.goals.get({}, callback) // GET /nudge/api/v.1.0/users/@me/goals
74+
up.goals.get({}, callback) // GET /nudge/api/v.1.1/users/@me/goals
9375
```
9476

9577
## Moves
9678

97-
[Moves Documentation](http://ryanseys.github.io/node-jawbone-up/docs/moves.html)
98-
9979
```javascript
10080
// get all moves (paginated results)
101-
up.moves.get({}, callback) // GET /nudge/api/v.1.0/users/@me/moves
81+
up.moves.get({}, callback) // GET /nudge/api/v.1.1/users/@me/moves
10282

10383
// get a specific moves
104-
up.moves.get({ xid : move_xid }, callback) // GET /nudge/api/v.1.0/moves/{move_xid}
84+
up.moves.get({ xid : move_xid }, callback) // GET /nudge/api/v.1.1/moves/{move_xid}
10585

10686
// get a specific move image
107-
up.moves.image({ xid : move_xid }, callback) // GET /nudge/api/v.1.0/moves/{move_xid}/image
87+
up.moves.image({ xid : move_xid }, callback) // GET /nudge/api/v.1.1/moves/{move_xid}/image
10888

10989
// get a specific move intensity
110-
up.moves.snapshot({ xid : move_xid }, callback) // GET /nudge/api/v.1.0/moves/{move_xid}/snapshot
90+
up.moves.ticks({ xid : move_xid }, callback) // GET /nudge/api/v.1.1/moves/{move_xid}/ticks
11191
```
11292

11393
## Workouts
11494

115-
[Workouts Documentation](http://ryanseys.github.io/node-jawbone-up/docs/workouts.html)
116-
11795
```javascript
11896
// get all workouts (paginated results)
119-
up.workouts.get({}, callback) // GET /nudge/api/v.1.0/users/@me/workouts
97+
up.workouts.get({}, callback) // GET /nudge/api/v.1.1/users/@me/workouts
12098

12199
// create a new workout
122-
up.workouts.create(options, callback) // POST /nudge/api/v.1.0/users/@me/workouts
100+
up.workouts.create(options, callback) // POST /nudge/api/v.1.1/users/@me/workouts
123101

124102
// get a specific workout
125-
up.workouts.get({ xid : workout_xid }, callback) // GET /nudge/api/v.1.0/workouts/{workout_xid}
103+
up.workouts.get({ xid : workout_xid }, callback) // GET /nudge/api/v.1.1/workouts/{workout_xid}
104+
105+
// update a specific workout
106+
up.workouts.update(options, callback) // POST https://jawbone.com/nudge/api/v.1.1/workouts/{xid}/partialUpdate
126107

127108
// get a specific workout image
128-
up.workouts.image({ xid : workout_xid }, callback) // GET /nudge/api/v.1.0/workouts/{workout_xid}/image
109+
up.workouts.image({ xid : workout_xid }, callback) // GET /nudge/api/v.1.1/workouts/{workout_xid}/image
129110

130111
// get a specific workout intensity
131-
up.workouts.snapshot({ xid : workout_xid }, callback) // GET /nudge/api/v.1.0/workouts/{workout_xid}/snapshot
112+
up.workouts.ticks({ xid : workout_xid }, callback) // GET /nudge/api/v.1.1/workouts/{workout_xid}/ticks
132113
```
133114

134115
## Sleeps
135116

136-
[Sleeps Documentation](http://ryanseys.github.io/node-jawbone-up/docs/sleeps.html)
137-
138117
```javascript
139118
// get all sleeps (paginated results)
140-
up.sleeps.get({}, callback) // GET /nudge/api/v.1.0/users/@me/sleeps
119+
up.sleeps.get({}, callback) // GET /nudge/api/v.1.1/users/@me/sleeps
141120

142121
// get a specific sleep
143-
up.sleeps.get({ xid : sleep_xid }, callback) // GET /nudge/api/v.1.0/sleeps/{sleep_xid}
122+
up.sleeps.get({ xid : sleep_xid }, callback) // GET /nudge/api/v.1.1/sleeps/{sleep_xid}
144123

145124
// create a new sleep
146-
up.sleeps.create(options, callback) // POST /nudge/api/v.1.0/users/@me/sleeps
125+
up.sleeps.create(options, callback) // POST /nudge/api/v.1.1/users/@me/sleeps
147126

148127
// get a specific sleep image
149-
up.sleeps.image({ xid : sleep_xid }, callback) // GET /nudge/api/v.1.0/sleeps/{sleep_xid}/image
128+
up.sleeps.image({ xid : sleep_xid }, callback) // GET /nudge/api/v.1.1/sleeps/{sleep_xid}/image
150129

151-
// get a specific sleep snapshot
152-
up.sleeps.snapshot({ xid : sleep_xid }, callback) // GET /nudge/api/v.1.0/sleeps/{sleep_xid}/snapshot
130+
// get a specific sleep ticks
131+
up.sleeps.ticks({ xid : sleep_xid }, callback) // GET /nudge/api/v.1.1/sleeps/{sleep_xid}/ticks
153132

154133
// delete a specific sleep
155-
up.sleeps.delete({ xid : sleep_xid }, callback) // DELETE /nudge/api/v.1.0/sleeps/{sleep_xid}
134+
up.sleeps.delete({ xid : sleep_xid }, callback) // DELETE /nudge/api/v.1.1/sleeps/{sleep_xid}
156135
```
157136

158137
## Meals
159138

160-
[Meals Documentation](http://ryanseys.github.io/node-jawbone-up/docs/meals.html)
161-
162139
```javascript
163140
// get all meals (paginated results)
164-
up.meals.get({}, callback) // GET /nudge/api/v.1.0/users/@me/meals
141+
up.meals.get({}, callback) // GET /nudge/api/v.1.1/users/@me/meals
165142

166143
// create a new meal
167-
up.meals.create(options, callback) // POST /nudge/api/v.1.0/users/@me/meals
144+
up.meals.create(options, callback) // POST /nudge/api/v.1.1/users/@me/meals
145+
146+
// update a specific meal
147+
up.meals.update(options, callback) // POST https://jawbone.com/nudge/api/v.1.1/meals/{xid}/partialUpdate
168148

169149
// get a specific meal
170-
up.meals.get({ xid : meal_xid }, callback) // GET /nudge/api/v.1.0/meals/{meal_xid}
150+
up.meals.get({ xid : meal_xid }, callback) // GET /nudge/api/v.1.1/meals/{meal_xid}
171151
```
172152

173153
## Body Composition
174154

175-
[Body Events Documentation](http://ryanseys.github.io/node-jawbone-up/docs/events.body.html)
176-
177155
```javascript
178156
// get all body events (paginated results)
179-
up.events.body.get({}, callback) // GET /nudge/api/v.1.0/users/@me/body_events
157+
up.events.body.get({}, callback) // GET /nudge/api/v.1.1/users/@me/body_events
180158

181159
// get a specific body event
182-
up.events.body.get({ xid : event_xid }, callback) // GET /nudge/api/v.1.0/body_events/{event_xid}
160+
up.events.body.get({ xid : event_xid }, callback) // GET /nudge/api/v.1.1/body_events/{event_xid}
183161

184162
// create a new body event
185-
up.events.body.create(options, callback) // POST /nudge/api/v.1.0/users/@me/body_events
163+
up.events.body.create(options, callback) // POST /nudge/api/v.1.1/users/@me/body_events
186164

187165
// delete a specific body event
188-
up.events.body.delete({ xid : event_xid }, callback) // DELETE /nudge/api/v.1.0/body_events/{event_xid}
166+
up.events.body.delete({ xid : event_xid }, callback) // DELETE /nudge/api/v.1.1/body_events/{event_xid}
189167
```
190168

191169
## Cardiac Metrics
192170

193-
[Cardiac Events Documentation](http://ryanseys.github.io/node-jawbone-up/docs/events.cardiac.html)
194-
195171
```javascript
196172
// get all cardiac events (paginated results)
197-
up.events.cardiac.get({}, callback) // GET /nudge/api/v.1.0/users/@me/cardiac_events
173+
up.events.cardiac.get({}, callback) // GET /nudge/api/v.1.1/users/@me/cardiac_events
198174

199175
// get a specific cardiac event
200-
up.events.cardiac.get({ xid : event_xid }, callback) // GET /nudge/api/v.1.0/cardiac_events/{event_xid}
176+
up.events.cardiac.get({ xid : event_xid }, callback) // GET /nudge/api/v.1.1/cardiac_events/{event_xid}
201177

202178
// create a new cardiac event
203-
up.events.cardiac.create(options, callback) // POST /nudge/api/v.1.0/users/@me/cardiac_events
179+
up.events.cardiac.create(options, callback) // POST /nudge/api/v.1.1/users/@me/cardiac_events
204180

205181
// delete a specific cardiac event
206-
up.events.cardiac.delete({ xid : event_xid }, callback) // DELETE /nudge/api/v.1.0/cardiac_events/{event_xid}
182+
up.events.cardiac.delete({ xid : event_xid }, callback) // DELETE /nudge/api/v.1.1/cardiac_events/{event_xid}
207183
```
208184

209185
## Generic Events
210186

211-
[Generic Events Documentation](http://ryanseys.github.io/node-jawbone-up/docs/events.generic.html)
212-
213187
```javascript
214188
// get all generic events (paginated results)
215-
up.events.generic.get({}, callback) // GET /nudge/api/v.1.0/users/@me/generic_events
189+
up.events.generic.get({}, callback) // GET /nudge/api/v.1.1/users/@me/generic_events
216190

217191
// get a specific generic event
218-
up.events.generic.get({ xid : event_xid }, callback) // GET /nudge/api/v.1.0/generic_events/{event_xid}
192+
up.events.generic.get({ xid : event_xid }, callback) // GET /nudge/api/v.1.1/generic_events/{event_xid}
219193

220194
// create a new generic event
221-
up.events.generic.create(options, callback) // POST /nudge/api/v.1.0/users/@me/generic_events
195+
up.events.generic.create(options, callback) // POST /nudge/api/v.1.1/users/@me/generic_events
196+
197+
// update an existing generic event
198+
up.events.generic.update(options, callback) // POST /nudge/api/v.1.1/users/@me/generic_events/{xid}/partialUpdate
222199

223200
// delete a specific generic event
224-
up.events.generic.delete({ xid : event_xid }, callback) // DELETE /nudge/api/v.1.0/generic_events/{event_xid}
201+
up.events.generic.delete({ xid : event_xid }, callback) // DELETE /nudge/api/v.1.1/generic_events/{event_xid}
225202
```
226203

227204
## Mood
228205

229-
[Mood Documentation](http://ryanseys.github.io/node-jawbone-up/docs/mood.html)
230-
231206
```javascript
232207
// get all moods (paginated results)
233-
up.mood.get({}, callback) // GET /nudge/api/v.1.0/users/@me/mood
208+
up.mood.get({}, callback) // GET /nudge/api/v.1.1/users/@me/mood
234209

235210
// get a specific mood
236-
up.mood.get({ xid : mood_xid }, callback) // GET /nudge/api/v.1.0/mood/{mood_xid}
211+
up.mood.get({ xid : mood_xid }, callback) // GET /nudge/api/v.1.1/mood/{mood_xid}
237212

238213
// create a new mood
239-
up.mood.create(options, callback) // POST /nudge/api/v.1.0/users/@me/mood
214+
up.mood.create(options, callback) // POST /nudge/api/v.1.1/users/@me/mood
240215

241216
// delete a specific mood
242-
up.mood.delete({ xid : mood_xid }, callback) // DELETE /nudge/api/v.1.0/mood/{mood_xid}
217+
up.mood.delete({ xid : mood_xid }, callback) // DELETE /nudge/api/v.1.1/mood/{mood_xid}
243218
```
244219

245220
## Time Zone
246221

247-
[Timezone Documentation](http://ryanseys.github.io/node-jawbone-up/docs/timezone.html)
248-
249222
```javascript
250223
// get a user's timezone
251-
up.timezone.get({}, callback) // GET /nudge/api/v.1.0/users/@me/timezone
224+
up.timezone.get({}, callback) // GET /nudge/api/v.1.1/users/@me/timezone
225+
```
226+
227+
## Refresh Token
228+
229+
Added in v.1.1
230+
231+
```javascript
232+
// get (technically POST) a refresh token (requires client_secret passed into options when initializing)
233+
up.refreshToken.get(callback) // POST /nudge/api/v.1.1/users/@me/refreshToken
234+
```
235+
236+
## Settings
237+
238+
Added in v.1.1
239+
240+
```javascript
241+
// get user settings
242+
up.settings.get(callback) // GET /nudge/api/v.1.1/users/@me/settings
243+
```
244+
245+
## Webhook
246+
247+
Added in v.1.1
248+
249+
```javascript
250+
// create a webhook
251+
up.webhook.create(webhook_url, callback) // POST /users/@me/pubsub?webhook={webhook_url};
252+
253+
// delete a webhook
254+
up.webhook.delete(callback) // DELETE /users/@me/pubsub
252255
```
253256

254257
# Tests
@@ -269,20 +272,6 @@ Then you may run all the tests with:
269272
npm test
270273
```
271274

272-
# Contributing
273-
274-
I would love contributions. Filing issues [on Github](https://github.com/ryanseys/node-jawbone-up/issues)
275-
or sending pull requests is always greatly appreciated.
276-
277275
# License
278276

279-
The MIT License (MIT)
280-
281-
Copyright (c) 2013 Ryan Seys
282-
283-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
284-
285-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
286-
287-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
288-
277+
[MIT](https://github.com/ryanseys/node-jawbone-up/blob/master/LICENSE.md) &copy; 2014 Ryan Seys

0 commit comments

Comments
 (0)